am 82e5c984: Update custom content hint after custom content is invalidated (Bug 11067230)

* commit '82e5c98446e1f1765aabca1725cba181a56edcb4':
  Update custom content hint after custom content is invalidated (Bug 11067230)
This commit is contained in:
Winson Chung
2013-10-10 12:26:53 -07:00
committed by Android Git Automerger
2 changed files with 58 additions and 5 deletions
+52 -5
View File
@@ -4182,6 +4182,57 @@ public class Launcher extends Activity
return false; 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() { public void showFirstRunCling() {
if (isClingsEnabled() && if (isClingsEnabled() &&
!mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) && !mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) &&
@@ -4211,11 +4262,7 @@ public class Launcher extends Activity
sbHint.setText(sbHintStr); sbHint.setText(sbHintStr);
sbHint.setVisibility(View.VISIBLE); sbHint.setVisibility(View.VISIBLE);
} }
if (!ccHintStr.isEmpty()) { setCustomContentHintVisibility(cling, ccHintStr, true, false);
TextView ccHint = (TextView) cling.findViewById(R.id.custom_content_hint);
ccHint.setText(ccHintStr);
ccHint.setVisibility(View.VISIBLE);
}
} }
initCling(R.id.first_run_cling, 0, false, true); initCling(R.id.first_run_cling, 0, false, true);
} else { } else {
+6
View File
@@ -539,6 +539,9 @@ public class Workspace extends SmoothPagedView
// Ensure that the current page and default page are maintained. // Ensure that the current page and default page are maintained.
mDefaultPage = mOriginalDefaultPage + 1; mDefaultPage = mOriginalDefaultPage + 1;
setCurrentPage(getCurrentPage() + 1); setCurrentPage(getCurrentPage() + 1);
// Update the custom content hint
mLauncher.updateCustomContentHintVisibility();
} }
public void removeCustomContentPage() { public void removeCustomContentPage() {
@@ -555,6 +558,9 @@ public class Workspace extends SmoothPagedView
// Ensure that the current page and default page are maintained. // Ensure that the current page and default page are maintained.
mDefaultPage = mOriginalDefaultPage - 1; mDefaultPage = mOriginalDefaultPage - 1;
setCurrentPage(getCurrentPage() - 1); setCurrentPage(getCurrentPage() - 1);
// Update the custom content hint
mLauncher.updateCustomContentHintVisibility();
} }
public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks, public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks,