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
@@ -70,8 +70,6 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
|
||||
private static final String TRACE_METHOD_NAME = "appwidget load-widget ";
|
||||
|
||||
private static final Integer NO_LAYOUT_ID = Integer.valueOf(0);
|
||||
|
||||
private final CheckLongPressHelper mLongPressHelper;
|
||||
protected final ActivityContext mActivityContext;
|
||||
|
||||
@@ -81,8 +79,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
private Runnable mAutoAdvanceRunnable;
|
||||
|
||||
private long mDeferUpdatesUntilMillis = 0;
|
||||
private RemoteViews mLastRemoteViews;
|
||||
private boolean mReapplyOnResumeUpdates = false;
|
||||
RemoteViews mLastRemoteViews;
|
||||
|
||||
private boolean mTrackingWidgetUpdate = false;
|
||||
|
||||
@@ -126,7 +123,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
@Override
|
||||
public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) {
|
||||
super.setAppWidget(appWidgetId, info);
|
||||
if (!mTrackingWidgetUpdate && appWidgetId != -1) {
|
||||
if (!mTrackingWidgetUpdate) {
|
||||
mTrackingWidgetUpdate = true;
|
||||
Log.i(TAG, "App widget created with id: " + appWidgetId);
|
||||
if (ATLEAST_Q) {
|
||||
@@ -145,11 +142,11 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
}
|
||||
mTrackingWidgetUpdate = false;
|
||||
}
|
||||
mLastRemoteViews = remoteViews;
|
||||
mReapplyOnResumeUpdates = isDeferringUpdates();
|
||||
if (mReapplyOnResumeUpdates) {
|
||||
if (isDeferringUpdates()) {
|
||||
mLastRemoteViews = remoteViews;
|
||||
return;
|
||||
}
|
||||
mLastRemoteViews = null;
|
||||
|
||||
super.updateAppWidget(remoteViews);
|
||||
|
||||
@@ -157,18 +154,6 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
checkIfAutoAdvance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View child) {
|
||||
super.onViewAdded(child);
|
||||
mReapplyOnResumeUpdates |= isDeferringUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View child) {
|
||||
super.onViewRemoved(child);
|
||||
mReapplyOnResumeUpdates |= isDeferringUpdates();
|
||||
}
|
||||
|
||||
private boolean checkScrollableRecursively(ViewGroup viewGroup) {
|
||||
if (viewGroup instanceof AdapterView) {
|
||||
return true;
|
||||
@@ -185,21 +170,6 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTaggedAsScrollable() {
|
||||
// TODO: Introduce new api in AppWidgetHostView to indicate whether the widget is
|
||||
// scrollable.
|
||||
for (int i = 0; i < this.getChildCount(); i++) {
|
||||
View child = this.getChildAt(i);
|
||||
final Integer layoutId = (Integer) child.getTag(android.R.id.widget_frame);
|
||||
if (layoutId != null) {
|
||||
// The layout id is only set to 0 when RemoteViews is created from
|
||||
// DrawInstructions.
|
||||
return NO_LAYOUT_ID.equals(layoutId);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the application of {@link RemoteViews} through {@link #updateAppWidget} are
|
||||
* currently being deferred.
|
||||
@@ -223,16 +193,18 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
* {@link #updateAppWidget} and apply any deferred updates.
|
||||
*/
|
||||
public void endDeferringUpdates() {
|
||||
RemoteViews remoteViews;
|
||||
mDeferUpdatesUntilMillis = 0;
|
||||
if (mReapplyOnResumeUpdates) {
|
||||
updateAppWidget(mLastRemoteViews);
|
||||
remoteViews = mLastRemoteViews;
|
||||
|
||||
if (remoteViews != null) {
|
||||
updateAppWidget(remoteViews);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
BaseDragLayer<?> dragLayer = mActivityContext.getDragLayer();
|
||||
BaseDragLayer dragLayer = mActivityContext.getDragLayer();
|
||||
if (mIsScrollable) {
|
||||
dragLayer.requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
@@ -242,7 +214,6 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
return mLongPressHelper.hasPerformedLongPress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
mLongPressHelper.onTouchEvent(ev);
|
||||
// We want to keep receiving though events to be able to cancel long press on ACTION_UP
|
||||
@@ -272,6 +243,16 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
mLongPressHelper.cancelLongPress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppWidgetProviderInfo getAppWidgetInfo() {
|
||||
AppWidgetProviderInfo info = super.getAppWidgetInfo();
|
||||
if (info != null && !(info instanceof LauncherAppWidgetProviderInfo)) {
|
||||
throw new IllegalStateException("Launcher widget must have"
|
||||
+ " LauncherAppWidgetProviderInfo");
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFocusedRect(Rect r) {
|
||||
super.getFocusedRect(r);
|
||||
@@ -291,7 +272,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
mIsScrollable = isTaggedAsScrollable() || checkScrollableRecursively(this);
|
||||
mIsScrollable = checkScrollableRecursively(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user