diff options
| author | 2023-10-11 03:54:48 +0000 | |
|---|---|---|
| committer | 2023-10-11 03:54:48 +0000 | |
| commit | 398351310d5ba3d4db00baecc4d66ae8d3dcc700 (patch) | |
| tree | 4a5944b91430e8900e33b4b367efeb01bf0bb3bf | |
| parent | b502a3cc178a48d9cdbb9fe26814d2abb13a6d5d (diff) | |
| parent | 11bf0a4ddd8fb34de3896a16c8c14d6076a6bf99 (diff) | |
Merge "Finish use_resource_processor for SettingsLib" into main
8 files changed, 33 insertions, 105 deletions
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp index ae87f388d9c2..8964adaf586e 100644 --- a/packages/SettingsLib/Android.bp +++ b/packages/SettingsLib/Android.bp @@ -11,50 +11,14 @@ android_library { name: "SettingsLib", static_libs: [ - "androidx.annotation_annotation", - "androidx.appcompat_appcompat", - "androidx.coordinatorlayout_coordinatorlayout", - "androidx.core_core", - "androidx.fragment_fragment", - "androidx.lifecycle_lifecycle-runtime", - "androidx.loader_loader", "androidx.localbroadcastmanager_localbroadcastmanager", - "androidx.preference_preference", - "androidx.recyclerview_recyclerview", - "com.google.android.material_material", - "iconloader", + "androidx.room_room-runtime", + "zxing-core", "WifiTrackerLibRes", - "SettingsLibDeviceStateRotationLock", - "SettingsLibDisplayUtils", - "SettingsLibEmergencyNumber", - "SettingsLibSearchWidget", - "SettingsLibUtils", - "SettingsLibWidget", + "iconloader", "setupdesign", - "zxing-core", - "androidx.room_room-runtime", - "settingslib_flags_lib", - ], - - plugins: ["androidx.room_room-compiler-plugin"], - use_resource_processor: true, - resource_dirs: ["res"], - - srcs: [ - "src/**/*.java", - "src/**/*.kt", - ], -} -// Group all the libraries with namespace "com.android.settingslib.widget", to allow SettingsLib to -// set use_resource_processor = true. -// We can remove SettingsLibWidget when all these libraries have its own namespace. -android_library { - name: "SettingsLibWidget", - visibility: ["//visibility:private"], - manifest: "AndroidManifest-SettingsLibWidget.xml", - static_libs: [ "SettingsLibActionBarShadow", "SettingsLibActionButtonsPreference", "SettingsLibAdaptiveIcon", @@ -63,6 +27,9 @@ android_library { "SettingsLibBarChartPreference", "SettingsLibButtonPreference", "SettingsLibCollapsingToolbarBaseActivity", + "SettingsLibDeviceStateRotationLock", + "SettingsLibDisplayUtils", + "SettingsLibEmergencyNumber", "SettingsLibEntityHeaderWidgets", "SettingsLibFooterPreference", "SettingsLibHelpUtils", @@ -72,31 +39,31 @@ android_library { "SettingsLibProfileSelector", "SettingsLibProgressBar", "SettingsLibRestrictedLockUtils", + "SettingsLibSearchWidget", "SettingsLibSelectorWithWidgetPreference", "SettingsLibSettingsSpinner", "SettingsLibSettingsTransition", "SettingsLibTopIntroPreference", "SettingsLibTwoTargetPreference", "SettingsLibUsageProgressBarPreference", + "SettingsLibUtils", + "settingslib_flags_lib", ], - resource_dirs: [], + plugins: ["androidx.room_room-compiler-plugin"], + use_resource_processor: true, + resource_dirs: ["res"], + + srcs: [ + "src/**/*.java", + "src/**/*.kt", + ], } // NOTE: Keep this module in sync with ./common.mk java_defaults { name: "SettingsLibDefaults", static_libs: [ - "androidx.annotation_annotation", - "androidx.appcompat_appcompat", - "androidx.coordinatorlayout_coordinatorlayout", - "androidx.core_core", - "androidx.fragment_fragment", - "androidx.lifecycle_lifecycle-runtime", - "androidx.loader_loader", - "androidx.localbroadcastmanager_localbroadcastmanager", - "androidx.preference_preference", - "androidx.recyclerview_recyclerview", "SettingsLib", ], } diff --git a/packages/SettingsLib/AndroidManifest-SettingsLibWidget.xml b/packages/SettingsLib/AndroidManifest-SettingsLibWidget.xml deleted file mode 100644 index 38a7d6ace1f8..000000000000 --- a/packages/SettingsLib/AndroidManifest-SettingsLibWidget.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2023 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. ---> - -<manifest package="com.android.settingslib.widget" /> diff --git a/packages/SettingsLib/MainSwitchPreference/Android.bp b/packages/SettingsLib/MainSwitchPreference/Android.bp index 33aa985b32e8..4871ef3097a5 100644 --- a/packages/SettingsLib/MainSwitchPreference/Android.bp +++ b/packages/SettingsLib/MainSwitchPreference/Android.bp @@ -9,6 +9,7 @@ package { android_library { name: "SettingsLibMainSwitchPreference", + use_resource_processor: true, srcs: ["src/**/*.java"], resource_dirs: ["res"], diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java index 56b3eacf6c1f..600115545a16 100644 --- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java +++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java @@ -31,12 +31,11 @@ import android.widget.TextView; import androidx.annotation.ColorInt; import com.android.settingslib.utils.BuildCompatUtils; +import com.android.settingslib.widget.mainswitch.R; import java.util.ArrayList; import java.util.List; -import com.android.settingslib.widget.mainswitch.R; - /** * MainSwitchBar is a View with a customized Switch. * This component is used as the main switch of the page @@ -77,7 +76,7 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec final TypedArray a = context.obtainStyledAttributes( new int[]{android.R.attr.colorAccent}); mBackgroundActivatedColor = a.getColor(0, 0); - mBackgroundColor = context.getColor(R.color.material_grey_600); + mBackgroundColor = context.getColor(androidx.appcompat.R.color.material_grey_600); a.recycle(); } diff --git a/packages/SettingsLib/common.mk b/packages/SettingsLib/common.mk index d9596569a0da..431fd44cd952 100644 --- a/packages/SettingsLib/common.mk +++ b/packages/SettingsLib/common.mk @@ -18,18 +18,5 @@ # to the corresponding module. # NOTE: keep this file and ./Android.bp in sync. -LOCAL_STATIC_JAVA_LIBRARIES += \ - androidx.annotation_annotation - LOCAL_STATIC_ANDROID_LIBRARIES += \ - androidx.appcompat_appcompat \ - androidx.coordinatorlayout_coordinatorlayout \ - androidx.core_core \ - androidx.fragment_fragment \ - androidx.lifecycle_lifecycle-runtime \ - androidx.loader_loader \ - androidx.localbroadcastmanager_localbroadcastmanager \ - androidx.preference_preference \ - androidx.recyclerview_recyclerview \ SettingsLib - diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayoutTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayoutTest.java index 2b1e8080d389..507dcbc1d8a2 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayoutTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayoutTest.java @@ -55,8 +55,7 @@ public class CollapsingCoordinatorLayoutTest { @Test public void onCreate_userAddedChildViewsBeMovedToContentFrame() { CollapsingCoordinatorLayout layout = mActivity.getCollapsingCoordinatorLayout(); - View contentFrameView = - layout.findViewById(com.android.settingslib.widget.R.id.content_frame); + View contentFrameView = layout.findViewById(R.id.content_frame); TextView textView = contentFrameView.findViewById(com.android.settingslib.robotests.R.id.text_hello_world); diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/AdaptiveIconTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/AdaptiveIconTest.java index 6195d754f8f0..71545b75989a 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/AdaptiveIconTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/AdaptiveIconTest.java @@ -36,10 +36,10 @@ import android.graphics.drawable.Icon; import android.graphics.drawable.ShapeDrawable; import android.os.Bundle; -import com.android.settingslib.widget.adaptiveicon.R; import com.android.settingslib.drawer.ActivityTile; import com.android.settingslib.drawer.CategoryKey; import com.android.settingslib.drawer.Tile; +import com.android.settingslib.widget.adaptiveicon.R; import org.junit.Before; import org.junit.Test; @@ -105,15 +105,15 @@ public class AdaptiveIconTest { icon.setBackgroundColor(mContext, tile); - assertThat(icon.mBackgroundColor).isEqualTo(mContext.getColor( - com.android.settingslib.widget.R.color.homepage_generic_icon_background)); + assertThat(icon.mBackgroundColor).isEqualTo( + mContext.getColor(R.color.homepage_generic_icon_background)); } @Test public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() { final Tile tile = spy(new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT, - com.android.settingslib.widget.R.color.bt_outline_color); + R.color.bt_outline_color); doReturn(Icon.createWithResource(mContext, com.android.settingslib.R.drawable.ic_system_update)) .when(tile).getIcon(mContext); @@ -121,8 +121,7 @@ public class AdaptiveIconTest { new AdaptiveIcon(mContext, new ColorDrawable(Color.BLACK)); icon.setBackgroundColor(mContext, tile); - assertThat(icon.mBackgroundColor).isEqualTo(mContext.getColor( - com.android.settingslib.widget.R.color.bt_outline_color)); + assertThat(icon.mBackgroundColor).isEqualTo(mContext.getColor(R.color.bt_outline_color)); } @Test diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java index ccbe4f03e80c..0ce83c6220ff 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java @@ -58,16 +58,14 @@ public class FooterPreferenceTest { @Test public void setLearnMoreText_shouldSetAsTextInLearnMore() { final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( - LayoutInflater.from(mContext) - .inflate(com.android.settingslib.widget.R.layout.preference_footer, null)); + LayoutInflater.from(mContext).inflate(R.layout.preference_footer, null)); mFooterPreference.setLearnMoreText("Custom learn more"); mFooterPreference.setLearnMoreAction(view -> { /* do nothing */ } /* listener */); mFooterPreference.onBindViewHolder(holder); - assertThat(((TextView) holder.findViewById( - com.android.settingslib.widget.R.id.settingslib_learn_more)).getText().toString()) - .isEqualTo("Custom learn more"); + TextView learnMoreView = (TextView) holder.findViewById(R.id.settingslib_learn_more); + assertThat(learnMoreView.getText().toString()).isEqualTo("Custom learn more"); } @Test @@ -95,8 +93,7 @@ public class FooterPreferenceTest { @Test public void onBindViewHolder_whenTitleIsNull_shouldNotRaiseNpe() { PreferenceViewHolder viewHolder = spy(PreferenceViewHolder.createInstanceForTests( - LayoutInflater.from(mContext) - .inflate(R.layout.preference_footer, null))); + LayoutInflater.from(mContext).inflate(R.layout.preference_footer, null))); when(viewHolder.findViewById(androidx.core.R.id.title)).thenReturn(null); Throwable actualThrowable = null; @@ -112,10 +109,8 @@ public class FooterPreferenceTest { @Test public void onBindViewHolder_whenLearnMoreIsNull_shouldNotRaiseNpe() { PreferenceViewHolder viewHolder = spy(PreferenceViewHolder.createInstanceForTests( - LayoutInflater.from(mContext) - .inflate(com.android.settingslib.widget.R.layout.preference_footer, null))); - when(viewHolder.findViewById(com.android.settingslib.widget.R.id.settingslib_learn_more)) - .thenReturn(null); + LayoutInflater.from(mContext).inflate(R.layout.preference_footer, null))); + when(viewHolder.findViewById(R.id.settingslib_learn_more)).thenReturn(null); Throwable actualThrowable = null; try { @@ -130,8 +125,7 @@ public class FooterPreferenceTest { @Test public void onBindViewHolder_whenIconFrameIsNull_shouldNotRaiseNpe() { PreferenceViewHolder viewHolder = spy(PreferenceViewHolder.createInstanceForTests( - LayoutInflater.from(mContext) - .inflate(com.android.settingslib.widget.R.layout.preference_footer, null))); + LayoutInflater.from(mContext).inflate(R.layout.preference_footer, null))); when(viewHolder.findViewById(R.id.icon_frame)).thenReturn(null); Throwable actualThrowable = null; |