What WindowManager flag is Facebook Messenger chatheads using - android

I'm making an overlay by adding views directly to the window using WindowManager. However, I can't seem to find flags necessary to do what chathead does, which is to have the overlay on top of the soft keyboard. My overlay always gets covered by keyboard when it pops up.
this is the params I am using for my views that are added to the window
private WindowManager.LayoutParams touchableParams = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);

Don't know your other requirements. I have been using this setup under Android 7.1.12 on a Google Pixel to make the overlay show on top of the soft keyboard. Hopefully this is what your are looking for.
mWindowsParams = new WindowManager.LayoutParams(
width,
height,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);

Related

creating service screen that will overlay all other app, but the issue is soft keyboard is not showing

Here's my code
val params = WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT
)
my end goal is to create a overlay that will lessen the overall brightness of the screen.
everything is working, i can tap/access all of the icon from other app.
The issue is, soft keyboard is not showing.
the device I am using is a Asus Zenfone 6 (Android 5.0)

When adding view to window with WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, it is not getting touch event

I need to display my view on top of dialer application, so I was using TYPE_PHONE for this purpose which is touchable, but still on some devices like Nexus 5 dialer application of device is hiding it.
Tried using TYPE_SYSTEM_OVERLAY makes view visible on top of dialer application, but touch is not there. Any help regarding this will be great.
After lot of searching for above problem, I found solution my self. Here it is how I made view to be on top of everything inside device and also making it touchable which was not possible with TYPE_SYSTEM_OVERLAY.
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSPARENT);
params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(view, params);

Android 5+ screen locks can't add view with WindowManager

I've got an Identified call app which worked very good till android 5+.
Basically I've got a BroadcastReceiver which "do his thing" when phone rings after identifying the call I add a small view.
on a new galaxy edge s6 it doesn't work when the phone is locked.
here is my related code
wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, // TYPE_PHONE
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.CENTER;
wm.addView(app.PhoneLayout, params);
app.PhoneLayout contains the layout after inflating etc..
Does anyone have any idea why such thing happen? and how am I able to fix that so that my view will be shown even when the phone is locked?
It's working fine on older devices.
Hope someone can share his thoughts on this

Using windowManager parameters to have keyboard

I am using these parameters to show an image on the screen. (this is running on a service cause of that i am using windowmanager instead of usual way- the image comes and goes continuesly)
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT
);
The Point is when I use FLAG_NOT_TOUCHABLE it allows user's touch go through the Picture, Which is fine and it is what I want. but when there is a need for text entry the keyboard keeps disappering (I want it to be there so I am able to input text even though the Picture is overlapping). this works for buttons and other input but the the keybord vanishes. How can I keep both?
changing WindowManager.LayoutParams.TYPE_PHONE to WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY solved the problem.

Android overlay (API 19) - how to cover bottom parts of SW buttons as well?

I'm adding an overlay view over the home screen using:
((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).addView(this, layoutParams);
Layout params are defined as follows:
layoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);
The overlay covers entire screen besides the bottom part of the SW buttons (home, back and multitasking buttons). Any idea how to make the overlay cover those parts as well, so that my overlay will treat events of those buttons as well?
Late I know, but someone can try this :
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Categories

Resources