Loading packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +5 −9 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.recents; import android.app.Activity; import android.app.ActivityOptions; import android.app.SearchManager; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.BroadcastReceiver; Loading @@ -35,7 +34,6 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewStub; import android.widget.Toast; import com.android.systemui.R; import com.android.systemui.recents.misc.DebugTrigger; import com.android.systemui.recents.misc.ReferenceCountedTrigger; Loading @@ -49,8 +47,6 @@ import com.android.systemui.recents.views.DebugOverlayView; import com.android.systemui.recents.views.RecentsView; import com.android.systemui.recents.views.SystemBarScrimViews; import com.android.systemui.recents.views.ViewAnimation; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.SystemUIApplication; import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; Loading Loading @@ -78,9 +74,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView RecentsResizeTaskDialog mResizeTaskDebugDialog; // Search AppWidget RecentsAppWidgetHost mAppWidgetHost; AppWidgetProviderInfo mSearchAppWidgetInfo; AppWidgetHostView mSearchAppWidgetHostView; RecentsAppWidgetHost mAppWidgetHost; RecentsAppWidgetHostView mSearchAppWidgetHostView; // Runnables to finish the Recents activity FinishRecentsRunnable mFinishLaunchHomeRunnable; Loading Loading @@ -245,7 +241,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView if (mEmptyView != null) { mEmptyView.setVisibility(View.GONE); } if (mRecentsView.hasSearchBar()) { if (mRecentsView.hasValidSearchBar()) { mRecentsView.setSearchBarVisibility(View.VISIBLE); } else { addSearchBarAppWidgetView(); Loading Loading @@ -295,8 +291,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView if (Constants.DebugFlags.App.EnableSearchLayout) { int appWidgetId = mConfig.searchBarAppWidgetId; if (appWidgetId >= 0) { mSearchAppWidgetHostView = mAppWidgetHost.createView(this, appWidgetId, mSearchAppWidgetInfo); mSearchAppWidgetHostView = (RecentsAppWidgetHostView) mAppWidgetHost.createView( this, appWidgetId, mSearchAppWidgetInfo); Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); Loading packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.recents; import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import com.android.systemui.recents.misc.SystemServicesProxy; Loading Loading @@ -60,6 +61,12 @@ public class RecentsAppWidgetHost extends AppWidgetHost { mIsListening = false; } @Override protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { return new RecentsAppWidgetHostView(context); } @Override protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidgetInfo) { if (mCb == null) return; Loading packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHostView.java 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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.systemui.recents; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.widget.RemoteViews; public class RecentsAppWidgetHostView extends AppWidgetHostView { private Context mContext; private int mPreviousOrientation; public RecentsAppWidgetHostView(Context context) { super(context); mContext = context; } @Override public void updateAppWidget(RemoteViews remoteViews) { // Store the orientation in which the widget was inflated updateLastInflationOrientation(); super.updateAppWidget(remoteViews); } /** * Updates the last orientation that this widget was inflated. */ private void updateLastInflationOrientation() { mPreviousOrientation = mContext.getResources().getConfiguration().orientation; } /** * @return whether the search widget was updated while Recents was in a different orientation * in the background. */ public boolean isReinflateRequired() { // Re-inflate is required if the orientation has changed since last inflated. int orientation = mContext.getResources().getConfiguration().orientation; if (mPreviousOrientation != orientation) { return true; } return false; } } packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +5 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.view.WindowInsets; import android.widget.FrameLayout; import com.android.systemui.R; import com.android.systemui.recents.Constants; import com.android.systemui.recents.RecentsAppWidgetHostView; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.model.RecentsPackageMonitor; Loading Loading @@ -69,7 +70,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV ArrayList<TaskStack> mStacks; List<TaskStackView> mTaskStackViews = new ArrayList<>(); View mSearchBar; RecentsAppWidgetHostView mSearchBar; RecentsViewCallbacks mCb; public RecentsView(Context context) { Loading Loading @@ -278,7 +279,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } /** Adds the search bar */ public void setSearchBar(View searchBar) { public void setSearchBar(RecentsAppWidgetHostView searchBar) { // Create the search bar (and hide it if we have no recent tasks) if (Constants.DebugFlags.App.EnableSearchLayout) { // Remove the previous search bar if one exists Loading @@ -294,8 +295,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } /** Returns whether there is currently a search bar */ public boolean hasSearchBar() { return mSearchBar != null; public boolean hasValidSearchBar() { return mSearchBar != null && !mSearchBar.isReinflateRequired(); } /** Sets the visibility of the search bar */ Loading Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +5 −9 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.recents; import android.app.Activity; import android.app.ActivityOptions; import android.app.SearchManager; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.BroadcastReceiver; Loading @@ -35,7 +34,6 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewStub; import android.widget.Toast; import com.android.systemui.R; import com.android.systemui.recents.misc.DebugTrigger; import com.android.systemui.recents.misc.ReferenceCountedTrigger; Loading @@ -49,8 +47,6 @@ import com.android.systemui.recents.views.DebugOverlayView; import com.android.systemui.recents.views.RecentsView; import com.android.systemui.recents.views.SystemBarScrimViews; import com.android.systemui.recents.views.ViewAnimation; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.SystemUIApplication; import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; Loading Loading @@ -78,9 +74,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView RecentsResizeTaskDialog mResizeTaskDebugDialog; // Search AppWidget RecentsAppWidgetHost mAppWidgetHost; AppWidgetProviderInfo mSearchAppWidgetInfo; AppWidgetHostView mSearchAppWidgetHostView; RecentsAppWidgetHost mAppWidgetHost; RecentsAppWidgetHostView mSearchAppWidgetHostView; // Runnables to finish the Recents activity FinishRecentsRunnable mFinishLaunchHomeRunnable; Loading Loading @@ -245,7 +241,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView if (mEmptyView != null) { mEmptyView.setVisibility(View.GONE); } if (mRecentsView.hasSearchBar()) { if (mRecentsView.hasValidSearchBar()) { mRecentsView.setSearchBarVisibility(View.VISIBLE); } else { addSearchBarAppWidgetView(); Loading Loading @@ -295,8 +291,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView if (Constants.DebugFlags.App.EnableSearchLayout) { int appWidgetId = mConfig.searchBarAppWidgetId; if (appWidgetId >= 0) { mSearchAppWidgetHostView = mAppWidgetHost.createView(this, appWidgetId, mSearchAppWidgetInfo); mSearchAppWidgetHostView = (RecentsAppWidgetHostView) mAppWidgetHost.createView( this, appWidgetId, mSearchAppWidgetInfo); Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.recents; import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import com.android.systemui.recents.misc.SystemServicesProxy; Loading Loading @@ -60,6 +61,12 @@ public class RecentsAppWidgetHost extends AppWidgetHost { mIsListening = false; } @Override protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { return new RecentsAppWidgetHostView(context); } @Override protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidgetInfo) { if (mCb == null) return; Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHostView.java 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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.systemui.recents; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.widget.RemoteViews; public class RecentsAppWidgetHostView extends AppWidgetHostView { private Context mContext; private int mPreviousOrientation; public RecentsAppWidgetHostView(Context context) { super(context); mContext = context; } @Override public void updateAppWidget(RemoteViews remoteViews) { // Store the orientation in which the widget was inflated updateLastInflationOrientation(); super.updateAppWidget(remoteViews); } /** * Updates the last orientation that this widget was inflated. */ private void updateLastInflationOrientation() { mPreviousOrientation = mContext.getResources().getConfiguration().orientation; } /** * @return whether the search widget was updated while Recents was in a different orientation * in the background. */ public boolean isReinflateRequired() { // Re-inflate is required if the orientation has changed since last inflated. int orientation = mContext.getResources().getConfiguration().orientation; if (mPreviousOrientation != orientation) { return true; } return false; } }
packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +5 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.view.WindowInsets; import android.widget.FrameLayout; import com.android.systemui.R; import com.android.systemui.recents.Constants; import com.android.systemui.recents.RecentsAppWidgetHostView; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.model.RecentsPackageMonitor; Loading Loading @@ -69,7 +70,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV ArrayList<TaskStack> mStacks; List<TaskStackView> mTaskStackViews = new ArrayList<>(); View mSearchBar; RecentsAppWidgetHostView mSearchBar; RecentsViewCallbacks mCb; public RecentsView(Context context) { Loading Loading @@ -278,7 +279,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } /** Adds the search bar */ public void setSearchBar(View searchBar) { public void setSearchBar(RecentsAppWidgetHostView searchBar) { // Create the search bar (and hide it if we have no recent tasks) if (Constants.DebugFlags.App.EnableSearchLayout) { // Remove the previous search bar if one exists Loading @@ -294,8 +295,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } /** Returns whether there is currently a search bar */ public boolean hasSearchBar() { return mSearchBar != null; public boolean hasValidSearchBar() { return mSearchBar != null && !mSearchBar.isReinflateRequired(); } /** Sets the visibility of the search bar */ Loading