From 3ac74c55cf8baef29db80e8c67ab4ab033b04417 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 30 Jun 2011 17:39:37 -0700 Subject: [PATCH] Tweaking the scroll indicators with new assets and sizing. - Showing the scroll indicators when changing between workspace/apps customize Change-Id: I791c09b76deb00108c466f08ae3c29b19d77c4d8 --- res/drawable-hdpi/hotseat_scrubber_holo.9.png | Bin 0 -> 184 bytes res/drawable-hdpi/hotseat_track_holo.9.png | Bin 0 -> 174 bytes res/drawable-hdpi/paged_view_indicator.9.png | Bin 358 -> 0 bytes res/drawable-mdpi/hotseat_scrubber_holo.9.png | Bin 0 -> 173 bytes res/drawable-mdpi/hotseat_track_holo.9.png | Bin 0 -> 157 bytes res/layout-land/launcher.xml | 10 +++- res/layout-port/launcher.xml | 13 ++++- res/layout/apps_customize_pane.xml | 9 +++- .../launcher2/AppsCustomizeTabHost.java | 8 +++ src/com/android/launcher2/Launcher.java | 16 ++++++ src/com/android/launcher2/PagedView.java | 49 +++++++++++++++--- src/com/android/launcher2/Workspace.java | 3 -- 12 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 res/drawable-hdpi/hotseat_scrubber_holo.9.png create mode 100644 res/drawable-hdpi/hotseat_track_holo.9.png delete mode 100644 res/drawable-hdpi/paged_view_indicator.9.png create mode 100644 res/drawable-mdpi/hotseat_scrubber_holo.9.png create mode 100644 res/drawable-mdpi/hotseat_track_holo.9.png diff --git a/res/drawable-hdpi/hotseat_scrubber_holo.9.png b/res/drawable-hdpi/hotseat_scrubber_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..78b540d470dd3afa8b2006cca763c3708af130d8 GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^hCs~5!3HF=9+z9s(?C{Gv15R2Zcmp5{@I0&>|{C=9vEHUBc^~td_W^Z(Q(oUDbnj%ab=_q$4(b&#ijXExPQS;`$5@H{0dS*$uZR b^z+u|-4QrxGL@wiXbXd9s(?08bak5R2Zcmp5`Y1n{suv@XypFNj@UpyXJ`t=kfAJA1- zDk~Tk%1`dQxmd?W+~8zbtntgBa)!$341JfDRH|>d^qH6KqxF>3Kk5f~bv}zQJ>Y(P Q31~Khr>mdKI;Vst0Ns5xk^lez literal 0 HcmV?d00001 diff --git a/res/drawable-hdpi/paged_view_indicator.9.png b/res/drawable-hdpi/paged_view_indicator.9.png deleted file mode 100644 index 9fd357a88a3329dd7be2880b829bf0441ce01d9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmV-s0h#`ZP)U z!6AAeEgRLy1y0ETRVR$kIr5#&10S63k3>EQE0J0BVF< zH5`&c)f0n8s&!~B8_I#Ka={9u!;RI_N)PJbIiNoc!nT3iQFYHswFNeJSm#U1q?sZ~ z9g=&by@1^x>vj-e06Y1J3qF$R8vp9s&Xe@_?35RHjPFKy&)c91yw;C-id9%n*c*(nho2XE$I!7XbJR5G0| zTID6Ak?awg>3PFWmV4QB)x0k%>7TU?lj|dy^wwMu=+P;vQ2EDG&9d);hrp=?b^mVw Pjb`w4^>bP0l+XkKwDL6~ literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/hotseat_track_holo.9.png b/res/drawable-mdpi/hotseat_track_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..a542cb7b9e6d7c8603df064d52231ff403ba02aa GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^N9s&Xdrud~5RHjPCv4U(|I#bW!aC;JPRks<}Zu-c86?Jy6wSa zAeplKO1+JR|B6-n91gsCC;7o{<2%7Ffdg!1fdWjyU2C|3MlpE0`njxgN@xNAvYRgZ literal 0 HcmV?d00001 diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index 3c5e0df365..d2f52c8399 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -39,6 +39,14 @@ + + + android:src="@drawable/hotseat_scrubber_holo" /> + + + android:src="@drawable/hotseat_scrubber_holo" /> + + android:src="@drawable/hotseat_scrubber_holo" /> diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index 587a3eb5fb..2623586006 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -152,6 +152,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona ObjectAnimator anim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f); anim.setDuration(duration); + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(android.animation.Animator animation) { + mAppsCustomizePane.flashScrollingIndicator(); + } + }); anim.start(); } }); @@ -212,5 +218,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona if (animation != null) { setLayerType(LAYER_TYPE_NONE, null); } + + mAppsCustomizePane.flashScrollingIndicator(); } } diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 54b7b9c2c1..0fb24f6e62 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2387,6 +2387,10 @@ public final class Launcher extends Activity toView.setTranslationY(0.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); + + // Hide the workspace scrollbar + mWorkspace.hideScrollingIndicator(true); + mWorkspace.hideScrollIndicatorTrack(); } @Override public void onAnimationEnd(Animator animation) { @@ -2418,6 +2422,10 @@ public final class Launcher extends Activity if (toView instanceof LauncherTransitionable) { ((LauncherTransitionable) toView).onLauncherTransitionStart(null); ((LauncherTransitionable) toView).onLauncherTransitionEnd(null); + + // Hide the workspace scrollbar + mWorkspace.hideScrollingIndicator(true); + mWorkspace.hideScrollIndicatorTrack(); } } } @@ -2475,6 +2483,10 @@ public final class Launcher extends Activity fromView.setVisibility(View.GONE); if (fromView instanceof LauncherTransitionable) { ((LauncherTransitionable) fromView).onLauncherTransitionEnd(alphaAnim); + + // Show the workspace scrollbar + mWorkspace.showScrollIndicatorTrack(); + mWorkspace.flashScrollingIndicator(); } } }); @@ -2486,6 +2498,10 @@ public final class Launcher extends Activity if (fromView instanceof LauncherTransitionable) { ((LauncherTransitionable) fromView).onLauncherTransitionStart(null); ((LauncherTransitionable) fromView).onLauncherTransitionEnd(null); + + // Show the workspace scrollbar + mWorkspace.showScrollIndicatorTrack(); + mWorkspace.flashScrollingIndicator(); } } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 9ca2f90ff4..a90d32fbf5 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -162,10 +162,12 @@ public abstract class PagedView extends ViewGroup { // Scrolling indicator private ImageView mScrollIndicator; + private ImageView mScrollTrack; private boolean mHasScrollIndicator = true; private static final int sScrollIndicatorFadeInDuration = 150; private static final int sScrollIndicatorFastFadeOutDuration = 50; private static final int sScrollIndicatorFadeOutDuration = 650; + private static final int sScrollIndicatorFlashDuration = 650; // If set, will defer loading associated pages until the scrolling settles private boolean mDeferLoadAssociatedPagesUntilScrollCompletes; @@ -1606,8 +1608,6 @@ public abstract class PagedView extends ViewGroup { } if (mContentIsRefreshable) { - hideScrollingIndicator(true); - // Update all the pages syncPages(); @@ -1644,6 +1644,16 @@ public abstract class PagedView extends ViewGroup { return true; } + protected void flashScrollingIndicator() { + showScrollingIndicator(); + postDelayed(new Runnable() { + @Override + public void run() { + hideScrollingIndicator(false); + } + }, sScrollIndicatorFlashDuration); + } + protected void showScrollingIndicator() { if (LauncherApplication.isScreenLarge()) return; if (getChildCount() <= 1) return; @@ -1651,13 +1661,9 @@ public abstract class PagedView extends ViewGroup { getScrollingIndicator(); if (mScrollIndicator != null) { - // Update the width of the indicator to the approx. width of each page in the full bar - mScrollIndicator.getLayoutParams().width = getPageWidthForScrollingIndicator() / getChildCount(); - mScrollIndicator.requestLayout(); - // Fade the indicator in updateScrollingIndicatorPosition(); - mScrollIndicator.animate().alpha(1f).setDuration(sScrollIndicatorFadeInDuration); + mScrollIndicator.animate().alpha(1f).setDuration(sScrollIndicatorFadeInDuration).start(); } } @@ -1671,7 +1677,7 @@ public abstract class PagedView extends ViewGroup { // Fade the indicator out updateScrollingIndicatorPosition(); mScrollIndicator.animate().alpha(0f).setDuration(immediately ? - sScrollIndicatorFastFadeOutDuration : sScrollIndicatorFadeOutDuration); + sScrollIndicatorFastFadeOutDuration : sScrollIndicatorFadeOutDuration).start(); } } @@ -1700,6 +1706,33 @@ public abstract class PagedView extends ViewGroup { int indicatorCenterOffset = indicatorWidth / 2 - mScrollIndicator.getMeasuredWidth() / 2; int indicatorPos = (int) (offset * pageWidth) + pageOffset + indicatorCenterOffset; mScrollIndicator.setTranslationX(indicatorPos); + mScrollIndicator.invalidate(); + } + + private ImageView getScrollingIndicatorTrack() { + if (mScrollTrack == null) { + ViewGroup parent = (ViewGroup) getParent(); + mScrollTrack = (ImageView) (parent.findViewById(R.id.paged_view_indicator_track)); + } + return mScrollTrack; + } + + public void showScrollIndicatorTrack() { + if (!LauncherApplication.isScreenLarge()) { + getScrollingIndicatorTrack(); + if (mScrollTrack != null) { + mScrollTrack.setVisibility(View.VISIBLE); + } + } + } + + public void hideScrollIndicatorTrack() { + if (!LauncherApplication.isScreenLarge()) { + getScrollingIndicatorTrack(); + if (mScrollTrack != null) { + mScrollTrack.setVisibility(View.GONE); + } + } } /* Accessibility */ diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 5ba9fd7af5..2b799ee63f 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -1381,9 +1381,6 @@ public class Workspace extends SmoothPagedView // Stop any scrolling, move to the current page right away setCurrentPage((mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage); - // Hide the scrollbar - hideScrollingIndicator(true); - CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage); if (currentPage == null) { Log.w(TAG, "currentPage is NULL! mCurrentPage " + mCurrentPage