summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2016-02-05 15:03:19 -0800
committerRoman Birg <roman@cyngn.com>2016-02-08 13:38:36 -0800
commitbba195586565f506bea5be6a2222544417ea076a (patch)
treeaf6d6789a9cf25dc37bacc1308ebfed42d60ed9a
parent76da31a853aeffce0d353a8f9b4fefe2a577865a (diff)
downloadframeworks_base-bba195586565f506bea5be6a2222544417ea076a.zip
frameworks_base-bba195586565f506bea5be6a2222544417ea076a.tar.gz
frameworks_base-bba195586565f506bea5be6a2222544417ea076a.tar.bz2
SystemUI: handle hiding recents search bar dynamically
If the "Show recents search bar" is toggled inside Settings, we need to catch that and reload the header bar as needed. Otherwise, having the setting disabled would still include search bar bounds while the view was hidden, causing some jarring animation jumps. Ref: CYNGNOS-342 Change-Id: I74597d6d225af0395da6cb7a611bd230fc9e0675 Signed-off-by: Roman Birg <roman@cyngn.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Recents.java39
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java4
4 files changed, 56 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index 3917bab..b3a3dfd 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -46,6 +46,7 @@ import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIApplication;
+import com.android.systemui.cm.UserContentObserver;
import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoadPlan;
@@ -61,6 +62,8 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar;
import java.util.ArrayList;
+import cyanogenmod.providers.CMSettings;
+
/**
* Annotation for a method that is only called from the primary user's SystemUI process and will be
* proxied to the current user.
@@ -161,6 +164,35 @@ public class Recents extends SystemUI
}
}
+ class RecentsSettingsObserver extends UserContentObserver {
+
+ public RecentsSettingsObserver(Handler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected void observe() {
+ super.observe();
+ mContext.getContentResolver().registerContentObserver(
+ CMSettings.System.getUriFor(CMSettings.System.RECENTS_SHOW_SEARCH_BAR),
+ false, this);
+ update();
+ }
+
+ @Override
+ protected void unobserve() {
+ super.unobserve();
+ mContext.getContentResolver().unregisterContentObserver(this);
+ }
+
+ @Override
+ protected void update() {
+ if (mConfig.updateShowSearch(mContext)) {
+ reloadHeaderBarLayout();
+ }
+ }
+ }
+
static RecentsComponent.Callbacks sRecentsComponentCallbacks;
static RecentsTaskLoadPlan sInstanceLoadPlan;
static Recents sInstance;
@@ -171,6 +203,7 @@ public class Recents extends SystemUI
TaskStackListenerImpl mTaskStackListener;
RecentsOwnerEventProxyReceiver mProxyBroadcastReceiver;
RecentsAppWidgetHost mAppWidgetHost;
+ RecentsSettingsObserver mSettingsObserver;
boolean mBootCompleted;
boolean mStartAnimationTriggered;
boolean mCanReuseTaskStackViews = true;
@@ -259,6 +292,9 @@ public class Recents extends SystemUI
// Load the header bar layout
reloadHeaderBarLayout();
+ mSettingsObserver = new RecentsSettingsObserver(mHandler);
+ mSettingsObserver.observe();
+
// When we start, preload the data associated with the previous recent tasks.
// We can use a new plan since the caches will be the same.
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
@@ -549,7 +585,8 @@ public class Recents extends SystemUI
// Try and pre-emptively bind the search widget on startup to ensure that we
// have the right thumbnail bounds to animate to.
// Note: We have to reload the widget id before we get the task stack bounds below
- if (mSystemServicesProxy.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
+ if (mConfig.searchBarEnabled &&
+ mSystemServicesProxy.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
mConfig.getSearchBarBounds(mWindowRect.width(), mWindowRect.height(),
mStatusBarHeight, searchBarBounds);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index bbf24142..3ded071 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -261,10 +261,14 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
mEmptyView.setVisibility(View.GONE);
mEmptyView.setOnClickListener(null);
}
- if (mRecentsView.hasValidSearchBar()) {
- mRecentsView.setSearchBarVisibility(View.VISIBLE);
+ if (!mConfig.searchBarEnabled) {
+ mRecentsView.setSearchBarVisibility(View.GONE);
} else {
- refreshSearchWidgetView();
+ if (mRecentsView.hasValidSearchBar()) {
+ mRecentsView.setSearchBarVisibility(View.VISIBLE);
+ } else {
+ refreshSearchWidgetView();
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 41d52b8..d7e8b99 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -31,6 +31,7 @@ import com.android.systemui.R;
import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.misc.SystemServicesProxy;
+import cyanogenmod.providers.CMSettings;
/** A static Recents configuration for the current context
* NOTE: We should not hold any references to a Context from a static instance */
@@ -73,6 +74,7 @@ public class RecentsConfiguration {
public int maxNumTasksToLoad;
/** Search bar */
+ public boolean searchBarEnabled = true;
public int searchBarSpaceHeightPx;
/** Task stack */
@@ -279,6 +281,13 @@ public class RecentsConfiguration {
svelteLevel = res.getInteger(R.integer.recents_svelte_level);
}
+ public boolean updateShowSearch(Context context) {
+ boolean wasEnabled = searchBarEnabled;
+ searchBarEnabled = CMSettings.System.getInt(context.getContentResolver(),
+ CMSettings.System.RECENTS_SHOW_SEARCH_BAR, 1) == 1;
+ return wasEnabled != searchBarEnabled;
+ }
+
/** Updates the system insets */
public void updateSystemInsets(Rect insets) {
systemInsets.set(insets);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 947c19c..64622620 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -323,7 +323,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
// Get the search bar bounds and measure the search bar layout
Rect searchBarSpaceBounds = new Rect();
- if (mSearchBar != null) {
+ if (mSearchBar != null && mConfig.searchBarEnabled) {
mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
mSearchBar.measure(
MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
@@ -360,7 +360,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
// Get the search bar bounds so that we lay it out
- if (mSearchBar != null) {
+ if (mSearchBar != null && mConfig.searchBarEnabled) {
Rect searchBarSpaceBounds = new Rect();
mConfig.getSearchBarBounds(getMeasuredWidth(), getMeasuredHeight(),
mConfig.systemInsets.top, searchBarSpaceBounds);