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
This commit is contained in:
Tsung-Mao Fang
2020-12-03 17:56:37 +08:00
parent a09105eef7
commit b29d495fd4
7 changed files with 60 additions and 8 deletions

View File

@@ -54,6 +54,7 @@ java_defaults {
"SettingsLibEmergencyNumber",
"SettingsLibTopIntroPreference",
"SettingsLibBannerMessagePreference",
"SettingsLibFooterPreference",
],
}

View File

@@ -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",
}

View File

@@ -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>

View File

@@ -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.

View File

@@ -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>

View File

@@ -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.util.AttributeSet;
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(

View File

@@ -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" />