mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 01:16:49 +00:00
Retain add button on rotation for two-pane and bottom sheet
Reselects the WidgetCell that was selected when reloading the sheet on rotation. WidgetsFullSheet is excluded because it does not retain the open header on rotation. Bug: 331429554 Test: manual, see screencast Flag: ACONFIG com.android.launcher3.enable_widget_tap_to_add NEXTFOOD Change-Id: Id3d21f44b1dc525e144296f513f5a460fc51474c
This commit is contained in:
@@ -70,6 +70,7 @@ import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.annotation.ChecksSdkIntAtLeast;
|
||||
@@ -104,6 +105,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -835,4 +837,27 @@ public final class Utilities {
|
||||
// No-Op
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a depth-first search through the View hierarchy starting at root, to find a view that
|
||||
* matches the predicate. Returns null if no View was found. View has a findViewByPredicate
|
||||
* member function but it is currently a @hide API.
|
||||
*/
|
||||
@Nullable
|
||||
public static <T extends View> T findViewByPredicate(@NonNull View root,
|
||||
@NonNull Predicate<View> predicate) {
|
||||
if (predicate.test(root)) {
|
||||
return (T) root;
|
||||
}
|
||||
if (root instanceof ViewGroup parent) {
|
||||
int count = parent.getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View view = findViewByPredicate(parent.getChildAt(i), predicate);
|
||||
if (view != null) {
|
||||
return (T) view;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user