mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-01-16 16:52:34 +01:00
refine extension preferences API
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package androidx.preference;
|
||||
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class CheckBoxPreference extends Preference {
|
||||
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/CheckBoxPreference.java
|
||||
|
||||
public CheckBoxPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,18 @@
|
||||
package androidx.preference;
|
||||
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class EditTextPreference extends Preference {
|
||||
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/EditTextPreference.java
|
||||
|
||||
private String title;
|
||||
private String text;
|
||||
private CharSequence summary;
|
||||
private CharSequence dialogTitle;
|
||||
private CharSequence dialogMessage;
|
||||
|
||||
@@ -15,22 +20,6 @@ public class EditTextPreference extends Preference {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence title) {
|
||||
this.title = (String) title;
|
||||
}
|
||||
|
||||
public CharSequence getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public void setSummary(CharSequence summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public CharSequence getDialogTitle() {
|
||||
return dialogTitle;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class Preference {
|
||||
|
||||
private String key;
|
||||
private CharSequence title;
|
||||
private CharSequence summary;
|
||||
private Object defaultValue;
|
||||
|
||||
@JsonIgnore
|
||||
@@ -41,14 +42,26 @@ public class Preference {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setDefaultValue(Object defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public CharSequence getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public CharSequence getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public void setSummary(CharSequence summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public void setDefaultValue(Object defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public void setOnPreferenceChangeListener(OnPreferenceChangeListener onPreferenceChangeListener) {
|
||||
this.onChangeListener = onPreferenceChangeListener;
|
||||
}
|
||||
@@ -61,6 +74,10 @@ public class Preference {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public String getDefaultValueType() {
|
||||
return defaultValue.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public interface OnPreferenceChangeListener {
|
||||
boolean onPreferenceChange(Preference preference, Object newValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user