Loading core/java/android/widget/RemoteViews.java +44 −5 Original line number Diff line number Diff line Loading @@ -300,6 +300,13 @@ public class RemoteViews implements Parcelable, Filter { */ public static final int FLAG_USE_LIGHT_BACKGROUND_LAYOUT = 4; /** * This mask determines which flags are propagated to nested RemoteViews (either added by * addView, or set as portrait/landscape/sized RemoteViews). */ static final int FLAG_MASK_TO_PROPAGATE = FLAG_WIDGET_IS_COLLECTION_CHILD | FLAG_USE_LIGHT_BACKGROUND_LAYOUT; /** * A ReadWriteHelper which has the same behavior as ReadWriteHelper.DEFAULT, but which is * intentionally a different instance in order to trick Bundle reader so that it doesn't allow Loading Loading @@ -467,6 +474,18 @@ public class RemoteViews implements Parcelable, Filter { */ public void addFlags(@ApplyFlags int flags) { mApplyFlags = mApplyFlags | flags; int flagsToPropagate = flags & FLAG_MASK_TO_PROPAGATE; if (flagsToPropagate != 0) { if (hasSizedRemoteViews()) { for (RemoteViews remoteView : mSizedRemoteViews) { remoteView.addFlags(flagsToPropagate); } } else if (hasLandscapeAndPortraitLayouts()) { mLandscape.addFlags(flagsToPropagate); mPortrait.addFlags(flagsToPropagate); } } } /** Loading Loading @@ -2407,6 +2426,10 @@ public class RemoteViews implements Parcelable, Filter { // will return -1. final int nextChild = getNextRecyclableChild(target); RemoteViews rvToApply = mNestedViews.getRemoteViewsToApply(context); int flagsToPropagate = mApplyFlags & FLAG_MASK_TO_PROPAGATE; if (flagsToPropagate != 0) rvToApply.addFlags(flagsToPropagate); if (nextChild >= 0 && mStableId != NO_ID) { // At that point, the views starting at index nextChild are the ones recyclable but // not yet recycled. All views added on that round of application are placed before. Loading @@ -2419,8 +2442,8 @@ public class RemoteViews implements Parcelable, Filter { target.removeViews(nextChild, recycledViewIndex - nextChild); } setNextRecyclableChild(target, nextChild + 1, target.getChildCount()); rvToApply.reapply(context, child, handler, null /* size */, colorResources, false /* topLevel */); rvToApply.reapplyNestedViews(context, child, rootParent, handler, null /* size */, colorResources); return; } // If we cannot recycle the views, we still remove all views in between to Loading @@ -2431,8 +2454,8 @@ public class RemoteViews implements Parcelable, Filter { // If we cannot recycle, insert the new view before the next recyclable child. // Inflate nested views and add as children View nestedView = rvToApply.apply(context, target, handler, null /* size */, colorResources); View nestedView = rvToApply.applyNestedViews(context, target, rootParent, handler, null /* size */, colorResources); if (mStableId != NO_ID) { setStableId(nestedView, mStableId); } Loading Loading @@ -3780,7 +3803,7 @@ public class RemoteViews implements Parcelable, Filter { * @param parcel */ public RemoteViews(Parcel parcel) { this(parcel, /* rootParent= */ null, /* info= */ null, /* depth= */ 0); this(parcel, /* rootData= */ null, /* info= */ null, /* depth= */ 0); } private RemoteViews(@NonNull Parcel parcel, @Nullable HierarchyRootData rootData, Loading Loading @@ -5580,6 +5603,16 @@ public class RemoteViews implements Parcelable, Filter { return result; } private View applyNestedViews(Context context, ViewGroup directParent, ViewGroup rootParent, InteractionHandler handler, SizeF size, ColorResources colorResources) { RemoteViews rvToApply = getRemoteViewsToApply(context, size); View result = inflateView(context, rvToApply, directParent, 0, colorResources); rvToApply.performApply(result, rootParent, handler, colorResources); return result; } private View inflateView(Context context, RemoteViews rv, ViewGroup parent) { return inflateView(context, rv, parent, 0, null); } Loading Loading @@ -5895,6 +5928,12 @@ public class RemoteViews implements Parcelable, Filter { } } private void reapplyNestedViews(Context context, View v, ViewGroup rootParent, InteractionHandler handler, SizeF size, ColorResources colorResources) { RemoteViews rvToApply = getRemoteViewsToReapply(context, v, size); rvToApply.performApply(v, rootParent, handler, colorResources); } /** * Applies all the actions to the provided view, moving as much of the task on the background * thread as possible. Loading core/tests/coretests/res/layout/remote_view_relative_layout.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** ** Copyright 2008, 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. */ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" /> core/tests/coretests/res/layout/remote_view_relative_layout_with_theme.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** ** Copyright 2008, 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. */ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/themed_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:theme="@style/RelativeLayoutAlignTop25Alpha"/> core/tests/coretests/res/layout/remote_views_light_background_text.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2016 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 --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/light_background_text" android:layout_width="match_parent" android:layout_height="match_parent" /> core/tests/coretests/res/layout/remote_views_list.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2016 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 --> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent"/> Loading
core/java/android/widget/RemoteViews.java +44 −5 Original line number Diff line number Diff line Loading @@ -300,6 +300,13 @@ public class RemoteViews implements Parcelable, Filter { */ public static final int FLAG_USE_LIGHT_BACKGROUND_LAYOUT = 4; /** * This mask determines which flags are propagated to nested RemoteViews (either added by * addView, or set as portrait/landscape/sized RemoteViews). */ static final int FLAG_MASK_TO_PROPAGATE = FLAG_WIDGET_IS_COLLECTION_CHILD | FLAG_USE_LIGHT_BACKGROUND_LAYOUT; /** * A ReadWriteHelper which has the same behavior as ReadWriteHelper.DEFAULT, but which is * intentionally a different instance in order to trick Bundle reader so that it doesn't allow Loading Loading @@ -467,6 +474,18 @@ public class RemoteViews implements Parcelable, Filter { */ public void addFlags(@ApplyFlags int flags) { mApplyFlags = mApplyFlags | flags; int flagsToPropagate = flags & FLAG_MASK_TO_PROPAGATE; if (flagsToPropagate != 0) { if (hasSizedRemoteViews()) { for (RemoteViews remoteView : mSizedRemoteViews) { remoteView.addFlags(flagsToPropagate); } } else if (hasLandscapeAndPortraitLayouts()) { mLandscape.addFlags(flagsToPropagate); mPortrait.addFlags(flagsToPropagate); } } } /** Loading Loading @@ -2407,6 +2426,10 @@ public class RemoteViews implements Parcelable, Filter { // will return -1. final int nextChild = getNextRecyclableChild(target); RemoteViews rvToApply = mNestedViews.getRemoteViewsToApply(context); int flagsToPropagate = mApplyFlags & FLAG_MASK_TO_PROPAGATE; if (flagsToPropagate != 0) rvToApply.addFlags(flagsToPropagate); if (nextChild >= 0 && mStableId != NO_ID) { // At that point, the views starting at index nextChild are the ones recyclable but // not yet recycled. All views added on that round of application are placed before. Loading @@ -2419,8 +2442,8 @@ public class RemoteViews implements Parcelable, Filter { target.removeViews(nextChild, recycledViewIndex - nextChild); } setNextRecyclableChild(target, nextChild + 1, target.getChildCount()); rvToApply.reapply(context, child, handler, null /* size */, colorResources, false /* topLevel */); rvToApply.reapplyNestedViews(context, child, rootParent, handler, null /* size */, colorResources); return; } // If we cannot recycle the views, we still remove all views in between to Loading @@ -2431,8 +2454,8 @@ public class RemoteViews implements Parcelable, Filter { // If we cannot recycle, insert the new view before the next recyclable child. // Inflate nested views and add as children View nestedView = rvToApply.apply(context, target, handler, null /* size */, colorResources); View nestedView = rvToApply.applyNestedViews(context, target, rootParent, handler, null /* size */, colorResources); if (mStableId != NO_ID) { setStableId(nestedView, mStableId); } Loading Loading @@ -3780,7 +3803,7 @@ public class RemoteViews implements Parcelable, Filter { * @param parcel */ public RemoteViews(Parcel parcel) { this(parcel, /* rootParent= */ null, /* info= */ null, /* depth= */ 0); this(parcel, /* rootData= */ null, /* info= */ null, /* depth= */ 0); } private RemoteViews(@NonNull Parcel parcel, @Nullable HierarchyRootData rootData, Loading Loading @@ -5580,6 +5603,16 @@ public class RemoteViews implements Parcelable, Filter { return result; } private View applyNestedViews(Context context, ViewGroup directParent, ViewGroup rootParent, InteractionHandler handler, SizeF size, ColorResources colorResources) { RemoteViews rvToApply = getRemoteViewsToApply(context, size); View result = inflateView(context, rvToApply, directParent, 0, colorResources); rvToApply.performApply(result, rootParent, handler, colorResources); return result; } private View inflateView(Context context, RemoteViews rv, ViewGroup parent) { return inflateView(context, rv, parent, 0, null); } Loading Loading @@ -5895,6 +5928,12 @@ public class RemoteViews implements Parcelable, Filter { } } private void reapplyNestedViews(Context context, View v, ViewGroup rootParent, InteractionHandler handler, SizeF size, ColorResources colorResources) { RemoteViews rvToApply = getRemoteViewsToReapply(context, v, size); rvToApply.performApply(v, rootParent, handler, colorResources); } /** * Applies all the actions to the provided view, moving as much of the task on the background * thread as possible. Loading
core/tests/coretests/res/layout/remote_view_relative_layout.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** ** Copyright 2008, 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. */ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" />
core/tests/coretests/res/layout/remote_view_relative_layout_with_theme.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** ** Copyright 2008, 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. */ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/themed_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:theme="@style/RelativeLayoutAlignTop25Alpha"/>
core/tests/coretests/res/layout/remote_views_light_background_text.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2016 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 --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/light_background_text" android:layout_width="match_parent" android:layout_height="match_parent" />
core/tests/coretests/res/layout/remote_views_list.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2016 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 --> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent"/>