yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] psx2pal:
It reduce the size. If you have a high quality image file, it will load to ram an then only scale in view. With this method it will load with a reduce size. So you need less ram.

For more read here (see answer 3). Maybe you can optimized it with automatic scale.

http://stackoverflow.com/questions/...sue-while-loading-an-image-to-a-bitmap-object

or here:

http://stackoverflow.com/questions/5340791/imageview-android-ram

they explain it better ;).

With new images i mean own images. The normal android icons/images are ugly with this method.

Edit important: look here http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

The android images are ugly, because i use the wrong inSampleSize . So i use my own images.

---------- Post added at 08:21 PM ---------- Previous post was at 07:45 PM ----------

So here is my final version for your library and the android images are ok now. The inSampleSize will now calculate automatic.

replace:

icon.setImageResource(item.icon);

with:

BitmapFactory.Options options;
options=new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap iconBm = BitmapFactory.decodeResource(getResources(), item.icon, options);
options.inSampleSize = calculateInSampleSize(options, 70, 70);
options.inJustDecodeBounds = false;
iconBm = BitmapFactory.decodeResource(getResources(), item.icon, options);
icon.setImageBitmap(iconBm);

Add this Method:

public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;

if (height > reqHeight || width > reqWidth) {
if (width > height) {
inSampleSize = Math.round((float) height / (float) reqHeight);
} else {
inSampleSize = Math.round((float) width / (float) reqWidth);
}
}
return inSampleSize;
}

I have this from: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
[Android Apps and Games] pingpongboss:
Ah, I see that this is really effective for large bitmaps, since you only need to load a low-res version into RAM because the target icon is small. But I don't think this might be overkill for this exact case, since the image loading is part of getDropDown(). Developers will be aware that their image resource is for a DropDown menu item, so they will know to use avoid unnecessarily large images.

Thanks for your help though! I was going to say that wow, your code looks very much like Bitmap decoding that the Android Gmail app team uses, but then I realized that it was standard practice :P
[Android Apps and Games] Jdbye:
I can't seem to make this work in my own project. The example works fine, and I modified the MultiWindow.java file for my own project, but when I try to show a floating window, the debug view shows a ClassNotFoundException for "wei.mark.standout.R$layout", right when the code tries to execute StandOutWindow.show(this, IRCChannelWindow.class, ++chanCount);

Does anyone have an idea what might be wrong? I'm rather new to Android development but I have previous experience with Java. I didn't make any large modifications to the MultiWindow.java code so I don't understand what could be wrong.

Edit: After adding the R class files to standout.jar, I now get this error instead: 09-11 01:11:57.985: W/ActivityManager(61): Unable to start service Intent { act=SHOW cmp=com.jdbye.floatircbeta/.IRCChannelWindow (has extras) }: not found

Edit2: I added the .IRCChannelWindow service to the manifest, now I'm getting a NullPointerException in ActivityThread.handleServiceArgs, before any of the functions in IRCChannelWindow.java are even executed. Could it have something to do with the layout? Here it is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textMessages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:scrollbars="vertical"
android:text="TextView" />

<ListView
android:id="@+id/listNicks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2" >

</ListView>

</LinearLayout>
[Android Apps and Games] pingpongboss:
I'm on my phone so I haven't looked into it too much but I think the reason why you're having issues it's because you're using the jar file. Please look at the first post for instructions on how to import the library into your own project the right way
[Android Apps and Games] Jdbye:
I don't see any instructions for that in the first post. The instructions only tell you how to import the projects, but I don't want to modify the example project, I want to import it into my own project. I think I have imported the JAR file correctly (placed it in libs and it appeared under "Android Dependencies", according to a guide I found on google), but since it doesn't work, I can't be sure. When I just referenced the JAR file from the StandOut directory like the example project, it didn't appear under Android Dependencies at all (and the debug console would show errors about failing to load the IRCChannelWindow because of a missing superclass)
[Android Apps and Games] pingpongboss:
It is definitely weird if you are new to Android, but I assure you that the instructions provided are the correct instructions from importing StandOut into your own projects :)

When you follow the directions, you will end up with 2 projects in Eclipse, as instructed. One of them is the library project (it MUST be imported this way. You cannot just copy a JAR like regular java), while the other one is the example project. You can ignore the example project and start your own. The reason the example project is there is because it shows you the various changes you need to make to your own project in order for StandOut to work. You'll need to edit AndroidManifest.xml the right way, set the minSDK and targetSDK to the right values, etc.

Welcome to the slightly weird world of Android development. If you don't want to take my word for it, review this documentation from Android http://developer.android.com/tools/projects/projects-eclipse.html
[Android Apps and Games] Jdbye:
I have imported the projects, however if I can't use the JAR file then how am I supposed to add it to the build path? I set the minSDK version to 7 (2.1) and the targetSDK to 15 (4.0), I figured that would work since this library requires 2.1+. That just happens to be the same versions used by StandOutExample. I did however notice that my project was lacking the SYSTEM_ALERT_WINDOW permission, that might be it.

Edit: That does not seem to be the problem since it still occurs. That means the problem must be occurring even before it tries to create the window. I'll read the page you linked and see if that can be of any help.
[Android Apps and Games] pingpongboss:
Not sure if you read the last link I sent you: http://developer.android.com/tools/projects/projects-eclipse.html

Please read it, especially the "Referencing a library project" part.

All permissions are necessary. You have to add it in your own project. You must also add your own StandOutWindow subclass to your AndroidManifest as a service (just like the example).

Please read that link!
[Android Apps and Games] Jdbye:
Yes, I've read it now. I see the method for importing a library is different than what I tried, it's a bit annoying that it's not tightly integrated enough with Eclipse that it can use the standard Build Path options, but it displays the window properly now. Thanks for the help.
[Android Apps and Games] pingpongboss:
Yup it really sucks! Last time I checked I think they were working on making library projects easier to import.
[Android Apps and Games] Jdbye:
I have one question. Is there a way to disable the persistant notification? I tried removing the related functions but the window wouldn't open at all. In the app I'm making, people might have a lot of windows running at once, and it's annoying having the notification tray filled with notifications for each window (plus the fact that when you minimize the window, there are 2 notifications shown - that's one thing you might want to change, or at least add an option for it)

Also, I have a feature request: Make the window collapsible when the titlebar is clicked. I saw this in a floating IM client (LilyPad) and it comes in handy when you just want to minimize screen area used by floating windows without minimizing them and having to open the notification tray to restore them again.
[Android Apps and Games] pingpongboss:
There needs to be a single persistent notification for the StandOut service, or else android will kill your service on low memory (which happens every 5 seconds). You are mistaken about the fact that there is a new persistent notification for each new window. Unless you have multiple types, you will only have one persistent notification no matter how many windows the user opens. If multiple types are an issue, look at FloatingFolders for how to implement multiple types in a single service.

This feature request seems useful. If you want to implement it yourself, you can edit getSystemDecorations() yourself and add in the functionality.
[Android Apps and Games] wutk3ksHD:
You can let the window collapse by some code in your onShow() method.

You have to set an onClickListener for the titlebar (it would be better if you add an additional button for this) and in its onClick() method do something like this...

...for minimizing:

Editor editme = getWindow(id).edit();

editme.setSize(width, titlebar.getHeight()); // shrink the window to its titlebar

editme.commit(); // submit the changes

How to get the windows size before shrinking:

LayoutParams params = getWindow(id).getLayoutParams();

int width = params.width;

int height = params.height;

How to get the whole titlebar?

titlebar = (LinearLayout) window.findViewById(R.id.titlebar);

Please make sure that you insert this code in your onShow() method.
[Android Apps and Games] pingpongboss:
whoa awesome dude. you're like a StandOut expert now :P This method might even be better than my suggestion to edit getSystemDecorations() because this allows you to override onShow() in your own subclass rather than editing the library directly.
[Android Apps and Games] Jdbye:
I'm aware that it will kill on low memory - that is why I would make it a setting toggleable by the user. On devices with a lot of memory this would not be a problem. However, if there is only one persistant notification per window type, then it's fine. Wouldn't it be possible to only have one persistant notification for the entire application, though? That way, I could have one persistant notification to hide/show all windows at once instead of having one notification for the settings window and one for the channel windows, I don't really have any use for a channel window notification in my IRC app.

Also, there doesn't seem to be a way to check if a window exists from a non-window class. This is a problem, because if data is sent to a closed window, StandOut will keep trying to send data to it and spam logcat, as well as preventing the activity from closing.

I will definitely try this, thanks. How would I go about adding another button (without modifying the library?)

I am not sure what kind of icon the button would have though. If it looks too similar to the minimize button, it'll just be confusing. That's why I didn't really consider that option before.
[Android Apps and Games] wutk3ksHD:
Thats the way to add a button to the titlebar without modifying the library:

in your onShow() method ...

...get the LinearLayout titlebar with:

titlebar = (LinearLayout) window.findViewById(R.id.titlebar);

create a new ImageView to add it later to the titlebar:

ImageView newButton = new ImageView(getApplicationContext());

newButton.setBackgroundResource(android.R.drawable.ic_menu_add);

add newButton to titlebar:

titlebar.addView(newButton);

Good luck :)
[Android Apps and Games] pingpongboss:
If you want one persistent notification for multiple Services (each subclass of StandOutWindow is a Service as defined in your AndroidManifest), then from what I know it's not possible. There's no way to tell Android "associate these 3 services with this foreground notification". If you do some research on http://developer.android.com/reference/android/app/Service.html#startForeground(int, android.app.Notification) maybe you will figure something out I haven't. One way to avoid multiple persistent notifications, like I mentioned earlier, is to take advantage of the id that every StandOut window has. The FloatingFolders advanced example shows how to use ids to differentiate between a Folder window and a App Selector window. Both of these 2 types exist in the same Service so only one persistent notification is shown. Please take a look.

sendData() sounds broken and needs to be fixed. I don't know if it's a good idea to allow any class to get the window of any other class. Sounds like a security hole if you could just edit the views of another developer's floating app. You could probably use Reflection to get another app's Class and try to screw around with any windows you might find.

I originally didn't intend for developers to mess with the system-provided titlebar (thought every window should have a close button or people could take advantage of StandOut to serve popup ads). I wanted people to unset FLAG_DECORATION_SYSTEM and create their own window decorations from createAndAttachView(). But meh, why not.
[Android Apps and Games] Jdbye:
Thanks.

Okay, I might try using ids to differentiate, thanks.

I'm having a problem with my code. It seems only one instance of the window class is created, which means I have to use IDs with arrays to differentiate between different windows of the same class. I thought getUniqueId() returned a window-unique ID, but it seems that is not the case, as it was different in createAndAttachView (0) and getDropDownItems (2). Do I have to use the id passed in function arguments? In that case I'll have to modify my own functions to require the ID as a argument. Also, does that ID change if the window is hidden and shown again?
[Android Apps and Games] wutk3ksHD:
As far as i know, the id of a window will never change when hiding or open it again.
[Android Apps and Games] Jdbye:
@pingpongboss - It's very hard to grab the corner in order to resize the window. I'm not sure if this is because I have a EditText at the bottom. I tried adding margins to the EditText widget, but it doesn't seem to help.

Okay, that's good. I got it working by using the window ID instead of getUniqueId(). I thought getUniqueId() would return the ID originally specified in StandOutWindow.show() but it seems that is not the case.
[Android Apps and Games] wutk3ksHD:
The Corner is a view (go to StandOut -> res ->layout -> system decorations). You can change the size of the corner in your onShow() method if you want.

Your EditText is not the cause, its just because you didnt hit the corner because its quite small. The corner is in the foreground, always.
[Android Apps and Games] Jdbye:
Are you sure about that? Because, even when I do manage to grab the corner, usually the window will only resize horizontally.
[Android Apps and Games] wutk3ksHD:
im sure. i developed an app with an edittext yet. pingpongboss, please correct me if im wrong.
[Android Apps and Games] Jdbye:
I've done this and it works. However, I don't know how to position the collapse button between hide and close. I could not find a procedural equivalent to "To Left Of" and "To Right Of" in the layout editor. Do you know how? And is there a way to animate the opening/closing?

Also, it doesn't seem to collapse completely (the corner is still visible along with half of the TextEdit). I don't know if this is a limitation of the library and it will keep the corner visible, or if I can solve this by simply decreasing the height further.

I made the corner bigger and it seems somewhat easier now. Still kind of tricky, I might have to make it even bigger.
[Android Apps and Games] pingpongboss:
Sorry, getUniqueId() has a confusing name. It is supposed to return a new id that does not conflict with any current windows.

If you keep seeing this horizontal-only behavior then let me know. It might be a bug?

You're right on everything so far ;)

Use the addView() that takes an index. http://developer.android.com/reference/android/view/ViewGroup.html#addView(android.view.View, int)

You might need to use your own logic to show/hide the corner and other stuff.
[Android Apps and Games] Jdbye:
I have already tried using corner.setVisibility(View.GONE), it doesn't make any difference.

The horizontal-only thing seems to have stopped after I made the corner bigger.

Also, I think I've found a bug: When the keyboard is open and you move the window near the top, it will maximize vertically and go under the keyboard. Additionally, it seems to maximize vertically every time I try to resize it while it's near the top (it starts near the top, and as soon as I resize it, it maximizes vertically). I don't think this used to happen earlier (it would maximize vertically but not go under the keyboard), but I'm not sure why that is.

Edit: addView() with an index solved the positioning problem, thanks. :)
[Android Apps and Games] pingpongboss:
Uhh I've been working on tiling (maximizing when the window hitting the edge). I didn't think I committed anything, so this is weird. But it sounds a lot like what I'm working on. Do you suspect that might be why?
[Android Apps and Games] wutk3ksHD:
i want to listen to it if a window looses focus. is there a method i can implement?
[Android Apps and Games] pingpongboss:
onFocusChange() is what you're looking for.
[Android Apps and Games] wutk3ksHD:
I got some problems with onFocusChange. I want to reset the position of the window if it loses focus, for example if the user taps the launcher of android. I am not sure about some things... :

Does a window loose focus when the user taps outside of a window or does a window loose its focus just if another window gets focus?

If the window's focus changed when it had focus, does onFocusChange() return focus = true or false?

This is my code so far to reset the position, but it doesnt work. Any idea?

@Override

protected boolean onFocusChange(int id, Window window, boolean focus)

{

Editor editme = window.edit();

editme.setPosition(-110,LayoutParams.CENTER);

editme.commit();

return false;

}
[Android Apps and Games] Jdbye:
Tiling is definitely in the library (FLAG_WINDOW_EDGE_TILE_ENABLE)

I removed it from my window since it seems buggy.

I also figured out why my windows wouldn't collapse fully - it was the minimum height set in the layout parameters. I used the ones from the example project and didn't think to change them. Doh.
[Android Apps and Games] pingpongboss:
1. A window loses focus when user taps outside of it AND when another window gains focus.

2. The return value of onFocusChange() is meant to signify whether you want to cancel the focus change or not. The boolean parameter signifies what the focus will be changed to.

Oops I didn't mean to put tiling in there. Yea don't use it please.
[Android Apps and Games] wutk3ksHD:
Thanks so far! I fixed my problem with the onFocusChange() method which wasnt called. I had set FLAG_WINDOW_FOCUSABLE_DISABLE. Works now :laugh:
[Android Apps and Games] pingpongboss:
Yea this particular error has to do with the StandOut menu: do you notice the window icon to the top-left of every window? if you click that, a drop-down appears. I'm guessing (wildly) that maybe you clicked multiple times quickly, and it tried to bring up the popup menu when the actual window itself was closing. You can try to turn off animations with flags and see if this stops happening.

If you could send me your APK I can try to reproduce your issue. But I'd guess yes, either 1. I have a bug in the library, or 2. the focus code assumes no one will mess with the window layout contents and you do so it is unstable.
[Android Apps and Games] Jdbye:
Yeah, I was spam clicking it and selecting options on it to try to reproduce the issue. However, it seems to happen sometimes long after I've opened the drop down menu. I've attached the APK so you can try to reproduce the issue.

I can't find a flag for disabling animations though. There definitely is no such thing in StandOutFlags.

Also, I have a question: Is there a way to update the persistant/hidden notification text without hiding/showing the window? I can't seem to find one by looking at the library source. If there isn't, could you add one?

And another thing, I can't get AdMob to work in a window. When I added it to the layout, it showed an error about needing to be initialized from an activity, so I removed it from the layout, created a new instance in MainActivity and added it to the window in FloatIRCWindow.createAndAttachView, however it never loads any ads (and I did adview.loadAd(new AdRequest()) after adding it to the window)

I saw a floating app in the market that had ads (LilyPad) so it must be possible.
[Android Apps and Games] nikad1970:
Been away from the forum for a month (moved house - ridiculously busy!) and just came back to be pleased to see some activity on this thread.

PingPongBoss, glad to see you back! Hope your travels were fun!

I have to say, I LOVE YOUR LIBRARY!!!

It's the one thing that got me back into programming (after 11 year break).

So what I had fun with was making a floating notepad using a stylus (I've got a galaxy note). It's knocking about here on this forum somewhere (look for FloatNote).

I also indulged myself with a version of Neko using your amazing library. I'll edit this post later with the apk for everyone's enjoyment/annoyance :D

Have fun guys,

Nikad
[Android Apps and Games] pingpongboss:
You can use

mNotificationManager.notify(getClass().hashCode() + id, notification)

to update manually. Look at https://github.com/pingpongboss/Sta...c/wei/mark/standout/StandOutWindow.java#L1560

But you're right, there should be an easier way to do this. I'll add it to my long list of feature requests.

Components that need a backing Activity (MapView and ads are some examples) have issues with StandOut. I haven't figured out how to "trick" these components yet, and if anyone has figured it out, please share with the rest of us! I'll add it to the library so it's easy for all.

Past issues we've had include: EditText was not supported, Buttons don't change their press state, keyboards crashing, etc. And we've figured all that out so I'm sure we'll eventually figure this out too :)

Nikad thanks for the compliments! I made StandOut in the hopes that people like you will find it useful and enjoyable.