Merge "Move OnBackInvoked to BaseActivity." into tm-qpr-dev am: 364af1837e

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/19995367

Change-Id: I2c343441fcc369973d4f487668a070e20e988df4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yein Jo
2022-09-21 22:14:12 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 14 deletions
@@ -25,12 +25,16 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.window.OnBackInvokedDispatcher;
import androidx.annotation.IntDef;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.AppLauncher;
@@ -171,6 +175,19 @@ public abstract class BaseActivity extends Activity implements AppLauncher,
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Utilities.ATLEAST_T) {
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
() -> {
onBackPressed();
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onBackInvoked");
});
}
}
@Override
protected void onStart() {
addActivityFlags(ACTIVITY_STATE_STARTED);
-14
View File
@@ -114,7 +114,6 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageView;
import android.widget.Toast;
import android.window.OnBackInvokedDispatcher;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
@@ -544,8 +543,6 @@ public class Launcher extends StatefulActivity<LauncherState>
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
}
setTitle(R.string.home_screen);
registerOnBackInvokedCallback();
}
protected LauncherOverlayManager getDefaultOverlay() {
@@ -2065,17 +2062,6 @@ public class Launcher extends StatefulActivity<LauncherState>
mStateManager.getState().onBackPressed(this);
}
private void registerOnBackInvokedCallback() {
if (Utilities.ATLEAST_T) {
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
() -> {
onBackPressed();
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onBackInvoked");
});
}
}
protected void onScreenOff() {
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop