feat: Add option to clear home screen in settings (#6125)
Signed-off-by: abhixv <abhi.sharma1@hotmail.com>
This commit is contained in:
1 parent
9898749619
commit
5f3a03f4fb
1577 files changed
+112559
-80244
No files matched your search
@@ -42,14 +42,10 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.MSDLPlayerWrapper;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
import com.google.android.msdl.data.model.MSDLToken;
|
||||
|
||||
import app.lawnchair.theme.color.tokens.ColorTokens;
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
/**
|
||||
* Implements a DropTarget.
|
||||
@@ -70,13 +66,15 @@ public abstract class ButtonDropTarget extends TextView
|
||||
protected final ActivityContext mActivityContext;
|
||||
protected final DropTargetHandler mDropTargetHandler;
|
||||
protected DropTargetBar mDropTargetBar;
|
||||
private MSDLPlayerWrapper mMSDLPlayerWrapper;
|
||||
|
||||
/** Whether this drop target is active for the current drag */
|
||||
protected boolean mActive;
|
||||
/** Whether an accessible drag is in progress */
|
||||
private boolean mAccessibleDrag;
|
||||
/** An item must be dragged at least this many pixels before this drop target is enabled. */
|
||||
/**
|
||||
* An item must be dragged at least this many pixels before this drop target is
|
||||
* enabled.
|
||||
*/
|
||||
private final int mDragDistanceThreshold;
|
||||
/** The size of the drawable shown in the drop target. */
|
||||
private final int mDrawableSize;
|
||||
@@ -95,6 +93,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
public ButtonDropTarget(Context context) {
|
||||
this(context, null, 0);
|
||||
}
|
||||
|
||||
public ButtonDropTarget(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
@@ -103,7 +102,6 @@ public abstract class ButtonDropTarget extends TextView
|
||||
super(context, attrs, defStyle);
|
||||
mActivityContext = ActivityContext.lookupContext(context);
|
||||
mDropTargetHandler = mActivityContext.getDropTargetHandler();
|
||||
mMSDLPlayerWrapper = MSDLPlayerWrapper.INSTANCE.get(context);
|
||||
|
||||
Resources resources = getResources();
|
||||
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
|
||||
@@ -143,7 +141,8 @@ public abstract class ButtonDropTarget extends TextView
|
||||
}
|
||||
|
||||
protected void setDrawable(int resId) {
|
||||
// We do not set the drawable in the xml as that inflates two drawables corresponding to
|
||||
// We do not set the drawable in the xml as that inflates two drawables
|
||||
// corresponding to
|
||||
// drawableLeft and drawableStart.
|
||||
mDrawable = getContext().getDrawable(resId).mutate();
|
||||
mDrawable.setTintList(getTextColors());
|
||||
@@ -163,10 +162,6 @@ public abstract class ButtonDropTarget extends TextView
|
||||
|
||||
@Override
|
||||
public final void onDragEnter(DragObject d) {
|
||||
// Perform Haptic feedback
|
||||
if (Flags.msdlFeedback()) {
|
||||
mMSDLPlayerWrapper.playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR);
|
||||
}
|
||||
if (!mAccessibleDrag && !mTextVisible) {
|
||||
// Show tooltip
|
||||
hideTooltip();
|
||||
@@ -245,8 +240,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
@Override
|
||||
public boolean isDropEnabled() {
|
||||
return mActive && (mAccessibleDrag ||
|
||||
mActivityContext.getDragController().getDistanceDragged()
|
||||
>= mDragDistanceThreshold);
|
||||
mActivityContext.getDragController().getDistanceDragged() >= mDragDistanceThreshold);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,7 +284,8 @@ public abstract class ButtonDropTarget extends TextView
|
||||
public abstract int getAccessibilityAction();
|
||||
|
||||
@Override
|
||||
public void prepareAccessibilityDrop() { }
|
||||
public void prepareAccessibilityDrop() {
|
||||
}
|
||||
|
||||
public abstract void onAccessibilityDrop(View view, ItemInfo item);
|
||||
|
||||
@@ -365,7 +360,8 @@ public abstract class ButtonDropTarget extends TextView
|
||||
}
|
||||
|
||||
/**
|
||||
* Display button text over multiple lines when isMultiLine is true, single line otherwise.
|
||||
* Display button text over multiple lines when isMultiLine is true, single line
|
||||
* otherwise.
|
||||
*/
|
||||
public void setTextMultiLine(boolean isMultiLine) {
|
||||
if (mTextMultiLine != isMultiLine) {
|
||||
@@ -431,19 +427,20 @@ public abstract class ButtonDropTarget extends TextView
|
||||
return !TextUtils.equals(mText, firstLine);
|
||||
}
|
||||
if (TextUtils.equals(mText, firstLine)) {
|
||||
// When multi-line is active, if it can display as one line, then text is not truncated.
|
||||
// When multi-line is active, if it can display as one line, then text is not
|
||||
// truncated.
|
||||
return false;
|
||||
}
|
||||
CharSequence secondLine =
|
||||
TextUtils.ellipsize(mText.subSequence(firstLine.length(), mText.length()),
|
||||
getPaint(), availableWidth, TextUtils.TruncateAt.END);
|
||||
CharSequence secondLine = TextUtils.ellipsize(mText.subSequence(firstLine.length(), mText.length()),
|
||||
getPaint(), availableWidth, TextUtils.TruncateAt.END);
|
||||
return !(TextUtils.equals(mText.subSequence(0, firstLine.length()), firstLine)
|
||||
&& TextUtils.equals(mText.subSequence(firstLine.length(), secondLine.length()),
|
||||
secondLine));
|
||||
secondLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the text will be clipped vertically within the provided availableHeight.
|
||||
* Returns if the text will be clipped vertically within the provided
|
||||
* availableHeight.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
protected boolean isTextClippedVertically(int availableHeight) {
|
||||
@@ -454,22 +451,21 @@ public abstract class ButtonDropTarget extends TextView
|
||||
return textHeight + getPaddingTop() + getPaddingBottom() >= availableHeight;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setMSDLPlayerWrapper(MSDLPlayerWrapper wrapper) {
|
||||
mMSDLPlayerWrapper = wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce the size of the text until it fits the measured width or reaches a minimum.
|
||||
* Reduce the size of the text until it fits the measured width or reaches a
|
||||
* minimum.
|
||||
*
|
||||
* The minimum size is defined by {@code R.dimen.button_drop_target_min_text_size} and
|
||||
* The minimum size is defined by
|
||||
* {@code R.dimen.button_drop_target_min_text_size} and
|
||||
* it diminishes by intervals defined by
|
||||
* {@code R.dimen.button_drop_target_resize_text_increment}
|
||||
* This functionality is very similar to the option
|
||||
* {@link TextView#setAutoSizeTextTypeWithDefaults(int)} but can't be used in this view because
|
||||
* {@link TextView#setAutoSizeTextTypeWithDefaults(int)} but can't be used in
|
||||
* this view because
|
||||
* the layout width is {@code WRAP_CONTENT}.
|
||||
*
|
||||
* @return The biggest text size in SP that makes the text fit or if the text can't fit returns
|
||||
* @return The biggest text size in SP that makes the text fit or if the text
|
||||
* can't fit returns
|
||||
* the min available value
|
||||
*/
|
||||
public float resizeTextToFit() {
|
||||
|
||||
Reference in new issue
Block a user