Merge "swipe-dismiss: reintroduce windowSwipeToDismiss for compatibility" into main
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
@@ -33,6 +34,7 @@ import android.view.IWindowSession;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@@ -62,6 +64,9 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
||||
.getInt("persist.wm.debug.predictive_back", 1) != 0;
|
||||
private static final boolean ALWAYS_ENFORCE_PREDICTIVE_BACK = SystemProperties
|
||||
.getInt("persist.wm.debug.predictive_back_always_enforce", 0) != 0;
|
||||
private static final boolean PREDICTIVE_BACK_FALLBACK_WINDOW_ATTRIBUTE =
|
||||
SystemProperties.getInt("persist.wm.debug.predictive_back_fallback_window_attribute", 0)
|
||||
!= 0;
|
||||
@Nullable
|
||||
private ImeOnBackInvokedDispatcher mImeDispatcher;
|
||||
|
||||
@@ -500,6 +505,31 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
||||
applicationInfo.packageName,
|
||||
requestsPredictiveBack));
|
||||
}
|
||||
|
||||
if (PREDICTIVE_BACK_FALLBACK_WINDOW_ATTRIBUTE && !requestsPredictiveBack) {
|
||||
// Compatibility check for legacy window style flag used by Wear OS.
|
||||
// Note on compatibility behavior:
|
||||
// 1. windowSwipeToDismiss should be respected for all apps not opted in.
|
||||
// 2. windowSwipeToDismiss should be true for all apps not opted in, which
|
||||
// enables the PB animation for them.
|
||||
// 3. windowSwipeToDismiss=false should be respected for apps not opted in,
|
||||
// which disables PB & onBackPressed caused by BackAnimController's
|
||||
// setTrigger(true)
|
||||
TypedArray windowAttr =
|
||||
context.obtainStyledAttributes(
|
||||
new int[] {android.R.attr.windowSwipeToDismiss});
|
||||
boolean windowSwipeToDismiss = true;
|
||||
if (windowAttr.getIndexCount() > 0) {
|
||||
windowSwipeToDismiss = windowAttr.getBoolean(0, true);
|
||||
}
|
||||
windowAttr.recycle();
|
||||
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "falling back to windowSwipeToDismiss: " + windowSwipeToDismiss);
|
||||
}
|
||||
|
||||
requestsPredictiveBack = windowSwipeToDismiss;
|
||||
}
|
||||
}
|
||||
|
||||
return requestsPredictiveBack;
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
<!-- Always overscan by default to ensure onApplyWindowInsets will always be called. -->
|
||||
<bool name="config_windowOverscanByDefault">true</bool>
|
||||
|
||||
<!-- Enable windowSwipeToDismiss. -->
|
||||
<bool name="config_windowSwipeToDismiss">true</bool>
|
||||
|
||||
<!-- Style the scrollbars accoridngly. -->
|
||||
<drawable name="config_scrollbarThumbVertical">@drawable/scrollbar_vertical_thumb</drawable>
|
||||
<drawable name="config_scrollbarTrackVertical">@drawable/scrollbar_vertical_track</drawable>
|
||||
|
||||
Reference in New Issue
Block a user