How to blur behind of AlertDialog - java

I have AlertDialog class in my app. It's used in a lot of activities, so I implemented blur logic in AlertDialog class itself instead of implementing and handling it in every activity. Is it possible to blur behind AlertDialog for all its implementations universally or I should use another libraries to blur on attach/unblur on detach for every instance?
To achieve behind blur I used FLAG_BLUR_BEHIND with setBackgroundBlurRadius() applied to AlertDialog. It works just fine, but appears it won't work on devices, that have no support of hardware blur(and there are a lot of them).

Related

`dispatchGesture` ignore overlay view

I'm using the dispatchGesture API from Android accessibility.
I've added an overlay to the screen and I'm looking for a way to dispatchGesture behind the overlay (the overlay is what's intercepting the original gesture) since otherwise the gesture is dispatched on my OverlayView and don't play back in the app.
Is there any way to do this with the accessibility API?
For context - I want to be able to help people record actions in Android and replay them for accessibility.
Alas, there is no way to do this generally. A touchable overlay will capture all touches, as you're observing. It's not possible to do general-purpose filtering of touch events.
You've probably already thought of this, but if you're playing back pre-recorded gestures, you can remove your overlay before you dispatch them.
The general purpose filtering API doesn't exist because it's very difficult to filter touch events outside the system process without introducing serious jank.
You must use FLAG_NOT_TOUCHABLE params flag for your view and then dispatch your click.

managing Persistent Visual Data (event driven buttons and ImageViews) throughout Activities of an application

I need some advice for those who are experienced making Android applications. What I would really like to have, for my application's appearance: at the top, a title-bar which is a ImageView (content is a png), and at the bottom a series of custom buttons which make up a tab-bar like thing. In between the title and the tab-bar is the Content, which may be anything... (most likely buttons)
I have been doing this by making a RelativeLayout which specifies LeftMargin and UpperMargin for x,y coordinates--
Currently all of my activities are inheriting a custom MyActivity class, which rebuilds the title and the tab-bar at the time of onCreate. This seems bad to me!
PART1)
---A solution to Persistent data
Since the "tab-bar" and the title are persistent no matter what screen you're on during this application's run-time, it makes the most sense to store them somewhere... How should I do this? Make a singleton object that the Activity's ask for?
I thought a little about the singleton object, and I'm not even sure what I would store, since the Views that are on displayed during Activity A have activity A as context, and not Activity B.
PART2)
---Animation Aesthetics
I would really like to have the "Content" (the view in the middle between title and tabbar) slide out to the left, and the new content slide in from the right. I.e, I'd like the tab-bar and the title to remain fixed while the "activities" change. is this at all possible? What should I do to achieve it?
one idea I had, was to make all of the program in one activity! I would create an animation for the Custom View in the middle, and I would override the "back" button to navigate correctly to the previous Custom View. Is that a horrible idea?
Anyone have any advice?
Read http://developer.android.com/design. Most of the design principles can be applied to apps that run on legacy releases; it's not just limited to Honeycomb and Ice Cream Sandwich. Do consider the Action Bar and Dashboard design patterns.
I don't really recommend using just one Activity -- generally, an Activity should be a separate, encapsulated, pretty well defined chunk of functionality that can execute independently of other Activities.
To avoid duplication of your UI, consider reusing XML layouts.
To avoid duplication of your logic, consider using Fragments. You should be able to mix and match them in your activities.
To achieve the animation you describe, consider implementing a ViewPager.
Using the ActionBarCompat sample app and Android Support Library, you can enjoy modern goodies like Action Bar, fragments, tabs, and horizontal sliding transitions on devices running Android all the way back to Donut (1.6).

is multiple activities and surface views the correct way to go?

I'm currently in the process of making one of my first android games and have come into some difficulty understanding how to make the transitions between screens.. for example:
My game starts its main activity, which then loads TitleScreen surface view which initializes its own thread
on tap I start a new intent which loads a new activity which loads GameView surface view which initializes its own thread
This all works fine when testing on my device (Evo 3d) but crashes on tap on my test bed, I'm using android x86 in virtual box for quick testing. Is this likely to be a problem in my code or a problem with the simulator?
Also I'm wanting to add a level select screen in between the title screen and the game screen and figured i could do this by creating another activity/surface view/thread combo, Is this acceptable coding practice or is this a wasteful/process heavy method?
You could create a variety of methods that you call from your onDraw method. Each method would draw one screen (game, level, score). To start simple a switch case in the onDraw checks the screen and then calls the right thing to draw.
If you want to have different layers, you should use different acitvities so that the background (game) is being paused while the scoreboard is active. This only makes sense if you want the background to be still visible or need the acitivites for other reasons.
But you should never have more than one surface view active at the same time, android doesnt like that.
I think its not good to use more activities for single application. Try to use ViewFlipper with number of xml layout files. Here you can apply transition effects very easily.
I am suggesting you it for transition effects, but you also check it once. I am also thinking which one is good.

Easy way to detect where ui thread is stalling on Android?

I have taken over an Android project from a past employee and am wondering if there is an easy tool to use for profiling an Android application. I have a LinearLayout with a ProgressBar spinner inside of it. Now I am running a network call on a different thread while that spinner is showing. I use a translate animation to show the entire LinearLayout and when the network call returns on the other thread I hide the LinearLayout. Now this works great but I see that the spinner kind of stops spinning while it is showing. Now it kind of looks like if I interact with the screen, such as trying to scroll, the spinner will continue to spin. For a standard ProgressBar spinner do I need to set some command on the spinner to keep it spinning? Any information on this would be great.
Thanks
You could use StrictMode to detect expensive calls that are being done on the UI Thread.
Why not try implementing your network call in an AsyncTask? In the onPostExecute method implementation you can do whatever is necessary on the UI (i.e hide your progressBar, etc.).
Or, if you are using the compatibility / support library, or targeting Honeycomb or later, use a Loader instead.

Animation support for Android SDK 1.5?

I'm trying to add some animations to my application. I've essentially got a few menu screens, that all eventually lead to the main application that is a surface view. I want to add some nice animations between screen like fading in and out between screens. What's the easiest way to do this that is supported by SDK1.5 and above (I want to target most users)?
I'm confused by what is and isn't supported in SDK1.5. My belief at the moment is that animations between different activities is not supported in 1.5 but animations in things like ViewFlipper are. It seems the easiest way is to set up a ViewFlipper, put each of my screens in that, set the animation settings and then use this to get nice transitions.
Also, is there a way to override the "no animations" setting that can be found in the phone's main settings screen under display? I'm making a game, so presentation is important, so I want to be sure that whatever I use will cause an animation regardless of this global setting.
My belief at the moment is that
animations between different
activities is not supported in 1.5 but
animations in things like ViewFlipper
are.
Correct.
It seems the easiest way is to set up
a ViewFlipper, put each of my screens
in that, set the animation settings
and then use this to get nice
transitions.
Either that or just directly apply AlphaAnimation and kin to your Views.
is there a way to override the "no
animations" setting that can be found
in the phone's main settings screen
under display?
No, but bear in mind that is only for inter-activity animations.
I'm making a game, so presentation is
important, so I want to be sure that
whatever I use will cause an animation
regardless of this global setting.
Then do not rely upon global settings. Which, in this case, means do not rely upon inter-activity animations.

Categories

Resources