sync androidx.preference method signatures with extensions-lib

This commit is contained in:
Aria Moradi
2021-07-31 08:28:45 +04:30
parent 345ca27f85
commit 30787846a2
9 changed files with 148 additions and 37 deletions

View File

@@ -9,7 +9,7 @@ package androidx.preference;
import android.content.Context;
public class CheckBoxPreference extends Preference {
public class CheckBoxPreference extends TwoStatePreference {
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/CheckBoxPreference.java
public CheckBoxPreference(Context context) {

View File

@@ -0,0 +1,34 @@
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 abstract class DialogPreference extends Preference {
private CharSequence dialogTitle;
private CharSequence dialogMessage;
public DialogPreference(Context context) { super(context); }
public CharSequence getDialogTitle() {
return dialogTitle;
}
public void setDialogTitle(CharSequence dialogTitle) {
this.dialogTitle = dialogTitle;
}
public CharSequence getDialogMessage() {
return dialogMessage;
}
public void setDialogMessage(CharSequence dialogMessage) {
this.dialogMessage = dialogMessage;
}
}

View File

@@ -13,12 +13,10 @@ import android.content.Context;
import android.widget.EditText;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class EditTextPreference extends Preference {
public class EditTextPreference extends DialogPreference {
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/EditTextPreference.java
private String text;
private CharSequence dialogTitle;
private CharSequence dialogMessage;
@JsonIgnore
private OnBindEditTextListener onBindEditTextListener;
@@ -27,22 +25,6 @@ public class EditTextPreference extends Preference {
super(context);
}
public CharSequence getDialogTitle() {
return dialogTitle;
}
public void setDialogTitle(CharSequence dialogTitle) {
this.dialogTitle = dialogTitle;
}
public CharSequence getDialogMessage() {
return dialogMessage;
}
public void setDialogMessage(CharSequence dialogMessage) {
this.dialogMessage = dialogMessage;
}
public String getText() {
return text;
}

View File

@@ -8,7 +8,6 @@ package androidx.preference;
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import android.content.Context;
import androidx.annotation.ArrayRes;
public class ListPreference extends Preference {
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/ListPreference.java
@@ -28,9 +27,7 @@ public class ListPreference extends Preference {
this.entries = entries;
}
public void setEntries(@ArrayRes int entriesResId) {
throw new RuntimeException("Stub!");
}
public int findIndexOfValue(String value) { throw new RuntimeException("Stub!"); }
public CharSequence[] getEntryValues() {
return entryValues;
@@ -40,7 +37,9 @@ public class ListPreference extends Preference {
this.entryValues = entryValues;
}
public void setEntryValues(@ArrayRes int entryValuesResId) {
throw new RuntimeException("Stub!");
}
public void setValueIndex(int index) { throw new RuntimeException("Stub!"); }
public String getValue() { throw new RuntimeException("Stub!"); }
public void setValue(String value) { throw new RuntimeException("Stub!"); }
}

View File

@@ -0,0 +1,32 @@
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;
import java.util.Set;
public class MultiSelectListPreference extends DialogPreference {
public MultiSelectListPreference(Context context) { super(context); }
public void setEntries(CharSequence[] entries) { throw new RuntimeException("Stub!"); }
public CharSequence[] getEntries() { throw new RuntimeException("Stub!"); }
public void setEntryValues(CharSequence[] entryValues) { throw new RuntimeException("Stub!"); }
public CharSequence[] getEntryValues() { throw new RuntimeException("Stub!"); }
public void setValues(Set<String> values) { throw new RuntimeException("Stub!"); }
public Set<String> getValues() { throw new RuntimeException("Stub!"); }
public int findIndexOfValue(String value) { throw new RuntimeException("Stub!"); }
}

View File

@@ -10,7 +10,9 @@ package androidx.preference;
import android.content.Context;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** A minimal implementation of androidx.preference.Preference */
/**
* A minimal implementation of androidx.preference.Preference
*/
public class Preference {
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/Preference.java
// Note: `Preference` doesn't actually hold or persist the value, `OnPreferenceChangeListener` is called and it's up to the extension to persist it.
@@ -34,12 +36,12 @@ public class Preference {
return context;
}
public String getKey() {
return key;
public void setOnPreferenceChangeListener(OnPreferenceChangeListener onPreferenceChangeListener) {
this.onChangeListener = onPreferenceChangeListener;
}
public void setKey(String key) {
this.key = key;
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener) {
throw new RuntimeException("Stub!");
}
public CharSequence getTitle() {
@@ -58,12 +60,20 @@ public class Preference {
this.summary = summary;
}
public void setDefaultValue(Object defaultValue) {
this.defaultValue = defaultValue;
public void setEnabled(boolean enabled) {
throw new RuntimeException("Stub!");
}
public void setOnPreferenceChangeListener(OnPreferenceChangeListener onPreferenceChangeListener) {
this.onChangeListener = onPreferenceChangeListener;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public void setDefaultValue(Object defaultValue) {
this.defaultValue = defaultValue;
}
public boolean callChangeListener(Object newValue) {
@@ -82,4 +92,7 @@ public class Preference {
boolean onPreferenceChange(Preference preference, Object newValue);
}
public interface OnPreferenceClickListener {
boolean onPreferenceClick(Preference preference);
}
}

View File

@@ -13,9 +13,9 @@ import java.util.LinkedList;
import java.util.List;
public class PreferenceScreen extends Preference {
// Tachidesk API
private List<Preference> preferences = new LinkedList<>();
public PreferenceScreen(Context context) {
super(context);
}
@@ -26,6 +26,7 @@ public class PreferenceScreen extends Preference {
return true;
}
// Tachidesk API
public List<Preference> getPreferences(){
return preferences;
}

View File

@@ -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 SwitchPreferenceCompat extends Preference {
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/CheckBoxPreference.java
public SwitchPreferenceCompat(Context context) {
super(context);
}
}

View File

@@ -0,0 +1,32 @@
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 TwoStatePreference extends Preference {
public TwoStatePreference(Context context) { super(context); }
public boolean isChecked() { throw new RuntimeException("Stub!"); }
public void setChecked(boolean checked) { throw new RuntimeException("Stub!"); }
public CharSequence getSummaryOn() { throw new RuntimeException("Stub!"); }
public void setSummaryOn(CharSequence summary) { throw new RuntimeException("Stub!"); }
public CharSequence getSummaryOff() { throw new RuntimeException("Stub!"); }
public void setSummaryOff(CharSequence summary) { throw new RuntimeException("Stub!"); }
public boolean getDisableDependentsState() { throw new RuntimeException("Stub!"); }
public void setDisableDependentsState(boolean disableDependentsState) { throw new RuntimeException("Stub!"); }
}