Move activity starting logic into new ActivityContext extension.

This code branch is needed for taskbar, so needs to be moved from the
activity classes to an interface that both can share.

Test: Manual
Bug: 216683257
Change-Id: I042c0dcf08207d94847b9d7a1783acc14613ef5f
This commit is contained in:
Brian Isganitis
2022-03-15 13:35:06 -07:00
parent 763fd21b34
commit bde3c8b6bd
4 changed files with 225 additions and 146 deletions

View File

@@ -16,7 +16,6 @@
package com.android.launcher3;
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS;
import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -25,12 +24,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.LauncherApps;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import androidx.annotation.IntDef;
@@ -39,7 +33,7 @@ import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.AppLauncher;
import com.android.launcher3.views.ScrimView;
import java.io.PrintWriter;
@@ -50,7 +44,7 @@ import java.util.List;
/**
* Launcher BaseActivity
*/
public abstract class BaseActivity extends Activity implements ActivityContext,
public abstract class BaseActivity extends Activity implements AppLauncher,
DeviceProfileListenable {
private static final String TAG = "BaseActivity";
@@ -314,22 +308,6 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
writer.println(prefix + "mForceInvisible: " + mForceInvisible);
}
/**
* A wrapper around the platform method with Launcher specific checks
*/
public void startShortcut(String packageName, String id, Rect sourceBounds,
Bundle startActivityOptions, UserHandle user) {
if (GO_DISABLE_WIDGETS) {
return;
}
try {
getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds,
startActivityOptions, user);
} catch (SecurityException | IllegalStateException e) {
Log.e(TAG, "Failed to start shortcut", e);
}
}
public static <T extends BaseActivity> T fromContext(Context context) {
if (context instanceof BaseActivity) {
return (T) context;