Finish use_resource_processor for SettingsLib
Temp module SettingsLibWidget is removed.
Bug: 293810334
Test: m Settings
Change-Id: If0b857ec5e5492572fb0e9d192ee2bac7e89c939
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp
index ae87f38..8964ada 100644
--- a/packages/SettingsLib/Android.bp
+++ b/packages/SettingsLib/Android.bp
@@ -11,29 +11,42 @@
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",
+ "iconloader",
+ "setupdesign",
+
+ "SettingsLibActionBarShadow",
+ "SettingsLibActionButtonsPreference",
+ "SettingsLibAdaptiveIcon",
+ "SettingsLibAppPreference",
+ "SettingsLibBannerMessagePreference",
+ "SettingsLibBarChartPreference",
+ "SettingsLibButtonPreference",
+ "SettingsLibCollapsingToolbarBaseActivity",
"SettingsLibDeviceStateRotationLock",
"SettingsLibDisplayUtils",
"SettingsLibEmergencyNumber",
+ "SettingsLibEntityHeaderWidgets",
+ "SettingsLibFooterPreference",
+ "SettingsLibHelpUtils",
+ "SettingsLibIllustrationPreference",
+ "SettingsLibLayoutPreference",
+ "SettingsLibMainSwitchPreference",
+ "SettingsLibProfileSelector",
+ "SettingsLibProgressBar",
+ "SettingsLibRestrictedLockUtils",
"SettingsLibSearchWidget",
+ "SettingsLibSelectorWithWidgetPreference",
+ "SettingsLibSettingsSpinner",
+ "SettingsLibSettingsTransition",
+ "SettingsLibTopIntroPreference",
+ "SettingsLibTwoTargetPreference",
+ "SettingsLibUsageProgressBarPreference",
"SettingsLibUtils",
- "SettingsLibWidget",
- "setupdesign",
- "zxing-core",
- "androidx.room_room-runtime",
"settingslib_flags_lib",
],
@@ -47,56 +60,10 @@
],
}
-// 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",
- "SettingsLibAppPreference",
- "SettingsLibBannerMessagePreference",
- "SettingsLibBarChartPreference",
- "SettingsLibButtonPreference",
- "SettingsLibCollapsingToolbarBaseActivity",
- "SettingsLibEntityHeaderWidgets",
- "SettingsLibFooterPreference",
- "SettingsLibHelpUtils",
- "SettingsLibIllustrationPreference",
- "SettingsLibLayoutPreference",
- "SettingsLibMainSwitchPreference",
- "SettingsLibProfileSelector",
- "SettingsLibProgressBar",
- "SettingsLibRestrictedLockUtils",
- "SettingsLibSelectorWithWidgetPreference",
- "SettingsLibSettingsSpinner",
- "SettingsLibSettingsTransition",
- "SettingsLibTopIntroPreference",
- "SettingsLibTwoTargetPreference",
- "SettingsLibUsageProgressBarPreference",
- ],
-
- resource_dirs: [],
-}
-
// 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 38a7d6a..0000000
--- 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 33aa985..4871ef3 100644
--- a/packages/SettingsLib/MainSwitchPreference/Android.bp
+++ b/packages/SettingsLib/MainSwitchPreference/Android.bp
@@ -9,6 +9,7 @@
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 56b3eac..6001155 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 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 @@
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 d959656..431fd44 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 2b1e808..507dcbc 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 @@
@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 6195d75..71545b7 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.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 @@
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 @@
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 ccbe4f0..0ce83c6 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 @@
@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 @@
@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 @@
@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 @@
@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;