diff options
author | Winson Chung <winsonc@google.com> | 2013-10-09 12:04:50 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2013-10-10 11:59:35 -0700 |
commit | 82e5c98446e1f1765aabca1725cba181a56edcb4 (patch) | |
tree | 7a74c3cc5546592f1f619adf5733872b06d9a5c5 /src | |
parent | f248abc12238e79432c07e8cbc435ed5ac8c1ce9 (diff) | |
download | android_packages_apps_Trebuchet-82e5c98446e1f1765aabca1725cba181a56edcb4.tar.gz android_packages_apps_Trebuchet-82e5c98446e1f1765aabca1725cba181a56edcb4.tar.bz2 android_packages_apps_Trebuchet-82e5c98446e1f1765aabca1725cba181a56edcb4.zip |
Update custom content hint after custom content is invalidated (Bug 11067230)
Change-Id: I5f98e2a0e4bc3439ff36688555990798c59efa58
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 57 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 6 |
2 files changed, 58 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 2e29ae28b..324a479c4 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -4182,6 +4182,57 @@ public class Launcher extends Activity return false; } + public void updateCustomContentHintVisibility() { + Cling cling = (Cling) findViewById(R.id.first_run_cling); + String ccHintStr = getFirstRunCustomContentHint(); + + if (mWorkspace.hasCustomContent()) { + // Show the custom content hint if ccHintStr is not empty + if (cling != null) { + setCustomContentHintVisibility(cling, ccHintStr, true, true); + } + } else { + // Hide the custom content hint + if (cling != null) { + setCustomContentHintVisibility(cling, ccHintStr, false, true); + } + } + } + + private void setCustomContentHintVisibility(Cling cling, String ccHintStr, boolean visible, + boolean animate) { + final TextView ccHint = (TextView) cling.findViewById(R.id.custom_content_hint); + if (ccHint != null) { + if (visible && !ccHintStr.isEmpty()) { + ccHint.setText(ccHintStr); + ccHint.setVisibility(View.VISIBLE); + if (animate) { + ccHint.setAlpha(0f); + ccHint.animate().alpha(1f) + .setDuration(SHOW_CLING_DURATION) + .start(); + } else { + ccHint.setAlpha(1f); + } + } else { + if (animate) { + ccHint.animate().alpha(0f) + .setDuration(SHOW_CLING_DURATION) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + ccHint.setVisibility(View.GONE); + } + }) + .start(); + } else { + ccHint.setAlpha(0f); + ccHint.setVisibility(View.GONE); + } + } + } + } + public void showFirstRunCling() { if (isClingsEnabled() && !mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) && @@ -4211,11 +4262,7 @@ public class Launcher extends Activity sbHint.setText(sbHintStr); sbHint.setVisibility(View.VISIBLE); } - if (!ccHintStr.isEmpty()) { - TextView ccHint = (TextView) cling.findViewById(R.id.custom_content_hint); - ccHint.setText(ccHintStr); - ccHint.setVisibility(View.VISIBLE); - } + setCustomContentHintVisibility(cling, ccHintStr, true, false); } initCling(R.id.first_run_cling, 0, false, true); } else { diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 4515b03ab..3c9a139fe 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -539,6 +539,9 @@ public class Workspace extends SmoothPagedView // Ensure that the current page and default page are maintained. mDefaultPage = mOriginalDefaultPage + 1; setCurrentPage(getCurrentPage() + 1); + + // Update the custom content hint + mLauncher.updateCustomContentHintVisibility(); } public void removeCustomContentPage() { @@ -555,6 +558,9 @@ public class Workspace extends SmoothPagedView // Ensure that the current page and default page are maintained. mDefaultPage = mOriginalDefaultPage - 1; setCurrentPage(getCurrentPage() - 1); + + // Update the custom content hint + mLauncher.updateCustomContentHintVisibility(); } public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks, |