Fix loading screens for manage and running apps
Also add loading screen to manage permissions as this can take a
long time to load in some circumstances. Build loading screens into
Utils and SettingsPreferenceFragment so that it can be easily used
other places in the future.
Change-Id: I7febd06695487e02ced793a9fd418051b5f0eab8
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 23b2c85..dc4b484 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -39,8 +39,8 @@
import android.content.pm.Signature;
import android.content.pm.UserInfo;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.content.res.Resources.NotFoundException;
+import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -74,6 +74,9 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.Animation.AnimationListener;
+import android.view.animation.AnimationUtils;
import android.widget.ListView;
import android.widget.TabWidget;
@@ -1158,4 +1161,39 @@
? R.string.launch_defaults_some
: R.string.launch_defaults_none);
}
+
+ public static void handleLoadingContainer(View loading, View doneLoading, boolean done,
+ boolean animate) {
+ setViewShown(loading, !done, animate);
+ setViewShown(doneLoading, done, animate);
+ }
+
+ private static void setViewShown(final View view, boolean shown, boolean animate) {
+ if (animate) {
+ Animation animation = AnimationUtils.loadAnimation(view.getContext(),
+ shown ? android.R.anim.fade_in : android.R.anim.fade_out);
+ if (shown) {
+ view.setVisibility(View.VISIBLE);
+ } else {
+ animation.setAnimationListener(new AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ view.setVisibility(View.INVISIBLE);
+ }
+ });
+ }
+ view.startAnimation(animation);
+ } else {
+ view.clearAnimation();
+ view.setVisibility(shown ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
}