[Q] addView from a Service to top level window - Android Software Development

I'm adding a GestureOverlayView and Button to the top level window
Code:
mWindowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
so both components always appear on top of every window. I'm arranging the layout programmatically then adding them (WindowManager.addView) from a Service and managing the onClickListeners from this service. The views appear as expected and the clicks are detected also.
The problem is that both the button and GestureOverlayView do not visually update correctly. The button background doesn't change (a normal button turns orange, right?) when pressed, so I ended up setting the background manually in the onTouch method with setBackgroundDrawable on both ACTION_DOWN and ACTION_UP.
The GestureOverlayView lets me draw gesture lines as usual but normally (in an Activity) when you release your finger, the yellow line is removed. For me, it isn't. What am I missing here? I kind of hacked together a fix for the button but the gesture has stumped me.

Related

Opening the Calender during a phonecall

i'm in a phone conversation, and someone asks me if I'm available on a certain date, i would want to check my calendar to see if i'm available.
i wanted to do this yesterday but after looking for more then a minute (while the call was open) i gave up.
does anyone know how to do this or even if it is possible???
(so open my calendar during a phone conversation)
pin it to the start menu
push hardware home button. then hit calendar on home screen. hit call hardware button or phone status in task bar on touch screen to get back to dialer screen.
I have the calendar in the start program. Everyone by default also has the "Today" on line one of the start menu, which will minimize the phone, take you to home screen, and allow you to open Tasks (or in your case, calendar). Finally, use the close button (X in upper right) to close the phone. It doesn't disconnect the phone.
I have the calendar in the start program. Everyone by default also has the "Today" on line one of the start menu, which will minimize the phone, take you to home screen, and allow you to open Tasks (or in your case, calendar). Finally, use the close button (X in upper right) to close the phone. It doesn't disconnect the phone call even if you close the window (trust me, do it daily for work).
thx for the replies guys!

Dialer optimization - double tap / click to dial and up/down arrows

Guys,
does anybody know if and how can I make my dialer not dial the person when I single tap on the row but only highlight it and then use either the hardware dial button or the big green "talk" button ... or double tapping the highlighted row?
I find it very annoying when I tap an adjacent row by mistake and have to search again. This happens pretty often when I drive and have my HD2 on a stand but it also happens from time to time when hold the phone in one hand I try to select/dial the topmost row in the result list.
The last part brings another question - is there a way to add two arrow buttons at the bottom of the dialer which will go trough up/down through the list? These will be very helpful in such "car" situations and also in the case where the search criteria results in large list (more than 3-4 items) which requires a scroll (flip scroll) and/or hiding the dialing pad to see the full list. Currently I've mapped the Vol Up/Down keys for up/down directions with AEButtons but it's not very convenient / comfortable.
I'll try to make some kind of screen shot to show what exactly I mean but I believe you get the point.
Here are the screen shots - the original and the modified (using paint)
It would be great if somebody can make such a dialer ... or explain what I need to make it myself. (the arrow buttons should stay visible when one hides the dialer ... or when the user presses them to start moving the "focused" contact just as if hardware arrows are pressed).
pankov said:
Here are the screen shots - the original and the modified (using paint)
It would be great if somebody can make such a dialer ... or explain what I need to make it myself. (the arrow buttons should stay visible when one hides the dialer ... or when the user presses them to start moving the "focused" contact just as if hardware arrows are pressed).
Click to expand...
Click to collapse
I'm not sure but I don't think I can do it. I'm not to good at editing those resource dll files.
Someone like RyanMogul6800, or Fards, would know about this. Maybe senf one of them a PM.

Transparent Button/Background

Hopefully someone can point me in the right direction as I'm not finding what I need, if it's even possible.
I need a button that is full-scrren transparent, clickable, but I want to see a ListView of items "under" the button.
I can make the full-screen button transparent and add items to the List and then just bring up the list in another Activity no problem.
But this is a client request to see the list under the button.
Anyone care to point me in the right direction...Overlays? FrameLayout? Custom Theme?
Thanks,
Roots
not really sure if I know what you mean, but you can try to make a png that is transparent and then assign it as your background image of the button in the xml file
Imagine a button that is full-screen and normal "gray" color.
Imagine a listview of some data displayed "under" that button. You make the button transparent and you can now see the list. All in the same Acitvity.
So cant stack 2 clickable items and have them both respond to clicks
Well, I tried a FrameLayout and it worked, sort of. LOL
I clicked the "invisible" button and saw my list grow in the background, but it seemed to "stop" when I hit the end of the screen.
The client is quite adamant about this requirement, but I might be able to sell them on having their data on a third screen and they can get to it on a hard or long button press. This app IS timer dependent, but the second or two it would take to bring up the data on a third screen can't be show stopper...I hope
Well, I've made some progress on the transparent button with another Activity's data showing underneath, but I still have one problem. Bear with me, this app can be confusing.
I have a screen that is a full-size transparent button. In the Manifest, it's also set to Translucent theme.
On press, it runs another Activity which has a button that adds text next to the button. Problem is, when I go back to the original activity, I can still see the button, but the setText("whatever") data is gone! If I don't make the full-screen button as "visible", the text is there.
So, I understand the concept of the setText disappearing, but why is the button still there? I need to see the text too. By the way, the button is visible when I first start the app (as it should be).
It's like I need a "setStaticText" method for TextView. I have returned the data to the calling Activity and can display it fine in a Toast. I even setText() it there, But as soon as that button goes "visible", goodbye text
Any and all ideas welcome!

[Q] switching buttons in android studios

I am trying to design a game that has multiple buttons in rows. I want the user to be able to press a button, hole it and move it to a button on the side, top, or bottom of it and the two buttons will change places. Were do I start the programing to make this possible. I am new to programing so any help would be appreciated thanks.
You can try implement an ontouchlistener for your buttons, and when event is move do the movement via setting margin on the button.
Take a look there also:
stackoverflow.com/questions/17464428/property-animation-of-a-moving-button-android
To identify when the button is above the other button or near it, to perform the swap (you may need to animate this as the above link, too) try to get all the buttons position via view.getTop and view.getLeft ( as described there) and store them. When you move a button you have the coordinates of your finger dragging the button, so by extension you have also the coordinates of the button being moved. So then you check inside the ontouch event move again, when, after the set margin, your button is close enough to any button and perform the swap between them
See here for getting positions of buttons.
( stackoverflow.com/questions/7203740/retrieve-the-x-y-coordinates-of-a-button-in-android )

How to detect when my Activity has been obscured?

Hi,
I would like to be able to detect if my Activity has been obscured by, say, a system alert or some other overlay (for example the power menu when I long press on the power button, or the volume control Toast), or some malware that detects the launch of my Activity. I noticed that the foreground app in this case would still be my app, so I can't simply base it on what the foreground app is. I also notice that onPause() isn't called when my Activity is obscured, so I can't put any logic in onPause() either. Even if I can though, I would then have to differentiate between a system alert/overlay and the user pressing the back/home button.
Are there any other ways for me to accomplish this?
I am able to partially accomplish this by placing OnTouchListener to my UI elements as well as the root View. In this case, if the overlay relays touch events to my activity, AND the part of my Activity that was touched is obscured, then I'm able to detect that it's obscured and do something about it. However, it still doesn't guard against 2 cases:
1. If the overlay doesn't relay touch events to my Activity. In this case the OnTouchListener won't be called.
2. If the area that was touched is not obscured by the overlay, in the case of a partial overlay. In this case, the OnTouchListener won't know that the Activity is partially obscured, it only knows that it's not. This still leaves me open to a peephole attack.
I'm not convinced that there is a way. I know one can detect that the app is paused or exited, but not that it's obscured.

Categories

Resources