Merge "Migrate ScreenshotController to Predictive Back" into tm-qpr-dev am: ae06460d37
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20535343 Change-Id: I667562d640892a71cbdcad03f4f35f569f6d97c3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -84,6 +84,8 @@ import android.view.WindowManager;
|
|||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.window.OnBackInvokedCallback;
|
||||||
|
import android.window.OnBackInvokedDispatcher;
|
||||||
import android.window.WindowContext;
|
import android.window.WindowContext;
|
||||||
|
|
||||||
import androidx.concurrent.futures.CallbackToFutureAdapter;
|
import androidx.concurrent.futures.CallbackToFutureAdapter;
|
||||||
@@ -279,6 +281,13 @@ public class ScreenshotController {
|
|||||||
private final ActionIntentExecutor mActionExecutor;
|
private final ActionIntentExecutor mActionExecutor;
|
||||||
private final UserManager mUserManager;
|
private final UserManager mUserManager;
|
||||||
|
|
||||||
|
private final OnBackInvokedCallback mOnBackInvokedCallback = () -> {
|
||||||
|
if (DEBUG_INPUT) {
|
||||||
|
Log.d(TAG, "Predictive Back callback dispatched");
|
||||||
|
}
|
||||||
|
respondToBack();
|
||||||
|
};
|
||||||
|
|
||||||
private ScreenshotView mScreenshotView;
|
private ScreenshotView mScreenshotView;
|
||||||
private Bitmap mScreenBitmap;
|
private Bitmap mScreenBitmap;
|
||||||
private SaveImageInBackgroundTask mSaveInBgTask;
|
private SaveImageInBackgroundTask mSaveInBgTask;
|
||||||
@@ -465,6 +474,10 @@ public class ScreenshotController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void respondToBack() {
|
||||||
|
dismissScreenshot(SCREENSHOT_DISMISSED_OTHER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update resources on configuration change. Reinflate for theme/color changes.
|
* Update resources on configuration change. Reinflate for theme/color changes.
|
||||||
*/
|
*/
|
||||||
@@ -476,6 +489,26 @@ public class ScreenshotController {
|
|||||||
// Inflate the screenshot layout
|
// Inflate the screenshot layout
|
||||||
mScreenshotView = (ScreenshotView)
|
mScreenshotView = (ScreenshotView)
|
||||||
LayoutInflater.from(mContext).inflate(R.layout.screenshot, null);
|
LayoutInflater.from(mContext).inflate(R.layout.screenshot, null);
|
||||||
|
mScreenshotView.addOnAttachStateChangeListener(
|
||||||
|
new View.OnAttachStateChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onViewAttachedToWindow(@NonNull View v) {
|
||||||
|
if (DEBUG_INPUT) {
|
||||||
|
Log.d(TAG, "Registering Predictive Back callback");
|
||||||
|
}
|
||||||
|
mScreenshotView.findOnBackInvokedDispatcher().registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT, mOnBackInvokedCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewDetachedFromWindow(@NonNull View v) {
|
||||||
|
if (DEBUG_INPUT) {
|
||||||
|
Log.d(TAG, "Unregistering Predictive Back callback");
|
||||||
|
}
|
||||||
|
mScreenshotView.findOnBackInvokedDispatcher()
|
||||||
|
.unregisterOnBackInvokedCallback(mOnBackInvokedCallback);
|
||||||
|
}
|
||||||
|
});
|
||||||
mScreenshotView.init(mUiEventLogger, new ScreenshotView.ScreenshotViewCallback() {
|
mScreenshotView.init(mUiEventLogger, new ScreenshotView.ScreenshotViewCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onUserInteraction() {
|
public void onUserInteraction() {
|
||||||
@@ -503,7 +536,7 @@ public class ScreenshotController {
|
|||||||
if (DEBUG_INPUT) {
|
if (DEBUG_INPUT) {
|
||||||
Log.d(TAG, "onKeyEvent: KeyEvent.KEYCODE_BACK");
|
Log.d(TAG, "onKeyEvent: KeyEvent.KEYCODE_BACK");
|
||||||
}
|
}
|
||||||
dismissScreenshot(SCREENSHOT_DISMISSED_OTHER);
|
respondToBack();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user