Animated Android View with EditText - android

For the app I'm working on, the signon screen (the main activity) has some animations. Several of the signon related controls (the EditText, an application banner image, the signon button, locked out link, etc) are wrapped into a LinearLayout that starts out centered in parent within a full screen RelativeLayout. When the user taps into the EditText, the animation fades out the banner image as the logon form translates to the top of the screen. When the user dismisses the keyboard the banner image fades in as the form slides back down to the center of the screen.
The two issues are as follows (the first one is the most important since I don't have a workaround for it right now):
When the user is typing into the EditText after it's been animated to the top (it isn't actually animated to the top, the containing LinearLayout is) then you almost never see any text that is typed. It's random... sometimes the hint stays there and sometimes you might see a letter or two. When the keyboard is dismissed and the animation moves everything back to the start, the text is visible. Why?!
When the signon screen is put into the background and then resumed, Android appears to show some cached version of the screen where the controls are in their "focused" state but none of them work. Tapping on the screen where the controls would normally be (in the center) reveals the controls and starts the animation to move them to the top. This happens even if when the screen goes into the background, it's in it's regular state. I "fixed" this by setting a flag when the activity is paused and then checking if the flag is set in resume... if it is then I recreate the activity (by launching a new intent, not by calling recreate since I have to support an older API). It would be awesome if it just didn't show the cached version without me having to jump through these hoops.

Related

Delegate event from my activity to screen

I have a activity themed like a dialog and I have it setup so that it finishes when the user click outside.
this.setFinishOnTouchOutside(true);
As expected when the user clicks outside, it finishes. The activity is marked as floating activity and is only shown on top of the phone.
Now, if the user click on any other part of screen like the phone button/contact button on home screen, then the activity gets finished, but the user has to click on phone/contact app icon again to open phone/conatct app.
What I want is that if user click outside my activity, then the action must be performed as if the activity is not at all present on screen. Something like notification, which does not prevent user from doing other other tasks.
The only way you might be able to do this is by using a hidden WindowManager.LayoutParams flag, FLAG_SLIPPERY.
This allows touches starting on your View to continue to whatever View is below when the touch leaves your View but remains on the screen. However, I don't think this will work.
Android prevents you from touching "through" a touchable Window because it assumes that Window should be receiving the TouchEvent. Android also prevents you from programmatically "touching" the screen (without root or system access), most likely for security reasons.
I dug through AOSP for a while and found this.
Reading the comments, it's possible to infer that, while what you see doesn't take up the whole screen, the Activity's Window does. So, while nothing in your Activity is clicked, the Window is still overlaying everything, just with a transparent background, and is dealing with the touches that aren't passed to your Activity's UI. This brings us back to the "touching through" issue.

Popup window to block only parts of the view hierachy behind it

I have an app that works in the following way:
Upper part of the screen is the 'primary' part of the app, the actual content that the user can interact with is displayed here.
Lower part of the screen (maybe 1/4 of the screen height or so) is a navigation wheel. The user can turn this wheel to change the upper part of the display. When turned the entire upper part is replaced by something else.
These two part are implemented using fragments. The lower part (navigation wheel) is just a static fragment that displays a view hierarchy that can be rotated. The upper part (content display area) is a fragment as well, but it can be switched to other fragments when the wheel is turned.
Now what I want is that when the app starts, we are displaying a free content section, however when the user turns the wheel to one of the other content sections a window pops up to block the content display area, saying "buy this mode on Google Play." This popup should obviously block the content area behind it, so the user can see some of the display area behind the popup, but he/she cannot interact with it before he/she has completed the Google Play transaction. It would be nice if the views of the content area could be greyed out as well. The navigation wheel in the bottom of the screen however should not be blocked so that the user is able to navigate back to where he/she came from or further on to another content section. How can I make a popup that blocks the top view hierarchy from interaction but leaves the lower one intact?
As far as I know it is not possible to use the PopupWindow class to create a popup that will only block some of the screen behind it. It seems to always block it all.
Here is an of illustration the design. 'P' for paid and 'F' for free. On the second screen the app should ignore any press on the content section (behind the grey window), but the navigation wheel should still be able to turn.
Thank you.
On the second screen the app should ignore any press on the content
section (behind the grey window), but the navigation wheel should
still be able to turn.
You could make an overlay and set it up to eat all touch events(either by setting a OnTouchListener on it or by using a custom layout with the onTouch() method overriden to return true) and put it on top of your normal fragment content. This way the actual content will be visible underneath but will not receive any touch events. You could also add some content to your overlay right like in your image.
Also, as the overlay will only cover the paid fragment the wheel at the bottom will be touchable by the user(I don't know how that wheel actually interacts with your fragments so the approach above might not work).
I've made a small rudimentary sample as an example(you can find it here).
It would be nice if the views of the content area could be greyed out
as well.
You could make a recursive method to traverse the view hierarchy of your paid fragment and call View.setEnabled(false) on the views it meets.
Seems overly complicated to me.. I cannot imagine the design..
I would create a different fragment to be triggered if the user has purchased the item, with a different interaction, like a Dialog to be shown at every click, or something like that.
In pseudocode:
if wheel.position == 4
if itemPurchased
showFullFragment
else
showMockFragment
Create a default fragment with one button, that opens the right page of Google Play to buy the content. Then, every time the navigation wheel is turned, you decide in your code if you show the fragment with content (when user has finished the Google Play transaction) or you show the default fragment with just the button to Google Play.
Only one thing: Google Play is asynchronous. There might be some time when the user actually has finished the transaction but Google Play didn't inform your App, yet.
If the transaction was initiated you must decide if you show the content without having to 100% clarity that the user actually paid, or if you show a blank fragment. In any way, you should not show the button again, because that would confuse the user ("I paid! Why do I need to go to Google Play again???")

Screen goes black when virtual keyboard hides - Samsung Galaxy Tab 10.1 / Android 3.1 / PhoneGap

If I position a text input in the lower half of a page, when the user taps it to show the virtual keyboard, the page automatically slides up. When you tap away from the keyboard, the page automatically slides down again. I.e., everything is fine.
But when the text input is located in the top half of the page (in which case the page doesn't automatically slide when the keyboard appears), the behaviour is bad:
User taps the text input;
The whole screen (except the text input) turns black momentarily, then the keyboard slides up;
The user taps away from the keyboard;
The screen flashes black before the page is rendered again.
However, if you try the above steps a second time, the sequence is:
1. Same as above;
Same as above;
Same as above;
The screen turns black and stays black;
The user taps on the black screen;
The page is shown again.
I've tried a few different things, like detecting when the text input loses focus (i.e., keyboard hidden) to show to page, scroll the page, etc. but nothing seems to prevent this problem with the black screen.
Showing a javascript alert when the text input loses focus avoids the black screen problem (but I don't want an alert to show either!).
I've also tried using android:hardwareAccelerated="true" inside my AndroidManifest.xml's tag. And whilst that does fix this particular problem, it unfortunately creates many more rendering problems throughout the web app.
Does anyone have any suggestions?
Put this code in your manifest file in your launching activity tag
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:windowSoftInputMode="stateHidden|adjustPan"

Visual effects, and Activity redraw after pressing home button and come back

I am programming an Android app and it seems to work well, but when the user presses the 'home' button, and after returns to the app, the activity has changed his position some pixels, and due to this some buttons are hidden.
It only happens in some phone models , and only with visual effects enabled on the operating system.
It seems that the activity is drawn before the top bar of Android dissapears (the bar with the battery info, wifi... etc), and the activity starts to draw under the place of this bar.
What can be happening? how can I solve it?
Thank you very much!
PD: I am using a relative layout on this activity, and some layouts inside placed at top and bottom.
PD2: I forgot to tell that the app is in "no tittle bar and fullscreen".

Android keyboard hides itself, showing blank space below, after coming back from screensaver

I am working on an android app and really enjoying it too. But today, I got stuck on a small problem with soft keyboard.
I have an EditText at the bottom of the screen and when user clicks on it a keyboard pops up ,resizing the entire view to show the EditText above keyboard, which is as it should be. But if user doesn't do anything for sometime, phone sleeps and screen gets locked with the keyboard still present in the screen. When phone comes back after sleep, the keyboard seems to hide itself, leaving my views in a resized state. A blank space is shown where the keyboard has been present..I would be happy if
The keyboard remains there after
coming back from sleep..
Let the keyboard hide,but my views
should go back to original size, ie
without any blank space..
What can I do to achieve any of these?

Categories

Resources