Set summary automatically if required
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
package lineageos.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
public class LineageSecureSettingListPreference extends SelfRemovingListPreference {
|
||||
|
||||
private boolean mAutoSummary = false;
|
||||
|
||||
public LineageSecureSettingListPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
@@ -20,6 +23,24 @@ public class LineageSecureSettingListPreference extends SelfRemovingListPreferen
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
super.setValue(value);
|
||||
if (mAutoSummary || TextUtils.isEmpty(getSummary())) {
|
||||
setSummary(getEntry(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSummary(CharSequence summary) {
|
||||
setSummary(summary, false);
|
||||
}
|
||||
|
||||
private void setSummary(CharSequence summary, boolean autoSummary) {
|
||||
mAutoSummary = autoSummary;
|
||||
super.setSummary(summary);
|
||||
}
|
||||
|
||||
public int getIntValue(int defValue) {
|
||||
return getValue() == null ? defValue : Integer.valueOf(getValue());
|
||||
}
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
package lineageos.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
public class LineageSystemSettingListPreference extends SelfRemovingListPreference {
|
||||
|
||||
private boolean mAutoSummary = false;
|
||||
|
||||
public LineageSystemSettingListPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
@@ -19,6 +23,24 @@ public class LineageSystemSettingListPreference extends SelfRemovingListPreferen
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
super.setValue(value);
|
||||
if (mAutoSummary || TextUtils.isEmpty(getSummary())) {
|
||||
setSummary(getEntry(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSummary(CharSequence summary) {
|
||||
setSummary(summary, false);
|
||||
}
|
||||
|
||||
private void setSummary(CharSequence summary, boolean autoSummary) {
|
||||
mAutoSummary = autoSummary;
|
||||
super.setSummary(summary);
|
||||
}
|
||||
|
||||
public int getIntValue(int defValue) {
|
||||
return getValue() == null ? defValue : Integer.valueOf(getValue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user