Merge "Adding signposting to Phone UI in Workspace/AppsCustomize."

This commit is contained in:
Winson Chung authored and Android (Google) Code Review committed 2011-06-14 16:03:32 -07:00
commit ec18d35d4f
8 files changed
+145 -12

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

+9
View File
@@ -39,6 +39,15 @@
<include android:id="@+id/cell4" layout="@layout/workspace_screen" />
<include android:id="@+id/cell5" layout="@layout/workspace_screen" />
</com.android.launcher2.Workspace>
<ImageView
android:id="@+id/paged_view_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
android:alpha="0"
android:scaleType="fitXY"
android:src="@drawable/paged_view_indicator" />
<include layout="@layout/qsb_bar"
android:id="@+id/qsb_bar"
+10
View File
@@ -37,6 +37,16 @@
<include android:id="@+id/cell4" layout="@layout/workspace_screen" />
<include android:id="@+id/cell5" layout="@layout/workspace_screen" />
</com.android.launcher2.Workspace>
<ImageView
android:id="@+id/paged_view_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
android:paddingBottom="@dimen/button_bar_height"
android:alpha="0"
android:scaleType="fitXY"
android:src="@drawable/paged_view_indicator" />
<include layout="@layout/qsb_bar"
android:id="@+id/qsb_bar"
+9
View File
@@ -72,6 +72,15 @@
launcher:widgetCellHeightGap="@dimen/apps_customize_widget_cell_height_gap"
launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y" />
<ImageView
android:id="@+id/paged_view_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
android:alpha="0"
android:scaleType="fitXY"
android:src="@drawable/paged_view_indicator" />
</FrameLayout>
</LinearLayout>
</com.android.launcher2.AppsCustomizeTabHost>
@@ -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();
}
}
+89
View File
@@ -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);
}
}
+23 -2
View File
@@ -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