diff options
author | Winson Chung <winsonc@google.com> | 2011-08-09 14:14:23 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-08-22 21:26:06 -0700 |
commit | 82f5553a137f0a25f7333a6fc9507c847b7a42ed (patch) | |
tree | 1b1f7967459115979fe4fb1b4f63f598e2823f5b /src/com/android/launcher2/Launcher.java | |
parent | 30a22f32b07f7a864112d92ac959db0e84e0c374 (diff) | |
download | packages_apps_trebuchet-82f5553a137f0a25f7333a6fc9507c847b7a42ed.zip packages_apps_trebuchet-82f5553a137f0a25f7333a6fc9507c847b7a42ed.tar.gz packages_apps_trebuchet-82f5553a137f0a25f7333a6fc9507c847b7a42ed.tar.bz2 |
Cling ALL the things! (Workspace and AllApps)
Change-Id: Iee6b38dbb4f0b2fb85f854d70fd86db1e7b1d8f7
Diffstat (limited to 'src/com/android/launcher2/Launcher.java')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index a0601e0..41fb185 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -40,6 +40,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -72,8 +73,8 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.Surface; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnLongClickListener; +import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.InputMethodManager; @@ -155,6 +156,7 @@ public final class Launcher extends Activity static final int APPWIDGET_HOST_ID = 1024; private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300; private static final int EXIT_SPRINGLOADED_MODE_LONG_TIMEOUT = 600; + private static final int DISMISS_CLING_DURATION = 300; private static final Object sLock = new Object(); private static int sScreen = DEFAULT_SCREEN; @@ -264,6 +266,7 @@ public final class Launcher extends Activity checkForLocaleChange(); setContentView(R.layout.launcher); setupViews(); + enableClingsIfNecessary(); registerContentObservers(); @@ -2960,6 +2963,54 @@ public final class Launcher extends Activity }, mRestoreScreenOrientationDelay); } + /* Cling related */ + private static final String WORKSPACE_CLING_DISMISSED_KEY = "cling.workspace.dismissed"; + private static final String ALLAPPS_CLING_DISMISSED_KEY = "cling.allapps.dismissed"; + private void enableClingsIfNecessary() { + // TEMPORARY: DISABLE CLINGS ON LARGE UI + if (LauncherApplication.isScreenLarge()) return; + + // Enable the clings only if they have not been dismissed before + SharedPreferences prefs = + getSharedPreferences("com.android.launcher2.prefs", Context.MODE_PRIVATE); + if (!prefs.getBoolean(WORKSPACE_CLING_DISMISSED_KEY, false)) { + Cling cling = (Cling) findViewById(R.id.workspace_cling); + cling.init(this); + cling.setVisibility(View.VISIBLE); + } + if (!prefs.getBoolean(ALLAPPS_CLING_DISMISSED_KEY, false)) { + Cling cling = (Cling) findViewById(R.id.all_apps_cling); + cling.init(this); + cling.setVisibility(View.VISIBLE); + } + } + private void dismissCling(final Cling cling, final String flag) { + if (cling != null) { + ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f); + anim.setDuration(DISMISS_CLING_DURATION); + anim.addListener(new AnimatorListenerAdapter() { + public void onAnimationEnd(Animator animation) { + cling.setVisibility(View.GONE); + cling.cleanup(); + SharedPreferences prefs = + getSharedPreferences("com.android.launcher2.prefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(flag, true); + editor.commit(); + }; + }); + anim.start(); + } + } + public void dismissWorkspaceCling(View v) { + Cling cling = (Cling) findViewById(R.id.workspace_cling); + dismissCling(cling, WORKSPACE_CLING_DISMISSED_KEY); + } + public void dismissAllAppsCling(View v) { + Cling cling = (Cling) findViewById(R.id.all_apps_cling); + dismissCling(cling, ALLAPPS_CLING_DISMISSED_KEY); + } + /** * Prints out out state for debugging. */ |