Add a preview image to the color mode preference.

For high-color displays, it's desirable to have a preview of the
impact the user's color preference will have on images.  This commit
adds that functionality to ColorModePreferenceFragment by extending
RadioButtonPickerFragment to support static content.

The image used here is a placeholder pending UX.

Bug: 73670362
Test: Added a test verifying that the preview is added correctly.
Change-Id: Id54316bbef6a22291a8e8acbda5fcb2839b88c23
This commit is contained in:
Sean Callanan
2018-02-20 18:57:29 -08:00
parent 45520fce49
commit 2dd4377423
5 changed files with 74 additions and 0 deletions

View File

@@ -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();