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
@@ -34,8 +34,6 @@ import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.LinearLayout;
|
||||
import android.window.OnBackAnimationCallback;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
@@ -51,7 +49,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
public abstract class AbstractFloatingView extends LinearLayout implements TouchController,
|
||||
OnBackAnimationCallback {
|
||||
OnBackPressedHandler {
|
||||
|
||||
@IntDef(flag = true, value = {
|
||||
TYPE_COMPOSE_VIEW,
|
||||
@@ -75,12 +73,12 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
TYPE_TASKBAR_ALL_APPS,
|
||||
TYPE_ADD_TO_HOME_CONFIRMATION,
|
||||
TYPE_TASKBAR_OVERLAY_PROXY,
|
||||
TYPE_TASKBAR_PINNING_POPUP,
|
||||
TYPE_PIN_IME_POPUP,
|
||||
TYPE_ONE_GRID_MIGRATION_EDU,
|
||||
TYPE_TASKBAR_PINNING_POPUP
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FloatingViewType {}
|
||||
public @interface FloatingViewType {
|
||||
}
|
||||
|
||||
public static final int TYPE_FOLDER = 1 << 0;
|
||||
public static final int TYPE_ACTION_POPUP = 1 << 1;
|
||||
public static final int TYPE_WIDGETS_BOTTOM_SHEET = 1 << 2;
|
||||
@@ -106,10 +104,9 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
public static final int TYPE_TASKBAR_OVERLAY_PROXY = 1 << 20;
|
||||
public static final int TYPE_TASKBAR_PINNING_POPUP = 1 << 21;
|
||||
public static final int TYPE_PIN_IME_POPUP = 1 << 22;
|
||||
public static final int TYPE_ONE_GRID_MIGRATION_EDU = 1 << 23;
|
||||
|
||||
// Custom compose popups
|
||||
public static final int TYPE_COMPOSE_VIEW = 1 << 24;
|
||||
public static final int TYPE_COMPOSE_VIEW = 1 << 23;
|
||||
|
||||
public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP
|
||||
| TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET
|
||||
@@ -118,34 +115,37 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
| TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP | TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP
|
||||
| TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS | TYPE_OPTIONS_POPUP_DIALOG
|
||||
| TYPE_ADD_TO_HOME_CONFIRMATION | TYPE_TASKBAR_OVERLAY_PROXY
|
||||
| TYPE_TASKBAR_PINNING_POPUP | TYPE_PIN_IME_POPUP | TYPE_ONE_GRID_MIGRATION_EDU | TYPE_COMPOSE_VIEW;
|
||||
| TYPE_TASKBAR_PINNING_POPUP | TYPE_PIN_IME_POPUP | TYPE_COMPOSE_VIEW;
|
||||
|
||||
// Type of popups which should be kept open during launcher rebind
|
||||
public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET
|
||||
| TYPE_WIDGETS_BOTTOM_SHEET | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE
|
||||
| TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE | TYPE_TASKBAR_EDUCATION_DIALOG
|
||||
| TYPE_TASKBAR_ALL_APPS | TYPE_OPTIONS_POPUP_DIALOG | TYPE_TASKBAR_OVERLAY_PROXY
|
||||
| TYPE_PIN_IME_POPUP | TYPE_ONE_GRID_MIGRATION_EDU | TYPE_COMPOSE_VIEW;
|
||||
| TYPE_PIN_IME_POPUP | TYPE_COMPOSE_VIEW;
|
||||
|
||||
/** Type of popups that should get exclusive accessibility focus. */
|
||||
public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE & ~TYPE_LISTENER
|
||||
& ~TYPE_ALL_APPS_EDU & ~TYPE_TASKBAR_ALL_APPS & ~TYPE_PIN_IME_POPUP
|
||||
& ~TYPE_WIDGET_RESIZE_FRAME & ~TYPE_ONE_GRID_MIGRATION_EDU & ~TYPE_ON_BOARD_POPUP
|
||||
& ~TYPE_TASKBAR_OVERLAY_PROXY;
|
||||
& ~TYPE_WIDGET_RESIZE_FRAME;
|
||||
|
||||
// These view all have particular operation associated with swipe down interaction.
|
||||
// These view all have particular operation associated with swipe down
|
||||
// interaction.
|
||||
public static final int TYPE_STATUS_BAR_SWIPE_DOWN_DISALLOW = TYPE_WIDGETS_BOTTOM_SHEET |
|
||||
TYPE_WIDGETS_FULL_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_ON_BOARD_POPUP |
|
||||
TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU | TYPE_DRAG_DROP_POPUP | TYPE_COMPOSE_VIEW;
|
||||
|
||||
// Floating views that are exclusive to the taskbar overlay window.
|
||||
public static final int TYPE_TASKBAR_OVERLAYS =
|
||||
TYPE_TASKBAR_ALL_APPS | TYPE_TASKBAR_EDUCATION_DIALOG;
|
||||
public static final int TYPE_TASKBAR_OVERLAYS = TYPE_TASKBAR_ALL_APPS | TYPE_TASKBAR_EDUCATION_DIALOG;
|
||||
|
||||
// Floating views that a TouchController should not try to intercept touches from.
|
||||
// Floating views that a TouchController should not try to intercept touches
|
||||
// from.
|
||||
public static final int TYPE_TOUCH_CONTROLLER_NO_INTERCEPT = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE
|
||||
& ~TYPE_LISTENER & ~TYPE_TASKBAR_OVERLAYS;
|
||||
|
||||
public static final int TYPE_ALL_EXCEPT_ON_BOARD_POPUP = TYPE_ALL & ~TYPE_ON_BOARD_POPUP
|
||||
& ~TYPE_PIN_IME_POPUP;
|
||||
|
||||
protected boolean mIsOpen;
|
||||
|
||||
public AbstractFloatingView(Context context, AttributeSet attrs) {
|
||||
@@ -157,7 +157,8 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to handle touch events to prevent them from falling through to the workspace below.
|
||||
* We need to handle touch events to prevent them from falling through to the
|
||||
* workspace below.
|
||||
*/
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@@ -177,11 +178,15 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
protected abstract void handleClose(boolean animate);
|
||||
|
||||
/**
|
||||
* Creates a user-controlled animation to hint that the view will be closed if completed.
|
||||
* @param distanceToMove The max distance that elements should move from their starting point.
|
||||
* Creates a user-controlled animation to hint that the view will be closed if
|
||||
* completed.
|
||||
*
|
||||
* @param distanceToMove The max distance that elements should move from their
|
||||
* starting point.
|
||||
*/
|
||||
public void addHintCloseAnim(
|
||||
float distanceToMove, Interpolator interpolator, PendingAnimation target) { }
|
||||
float distanceToMove, Interpolator interpolator, PendingAnimation target) {
|
||||
}
|
||||
|
||||
public final boolean isOpen() {
|
||||
return mIsOpen;
|
||||
@@ -238,14 +243,16 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether there is at least one view of the given type where {@link #isOpen()} == true.
|
||||
* Returns whether there is at least one view of the given type where
|
||||
* {@link #isOpen()} == true.
|
||||
*/
|
||||
public static boolean hasOpenView(ActivityContext activity, @FloatingViewType int type) {
|
||||
return getOpenView(activity, type) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view matching FloatingViewType, and {@link #isOpen()} may be false (if animating
|
||||
* Returns a view matching FloatingViewType, and {@link #isOpen()} may be false
|
||||
* (if animating
|
||||
* closed).
|
||||
*/
|
||||
public static <T extends AbstractFloatingView> T getAnyView(
|
||||
@@ -256,8 +263,10 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
private static <T extends AbstractFloatingView> T getView(
|
||||
ActivityContext activity, @FloatingViewType int type, boolean mustBeOpen) {
|
||||
BaseDragLayer dragLayer = activity.getDragLayer();
|
||||
if (dragLayer == null) return null;
|
||||
// Iterate in reverse order. AbstractFloatingView is added later to the dragLayer,
|
||||
if (dragLayer == null)
|
||||
return null;
|
||||
// Iterate in reverse order. AbstractFloatingView is added later to the
|
||||
// dragLayer,
|
||||
// and will be one of the last views.
|
||||
for (int i = dragLayer.getChildCount() - 1; i >= 0; i--) {
|
||||
View child = dragLayer.getChildAt(i);
|
||||
@@ -294,13 +303,13 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
}
|
||||
|
||||
public static void closeAllOpenViewsExcept(ActivityContext activity, boolean animate,
|
||||
@FloatingViewType int type) {
|
||||
@FloatingViewType int type) {
|
||||
closeOpenViews(activity, animate, TYPE_ALL & ~type);
|
||||
activity.finishAutoCancelActionMode();
|
||||
}
|
||||
|
||||
public static void closeAllOpenViewsExcept(ActivityContext activity,
|
||||
@FloatingViewType int type) {
|
||||
@FloatingViewType int type) {
|
||||
closeAllOpenViewsExcept(activity, true, type);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user