summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/folder
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-05-18 14:12:02 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-05-18 17:50:34 -0700
commitc64cfdd8fa18de45fc1646c8ef2449f39ef83022 (patch)
tree391350ff19d812cc0f52c9d5324ec90c530352ea /src/com/android/launcher3/folder
parent770217c697a92b441b66fac6d3441db1c0a84a3a (diff)
downloadandroid_packages_apps_Trebuchet-c64cfdd8fa18de45fc1646c8ef2449f39ef83022.tar.gz
android_packages_apps_Trebuchet-c64cfdd8fa18de45fc1646c8ef2449f39ef83022.tar.bz2
android_packages_apps_Trebuchet-c64cfdd8fa18de45fc1646c8ef2449f39ef83022.zip
Updating the folder page indicator to be more like the
framework page indicator (used in quick settings) The active page is indicated with the accent color. During scroll the active indicator expands to 2 dots corresponding to the visible pages. Change-Id: Iaf57836b642cf87e5eed98048ecca7dd8e7643a4
Diffstat (limited to 'src/com/android/launcher3/folder')
-rw-r--r--src/com/android/launcher3/folder/Folder.java9
-rw-r--r--src/com/android/launcher3/folder/FolderPagedView.java52
2 files changed, 16 insertions, 45 deletions
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 1ebe8fdfb..6df296e7d 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -78,6 +78,7 @@ import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
+import com.android.launcher3.pageindicators.PageIndicatorDots;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.Thunk;
@@ -148,6 +149,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
@Thunk FolderPagedView mContent;
@Thunk View mContentWrapper;
public ExtendedEditText mFolderName;
+ private PageIndicatorDots mPageIndicator;
private View mFooter;
private int mFooterHeight;
@@ -228,6 +230,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mContent = (FolderPagedView) findViewById(R.id.folder_content);
mContent.setFolder(this);
+ mPageIndicator = (PageIndicatorDots) findViewById(R.id.folder_page_indicator);
mFolderName = (ExtendedEditText) findViewById(R.id.folder_name);
mFolderName.setOnBackKeyListener(new ExtendedEditText.OnBackKeyListener() {
@Override
@@ -612,7 +615,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
float textWidth = mFolderName.getPaint().measureText(mFolderName.getText().toString());
float translation = (footerWidth - textWidth) / 2;
mFolderName.setTranslationX(mContent.mIsRtl ? -translation : translation);
- mContent.setMarkerScale(0);
+ mPageIndicator.prepareEntryAnimation();
// Do not update the flag if we are in drag mode. The flag will be updated, when we
// actually drop the icon.
@@ -628,7 +631,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
AnimationUtils.loadInterpolator(mLauncher,
android.R.interpolator.fast_out_slow_in)
: new LogDecelerateInterpolator(100, 0));
- mContent.animateMarkers();
+ mPageIndicator.playEntryAnimation();
if (updateAnimationFlag) {
mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncher);
@@ -637,9 +640,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
});
} else {
mFolderName.setTranslationX(0);
- mContent.setMarkerScale(1);
}
+ mPageIndicator.stopAllAnimations();
openFolderAnim.start();
// Make sure the folder picks up the last drag move even if the finger doesn't move.
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index e1a143165..bb8ca160d 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -25,8 +25,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewDebug;
import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-import android.view.animation.OvershootInterpolator;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.CellLayout;
@@ -39,8 +37,6 @@ import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
-import com.android.launcher3.pageindicators.PageIndicatorDots;
-import com.android.launcher3.pageindicators.PageIndicator.PageMarkerResources;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
@@ -48,6 +44,7 @@ import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace.ItemOperator;
import com.android.launcher3.dragndrop.DragController;
+import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -65,13 +62,6 @@ public class FolderPagedView extends PagedView {
private static final int START_VIEW_REORDER_DELAY = 30;
private static final float VIEW_REORDER_DELAY_FACTOR = 0.9f;
- private static final int PAGE_INDICATOR_ANIMATION_START_DELAY = 300;
- private static final int PAGE_INDICATOR_ANIMATION_STAGGERED_DELAY = 150;
- private static final int PAGE_INDICATOR_ANIMATION_DURATION = 400;
-
- // This value approximately overshoots to 1.5 times the original size.
- private static final float PAGE_INDICATOR_OVERSHOOT_TENSION = 4.9f;
-
/**
* Fraction of the width to scroll when showing the next page hint.
*/
@@ -103,7 +93,7 @@ public class FolderPagedView extends PagedView {
private FocusIndicatorView mFocusIndicatorView;
private PagedFolderKeyEventListener mKeyListener;
- private PageIndicatorDots mPageIndicator;
+ private PageIndicator mPageIndicator;
public FolderPagedView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -128,7 +118,7 @@ public class FolderPagedView extends PagedView {
mFolder = folder;
mFocusIndicatorView = (FocusIndicatorView) folder.findViewById(R.id.focus_indicator);
mKeyListener = new PagedFolderKeyEventListener(folder);
- mPageIndicator = (PageIndicatorDots) folder.findViewById(R.id.folder_page_indicator);
+ mPageIndicator = (PageIndicator) folder.findViewById(R.id.folder_page_indicator);
}
/**
@@ -285,6 +275,12 @@ public class FolderPagedView extends PagedView {
}
}
+ @Override
+ protected void onScrollChanged(int l, int t, int oldl, int oldt) {
+ super.onScrollChanged(l, t, oldl, oldt);
+ mPageIndicator.setScroll(l, mMaxScrollX);
+ }
+
/**
* Updates position and rank of all the children in the view.
* It essentially removes all views from all the pages and then adds them again in appropriate
@@ -369,7 +365,7 @@ public class FolderPagedView extends PagedView {
setEnableOverscroll(getPageCount() > 1);
// Update footer
- mPageIndicator.setVisibility(getPageCount() > 1 ? View.VISIBLE : View.GONE);
+ mPageIndicator.getView().setVisibility(getPageCount() > 1 ? View.VISIBLE : View.GONE);
// Set the gravity as LEFT or RIGHT instead of START, as START depends on the actual text.
mFolder.mFolderName.setGravity(getPageCount() > 1 ?
(mIsRtl ? Gravity.RIGHT : Gravity.LEFT) : Gravity.CENTER_HORIZONTAL);
@@ -409,12 +405,6 @@ public class FolderPagedView extends PagedView {
pageIndex * mMaxItemsPerPage + sTempPosArray[1] * mGridCountX + sTempPosArray[0]);
}
- @Override
- protected PageMarkerResources getPageIndicatorMarker(int pageIndex) {
- return new PageMarkerResources(R.drawable.ic_pageindicator_current_folder,
- R.drawable.ic_pageindicator_default_folder);
- }
-
public boolean isFull() {
return !ALLOW_FOLDER_SCROLL && getItemCount() >= mMaxItemsPerPage;
}
@@ -676,28 +666,6 @@ public class FolderPagedView extends PagedView {
}
}
- public void setMarkerScale(float scale) {
- int count = mPageIndicator.getChildCount();
- for (int i = 0; i < count; i++) {
- View marker = mPageIndicator.getChildAt(i);
- marker.animate().cancel();
- marker.setScaleX(scale);
- marker.setScaleY(scale);
- }
- }
-
- public void animateMarkers() {
- int count = mPageIndicator.getChildCount();
- Interpolator interpolator = new OvershootInterpolator(PAGE_INDICATOR_OVERSHOOT_TENSION);
- for (int i = 0; i < count; i++) {
- mPageIndicator.getChildAt(i).animate().scaleX(1).scaleY(1)
- .setInterpolator(interpolator)
- .setDuration(PAGE_INDICATOR_ANIMATION_DURATION)
- .setStartDelay(PAGE_INDICATOR_ANIMATION_STAGGERED_DELAY * i
- + PAGE_INDICATOR_ANIMATION_START_DELAY);
- }
- }
-
public int itemsPerPage() {
return mMaxItemsPerPage;
}