diff options
author | Winson Chung <winsonc@google.com> | 2014-07-18 23:46:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-17 21:58:28 +0000 |
commit | 57eea0f78846271ea06caf075a01769eb7c1447f (patch) | |
tree | bbf79cf8bde18858f8eed1ebba8daadf536698ba /packages | |
parent | 76053fa803e6751b790b6cdbd6d19063b284873b (diff) | |
parent | 56e09b42a0f1670970872bef611a8036904ad6bf (diff) | |
download | frameworks_base-57eea0f78846271ea06caf075a01769eb7c1447f.zip frameworks_base-57eea0f78846271ea06caf075a01769eb7c1447f.tar.gz frameworks_base-57eea0f78846271ea06caf075a01769eb7c1447f.tar.bz2 |
Merge "Add setting to guard the lock-to-app recents icon" into lmp-dev
Diffstat (limited to 'packages')
9 files changed, 68 insertions, 34 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java index b6d7d7e..66e5d14 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java +++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java @@ -84,7 +84,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta mContext = context; mSystemServicesProxy = new SystemServicesProxy(context); mHandler = new Handler(); - mConfig = RecentsConfiguration.reinitialize(context); + mConfig = RecentsConfiguration.reinitialize(context, mSystemServicesProxy); mWindowRect = mSystemServicesProxy.getWindowRect(); mTaskStackBounds = new Rect(); mConfig.getTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mTaskStackBounds); @@ -147,7 +147,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta } public void onConfigurationChanged(Configuration newConfig) { - mConfig = RecentsConfiguration.reinitialize(mContext); + mConfig = RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy); mConfig.updateOnConfigurationChange(); mWindowRect = mSystemServicesProxy.getWindowRect(); mConfig.getTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mTaskStackBounds); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index 29a0262..5741f22 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -340,7 +340,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // Initialize the loader and the configuration RecentsTaskLoader.initialize(this); - mConfig = RecentsConfiguration.reinitialize(this); + mConfig = RecentsConfiguration.reinitialize(this, + RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Create the home intent runnable Intent homeIntent = new Intent(Intent.ACTION_MAIN, null); @@ -405,7 +406,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView void onConfigurationChange() { // Update RecentsConfiguration - mConfig = RecentsConfiguration.reinitialize(this); + mConfig = RecentsConfiguration.reinitialize(this, + RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Try and start the enter animation (or restart it on configuration changed) ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java index 439765e..a0cab5c 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java @@ -29,6 +29,7 @@ import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import com.android.systemui.R; import com.android.systemui.recents.misc.Console; +import com.android.systemui.recents.misc.SystemServicesProxy; /** A static Recents configuration for the current context @@ -109,7 +110,8 @@ public class RecentsConfiguration { public boolean launchedFromHome; public int launchedToTaskId; - /** Dev options */ + /** Dev options and global settings */ + public boolean lockToAppEnabled; public boolean developerOptionsEnabled; public boolean debugModeEnabled; @@ -127,15 +129,10 @@ public class RecentsConfiguration { com.android.internal.R.interpolator.linear_out_slow_in); quintOutInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.decelerate_quint); - - // Check if the developer options are enabled - ContentResolver cr = context.getContentResolver(); - developerOptionsEnabled = Settings.Global.getInt(cr, - Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; } /** Updates the configuration to the current context */ - public static RecentsConfiguration reinitialize(Context context) { + public static RecentsConfiguration reinitialize(Context context, SystemServicesProxy ssp) { if (sInstance == null) { sInstance = new RecentsConfiguration(context); } @@ -144,6 +141,7 @@ public class RecentsConfiguration { sInstance.update(context); sPrevConfigurationHashCode = configHashCode; } + sInstance.updateOnReinitialize(context, ssp); return sInstance; } @@ -260,6 +258,15 @@ public class RecentsConfiguration { appWidgetId).apply(); } + /** Updates the states that need to be re-read whenever we re-initialize. */ + void updateOnReinitialize(Context context, SystemServicesProxy ssp) { + // Check if the developer options are enabled + developerOptionsEnabled = ssp.getGlobalSetting(context, + Settings.Global.DEVELOPMENT_SETTINGS_ENABLED) != 0; + lockToAppEnabled = ssp.getSystemSetting(context, + Settings.System.LOCK_TO_APP_ENABLED) != 0; + } + /** Called when the configuration has changed, and we want to reset any configuration specific * members. */ public void updateOnConfigurationChange() { diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index ced4043..5fadc71 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -26,6 +26,7 @@ import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -47,6 +48,7 @@ import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; +import android.provider.Settings; import android.util.Log; import android.util.Pair; import android.view.Display; @@ -413,6 +415,22 @@ public class SystemServicesProxy { } /** + * Returns a global setting. + */ + public int getGlobalSetting(Context context, String setting) { + ContentResolver cr = context.getContentResolver(); + return Settings.Global.getInt(cr, setting, 0); + } + + /** + * Returns a system setting. + */ + public int getSystemSetting(Context context, String setting) { + ContentResolver cr = context.getContentResolver(); + return Settings.System.getInt(cr, setting, 0); + } + + /** * Returns the window rect. */ public Rect getWindowRect() { diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java index adf0794..9325947 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java @@ -27,6 +27,9 @@ import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.HandlerThread; import android.os.UserHandle; +import android.provider.Settings; +import android.provider.Settings.SettingNotFoundException; + import com.android.systemui.recents.Constants; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.misc.SystemServicesProxy; @@ -340,7 +343,7 @@ public class RecentsTaskLoader { // Create a new task Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, t.affiliatedTaskId, activityLabel, activityIcon, activityColor, t.userId, t.firstActiveTime, - t.lastActiveTime, (i == (taskCount - 1))); + t.lastActiveTime, (i == (taskCount - 1)), config.lockToAppEnabled); // Preload the specified number of apps if (i >= (taskCount - preloadCount)) { @@ -395,6 +398,7 @@ public class RecentsTaskLoader { /** Creates a lightweight stack of the current recent tasks, without thumbnails and icons. */ public static TaskStack getShallowTaskStack(SystemServicesProxy ssp) { + RecentsConfiguration config = RecentsConfiguration.getInstance(); List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp); TaskStack stack = new TaskStack(); @@ -405,7 +409,8 @@ public class RecentsTaskLoader { if (info == null) continue; stack.addTask(new Task(t.persistentId, true, t.baseIntent, t.affiliatedTaskId, null, - null, 0, 0, t.firstActiveTime, t.lastActiveTime, (i == (taskCount - 1)))); + null, 0, 0, t.firstActiveTime, t.lastActiveTime, (i == (taskCount - 1)), + config.lockToAppEnabled)); } stack.createAffiliatedGroupings(); return stack; diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java index 2473352..4cf9235 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java @@ -84,7 +84,8 @@ public class Task { public boolean useLightOnPrimaryColor; public Bitmap thumbnail; public boolean isActive; - public boolean canLockToTask; + public boolean lockToThisTask; + public boolean lockToTaskEnabled; public int userId; TaskCallbacks mCb; @@ -95,7 +96,8 @@ public class Task { public Task(int id, boolean isActive, Intent intent, int taskAffiliation, String activityTitle, Drawable activityIcon, int colorPrimary, int userId, - long firstActiveTime, long lastActiveTime, boolean canLockToTask) { + long firstActiveTime, long lastActiveTime, boolean lockToThisTask, + boolean lockToTaskEnabled) { this.key = new TaskKey(id, intent, userId, firstActiveTime, lastActiveTime); this.taskAffiliation = taskAffiliation; this.activityLabel = activityTitle; @@ -104,7 +106,8 @@ public class Task { this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(colorPrimary, Color.WHITE) > 3f; this.isActive = isActive; - this.canLockToTask = canLockToTask; + this.lockToThisTask = lockToTaskEnabled && lockToThisTask; + this.lockToTaskEnabled = lockToTaskEnabled; this.userId = userId; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java index 13fbe64..fdc5775 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java @@ -17,6 +17,7 @@ package com.android.systemui.recents.model; import com.android.systemui.recents.Constants; +import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.misc.NamedCounter; import java.util.ArrayList; @@ -204,10 +205,10 @@ public class TaskStack { removeGroup(group); } // Update the lock-to-app state - t.canLockToTask = false; + t.lockToThisTask = false; Task newFrontMostTask = getFrontMostTask(); - if (newFrontMostTask != null) { - newFrontMostTask.canLockToTask = true; + if (newFrontMostTask != null && newFrontMostTask.lockToTaskEnabled) { + newFrontMostTask.lockToThisTask = true; } if (mCb != null) { // Notify that a task has been removed diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java index 068cbfe..191dc37 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java @@ -356,7 +356,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback { // Disallow touch events from this task view tv.setTouchEnabled(false); // Hide the footer - tv.animateFooterVisibility(false, mSv.mConfig.taskViewLockToAppShortAnimDuration, 0); + tv.animateFooterVisibility(false, mSv.mConfig.taskViewLockToAppShortAnimDuration); // Disallow parents from intercepting touch events final ViewParent parent = mSv.getParent(); if (parent != null) { @@ -396,7 +396,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback { // Re-enable touch events from this task view tv.setTouchEnabled(true); // Restore the footer - tv.animateFooterVisibility(true, mSv.mConfig.taskViewLockToAppShortAnimDuration, 0); + tv.animateFooterVisibility(true, mSv.mConfig.taskViewLockToAppShortAnimDuration); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index 199d3f3..e973717 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -32,11 +32,9 @@ import android.view.ViewPropertyAnimator; import android.view.animation.AccelerateInterpolator; import android.widget.FrameLayout; import com.android.systemui.R; -import com.android.systemui.recents.misc.Console; import com.android.systemui.recents.Constants; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.model.Task; -import com.android.systemui.recents.model.TaskStack; /* A task view */ @@ -314,7 +312,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On mBarView.startEnterRecentsAnimation(0, mEnableThumbnailClip); setVisibility(View.VISIBLE); // Animate the footer into view - animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration, 0); + animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration); // Decrement the post animation trigger ctx.postAnimationTrigger.decrement(); } @@ -363,8 +361,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On ctx.postAnimationTrigger.increment(); // Animate the footer into view - animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration, - mConfig.taskBarEnterAnimDelay); + animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration + ); } else { mEnableThumbnailClip.run(); } @@ -398,14 +396,14 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On ctx.postAnimationTrigger.increment(); // Animate the footer into view - animateFooterVisibility(true, mConfig.taskViewEnterFromHomeDuration, - mConfig.taskBarEnterAnimDelay); + animateFooterVisibility(true, mConfig.taskViewEnterFromHomeDuration + ); } else { // Otherwise, just enable the thumbnail clip mEnableThumbnailClip.run(); // Animate the footer into view - animateFooterVisibility(true, 0, 0); + animateFooterVisibility(true, 0); } } @@ -555,8 +553,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On } /** Animates the footer into and out of view. */ - public void animateFooterVisibility(boolean visible, int duration, int delay) { - if (!mTask.canLockToTask) { + public void animateFooterVisibility(boolean visible, int duration) { + if (!mTask.lockToThisTask) { if (mLockToAppButtonView.getVisibility() == View.VISIBLE) { mLockToAppButtonView.setVisibility(View.INVISIBLE); } @@ -684,9 +682,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On mTask.setCallbacks(this); if (getMeasuredWidth() == 0) { // If we haven't yet measured, we should just set the footer height with any animation - animateFooterVisibility(t.canLockToTask, 0, 0); + animateFooterVisibility(t.lockToThisTask, 0); } else { - animateFooterVisibility(t.canLockToTask, mConfig.taskViewLockToAppLongAnimDuration, 0); + animateFooterVisibility(t.lockToThisTask, mConfig.taskViewLockToAppLongAnimDuration); } } @@ -754,7 +752,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On } }); // Hide the footer - tv.animateFooterVisibility(false, mConfig.taskViewRemoveAnimDuration, 0); + tv.animateFooterVisibility(false, mConfig.taskViewRemoveAnimDuration); } else if (v == tv || v == mLockToAppButtonView) { mCb.onTaskViewClicked(tv, tv.getTask(), (v == mLockToAppButtonView)); } |