Merge "Adding All Apps action even when launcher is not in foreground" into ub-launcher3-rvc-dev
This commit is contained in:
@@ -31,6 +31,8 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACT
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.RemoteAction;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -38,6 +40,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
@@ -46,6 +49,7 @@ import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
import android.view.InputEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.BinderThread;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -53,6 +57,7 @@ import androidx.annotation.UiThread;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.DiscoveryBounce;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
@@ -126,6 +131,12 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once";
|
||||
private static final int MAX_BACK_NOTIFICATION_COUNT = 3;
|
||||
|
||||
/**
|
||||
* System Action ID to show all apps. This ID should follow the ones in
|
||||
* com.android.systemui.accessibility.SystemActions.
|
||||
*/
|
||||
private static final int SYSTEM_ACTION_ID_ALL_APPS = 100;
|
||||
|
||||
private int mBackGestureNotificationCounter = -1;
|
||||
@Nullable
|
||||
private OverscrollPlugin mOverscrollPlugin;
|
||||
@@ -351,6 +362,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
|
||||
PluginManagerWrapper.INSTANCE.get(getBaseContext()).addPluginListener(this,
|
||||
OverscrollPlugin.class, false /* allowMultiple */);
|
||||
|
||||
mOverviewComponentObserver.setOverviewChangeListener(this::onOverviewTargetChange);
|
||||
onOverviewTargetChange(mOverviewComponentObserver.isHomeAndOverviewSame());
|
||||
}
|
||||
|
||||
private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() {
|
||||
@@ -370,6 +384,24 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
}
|
||||
}
|
||||
|
||||
private void onOverviewTargetChange(boolean isHomeAndOverviewSame) {
|
||||
AccessibilityManager am = getSystemService(AccessibilityManager.class);
|
||||
|
||||
if (isHomeAndOverviewSame) {
|
||||
Intent intent = new Intent(mOverviewComponentObserver.getHomeIntent())
|
||||
.setAction(Intent.ACTION_ALL_APPS);
|
||||
RemoteAction allAppsAction = new RemoteAction(
|
||||
Icon.createWithResource(this, R.drawable.ic_apps),
|
||||
getString(R.string.all_apps_label),
|
||||
getString(R.string.all_apps_label),
|
||||
PendingIntent.getActivity(this, SYSTEM_ACTION_ID_ALL_APPS, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
am.registerSystemAction(allAppsAction, SYSTEM_ACTION_ID_ALL_APPS);
|
||||
} else {
|
||||
am.unregisterSystemAction(SYSTEM_ACTION_ID_ALL_APPS);
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
private void onSystemUiFlagsChanged() {
|
||||
if (mDeviceState.isUserUnlocked()) {
|
||||
@@ -408,6 +440,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
ProtoTracer.INSTANCE.get(TouchInteractionService.this).stop();
|
||||
ProtoTracer.INSTANCE.get(this).remove(this);
|
||||
|
||||
getSystemService(AccessibilityManager.class)
|
||||
.unregisterSystemAction(SYSTEM_ACTION_ID_ALL_APPS);
|
||||
|
||||
sConnected = false;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import android.view.View;
|
||||
|
||||
import com.android.launcher3.LauncherState.ScaleAndTranslation;
|
||||
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||
import com.android.launcher3.accessibility.SystemActions;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.WellbeingModel;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
@@ -70,7 +69,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
implements NavigationModeChangeListener {
|
||||
|
||||
private DepthController mDepthController = new DepthController(this);
|
||||
protected SystemActions mSystemActions;
|
||||
|
||||
/**
|
||||
* Reusable command for applying the back button alpha on the background thread.
|
||||
@@ -86,7 +84,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mSystemActions = new SystemActions(this);
|
||||
|
||||
SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);
|
||||
|
||||
@@ -141,12 +138,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
getDragLayer().recreateControllers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
mSystemActions.onActivityResult(requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterAnimationComplete() {
|
||||
super.onEnterAnimationComplete();
|
||||
@@ -210,15 +201,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
// removes the task itself.
|
||||
startActivity(ProxyActivityStarter.getLaunchIntent(this, null));
|
||||
}
|
||||
|
||||
// Register all system actions once they are available
|
||||
mSystemActions.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mSystemActions.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.accessibility;
|
||||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.app.RemoteAction;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.LauncherStateManager;
|
||||
import com.android.launcher3.R;
|
||||
|
||||
/**
|
||||
* Manages the launcher system actions presented to accessibility services.
|
||||
*/
|
||||
public class SystemActions {
|
||||
|
||||
/**
|
||||
* System Action ID to show all apps. This ID should follow the ones in
|
||||
* com.android.systemui.accessibility.SystemActions.
|
||||
*/
|
||||
private static final int SYSTEM_ACTION_ID_ALL_APPS = 100;
|
||||
|
||||
private Launcher mLauncher;
|
||||
private AccessibilityManager mAccessibilityManager;
|
||||
private RemoteAction mAllAppsAction;
|
||||
private boolean mRegistered;
|
||||
|
||||
public SystemActions(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
mAccessibilityManager = (AccessibilityManager) launcher.getSystemService(
|
||||
Context.ACCESSIBILITY_SERVICE);
|
||||
mAllAppsAction = new RemoteAction(
|
||||
Icon.createWithResource(launcher, R.drawable.ic_apps),
|
||||
launcher.getString(R.string.all_apps_label),
|
||||
launcher.getString(R.string.all_apps_label),
|
||||
launcher.createPendingResult(SYSTEM_ACTION_ID_ALL_APPS, new Intent(),
|
||||
0 /* flags */));
|
||||
}
|
||||
|
||||
public void register() {
|
||||
if (mRegistered) {
|
||||
return;
|
||||
}
|
||||
mAccessibilityManager.registerSystemAction(mAllAppsAction, SYSTEM_ACTION_ID_ALL_APPS);
|
||||
mRegistered = true;
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
if (!mRegistered) {
|
||||
return;
|
||||
}
|
||||
mAccessibilityManager.unregisterSystemAction(SYSTEM_ACTION_ID_ALL_APPS);
|
||||
mRegistered = false;
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode) {
|
||||
if (requestCode == SYSTEM_ACTION_ID_ALL_APPS) {
|
||||
showAllApps();
|
||||
}
|
||||
}
|
||||
|
||||
private void showAllApps() {
|
||||
LauncherStateManager stateManager = mLauncher.getStateManager();
|
||||
stateManager.goToState(NORMAL);
|
||||
stateManager.goToState(ALL_APPS);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import com.android.systemui.shared.system.PackageManagerWrapper;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Class to keep track of the current overview component based off user preferences and app updates
|
||||
@@ -57,6 +58,9 @@ public final class OverviewComponentObserver {
|
||||
private final Intent mMyHomeIntent;
|
||||
private final Intent mFallbackIntent;
|
||||
private final SparseIntArray mConfigChangesMap = new SparseIntArray();
|
||||
|
||||
private Consumer<Boolean> mOverviewChangeListener = b -> { };
|
||||
|
||||
private String mUpdateRegisteredPackage;
|
||||
private BaseActivityInterface mActivityInterface;
|
||||
private Intent mOverviewIntent;
|
||||
@@ -64,10 +68,10 @@ public final class OverviewComponentObserver {
|
||||
private boolean mIsDefaultHome;
|
||||
private boolean mIsHomeDisabled;
|
||||
|
||||
|
||||
public OverviewComponentObserver(Context context, RecentsAnimationDeviceState deviceState) {
|
||||
mContext = context;
|
||||
mDeviceState = deviceState;
|
||||
|
||||
mCurrentHomeIntent = new Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Intent.CATEGORY_HOME)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -95,6 +99,13 @@ public final class OverviewComponentObserver {
|
||||
updateOverviewTargets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a listener for changes in {@link #isHomeAndOverviewSame()}
|
||||
*/
|
||||
public void setOverviewChangeListener(Consumer<Boolean> overviewChangeListener) {
|
||||
mOverviewChangeListener = overviewChangeListener;
|
||||
}
|
||||
|
||||
public void onSystemUiStateChanged() {
|
||||
if (mDeviceState.isHomeDisabled() != mIsHomeDisabled) {
|
||||
updateOverviewTargets();
|
||||
@@ -159,6 +170,7 @@ public final class OverviewComponentObserver {
|
||||
ACTION_PACKAGE_REMOVED));
|
||||
}
|
||||
}
|
||||
mOverviewChangeListener.accept(mIsHomeAndOverviewSame);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1443,6 +1443,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mLauncherCallbacks.onHomeIntent(internalStateHandled);
|
||||
}
|
||||
mOverlayManager.hideOverlay(isStarted() && !isForceInvisible());
|
||||
} else if (Intent.ACTION_ALL_APPS.equals(intent.getAction())) {
|
||||
getStateManager().goToState(ALL_APPS, alreadyOnHome);
|
||||
}
|
||||
|
||||
TraceHelper.INSTANCE.endSection(traceToken);
|
||||
|
||||
Reference in New Issue
Block a user