mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-05-13 00:10:05 -05:00
checker ui upd
This commit is contained in:
+1
-1
Submodule MediaServiceCore updated: 91f79f1210...c95f7e3826
+1
-1
Submodule SharedModules updated: f3d5bd858a...e70e03b94d
+21
-6
@@ -20,17 +20,23 @@ public class VideoSettingsPresenter implements Presenter<VideoSettingsView> {
|
||||
|
||||
public static class SettingsCategory {
|
||||
public static SettingsCategory radioList(String title, List<OptionItem> items) {
|
||||
return new SettingsCategory(title, items, TYPE_RADIO);
|
||||
return new SettingsCategory(title, items, TYPE_RADIO_LIST);
|
||||
}
|
||||
|
||||
public static SettingsCategory checkedList(String title, List<OptionItem> items) {
|
||||
return new SettingsCategory(title, items, TYPE_CHECKBOX);
|
||||
return new SettingsCategory(title, items, TYPE_CHECKBOX_LIST);
|
||||
}
|
||||
|
||||
public static SettingsCategory singleSwitch(OptionItem item) {
|
||||
ArrayList<OptionItem> items = new ArrayList<>();
|
||||
items.add(item);
|
||||
return new SettingsCategory(null, items, TYPE_SWITCH);
|
||||
return new SettingsCategory(null, items, TYPE_SINGLE_SWITCH);
|
||||
}
|
||||
|
||||
public static SettingsCategory singleButton(OptionItem item) {
|
||||
ArrayList<OptionItem> items = new ArrayList<>();
|
||||
items.add(item);
|
||||
return new SettingsCategory(null, items, TYPE_SINGLE_BUTTON);
|
||||
}
|
||||
|
||||
private SettingsCategory(String title, List<OptionItem> items, int type) {
|
||||
@@ -39,9 +45,10 @@ public class VideoSettingsPresenter implements Presenter<VideoSettingsView> {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public static final int TYPE_RADIO = 0;
|
||||
public static final int TYPE_CHECKBOX = 1;
|
||||
public static final int TYPE_SWITCH = 2;
|
||||
public static final int TYPE_RADIO_LIST = 0;
|
||||
public static final int TYPE_CHECKBOX_LIST = 1;
|
||||
public static final int TYPE_SINGLE_SWITCH = 2;
|
||||
public static final int TYPE_SINGLE_BUTTON = 3;
|
||||
public int type;
|
||||
public String title;
|
||||
public List<OptionItem> items;
|
||||
@@ -87,6 +94,10 @@ public class VideoSettingsPresenter implements Presenter<VideoSettingsView> {
|
||||
mView.addCategories(mCategories);
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
showDialog(null);
|
||||
}
|
||||
|
||||
public void showDialog(Runnable onClose) {
|
||||
mOnClose = onClose;
|
||||
ViewManager.instance(mContext).startView(VideoSettingsView.class);
|
||||
@@ -103,4 +114,8 @@ public class VideoSettingsPresenter implements Presenter<VideoSettingsView> {
|
||||
public void appendSingleSwitch(OptionItem optionItem) {
|
||||
mCategories.add(SettingsCategory.singleSwitch(optionItem));
|
||||
}
|
||||
|
||||
public void appendButton(OptionItem optionItem) {
|
||||
mCategories.add(SettingsCategory.singleButton(optionItem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
android:icon="@mipmap/app_icon"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Leanback"
|
||||
tools:node="merge"
|
||||
tools:replace="android:theme,android:allowBackup"
|
||||
tools:ignore="GoogleAppIndexingWarning,LockedOrientationActivity,UnusedAttribute">
|
||||
|
||||
|
||||
+32
-4
@@ -144,15 +144,43 @@ public class VideoSettingsFragment extends LeanbackSettingsFragment
|
||||
}
|
||||
|
||||
public Preference createPreference(SettingsCategory category) {
|
||||
if (category.type == SettingsCategory.TYPE_CHECKBOX) {
|
||||
return createCheckedListPreference(category);
|
||||
} else if (category.type == SettingsCategory.TYPE_SWITCH) {
|
||||
return createSwitchListPreference(category);
|
||||
//if (category.type == SettingsCategory.TYPE_CHECKBOX) {
|
||||
// return createCheckedListPreference(category);
|
||||
//} else if (category.type == SettingsCategory.TYPE_SWITCH) {
|
||||
// return createSwitchListPreference(category);
|
||||
//}
|
||||
|
||||
switch (category.type) {
|
||||
case SettingsCategory.TYPE_CHECKBOX_LIST:
|
||||
return createCheckedListPreference(category);
|
||||
case SettingsCategory.TYPE_SINGLE_SWITCH:
|
||||
return createSwitchListPreference(category);
|
||||
case SettingsCategory.TYPE_SINGLE_BUTTON:
|
||||
return createButtonListPreference(category);
|
||||
}
|
||||
|
||||
return createRadioListPreference(category);
|
||||
}
|
||||
|
||||
private Preference createButtonListPreference(SettingsCategory category) {
|
||||
Preference result = null;
|
||||
|
||||
if (category.items.size() == 1) {
|
||||
OptionItem item = category.items.get(0);
|
||||
Preference preference = new Preference(mStyledContext);
|
||||
preference.setPersistent(false);
|
||||
preference.setTitle(item.getTitle());
|
||||
preference.setOnPreferenceClickListener(pref -> {
|
||||
item.onSelect(true);
|
||||
return true;
|
||||
});
|
||||
|
||||
result = preference;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Preference createSwitchListPreference(SettingsCategory category) {
|
||||
Preference result = null;
|
||||
|
||||
|
||||
+3
-1
@@ -51,7 +51,9 @@ public class AppUpdateManager implements AppUpdateCheckerListener {
|
||||
|
||||
private void showUpdateDialog(List<String> changelog, String apkPath) {
|
||||
mSettingsPresenter.appendChecked("Changelog", createChangelogOptions(changelog));
|
||||
mSettingsPresenter.showDialog(null);
|
||||
mSettingsPresenter.appendButton(
|
||||
UiOptionItem.from("Install update", optionItem -> mUpdateChecker.installUpdate(), false));
|
||||
mSettingsPresenter.showDialog();
|
||||
}
|
||||
|
||||
private List<OptionItem> createChangelogOptions(List<String> changelog) {
|
||||
|
||||
Reference in New Issue
Block a user