Merge "Add a preview image to the color mode preference."
This commit is contained in:
committed by
Android (Google) Code Review
commit
1619695402
@@ -16,10 +16,12 @@ package com.android.settings.display;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
@@ -50,6 +52,19 @@ public class ColorModePreferenceFragment extends RadioButtonPickerFragment {
|
||||
return R.xml.color_mode_settings;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void configureAndInstallPreview(LayoutPreference preview, PreferenceScreen screen) {
|
||||
preview.setSelectable(false);
|
||||
screen.addPreference(preview);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addStaticPreferences(PreferenceScreen screen) {
|
||||
final LayoutPreference preview = new LayoutPreference(screen.getContext(),
|
||||
R.layout.color_mode_preview);
|
||||
configureAndInstallPreview(preview, screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends CandidateInfo> getCandidates() {
|
||||
Context c = getContext();
|
||||
|
@@ -101,6 +101,13 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate any static preferences, independent of the radio buttons.
|
||||
* These might be used to provide extra information about the choices.
|
||||
**/
|
||||
protected void addStaticPreferences(PreferenceScreen screen) {
|
||||
}
|
||||
|
||||
protected CandidateInfo getCandidate(String key) {
|
||||
return mCandidates.get(key);
|
||||
}
|
||||
@@ -134,6 +141,7 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
final String systemDefaultKey = getSystemDefaultKey();
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
screen.removeAll();
|
||||
addStaticPreferences(screen);
|
||||
|
||||
final int customLayoutResId = getRadioButtonPreferenceCustomLayoutResId();
|
||||
if (shouldShowItemNone()) {
|
||||
|
Reference in New Issue
Block a user