Merge "Fxing issues with the scroll bar"

This commit is contained in:
Winson Chung
2011-07-20 09:26:48 -07:00
committed by Android (Google) Code Review
12 changed files with 133 additions and 80 deletions
+15 -15
View File
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/paged_view_indicator_track"
layout="@layout/scroll_indicator_track"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<include
android:id="@+id/paged_view_indicator"
layout="@layout/scroll_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher2.Workspace
android:id="@+id/workspace"
@@ -41,19 +54,6 @@
<include android:id="@+id/cell5" layout="@layout/workspace_screen" />
</com.android.launcher2.Workspace>
<include
android:id="@+id/paged_view_indicator_track"
layout="@layout/scroll_indicator_track"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<include
android:id="@+id/paged_view_indicator"
layout="@layout/scroll_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<include layout="@layout/qsb_bar"
android:id="@+id/qsb_bar"
android:layout_width="@dimen/qsb_bar_height"
+19 -17
View File
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,23 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
<include
android:id="@+id/paged_view_indicator_track"
layout="@layout/scroll_indicator_track"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/button_bar_height" />
<include
android:id="@+id/paged_view_indicator"
layout="@layout/scroll_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/button_bar_height" />
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher2.Workspace
android:id="@+id/workspace"
@@ -39,21 +56,6 @@
<include android:id="@+id/cell5" layout="@layout/workspace_screen" />
</com.android.launcher2.Workspace>
<include
android:id="@+id/paged_view_indicator_track"
layout="@layout/scroll_indicator_track"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/button_bar_height" />
<include
android:id="@+id/paged_view_indicator"
layout="@layout/scroll_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/button_bar_height" />
<include layout="@layout/qsb_bar"
android:id="@+id/qsb_bar"
android:layout_width="match_parent"
-7
View File
@@ -78,13 +78,6 @@
launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
launcher:maxGap="@dimen/workspace_max_gap" />
<include
style="@style/AppsCustomizeScrollTrack"
android:id="@+id/paged_view_indicator_track"
layout="@layout/scroll_indicator_track"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<include
android:id="@+id/paged_view_indicator"
layout="@layout/scroll_indicator"
+2 -2
View File
@@ -16,7 +16,7 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:paddingLeft="@dimen/scroll_track_padding"
android:paddingRight="@dimen/scroll_track_padding"
android:paddingLeft="@dimen/scroll_track_padding_left"
android:paddingRight="@dimen/scroll_track_padding_right"
android:scaleType="fitXY"
android:src="@drawable/hotseat_track_holo" />
+2
View File
@@ -25,6 +25,8 @@
<dimen name="workspace_top_padding">0dp</dimen>
<dimen name="workspace_bottom_padding">0dp</dimen>
<dimen name="workspace_page_spacing">8dp</dimen>
<dimen name="scroll_track_padding_left">@dimen/qsb_bar_height</dimen>
<dimen name="scroll_track_padding_right">@dimen/button_bar_height</dimen>
<dimen name="folder_cell_width">100dip</dimen>
<dimen name="folder_cell_height">74dip</dimen>
-5
View File
@@ -18,11 +18,6 @@
-->
<resources>
<!-- AppsCustomize -->
<style name="AppsCustomizeScrollTrack">
<item name="android:visibility">gone</item>
</style>
<!-- Workspace -->
<style name="ScrollIndicatorTrack">
<item name="android:visibility">gone</item>
+2 -1
View File
@@ -22,7 +22,8 @@
<dimen name="workspace_width_gap">-1dp</dimen>
<dimen name="workspace_height_gap">-1dp</dimen>
<dimen name="workspace_max_gap">8dp</dimen>
<dimen name="scroll_track_padding">10dp</dimen>
<dimen name="scroll_track_padding_left">12dp</dimen>
<dimen name="scroll_track_padding_right">12dp</dimen>
<!-- QSB -->
<dimen name="toolbar_button_vertical_padding">0dip</dimen>
+1 -5
View File
@@ -29,15 +29,11 @@
<item name="android:windowNoTitle">true</item>
</style>
<style name="AppsCustomizeScrollTrack">
<item name="android:visibility">visible</item>
</style>
<style name="AnimationPreview">
<item name="android:windowEnterAnimation">@anim/fade_in_fast</item>
<item name="android:windowExitAnimation">@anim/fade_out_fast</item>
</style>
<style name="WorkspaceIcon">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
@@ -146,6 +146,10 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
ObjectAnimator anim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 0f);
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(android.animation.Animator animation) {
mAppsCustomizePane.hideScrollingIndicator(false);
}
@Override
public void onAnimationEnd(android.animation.Animator animation) {
mAppsCustomizePane.setContentType(type);
+14 -12
View File
@@ -2410,12 +2410,6 @@ public final class Launcher extends Activity
toView.setTranslationY(0.0f);
toView.setVisibility(View.VISIBLE);
toView.bringToFront();
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
mWorkspace.hideScrollIndicatorTrack();
}
}
@Override
public void onAnimationEnd(Animator animation) {
@@ -2427,6 +2421,12 @@ public final class Launcher extends Activity
if (toView instanceof LauncherTransitionable) {
((LauncherTransitionable) toView).onLauncherTransitionEnd(scaleAnim);
}
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
mWorkspace.hideScrollIndicatorTrack();
}
}
});
@@ -2505,17 +2505,19 @@ public final class Launcher extends Activity
((LauncherTransitionable) fromView).onLauncherTransitionStart(alphaAnim);
}
alphaAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(android.animation.Animator animation) {
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Show the workspace scrollbar
mWorkspace.showScrollIndicatorTrack();
mWorkspace.flashScrollingIndicator();
}
}
@Override
public void onAnimationEnd(Animator animation) {
fromView.setVisibility(View.GONE);
if (fromView instanceof LauncherTransitionable) {
((LauncherTransitionable) fromView).onLauncherTransitionEnd(alphaAnim);
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Show the workspace scrollbar
mWorkspace.showScrollIndicatorTrack();
mWorkspace.flashScrollingIndicator();
}
}
}
});
+67 -16
View File
@@ -161,11 +161,11 @@ public abstract class PagedView extends ViewGroup {
protected boolean mIsDataReady = false;
// Scrolling indicator
private android.animation.ValueAnimator mScrollIndicatorAnimator;
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;
@@ -260,10 +260,6 @@ public abstract class PagedView extends ViewGroup {
return getChildAt(index);
}
int getScrollWidth() {
return getWidth();
}
/**
* Updates the scroll of the current page immediately to its final scroll position. We use this
* in CustomizePagedView to allow tabs to share the same PagedView while resetting the scroll of
@@ -1676,7 +1672,13 @@ public abstract class PagedView extends ViewGroup {
if (mScrollIndicator != null) {
// Fade the indicator in
updateScrollingIndicatorPosition();
mScrollIndicator.animate().alpha(1f).setDuration(sScrollIndicatorFadeInDuration).start();
mScrollIndicator.setVisibility(View.VISIBLE);
if (mScrollIndicatorAnimator != null) {
mScrollIndicatorAnimator.cancel();
}
mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 1f);
mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeInDuration);
mScrollIndicatorAnimator.start();
}
}
@@ -1688,11 +1690,41 @@ public abstract class PagedView extends ViewGroup {
if (mScrollIndicator != null) {
// Fade the indicator out
updateScrollingIndicatorPosition();
mScrollIndicator.animate().alpha(0f).setDuration(immediately ?
sScrollIndicatorFastFadeOutDuration : sScrollIndicatorFadeOutDuration).start();
if (mScrollIndicatorAnimator != null) {
mScrollIndicatorAnimator.cancel();
}
if (immediately) {
mScrollIndicator.setVisibility(View.GONE);
mScrollIndicator.setAlpha(0f);
} else {
mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 0f);
mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeOutDuration);
mScrollIndicatorAnimator.addListener(new AnimatorListenerAdapter() {
private boolean cancelled = false;
@Override
public void onAnimationCancel(android.animation.Animator animation) {
cancelled = true;
}
@Override
public void onAnimationEnd(Animator animation) {
if (!cancelled) {
mScrollIndicator.setVisibility(View.GONE);
}
}
});
mScrollIndicatorAnimator.start();
}
}
}
/**
* To be overridden by subclasses to determine whether the scroll indicator should stretch to
* fill its space on the track or not.
*/
protected boolean hasElasticScrollIndicator() {
return false;
}
private void updateScrollingIndicator() {
if (getChildCount() <= 1) return;
if (!isScrollingIndicatorEnabled()) return;
@@ -1706,16 +1738,35 @@ public abstract class PagedView extends ViewGroup {
private void updateScrollingIndicatorPosition() {
if (!isScrollingIndicatorEnabled()) return;
// We can make the page width smaller to make it look more centered
int numPages = getChildCount();
int pageWidth = getMeasuredWidth();
int maxPageWidth = (numPages * getMeasuredWidth()) + ((numPages - 1) * mPageSpacing);
int trackWidth = pageWidth;
int indicatorWidth = mScrollIndicator.getMeasuredWidth() -
mScrollIndicator.getPaddingLeft() - mScrollIndicator.getPaddingRight();
int paddingLeft = 0;
int paddingRight = 0;
// Get the track properties
getScrollingIndicatorTrack();
int pageWidth = mScrollTrack.getMeasuredWidth() - mScrollTrack.getPaddingLeft() -
mScrollTrack.getPaddingRight();
int maxPageWidth = getChildCount() * getMeasuredWidth();
if (mScrollTrack != null) {
paddingLeft = mScrollTrack.getPaddingLeft();
paddingRight = mScrollTrack.getPaddingRight();
trackWidth = mScrollTrack.getMeasuredWidth() - paddingLeft - paddingRight;
}
float offset = (float) getScrollX() / maxPageWidth;
int indicatorWidth = pageWidth / getChildCount();
int indicatorCenterOffset = indicatorWidth / 2 - mScrollIndicator.getMeasuredWidth() / 2;
int indicatorPos = (int) (offset * pageWidth) + mScrollTrack.getPaddingLeft() +
indicatorCenterOffset;
int indicatorSpace = trackWidth / numPages;
int indicatorPos = (int) (offset * trackWidth) + paddingLeft;
if (hasElasticScrollIndicator()) {
if (mScrollIndicator.getMeasuredWidth() != indicatorSpace) {
mScrollIndicator.getLayoutParams().width = indicatorSpace;
mScrollIndicator.requestLayout();
}
} else {
int indicatorCenterOffset = indicatorSpace / 2 - indicatorWidth / 2;
indicatorPos += indicatorCenterOffset;
}
mScrollIndicator.setTranslationX(indicatorPos);
mScrollIndicator.invalidate();
}
+7
View File
@@ -3334,4 +3334,11 @@ public class Workspace extends SmoothPagedView
public void getLocationInDragLayer(int[] loc) {
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
/**
* Return true because we want the scrolling indicator to stretch to fit the space.
*/
protected boolean hasElasticScrollIndicator() {
return true;
}
}