summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-06-14 13:27:53 -0700
committerWinson Chung <winsonc@google.com>2011-06-14 16:02:56 -0700
commit007c69867d821ea2b271398577a8b3440b3a7046 (patch)
treec850cd8c83b13fd5941bdeb78b75212394847d90 /src/com
parent1dfdf234cc70f5c6d0b74895babd31a5d0e36222 (diff)
downloadandroid_packages_apps_Trebuchet-007c69867d821ea2b271398577a8b3440b3a7046.tar.gz
android_packages_apps_Trebuchet-007c69867d821ea2b271398577a8b3440b3a7046.tar.bz2
android_packages_apps_Trebuchet-007c69867d821ea2b271398577a8b3440b3a7046.zip
Adding signposting to Phone UI in Workspace/AppsCustomize.
Change-Id: Id63f247745a5ec1a63bbaff84602e4c91354f789
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java15
-rw-r--r--src/com/android/launcher2/PagedView.java89
-rw-r--r--src/com/android/launcher2/Workspace.java25
3 files changed, 117 insertions, 12 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index dfdbce917..5b4f15062 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -84,7 +84,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private IconCache mIconCache;
// Dimens
- private Runnable mOnSizeChangedCallback;
private int mContentWidth;
private int mMaxWidgetSpan, mMinWidgetSpan;
private int mWidgetWidthGap, mWidgetHeightGap;
@@ -190,11 +189,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mWidgetCountY = Math.max(1, (int) Math.round(mCellCountY / 3f));
mContentWidth = mWidgetSpacingLayout.getContentWidth();
- // Notify our parent so that we can synchronize the tab bar width to this page width
- if (mOnSizeChangedCallback != null) {
- mOnSizeChangedCallback.run();
- }
-
invalidatePageData();
}
@@ -213,10 +207,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
- public void setOnSizeChangedCallback(Runnable r) {
- mOnSizeChangedCallback = r;
- }
-
/** Removes and returns the ResolveInfo with the specified ComponentName */
private ResolveInfo removeResolveInfoWithComponentName(List<ResolveInfo> list,
ComponentName cn) {
@@ -886,4 +876,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// TODO: If we are in the middle of any process (ie. for holographic outlines, etc) we
// should stop this now.
}
+
+ @Override
+ protected int getPageWidthForScrollingIndicator() {
+ return getPageContentWidth();
+ }
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index d83db7435..1fa23cf4c 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -41,6 +41,7 @@ import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Interpolator;
import android.widget.Checkable;
+import android.widget.ImageView;
import android.widget.Scroller;
import com.android.launcher.R;
@@ -162,6 +163,13 @@ public abstract class PagedView extends ViewGroup {
// All syncs and layout passes are deferred until data is ready.
protected boolean mIsDataReady = false;
+ // Scrolling indicator
+ private ImageView mScrollIndicator;
+ private boolean mHasScrollIndicator = true;
+ private static final int sScrollIndicatorFadeInDuration = 150;
+ private static final int sScrollIndicatorFastFadeOutDuration = 50;
+ private static final int sScrollIndicatorFadeOutDuration = 650;
+
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
}
@@ -306,10 +314,12 @@ public abstract class PagedView extends ViewGroup {
// a method that subclasses can override to add behavior
protected void onPageBeginMoving() {
+ showScrollingIndicator();
}
// a method that subclasses can override to add behavior
protected void onPageEndMoving() {
+ hideScrollingIndicator(false);
}
/**
@@ -612,6 +622,7 @@ public abstract class PagedView extends ViewGroup {
}
protected void screenScrolled(int screenCenter) {
+ updateScrollingIndicator();
}
@Override
@@ -1583,6 +1594,8 @@ public abstract class PagedView extends ViewGroup {
}
if (mContentIsRefreshable) {
+ hideScrollingIndicator(true);
+
// Update all the pages
syncPages();
@@ -1600,4 +1613,80 @@ public abstract class PagedView extends ViewGroup {
requestLayout();
}
}
+
+ private ImageView getScrollingIndicator() {
+ // We use mHasScrollIndicator to prevent future lookups if there is no sibling indicator
+ // found
+ if (mHasScrollIndicator && mScrollIndicator == null) {
+ ViewGroup parent = (ViewGroup) getParent();
+ mScrollIndicator = (ImageView) (parent.findViewById(R.id.paged_view_indicator));
+ mHasScrollIndicator = mScrollIndicator != null;
+ if (mHasScrollIndicator) {
+ mScrollIndicator.setVisibility(View.VISIBLE);
+ }
+ }
+ return mScrollIndicator;
+ }
+
+ protected boolean isScrollingIndicatorEnabled() {
+ return true;
+ }
+
+ protected void showScrollingIndicator() {
+ if (LauncherApplication.isScreenLarge()) return;
+ if (getChildCount() <= 1) return;
+ if (!isScrollingIndicatorEnabled()) return;
+
+ 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);
+ }
+ }
+
+ protected void hideScrollingIndicator(boolean immediately) {
+ if (LauncherApplication.isScreenLarge()) return;
+ if (getChildCount() <= 1) return;
+ if (!isScrollingIndicatorEnabled()) return;
+
+ getScrollingIndicator();
+ if (mScrollIndicator != null) {
+ // Fade the indicator out
+ updateScrollingIndicatorPosition();
+ mScrollIndicator.animate().alpha(0f).setDuration(immediately ?
+ sScrollIndicatorFastFadeOutDuration : sScrollIndicatorFadeOutDuration);
+ }
+ }
+
+ private void updateScrollingIndicator() {
+ if (LauncherApplication.isScreenLarge()) return;
+ if (getChildCount() <= 1) return;
+ if (!isScrollingIndicatorEnabled()) return;
+
+ getScrollingIndicator();
+ if (mScrollIndicator != null) {
+ updateScrollingIndicatorPosition();
+ }
+ }
+
+ protected int getPageWidthForScrollingIndicator() {
+ return getMeasuredWidth();
+ }
+
+ private void updateScrollingIndicatorPosition() {
+ // We can make the page width smaller to make it look more centered
+ int pageWidth = getPageWidthForScrollingIndicator();
+ int pageOffset = (getMeasuredWidth() - pageWidth) / 2;
+ int maxPageWidth = getChildCount() * pageWidth;
+ float offset = (float) getScrollX() / maxPageWidth;
+ int indicatorWidth = pageWidth / getChildCount();
+ int indicatorCenterOffset = indicatorWidth / 2 - mScrollIndicator.getMeasuredWidth() / 2;
+ int indicatorPos = (int) (offset * pageWidth) + pageOffset + indicatorCenterOffset;
+ mScrollIndicator.setTranslationX(indicatorPos);
+ }
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 1e012540b..1048fd570 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -635,7 +635,14 @@ public class Workspace extends SmoothPagedView
}
}
+ @Override
+ protected boolean isScrollingIndicatorEnabled() {
+ return mShrinkState != ShrinkState.SPRING_LOADED;
+ }
+
protected void onPageBeginMoving() {
+ super.onPageBeginMoving();
+
if (mNextPage != INVALID_PAGE) {
// we're snapping to a particular screen
enableChildrenCache(mCurrentPage, mNextPage);
@@ -644,14 +651,23 @@ public class Workspace extends SmoothPagedView
// swipe it either left or right (but we won't advance by more than one screen)
enableChildrenCache(mCurrentPage - 1, mCurrentPage + 1);
}
- showOutlines();
+
+ // Only show page outlines as we pan if we are on large screen
+ if (LauncherApplication.isScreenLarge()) {
+ showOutlines();
+ }
}
protected void onPageEndMoving() {
+ super.onPageEndMoving();
+
clearChildrenCache();
// Hide the outlines, as long as we're not dragging
if (!mDragController.dragging()) {
- hideOutlines();
+ // Only hide page outlines as we pan if we are on large screen
+ if (LauncherApplication.isScreenLarge()) {
+ hideOutlines();
+ }
}
mOverScrollMaxBackgroundAlpha = 0.0f;
mOverScrollPageIndex = -1;
@@ -1081,6 +1097,8 @@ public class Workspace extends SmoothPagedView
@Override
protected void screenScrolled(int screenCenter) {
+ super.screenScrolled(screenCenter);
+
// If the screen is not xlarge, then don't rotate the CellLayouts
// NOTE: If we don't update the side pages alpha, then we should not hide the side pages.
// see unshrink().
@@ -1425,6 +1443,9 @@ public class Workspace extends SmoothPagedView
updateWhichPagesAcceptDrops(shrinkState);
}
+ // Hide the scrollbar
+ hideScrollingIndicator(true);
+
CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage);
if (currentPage == null) {
Log.w(TAG, "currentPage is NULL! mCurrentPage " + mCurrentPage