diff options
6 files changed, 50 insertions, 48 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index ec181dac6b36..27f6a266597c 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -156,22 +156,6 @@ public class AppWidgetHostView extends FrameLayout implements AppWidgetHost.AppW } /** - * @hide - */ - public static class AdapterChildHostView extends AppWidgetHostView { - - public AdapterChildHostView(Context context) { - super(context); - } - - @Override - public Context getRemoteContextEnsuringCorrectCachedApkPath() { - // To reduce noise in error messages - return null; - } - } - - /** * Set the AppWidget that will be displayed by this view. This method also adds default padding * to widgets, as described in {@link #getDefaultPaddingForWidget(Context, ComponentName, Rect)} * and can be overridden in order to add custom padding. @@ -937,31 +921,17 @@ public class AppWidgetHostView extends FrameLayout implements AppWidgetHost.AppW setColorResources(RemoteViews.ColorResources.create(mContext, colorMapping)); } - private void setColorResourcesStates(RemoteViews.ColorResources colorResources) { - mColorResources = colorResources; - mColorMappingChanged = true; - mViewMode = VIEW_MODE_NOINIT; - } - /** @hide **/ public void setColorResources(RemoteViews.ColorResources colorResources) { if (colorResources == mColorResources) { return; } - setColorResourcesStates(colorResources); + mColorResources = colorResources; + mColorMappingChanged = true; + mViewMode = VIEW_MODE_NOINIT; reapplyLastRemoteViews(); } - /** - * @hide - */ - public void setColorResourcesNoReapply(RemoteViews.ColorResources colorResources) { - if (colorResources == mColorResources) { - return; - } - setColorResourcesStates(colorResources); - } - /** Check if, in the current context, the two color mappings are equivalent. */ private boolean isSameColorMapping(SparseIntArray oldColors, SparseIntArray newColors) { if (oldColors.size() != newColors.size()) { diff --git a/core/java/android/widget/RemoteCollectionItemsAdapter.java b/core/java/android/widget/RemoteCollectionItemsAdapter.java index 9b396aeea9eb..d84330828bf7 100644 --- a/core/java/android/widget/RemoteCollectionItemsAdapter.java +++ b/core/java/android/widget/RemoteCollectionItemsAdapter.java @@ -18,7 +18,6 @@ package android.widget; import android.annotation.NonNull; import android.annotation.Nullable; -import android.appwidget.AppWidgetHostView; import android.util.SparseIntArray; import android.view.View; import android.view.ViewGroup; @@ -26,6 +25,8 @@ import android.widget.RemoteViews.ColorResources; import android.widget.RemoteViews.InteractionHandler; import android.widget.RemoteViews.RemoteCollectionItems; +import com.android.internal.R; + import java.util.stream.IntStream; /** @@ -177,14 +178,40 @@ class RemoteCollectionItemsAdapter extends BaseAdapter { RemoteViews item = mItems.getItemView(position); item.addFlags(RemoteViews.FLAG_WIDGET_IS_COLLECTION_CHILD); + View reapplyView = getViewToReapply(convertView, item); + + // Reapply the RemoteViews if we can. + if (reapplyView != null) { + try { + item.reapply( + parent.getContext(), + reapplyView, + mInteractionHandler, + null /* size */, + mColorResources); + return reapplyView; + } catch (RuntimeException e) { + // We can't reapply for some reason, we'll fallback to an apply and inflate a + // new view. + } + } + + return item.apply( + parent.getContext(), + parent, + mInteractionHandler, + null /* size */, + mColorResources); + } + + /** Returns {@code convertView} if it can be used to reapply {@code item}, or null otherwise. */ + @Nullable + private static View getViewToReapply(@Nullable View convertView, @NonNull RemoteViews item) { + if (convertView == null) return null; + + Object layoutIdTag = convertView.getTag(R.id.widget_frame); + if (!(layoutIdTag instanceof Integer)) return null; - AppWidgetHostView newView = convertView instanceof AppWidgetHostView.AdapterChildHostView - widgetChildView - ? widgetChildView - : new AppWidgetHostView.AdapterChildHostView(parent.getContext()); - newView.setInteractionHandler(mInteractionHandler); - newView.setColorResourcesNoReapply(mColorResources); - newView.updateAppWidget(item); - return newView; + return item.getLayoutId() == (Integer) layoutIdTag ? convertView : null; } } diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 87e163a068bf..7f96266a1f69 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -6687,13 +6687,13 @@ public class RemoteViews implements Parcelable, Filter { View parent = (View) view.getParent(); // Break the for loop on the first encounter of: // 1) an AdapterView, - // 2) an AppWidgetHostView that is not a child of an adapter view, or + // 2) an AppWidgetHostView that is not a RemoteViewsFrameLayout, or // 3) a null parent. // 2) and 3) are unexpected and catch the case where a child is not // correctly parented in an AdapterView. while (parent != null && !(parent instanceof AdapterView<?>) && !((parent instanceof AppWidgetHostView) - && !(parent instanceof AppWidgetHostView.AdapterChildHostView))) { + && !(parent instanceof RemoteViewsAdapter.RemoteViewsFrameLayout))) { parent = (View) parent.getParent(); } diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java index 2f28a8704cd3..61a7599e8f73 100644 --- a/core/java/android/widget/RemoteViewsAdapter.java +++ b/core/java/android/widget/RemoteViewsAdapter.java @@ -368,7 +368,7 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback * A FrameLayout which contains a loading view, and manages the re/applying of RemoteViews when * they are loaded. */ - static class RemoteViewsFrameLayout extends AppWidgetHostView.AdapterChildHostView { + static class RemoteViewsFrameLayout extends AppWidgetHostView { private final FixedSizeRemoteViewsCache mCache; public int cacheIndex = -1; @@ -408,6 +408,11 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback } @Override + protected Context getRemoteContextEnsuringCorrectCachedApkPath() { + return null; + } + + @Override protected View getErrorView() { // Use the default loading view as the error view. return getDefaultView(); diff --git a/packages/SettingsLib/res/values-fr-rCA/strings.xml b/packages/SettingsLib/res/values-fr-rCA/strings.xml index 930a37327623..4afbd42a0ffd 100644 --- a/packages/SettingsLib/res/values-fr-rCA/strings.xml +++ b/packages/SettingsLib/res/values-fr-rCA/strings.xml @@ -175,7 +175,7 @@ <string name="launch_defaults_none" msgid="8049374306261262709">"Aucune préférence par défaut définie"</string> <string name="tts_settings" msgid="8130616705989351312">"Paramètres de synthèse vocale"</string> <string name="tts_settings_title" msgid="7602210956640483039">"Synthèse vocale"</string> - <string name="tts_default_rate_title" msgid="3964187817364304022">"Cadence"</string> + <string name="tts_default_rate_title" msgid="3964187817364304022">"Débit"</string> <string name="tts_default_rate_summary" msgid="3781937042151716987">"Vitesse à laquelle le texte est énoncé"</string> <string name="tts_default_pitch_title" msgid="6988592215554485479">"Ton"</string> <string name="tts_default_pitch_summary" msgid="9132719475281551884">"Touche le ton utilisé pour la synthèse vocale"</string> diff --git a/packages/SettingsLib/res/values-zh-rTW/strings.xml b/packages/SettingsLib/res/values-zh-rTW/strings.xml index e33934cead42..6f7280572bfa 100644 --- a/packages/SettingsLib/res/values-zh-rTW/strings.xml +++ b/packages/SettingsLib/res/values-zh-rTW/strings.xml @@ -361,7 +361,7 @@ <string name="show_hw_screen_updates_summary" msgid="3539770072741435691">"繪圖時在視窗中閃爍顯示畫面"</string> <string name="show_hw_layers_updates" msgid="5268370750002509767">"顯示硬體層更新"</string> <string name="show_hw_layers_updates_summary" msgid="5850955890493054618">"在硬體層更新時閃綠燈"</string> - <string name="debug_hw_overdraw" msgid="8944851091008756796">"針對 GPU 重複繪圖進行偵錯"</string> + <string name="debug_hw_overdraw" msgid="8944851091008756796">"針對 GPU 過度繪製進行偵錯"</string> <string name="disable_overlays" msgid="4206590799671557143">"停用硬體重疊圖層"</string> <string name="disable_overlays_summary" msgid="1954852414363338166">"一律使用 GPU 進行畫面合成"</string> <string name="simulate_color_space" msgid="1206503300335835151">"模擬色彩空間"</string> @@ -503,7 +503,7 @@ <string name="screen_zoom_summary_extremely_large" msgid="1438045624562358554">"最大"</string> <string name="screen_zoom_summary_custom" msgid="3468154096832912210">"自訂 (<xliff:g id="DENSITYDPI">%d</xliff:g>)"</string> <string name="content_description_menu_button" msgid="6254844309171779931">"選單"</string> - <string name="retail_demo_reset_message" msgid="5392824901108195463">"如要在示範模式中恢復原廠設定,請輸入密碼"</string> + <string name="retail_demo_reset_message" msgid="5392824901108195463">"如要在展示模式中恢復原廠設定,請輸入密碼"</string> <string name="retail_demo_reset_next" msgid="3688129033843885362">"下一步"</string> <string name="retail_demo_reset_title" msgid="1866911701095959800">"請輸入密碼"</string> <string name="active_input_method_subtypes" msgid="4232680535471633046">"啟用的輸入法"</string> |