Extract footer preference as a widget lib
Currently, developer needs to import SettingsLib to use
footer preference. But the size of SettingsLib is too huge.
We extract the footer preference as a lib so that developer
only needs to import a small lib for using footer.
Test: Rebuilt apk, and see the footer preference
Fix: 173088235
Change-Id: I35ba99a49c7a13542d79f0340eecdbe9844102d0
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp
index e6492aa..23cb36f 100644
--- a/packages/SettingsLib/Android.bp
+++ b/packages/SettingsLib/Android.bp
@@ -54,6 +54,7 @@
"SettingsLibEmergencyNumber",
"SettingsLibTopIntroPreference",
"SettingsLibBannerMessagePreference",
+ "SettingsLibFooterPreference",
],
}
diff --git a/packages/SettingsLib/FooterPreference/Android.bp b/packages/SettingsLib/FooterPreference/Android.bp
new file mode 100644
index 0000000..30d9bd2
--- /dev/null
+++ b/packages/SettingsLib/FooterPreference/Android.bp
@@ -0,0 +1,13 @@
+android_library {
+ name: "SettingsLibFooterPreference",
+
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+
+ static_libs: [
+ "androidx.annotation_annotation",
+ "androidx.preference_preference",
+ ],
+ sdk_version: "system_current",
+ min_sdk_version: "21",
+}
diff --git a/packages/SettingsLib/FooterPreference/AndroidManifest.xml b/packages/SettingsLib/FooterPreference/AndroidManifest.xml
new file mode 100644
index 0000000..96d9e51
--- /dev/null
+++ b/packages/SettingsLib/FooterPreference/AndroidManifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.settingslib.widget">
+
+ <uses-sdk android:minSdkVersion="21" />
+
+</manifest>
diff --git a/packages/SettingsLib/res/drawable/ic_info_outline_24.xml b/packages/SettingsLib/FooterPreference/res/drawable/ic_info_outline_24.xml
similarity index 95%
rename from packages/SettingsLib/res/drawable/ic_info_outline_24.xml
rename to packages/SettingsLib/FooterPreference/res/drawable/ic_info_outline_24.xml
index 317e43b..d9afeb0 100644
--- a/packages/SettingsLib/res/drawable/ic_info_outline_24.xml
+++ b/packages/SettingsLib/FooterPreference/res/drawable/ic_info_outline_24.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2019 The Android Open Source Project
+ Copyright (C) 2020 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.
diff --git a/packages/SettingsLib/FooterPreference/res/values/attrs.xml b/packages/SettingsLib/FooterPreference/res/values/attrs.xml
new file mode 100644
index 0000000..deba3af
--- /dev/null
+++ b/packages/SettingsLib/FooterPreference/res/values/attrs.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+
+<resources>
+ <attr name="footerPreferenceStyle" format="reference" />
+</resources>
\ No newline at end of file
diff --git a/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java b/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
similarity index 96%
rename from packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java
rename to packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
index 1557618..15301f6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java
+++ b/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -16,7 +16,6 @@
package com.android.settingslib.widget;
-import android.annotation.StringRes;
import android.content.Context;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
@@ -24,20 +23,19 @@
import android.widget.TextView;
import androidx.annotation.NonNull;
+import androidx.annotation.StringRes;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
-import com.android.settingslib.R;
-
/**
* A custom preference acting as "footer" of a page. It has a field for icon and text. It is added
* to screen as the last preference.
*/
public class FooterPreference extends Preference {
- static final int ORDER_FOOTER = Integer.MAX_VALUE - 1;
public static final String KEY_FOOTER = "footer_preference";
+ static final int ORDER_FOOTER = Integer.MAX_VALUE - 1;
public FooterPreference(Context context, AttributeSet attrs) {
super(context, attrs, TypedArrayUtils.getAttr(
diff --git a/packages/SettingsLib/res/values/attrs.xml b/packages/SettingsLib/res/values/attrs.xml
index 9aed54e..1e6cb33 100644
--- a/packages/SettingsLib/res/values/attrs.xml
+++ b/packages/SettingsLib/res/values/attrs.xml
@@ -46,8 +46,6 @@
<attr name="wifi_signal" format="reference" />
<attr name="wifi_friction" format="reference" />
- <attr name="footerPreferenceStyle" format="reference" />
-
<!-- Workaround for b/74248169. These are duplicates of attrs in AndroidX preferences. -->
<attr name="preferenceStyle" format="reference" />
<attr name="switchPreferenceStyle" format="reference" />