Loading packages/SystemUI/src/com/android/systemui/Prefs.java +9 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public final class Prefs { }) public @interface Key { String SEARCH_APP_WIDGET_ID = "searchAppWidgetId"; String SEARCH_APP_WIDGET_PACKAGE = "searchAppWidgetPackage"; String DEBUG_MODE_ENABLED = "debugModeEnabled"; String HOTSPOT_TILE_LAST_USED = "HotspotTileLastUsed"; String COLOR_INVERSION_TILE_LAST_USED = "ColorInversionTileLastUsed"; Loading Loading @@ -80,6 +81,14 @@ public final class Prefs { get(context).edit().putLong(key, value).apply(); } public static String getString(Context context, @Key String key, String defaultValue) { return get(context).getString(key, defaultValue); } public static void putString(Context context, @Key String key, String value) { get(context).edit().putString(key, value).apply(); } public static Map<String, ?> getAll(Context context) { return get(context).getAll(); } Loading packages/SystemUI/src/com/android/systemui/recents/Recents.java +19 −47 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.ITaskStackListener; import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetProviderInfo; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; Loading @@ -37,11 +36,10 @@ import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.util.MutableBoolean; import android.util.Pair; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.RecentsComponent; import com.android.systemui.SystemUI; Loading Loading @@ -170,6 +168,7 @@ public class Recents extends SystemUI Handler mHandler; TaskStackListenerImpl mTaskStackListener; RecentsOwnerEventProxyReceiver mProxyBroadcastReceiver; RecentsAppWidgetHost mAppWidgetHost; boolean mBootCompleted; boolean mStartAnimationTriggered; boolean mCanReuseTaskStackViews = true; Loading Loading @@ -235,6 +234,7 @@ public class Recents extends SystemUI mSystemServicesProxy = new SystemServicesProxy(mContext); mHandler = new Handler(); mTaskStackBounds = new Rect(); mAppWidgetHost = new RecentsAppWidgetHost(mContext, Constants.Values.App.AppWidgetHostId); // Register the task stack listener mTaskStackListener = new TaskStackListenerImpl(mHandler); Loading @@ -255,7 +255,7 @@ public class Recents extends SystemUI // Initialize some static datastructures TaskStackViewLayoutAlgorithm.initializeCurve(); // Load the header bar layout reloadHeaderBarLayout(true); reloadHeaderBarLayout(); // 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. Loading Loading @@ -488,11 +488,11 @@ public class Recents extends SystemUI // Don't reuse task stack views if the configuration changes mCanReuseTaskStackViews = false; // Reload the header bar layout reloadHeaderBarLayout(false); reloadHeaderBarLayout(); } /** Prepares the header bar layout. */ void reloadHeaderBarLayout(boolean reloadWidget) { void reloadHeaderBarLayout() { Resources res = mContext.getResources(); mWindowRect = mSystemServicesProxy.getWindowRect(); mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); Loading @@ -500,12 +500,16 @@ public class Recents extends SystemUI mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); mConfig = RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy); mConfig.updateOnConfigurationChange(); if (reloadWidget) { // Reload the widget id before we get the task stack bounds reloadSearchBarAppWidget(mContext, mSystemServicesProxy); Rect searchBarBounds = new Rect(); // 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) { mConfig.getSearchBarBounds(mWindowRect.width(), mWindowRect.height(), mStatusBarHeight, searchBarBounds); } mConfig.getAvailableTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mStatusBarHeight, (mConfig.hasTransposedNavBar ? mNavBarWidth : 0), mStatusBarHeight, (mConfig.hasTransposedNavBar ? mNavBarWidth : 0), searchBarBounds, mTaskStackBounds); if (mConfig.isLandscape && mConfig.hasTransposedNavBar) { mSystemInsets.set(0, mStatusBarHeight, mNavBarWidth, 0); Loading @@ -532,24 +536,6 @@ public class Recents extends SystemUI } } /** Prepares the search bar app widget */ void reloadSearchBarAppWidget(Context context, SystemServicesProxy ssp) { // Try and pre-emptively bind the search widget on startup to ensure that we // have the right thumbnail bounds to animate to. if (Constants.DebugFlags.App.EnableSearchLayout) { // If there is no id, then bind a new search app widget if (mConfig.searchBarAppWidgetId < 0) { AppWidgetHost host = new RecentsAppWidgetHost(context, Constants.Values.App.AppWidgetHostId); Pair<Integer, AppWidgetProviderInfo> widgetInfo = ssp.bindSearchAppWidget(host); if (widgetInfo != null) { // Save the app widget id into the settings mConfig.updateSearchBarAppWidgetId(context, widgetInfo.first); } } } } /** Toggles the recents activity */ void toggleRecentsActivity() { // If the user has toggled it too quickly, then just eat up the event here (it's better than Loading Loading @@ -799,27 +785,13 @@ public class Recents extends SystemUI // If there is no thumbnail transition, but is launching from home into recents, then // use a quick home transition and do the animation from home if (hasRecentTasks) { // Get the home activity info String homeActivityPackage = mSystemServicesProxy.getHomeActivityPackageName(); // Get the search widget info AppWidgetProviderInfo searchWidget = null; String searchWidgetPackage = null; if (mConfig.hasSearchBarAppWidget()) { searchWidget = mSystemServicesProxy.getAppWidgetInfo( mConfig.searchBarAppWidgetId); } else { searchWidget = mSystemServicesProxy.resolveSearchAppWidget(); } if (searchWidget != null && searchWidget.provider != null) { searchWidgetPackage = searchWidget.provider.getPackageName(); } // Determine whether we are coming from a search owned home activity boolean fromSearchHome = false; if (homeActivityPackage != null && searchWidgetPackage != null && homeActivityPackage.equals(searchWidgetPackage)) { fromSearchHome = true; } String searchWidgetPackage = Prefs.getString(mContext, Prefs.Key.SEARCH_APP_WIDGET_PACKAGE, null); // Determine whether we are coming from a search owned home activity boolean fromSearchHome = (homeActivityPackage != null) && homeActivityPackage.equals(searchWidgetPackage); ActivityOptions opts = getHomeTransitionActivityOptions(fromSearchHome); startAlternateRecentsActivity(topTask, opts, true /* fromHome */, fromSearchHome, false /* fromThumbnail */, stackVr); Loading packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +26 −66 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.content.IntentFilter; import android.os.Bundle; import android.os.SystemClock; import android.os.UserHandle; import android.util.Pair; import android.view.KeyEvent; import android.view.View; import android.view.ViewStub; Loading @@ -50,7 +49,6 @@ import com.android.systemui.recents.views.SystemBarScrimViews; import com.android.systemui.recents.views.ViewAnimation; import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; /** Loading @@ -75,9 +73,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView RecentsResizeTaskDialog mResizeTaskDebugDialog; // Search AppWidget AppWidgetProviderInfo mSearchAppWidgetInfo; AppWidgetProviderInfo mSearchWidgetInfo; RecentsAppWidgetHost mAppWidgetHost; RecentsAppWidgetHostView mSearchAppWidgetHostView; RecentsAppWidgetHostView mSearchWidgetHostView; // Runnables to finish the Recents activity FinishRecentsRunnable mFinishLaunchHomeRunnable; Loading Loading @@ -168,8 +166,10 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // When the screen turns off, dismiss Recents to Home dismissRecentsToHome(false); } else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) { // When the search activity changes, update the Search widget refreshSearchWidget(); // When the search activity changes, update the search widget view SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(context, mAppWidgetHost); refreshSearchWidgetView(); } } }; Loading Loading @@ -253,7 +253,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView if (mRecentsView.hasValidSearchBar()) { mRecentsView.setSearchBarVisibility(View.VISIBLE); } else { addSearchBarAppWidgetView(); refreshSearchWidgetView(); } } Loading @@ -261,60 +261,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView mScrimViews.prepareEnterRecentsAnimation(); } /** Attempts to allocate and bind the search bar app widget */ void bindSearchBarAppWidget() { if (Constants.DebugFlags.App.EnableSearchLayout) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); // Reset the host view and widget info mSearchAppWidgetHostView = null; mSearchAppWidgetInfo = null; // Try and load the app widget id from the settings int appWidgetId = mConfig.searchBarAppWidgetId; if (appWidgetId >= 0) { mSearchAppWidgetInfo = ssp.getAppWidgetInfo(appWidgetId); if (mSearchAppWidgetInfo == null) { // If there is no actual widget associated with that id, then delete it and // prepare to bind another app widget in its place ssp.unbindSearchAppWidget(mAppWidgetHost, appWidgetId); appWidgetId = -1; } } // If there is no id, then bind a new search app widget if (appWidgetId < 0) { Pair<Integer, AppWidgetProviderInfo> widgetInfo = ssp.bindSearchAppWidget(mAppWidgetHost); if (widgetInfo != null) { // Save the app widget id into the settings mConfig.updateSearchBarAppWidgetId(this, widgetInfo.first); mSearchAppWidgetInfo = widgetInfo.second; } } } } /** Creates the search bar app widget view */ void addSearchBarAppWidgetView() { if (Constants.DebugFlags.App.EnableSearchLayout) { int appWidgetId = mConfig.searchBarAppWidgetId; if (appWidgetId >= 0) { mSearchAppWidgetHostView = (RecentsAppWidgetHostView) mAppWidgetHost.createView( this, appWidgetId, mSearchAppWidgetInfo); Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); mSearchAppWidgetHostView.updateAppWidgetOptions(opts); // Set the padding to 0 for this search widget mSearchAppWidgetHostView.setPadding(0, 0, 0, 0); mRecentsView.setSearchBar(mSearchAppWidgetHostView); } else { mRecentsView.setSearchBar(null); } } } /** Dismisses recents if we are already visible and the intent is to toggle the recents view */ boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); Loading Loading @@ -393,7 +339,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView inflateDebugOverlay(); // Bind the search app widget when we first start up bindSearchBarAppWidget(); mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost); // Register the broadcast receiver to handle messages when the screen is turned off IntentFilter filter = new IntentFilter(); Loading Loading @@ -498,7 +444,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t); mRecentsView.startEnterRecentsAnimation(ctx); if (mConfig.searchBarAppWidgetId >= 0) { if (mSearchWidgetInfo != null) { final WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks> cbRef = new WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks>( RecentsActivity.this); Loading Loading @@ -654,9 +601,22 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /**** RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks Implementation ****/ @Override public void refreshSearchWidget() { bindSearchBarAppWidget(); addSearchBarAppWidgetView(); public void refreshSearchWidgetView() { if (mSearchWidgetInfo != null) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); int searchWidgetId = ssp.getSearchAppWidgetId(this); mSearchWidgetHostView = (RecentsAppWidgetHostView) mAppWidgetHost.createView( this, searchWidgetId, mSearchWidgetInfo); Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); mSearchWidgetHostView.updateAppWidgetOptions(opts); // Set the padding to 0 for this search widget mSearchWidgetHostView.setPadding(0, 0, 0, 0); mRecentsView.setSearchBar(mSearchWidgetHostView); } else { mRecentsView.setSearchBar(null); } } /**** DebugOverlayView.DebugOverlayViewCallbacks ****/ Loading packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java +7 −18 Original line number Diff line number Diff line Loading @@ -20,26 +20,20 @@ import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.model.RecentsTaskLoader; /** Our special app widget host for the Search widget */ public class RecentsAppWidgetHost extends AppWidgetHost { /* Callbacks to notify when an app package changes */ interface RecentsAppWidgetHostCallbacks { public void refreshSearchWidget(); void refreshSearchWidgetView(); } Context mContext; RecentsAppWidgetHostCallbacks mCb; RecentsConfiguration mConfig; boolean mIsListening; public RecentsAppWidgetHost(Context context, int hostId) { super(context, hostId); mContext = context; mConfig = RecentsConfiguration.getInstance(); } public void startListening(RecentsAppWidgetHostCallbacks cb) { Loading @@ -57,7 +51,6 @@ public class RecentsAppWidgetHost extends AppWidgetHost { } // Ensure that we release any references to the callbacks mCb = null; mContext = null; mIsListening = false; } Loading @@ -67,18 +60,14 @@ public class RecentsAppWidgetHost extends AppWidgetHost { return new RecentsAppWidgetHostView(context); } /** * Note: this is only called for packages that have updated, not removed. */ @Override protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidgetInfo) { if (mCb == null) return; if (mContext == null) return; SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); if (appWidgetId > -1 && appWidgetId == mConfig.searchBarAppWidgetId) { // The search provider may have changed, so just delete the old widget and bind it again ssp.unbindSearchAppWidget(this, appWidgetId); // Update the search widget mConfig.updateSearchBarAppWidgetId(mContext, -1); mCb.refreshSearchWidget(); super.onProviderChanged(appWidgetId, appWidgetInfo); if (mIsListening && mCb != null) { mCb.refreshSearchWidgetView(); } } } packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHostView.java +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.recents; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.view.View; import android.widget.RemoteViews; public class RecentsAppWidgetHostView extends AppWidgetHostView { Loading @@ -37,6 +38,14 @@ public class RecentsAppWidgetHostView extends AppWidgetHostView { super.updateAppWidget(remoteViews); } @Override protected View getErrorView() { // Just return an empty view as the error view when failing to inflate the Recents search // bar widget (this is mainly to catch the case where we try and inflate the widget view // while the search provider is updating) return new View(mContext); } /** * Updates the last orientation that this widget was inflated. */ Loading Loading
packages/SystemUI/src/com/android/systemui/Prefs.java +9 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public final class Prefs { }) public @interface Key { String SEARCH_APP_WIDGET_ID = "searchAppWidgetId"; String SEARCH_APP_WIDGET_PACKAGE = "searchAppWidgetPackage"; String DEBUG_MODE_ENABLED = "debugModeEnabled"; String HOTSPOT_TILE_LAST_USED = "HotspotTileLastUsed"; String COLOR_INVERSION_TILE_LAST_USED = "ColorInversionTileLastUsed"; Loading Loading @@ -80,6 +81,14 @@ public final class Prefs { get(context).edit().putLong(key, value).apply(); } public static String getString(Context context, @Key String key, String defaultValue) { return get(context).getString(key, defaultValue); } public static void putString(Context context, @Key String key, String value) { get(context).edit().putString(key, value).apply(); } public static Map<String, ?> getAll(Context context) { return get(context).getAll(); } Loading
packages/SystemUI/src/com/android/systemui/recents/Recents.java +19 −47 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.ITaskStackListener; import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetProviderInfo; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; Loading @@ -37,11 +36,10 @@ import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.util.MutableBoolean; import android.util.Pair; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.RecentsComponent; import com.android.systemui.SystemUI; Loading Loading @@ -170,6 +168,7 @@ public class Recents extends SystemUI Handler mHandler; TaskStackListenerImpl mTaskStackListener; RecentsOwnerEventProxyReceiver mProxyBroadcastReceiver; RecentsAppWidgetHost mAppWidgetHost; boolean mBootCompleted; boolean mStartAnimationTriggered; boolean mCanReuseTaskStackViews = true; Loading Loading @@ -235,6 +234,7 @@ public class Recents extends SystemUI mSystemServicesProxy = new SystemServicesProxy(mContext); mHandler = new Handler(); mTaskStackBounds = new Rect(); mAppWidgetHost = new RecentsAppWidgetHost(mContext, Constants.Values.App.AppWidgetHostId); // Register the task stack listener mTaskStackListener = new TaskStackListenerImpl(mHandler); Loading @@ -255,7 +255,7 @@ public class Recents extends SystemUI // Initialize some static datastructures TaskStackViewLayoutAlgorithm.initializeCurve(); // Load the header bar layout reloadHeaderBarLayout(true); reloadHeaderBarLayout(); // 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. Loading Loading @@ -488,11 +488,11 @@ public class Recents extends SystemUI // Don't reuse task stack views if the configuration changes mCanReuseTaskStackViews = false; // Reload the header bar layout reloadHeaderBarLayout(false); reloadHeaderBarLayout(); } /** Prepares the header bar layout. */ void reloadHeaderBarLayout(boolean reloadWidget) { void reloadHeaderBarLayout() { Resources res = mContext.getResources(); mWindowRect = mSystemServicesProxy.getWindowRect(); mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); Loading @@ -500,12 +500,16 @@ public class Recents extends SystemUI mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); mConfig = RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy); mConfig.updateOnConfigurationChange(); if (reloadWidget) { // Reload the widget id before we get the task stack bounds reloadSearchBarAppWidget(mContext, mSystemServicesProxy); Rect searchBarBounds = new Rect(); // 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) { mConfig.getSearchBarBounds(mWindowRect.width(), mWindowRect.height(), mStatusBarHeight, searchBarBounds); } mConfig.getAvailableTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mStatusBarHeight, (mConfig.hasTransposedNavBar ? mNavBarWidth : 0), mStatusBarHeight, (mConfig.hasTransposedNavBar ? mNavBarWidth : 0), searchBarBounds, mTaskStackBounds); if (mConfig.isLandscape && mConfig.hasTransposedNavBar) { mSystemInsets.set(0, mStatusBarHeight, mNavBarWidth, 0); Loading @@ -532,24 +536,6 @@ public class Recents extends SystemUI } } /** Prepares the search bar app widget */ void reloadSearchBarAppWidget(Context context, SystemServicesProxy ssp) { // Try and pre-emptively bind the search widget on startup to ensure that we // have the right thumbnail bounds to animate to. if (Constants.DebugFlags.App.EnableSearchLayout) { // If there is no id, then bind a new search app widget if (mConfig.searchBarAppWidgetId < 0) { AppWidgetHost host = new RecentsAppWidgetHost(context, Constants.Values.App.AppWidgetHostId); Pair<Integer, AppWidgetProviderInfo> widgetInfo = ssp.bindSearchAppWidget(host); if (widgetInfo != null) { // Save the app widget id into the settings mConfig.updateSearchBarAppWidgetId(context, widgetInfo.first); } } } } /** Toggles the recents activity */ void toggleRecentsActivity() { // If the user has toggled it too quickly, then just eat up the event here (it's better than Loading Loading @@ -799,27 +785,13 @@ public class Recents extends SystemUI // If there is no thumbnail transition, but is launching from home into recents, then // use a quick home transition and do the animation from home if (hasRecentTasks) { // Get the home activity info String homeActivityPackage = mSystemServicesProxy.getHomeActivityPackageName(); // Get the search widget info AppWidgetProviderInfo searchWidget = null; String searchWidgetPackage = null; if (mConfig.hasSearchBarAppWidget()) { searchWidget = mSystemServicesProxy.getAppWidgetInfo( mConfig.searchBarAppWidgetId); } else { searchWidget = mSystemServicesProxy.resolveSearchAppWidget(); } if (searchWidget != null && searchWidget.provider != null) { searchWidgetPackage = searchWidget.provider.getPackageName(); } // Determine whether we are coming from a search owned home activity boolean fromSearchHome = false; if (homeActivityPackage != null && searchWidgetPackage != null && homeActivityPackage.equals(searchWidgetPackage)) { fromSearchHome = true; } String searchWidgetPackage = Prefs.getString(mContext, Prefs.Key.SEARCH_APP_WIDGET_PACKAGE, null); // Determine whether we are coming from a search owned home activity boolean fromSearchHome = (homeActivityPackage != null) && homeActivityPackage.equals(searchWidgetPackage); ActivityOptions opts = getHomeTransitionActivityOptions(fromSearchHome); startAlternateRecentsActivity(topTask, opts, true /* fromHome */, fromSearchHome, false /* fromThumbnail */, stackVr); Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +26 −66 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.content.IntentFilter; import android.os.Bundle; import android.os.SystemClock; import android.os.UserHandle; import android.util.Pair; import android.view.KeyEvent; import android.view.View; import android.view.ViewStub; Loading @@ -50,7 +49,6 @@ import com.android.systemui.recents.views.SystemBarScrimViews; import com.android.systemui.recents.views.ViewAnimation; import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; /** Loading @@ -75,9 +73,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView RecentsResizeTaskDialog mResizeTaskDebugDialog; // Search AppWidget AppWidgetProviderInfo mSearchAppWidgetInfo; AppWidgetProviderInfo mSearchWidgetInfo; RecentsAppWidgetHost mAppWidgetHost; RecentsAppWidgetHostView mSearchAppWidgetHostView; RecentsAppWidgetHostView mSearchWidgetHostView; // Runnables to finish the Recents activity FinishRecentsRunnable mFinishLaunchHomeRunnable; Loading Loading @@ -168,8 +166,10 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // When the screen turns off, dismiss Recents to Home dismissRecentsToHome(false); } else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) { // When the search activity changes, update the Search widget refreshSearchWidget(); // When the search activity changes, update the search widget view SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(context, mAppWidgetHost); refreshSearchWidgetView(); } } }; Loading Loading @@ -253,7 +253,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView if (mRecentsView.hasValidSearchBar()) { mRecentsView.setSearchBarVisibility(View.VISIBLE); } else { addSearchBarAppWidgetView(); refreshSearchWidgetView(); } } Loading @@ -261,60 +261,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView mScrimViews.prepareEnterRecentsAnimation(); } /** Attempts to allocate and bind the search bar app widget */ void bindSearchBarAppWidget() { if (Constants.DebugFlags.App.EnableSearchLayout) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); // Reset the host view and widget info mSearchAppWidgetHostView = null; mSearchAppWidgetInfo = null; // Try and load the app widget id from the settings int appWidgetId = mConfig.searchBarAppWidgetId; if (appWidgetId >= 0) { mSearchAppWidgetInfo = ssp.getAppWidgetInfo(appWidgetId); if (mSearchAppWidgetInfo == null) { // If there is no actual widget associated with that id, then delete it and // prepare to bind another app widget in its place ssp.unbindSearchAppWidget(mAppWidgetHost, appWidgetId); appWidgetId = -1; } } // If there is no id, then bind a new search app widget if (appWidgetId < 0) { Pair<Integer, AppWidgetProviderInfo> widgetInfo = ssp.bindSearchAppWidget(mAppWidgetHost); if (widgetInfo != null) { // Save the app widget id into the settings mConfig.updateSearchBarAppWidgetId(this, widgetInfo.first); mSearchAppWidgetInfo = widgetInfo.second; } } } } /** Creates the search bar app widget view */ void addSearchBarAppWidgetView() { if (Constants.DebugFlags.App.EnableSearchLayout) { int appWidgetId = mConfig.searchBarAppWidgetId; if (appWidgetId >= 0) { mSearchAppWidgetHostView = (RecentsAppWidgetHostView) mAppWidgetHost.createView( this, appWidgetId, mSearchAppWidgetInfo); Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); mSearchAppWidgetHostView.updateAppWidgetOptions(opts); // Set the padding to 0 for this search widget mSearchAppWidgetHostView.setPadding(0, 0, 0, 0); mRecentsView.setSearchBar(mSearchAppWidgetHostView); } else { mRecentsView.setSearchBar(null); } } } /** Dismisses recents if we are already visible and the intent is to toggle the recents view */ boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); Loading Loading @@ -393,7 +339,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView inflateDebugOverlay(); // Bind the search app widget when we first start up bindSearchBarAppWidget(); mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost); // Register the broadcast receiver to handle messages when the screen is turned off IntentFilter filter = new IntentFilter(); Loading Loading @@ -498,7 +444,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t); mRecentsView.startEnterRecentsAnimation(ctx); if (mConfig.searchBarAppWidgetId >= 0) { if (mSearchWidgetInfo != null) { final WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks> cbRef = new WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks>( RecentsActivity.this); Loading Loading @@ -654,9 +601,22 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /**** RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks Implementation ****/ @Override public void refreshSearchWidget() { bindSearchBarAppWidget(); addSearchBarAppWidgetView(); public void refreshSearchWidgetView() { if (mSearchWidgetInfo != null) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); int searchWidgetId = ssp.getSearchAppWidgetId(this); mSearchWidgetHostView = (RecentsAppWidgetHostView) mAppWidgetHost.createView( this, searchWidgetId, mSearchWidgetInfo); Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); mSearchWidgetHostView.updateAppWidgetOptions(opts); // Set the padding to 0 for this search widget mSearchWidgetHostView.setPadding(0, 0, 0, 0); mRecentsView.setSearchBar(mSearchWidgetHostView); } else { mRecentsView.setSearchBar(null); } } /**** DebugOverlayView.DebugOverlayViewCallbacks ****/ Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java +7 −18 Original line number Diff line number Diff line Loading @@ -20,26 +20,20 @@ import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.model.RecentsTaskLoader; /** Our special app widget host for the Search widget */ public class RecentsAppWidgetHost extends AppWidgetHost { /* Callbacks to notify when an app package changes */ interface RecentsAppWidgetHostCallbacks { public void refreshSearchWidget(); void refreshSearchWidgetView(); } Context mContext; RecentsAppWidgetHostCallbacks mCb; RecentsConfiguration mConfig; boolean mIsListening; public RecentsAppWidgetHost(Context context, int hostId) { super(context, hostId); mContext = context; mConfig = RecentsConfiguration.getInstance(); } public void startListening(RecentsAppWidgetHostCallbacks cb) { Loading @@ -57,7 +51,6 @@ public class RecentsAppWidgetHost extends AppWidgetHost { } // Ensure that we release any references to the callbacks mCb = null; mContext = null; mIsListening = false; } Loading @@ -67,18 +60,14 @@ public class RecentsAppWidgetHost extends AppWidgetHost { return new RecentsAppWidgetHostView(context); } /** * Note: this is only called for packages that have updated, not removed. */ @Override protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidgetInfo) { if (mCb == null) return; if (mContext == null) return; SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); if (appWidgetId > -1 && appWidgetId == mConfig.searchBarAppWidgetId) { // The search provider may have changed, so just delete the old widget and bind it again ssp.unbindSearchAppWidget(this, appWidgetId); // Update the search widget mConfig.updateSearchBarAppWidgetId(mContext, -1); mCb.refreshSearchWidget(); super.onProviderChanged(appWidgetId, appWidgetInfo); if (mIsListening && mCb != null) { mCb.refreshSearchWidgetView(); } } }
packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHostView.java +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.recents; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.view.View; import android.widget.RemoteViews; public class RecentsAppWidgetHostView extends AppWidgetHostView { Loading @@ -37,6 +38,14 @@ public class RecentsAppWidgetHostView extends AppWidgetHostView { super.updateAppWidget(remoteViews); } @Override protected View getErrorView() { // Just return an empty view as the error view when failing to inflate the Recents search // bar widget (this is mainly to catch the case where we try and inflate the widget view // while the search provider is updating) return new View(mContext); } /** * Updates the last orientation that this widget was inflated. */ Loading