mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
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
This commit is contained in:
@@ -20,8 +20,6 @@ import android.view.ViewConfiguration;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.dynamicui.ExtractedColors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A PageIndicator that briefly shows a fraction of a line when moving between pages.
|
||||
*
|
||||
@@ -43,17 +41,17 @@ public class PageIndicatorLine extends View implements PageIndicator {
|
||||
private int mNumPages = 1;
|
||||
private Paint mLinePaint;
|
||||
|
||||
private Property<Paint, Integer> mPaintAlphaProperty
|
||||
= new Property<Paint, Integer>(Integer.class, "paint_alpha") {
|
||||
private static final Property<PageIndicatorLine, Integer> PAINT_ALPHA
|
||||
= new Property<PageIndicatorLine, Integer>(Integer.class, "paint_alpha") {
|
||||
@Override
|
||||
public Integer get(Paint paint) {
|
||||
return paint.getAlpha();
|
||||
public Integer get(PageIndicatorLine obj) {
|
||||
return obj.mLinePaint.getAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Paint paint, Integer alpha) {
|
||||
paint.setAlpha(alpha);
|
||||
invalidate();
|
||||
public void set(PageIndicatorLine obj, Integer alpha) {
|
||||
obj.mLinePaint.setAlpha(alpha);
|
||||
obj.invalidate();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -99,13 +97,12 @@ public class PageIndicatorLine extends View implements PageIndicator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(float progress) {
|
||||
public void setScroll(int currentScroll, int totalScroll) {
|
||||
if (getAlpha() == 0) {
|
||||
return;
|
||||
}
|
||||
progress = Utilities.boundToRange(progress, 0f, 1f);
|
||||
animateLineToAlpha(mAlpha);
|
||||
mProgress = progress;
|
||||
mProgress = Utilities.boundToRange(((float) currentScroll) / totalScroll, 0f, 1f);;
|
||||
invalidate();
|
||||
|
||||
// Hide after a brief period.
|
||||
@@ -113,33 +110,23 @@ public class PageIndicatorLine extends View implements PageIndicator {
|
||||
mHandler.postDelayed(mHideLineRunnable, LINE_FADE_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllMarkers(boolean allowAnimations) {
|
||||
mNumPages = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMarkers(ArrayList<PageMarkerResources> markers, boolean allowAnimations) {
|
||||
mNumPages += markers.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveMarker(int activePage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMarker(int pageIndex, PageMarkerResources pageIndicatorMarker,
|
||||
boolean allowAnimations) {
|
||||
public void addMarker() {
|
||||
mNumPages++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarker(int pageIndex, boolean allowAnimations) {
|
||||
public void removeMarker() {
|
||||
mNumPages--;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMarker(int pageIndex, PageMarkerResources pageIndicatorMarker) {
|
||||
public void setMarkersCount(int numMarkers) {
|
||||
mNumPages = numMarkers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +161,7 @@ public class PageIndicatorLine extends View implements PageIndicator {
|
||||
}
|
||||
mLineAlphaAnimator.cancel();
|
||||
}
|
||||
mLineAlphaAnimator = ObjectAnimator.ofInt(mLinePaint, mPaintAlphaProperty, alpha);
|
||||
mLineAlphaAnimator = ObjectAnimator.ofInt(this, PAINT_ALPHA, alpha);
|
||||
mLineAlphaAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
|
||||
Reference in New Issue
Block a user