diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index 85c250f1..cb3046aa 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -1,8 +1,5 @@ - - - diff --git a/src/main/scala/com/github/shadowsocks/preferences/DropDownPreference.scala b/src/main/scala/com/github/shadowsocks/preferences/DropDownPreference.scala index c42891f3..0067f403 100644 --- a/src/main/scala/com/github/shadowsocks/preferences/DropDownPreference.scala +++ b/src/main/scala/com/github/shadowsocks/preferences/DropDownPreference.scala @@ -38,7 +38,6 @@ final class DropDownPreference(private val mContext: Context, attrs: AttributeSe mSpinner.performClick true }) - initSummary(mContext, attrs) val a: TypedArray = mContext.obtainStyledAttributes(attrs, R.styleable.DropDownPreference) setEntries(a.getTextArray(R.styleable.DropDownPreference_entries)) mEntryValues = a.getTextArray(R.styleable.DropDownPreference_entryValues) diff --git a/src/main/scala/com/github/shadowsocks/preferences/NumberPickerPreference.scala b/src/main/scala/com/github/shadowsocks/preferences/NumberPickerPreference.scala index 9fa2d7aa..bbdcc833 100644 --- a/src/main/scala/com/github/shadowsocks/preferences/NumberPickerPreference.scala +++ b/src/main/scala/com/github/shadowsocks/preferences/NumberPickerPreference.scala @@ -22,7 +22,6 @@ final class NumberPickerPreference(context: Context, attrs: AttributeSet = null) setMax(a.getInt(R.styleable.NumberPickerPreference_max, Int.MaxValue - 1)) a.recycle } - initSummary(context, attrs) def getValue = value def getMin = if (picker == null) 0 else picker.getMinValue diff --git a/src/main/scala/com/github/shadowsocks/preferences/SummaryPreference.scala b/src/main/scala/com/github/shadowsocks/preferences/SummaryPreference.scala index 15e59970..4e5339a1 100644 --- a/src/main/scala/com/github/shadowsocks/preferences/SummaryPreference.scala +++ b/src/main/scala/com/github/shadowsocks/preferences/SummaryPreference.scala @@ -1,23 +1,12 @@ package com.github.shadowsocks.preferences -import android.content.Context import android.preference.Preference -import android.util.AttributeSet -import com.github.shadowsocks.R /** * Make your preference support %s in summary. Override getSummaryValue to customize what to put in. * @author Mygod */ trait SummaryPreference extends Preference { - private var mSummary: String = _ - - protected def initSummary(context: Context, attrs: AttributeSet) { - val a = context.obtainStyledAttributes(attrs, R.styleable.SummaryPreference) - mSummary = a.getString(R.styleable.SummaryPreference_summary) - a.recycle - } - protected def getSummaryValue: AnyRef /** @@ -26,19 +15,5 @@ trait SummaryPreference extends Preference { * * @return the summary with appropriate string substitution */ - override def getSummary = { - val entry = getSummaryValue - if (mSummary == null || entry == null) super.getSummary else String.format(mSummary, entry) - } - /** - * Sets the summary for this Preference with a CharSequence. If the summary has a String formatting marker in it - * (i.e. "%s" or "%1$s"), then the current entry value will be substituted in its place when it's retrieved. - * - * @param summary The summary for the preference. - */ - override def setSummary(summary: CharSequence) { - super.setSummary(summary) - if (summary == null && mSummary != null) mSummary = null - else if (summary != null && summary != mSummary) mSummary = summary.toString - } + override def getSummary = String.format(super.getSummary.toString, getSummaryValue) }