diff options
author | Vadim Tryshev <vadimt@google.com> | 2018-10-24 21:56:23 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-10-24 21:56:23 +0000 |
commit | e10fedb5f3af5980e73ba824d656ef4650bb8a77 (patch) | |
tree | 6704417c256bd293446781d76775a3ca70979eac /quickstep | |
parent | e3f664db79c19ccb423a72e806ec014d4c029741 (diff) | |
parent | 3514a2231394bf6d9bf22ee8ee7db25be87bb3e7 (diff) | |
download | android_packages_apps_Trebuchet-e10fedb5f3af5980e73ba824d656ef4650bb8a77.tar.gz android_packages_apps_Trebuchet-e10fedb5f3af5980e73ba824d656ef4650bb8a77.tar.bz2 android_packages_apps_Trebuchet-e10fedb5f3af5980e73ba824d656ef4650bb8a77.zip |
Merge "Adding code to open DWP settings of a recent task" into ub-launcher3-master
Diffstat (limited to 'quickstep')
-rw-r--r-- | quickstep/res/values/strings.xml | 3 | ||||
-rw-r--r-- | quickstep/src/com/android/quickstep/views/TaskView.java | 44 |
2 files changed, 46 insertions, 1 deletions
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml index a76899d3d..c712703cb 100644 --- a/quickstep/res/values/strings.xml +++ b/quickstep/res/values/strings.xml @@ -36,6 +36,9 @@ <!-- Content description for the recent apps's accessibility option that closes it. [CHAR LIMIT=NONE] --> <string name="accessibility_close_task">Close</string> + <!-- Content description for the recent apps's accessibility option that opens its usage settings. [CHAR LIMIT=NONE] --> + <string name="accessibility_app_usage_settings">App usage settings</string> + <!-- Recents: Title of a button that clears the task list, i.e. closes all tasks. [CHAR LIMIT=30] --> <string name="recents_clear_all">Clear all</string> diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index da5b79a9d..2a4226faa 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -17,6 +17,7 @@ package com.android.quickstep.views; import static android.widget.Toast.LENGTH_SHORT; + import static com.android.launcher3.BaseActivity.fromContext; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.LINEAR; @@ -26,7 +27,9 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.app.ActivityOptions; +import android.content.ActivityNotFoundException; import android.content.Context; +import android.content.Intent; import android.content.res.Resources; import android.graphics.Outline; import android.graphics.drawable.Drawable; @@ -43,8 +46,10 @@ import android.widget.FrameLayout; import android.widget.Toast; import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.quickstep.RecentsModel; @@ -100,7 +105,7 @@ public class TaskView extends FrameLayout implements PageCallbacks { } }; - private static FloatProperty<TaskView> FOCUS_TRANSITION = + private static final FloatProperty<TaskView> FOCUS_TRANSITION = new FloatProperty<TaskView>("focusTransition") { @Override public void setValue(TaskView taskView, float v) { @@ -113,6 +118,9 @@ public class TaskView extends FrameLayout implements PageCallbacks { } }; + static final Intent SEE_TIME_IN_APP_TEMPLATE = + new Intent("com.android.settings.action.TIME_SPENT_IN_APP"); + private final OnAttachStateChangeListener mTaskMenuStateListener = new OnAttachStateChangeListener() { @Override @@ -142,6 +150,8 @@ public class TaskView extends FrameLayout implements PageCallbacks { private TaskThumbnailCache.ThumbnailLoadRequest mThumbnailLoadRequest; private TaskIconCache.IconLoadRequest mIconLoadRequest; + private long mAppRemainingTimeMs = -1; + public TaskView(Context context) { this(context, null); } @@ -195,6 +205,10 @@ public class TaskView extends FrameLayout implements PageCallbacks { return mSnapshotView.getTaskOverlay(); } + private boolean hasRemainingTime() { + return mAppRemainingTimeMs > 0; + } + public void launchTask(boolean animate) { launchTask(animate, (result) -> { if (!result) { @@ -421,6 +435,13 @@ public class TaskView extends FrameLayout implements PageCallbacks { } } + if (hasRemainingTime()) { + info.addAction( + new AccessibilityNodeInfo.AccessibilityAction( + R.string.accessibility_app_usage_settings, + getContext().getText(R.string.accessibility_app_usage_settings))); + } + final RecentsView recentsView = getRecentsView(); final AccessibilityNodeInfo.CollectionItemInfo itemInfo = AccessibilityNodeInfo.CollectionItemInfo.obtain( @@ -437,6 +458,11 @@ public class TaskView extends FrameLayout implements PageCallbacks { return true; } + if (action == R.string.accessibility_app_usage_settings) { + openAppUsageSettings(); + return true; + } + final List<TaskSystemShortcut> shortcuts = mSnapshotView.getTaskOverlay().getEnabledShortcuts(this); final int count = shortcuts.size(); @@ -455,6 +481,22 @@ public class TaskView extends FrameLayout implements PageCallbacks { return super.performAccessibilityAction(action, arguments); } + private void openAppUsageSettings() { + final Intent intent = new Intent(SEE_TIME_IN_APP_TEMPLATE) + .putExtra(Intent.EXTRA_PACKAGE_NAME, + mTask.getTopComponent().getPackageName()).addFlags( + Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + try { + final Launcher launcher = Launcher.getLauncher(getContext()); + launcher.startActivity(intent); + launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP, + LauncherLogProto.ControlType.APP_USAGE_SETTINGS, this); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "Failed to open app usage settings for task " + + mTask.getTopComponent().getPackageName(), e); + } + } + private RecentsView getRecentsView() { return (RecentsView) getParent(); } |