Build a new FooterPreference UI.
- Create a new layout for footer prefs. - Create a new FooterPreference type to use the layout - Create a Mixin to create and add the pref to screen - Create a new lifecycle observer type to invoke mixin at right time - Switch SettingsPreferenceFragment to use footer mixin. - Switch FingerprintSettings to use the new footer pref. Bug: 33579394 Test: RunSettingsRoboTests Change-Id: I548ac39a0d120196a7ffed09b4f98bd9a80bae90
This commit is contained in:
@@ -48,6 +48,7 @@ import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.instrumentation.Instrumentable;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.widget.FooterPreferenceMixin;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -70,6 +71,9 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
|
||||
private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
|
||||
|
||||
protected final FooterPreferenceMixin mFooterPreferenceMixin =
|
||||
new FooterPreferenceMixin(this, getLifecycle());
|
||||
|
||||
private SettingsDialogFragment mDialogFragment;
|
||||
|
||||
private String mHelpUri;
|
||||
@@ -123,7 +127,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
|
||||
private LayoutPreference mHeader;
|
||||
|
||||
private LayoutPreference mFooter;
|
||||
private View mEmptyView;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private HighlightablePreferenceGroupAdapter mAdapter;
|
||||
@@ -277,10 +280,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
return mHeader;
|
||||
}
|
||||
|
||||
public LayoutPreference getFooterView() {
|
||||
return mFooter;
|
||||
}
|
||||
|
||||
protected void setHeaderView(int resource) {
|
||||
mHeader = new LayoutPreference(getPrefContext(), resource);
|
||||
addPreferenceToTop(mHeader);
|
||||
@@ -298,29 +297,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
}
|
||||
}
|
||||
|
||||
protected void setFooterView(int resource) {
|
||||
setFooterView(resource != 0 ? new LayoutPreference(getPrefContext(), resource) : null);
|
||||
}
|
||||
|
||||
protected void setFooterView(View v) {
|
||||
setFooterView(v != null ? new LayoutPreference(getPrefContext(), v) : null);
|
||||
}
|
||||
|
||||
private void setFooterView(LayoutPreference footer) {
|
||||
if (getPreferenceScreen() != null && mFooter != null) {
|
||||
getPreferenceScreen().removePreference(mFooter);
|
||||
}
|
||||
if (footer != null) {
|
||||
mFooter = footer;
|
||||
mFooter.setOrder(ORDER_LAST);
|
||||
if (getPreferenceScreen() != null) {
|
||||
getPreferenceScreen().addPreference(mFooter);
|
||||
}
|
||||
} else {
|
||||
mFooter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPreferenceScreen(PreferenceScreen preferenceScreen) {
|
||||
if (preferenceScreen != null && !preferenceScreen.isAttached()) {
|
||||
@@ -332,9 +308,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
if (mHeader != null) {
|
||||
preferenceScreen.addPreference(mHeader);
|
||||
}
|
||||
if (mFooter != null) {
|
||||
preferenceScreen.addPreference(mFooter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +316,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
if (getPreferenceScreen() != null) {
|
||||
boolean show = (getPreferenceScreen().getPreferenceCount()
|
||||
- (mHeader != null ? 1 : 0)
|
||||
- (mFooter != null ? 1 : 0)) <= 0;
|
||||
- (mFooterPreferenceMixin.hasFooter() ? 1 : 0)) <= 0;
|
||||
mEmptyView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
} else {
|
||||
mEmptyView.setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user