Update dark theme to have new screen

The dark theme preference should have it's own screen rather than
being a dialog. This adds some boilerplate code that will be
needed for the illustration as well as converting the current
list preference to open a new screen.

Test: robotests
Bug: 128686189
Change-Id: I5b62276353c0d39ad2ad00d21d2280e76cceb09b
This commit is contained in:
Salvador Martinez
2019-03-20 10:52:52 -07:00
parent 12256ca49f
commit 1053ec04b4
10 changed files with 433 additions and 162 deletions

View File

@@ -58,6 +58,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
protected UserManager mUserManager;
protected int mUserId;
private int mIllustrationId;
private int mIllustrationPreviewId;
private VideoPreference mVideoPreference;
@Override
public void onAttach(Context context) {
@@ -164,6 +167,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
if (mIllustrationId != 0) {
addIllustration(screen);
}
if (!mAppendStaticPreferences) {
addStaticPreferences(screen);
}
@@ -241,6 +247,23 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
}
}
/**
* Allows you to set an illustration at the top of this screen. Set the illustration id to 0
* if you want to remove the illustration.
* @param illustrationId The res id for the raw of the illustration.
* @param previewId The res id for the drawable of the illustration
*/
protected void setIllustration(int illustrationId, int previewId) {
mIllustrationId = illustrationId;
mIllustrationPreviewId = previewId;
}
private void addIllustration(PreferenceScreen screen) {
mVideoPreference = new VideoPreference(getContext());
mVideoPreference.setVideo(mIllustrationId, mIllustrationPreviewId);
screen.addPreference(mVideoPreference);
}
protected abstract List<? extends CandidateInfo> getCandidates();
protected abstract String getDefaultKey();