diff options
author | nebkat <nebkat@teamhacksung.org> | 2012-12-27 17:34:01 +0000 |
---|---|---|
committer | nebkat <nebkat@teamhacksung.org> | 2012-12-27 17:34:44 +0000 |
commit | 5ffcd2b98cad37a08338f6e1677b6ba0b6eee0be (patch) | |
tree | f4bf7468b0a1a8a3fc221a4fe1af0a4ab5e301ef /src/com/cyanogenmod/trebuchet/preference | |
parent | 16e27563f01f95ed7ded10f2a2ba76d2ea4e65b4 (diff) | |
download | packages_apps_trebuchet-5ffcd2b98cad37a08338f6e1677b6ba0b6eee0be.zip packages_apps_trebuchet-5ffcd2b98cad37a08338f6e1677b6ba0b6eee0be.tar.gz packages_apps_trebuchet-5ffcd2b98cad37a08338f6e1677b6ba0b6eee0be.tar.bz2 |
Hotseat: Icon scale
Change-Id: I6cae71283c164fe576dfd8338097f74d5d025b4a
Diffstat (limited to 'src/com/cyanogenmod/trebuchet/preference')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java | 3 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/SeekBarDialogPreference.java | 82 |
2 files changed, 85 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java index 8d747ce..224f992 100644 --- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java +++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java @@ -188,6 +188,9 @@ public final class PreferencesProvider { public static int getNumberIcons(int def) { return getInt("ui_dock_icons", def); } + public static int getIconScale(int def) { + return getInt("ui_dock_icon_scale", def); + } public static boolean getShowDivider() { return getBoolean("ui_dock_divider", true); } diff --git a/src/com/cyanogenmod/trebuchet/preference/SeekBarDialogPreference.java b/src/com/cyanogenmod/trebuchet/preference/SeekBarDialogPreference.java new file mode 100644 index 0000000..5d2c8d0 --- /dev/null +++ b/src/com/cyanogenmod/trebuchet/preference/SeekBarDialogPreference.java @@ -0,0 +1,82 @@ +package com.cyanogenmod.trebuchet.preference; + +import android.content.Context; +import android.content.res.TypedArray; +import android.preference.DialogPreference; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.SeekBar; +import android.widget.TextView; + +import com.cyanogenmod.trebuchet.R; + +/** + * @author nebkat + */ +public class SeekBarDialogPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener { + private int mMax, mMin, mDefault; + + private String mPrefix, mSuffix; + + private TextView mValueText; + private SeekBar mSeekBar; + + public SeekBarDialogPreference(Context context, AttributeSet attrs) { + super(context, attrs); + TypedArray dialogType = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.DialogPreference, 0, 0); + TypedArray seekBarType = context.obtainStyledAttributes(attrs, + R.styleable.SeekBarDialogPreference, 0, 0); + + mMax = seekBarType.getInt(R.styleable.SeekBarDialogPreference_max, 100); + mMin = seekBarType.getInt(R.styleable.SeekBarDialogPreference_min, 0); + + mDefault = dialogType.getInt(com.android.internal.R.styleable.Preference_defaultValue, mMin); + + mPrefix = seekBarType.getString(R.styleable.SeekBarDialogPreference_prefix); + mSuffix = seekBarType.getString(R.styleable.SeekBarDialogPreference_suffix); + if (mPrefix == null) { + mPrefix = ""; + } + if (mSuffix == null) { + mSuffix = "%"; + } + + dialogType.recycle(); + seekBarType.recycle(); + } + + @Override + protected View onCreateDialogView() { + LayoutInflater inflater = + (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View view = inflater.inflate(R.layout.seekbar_dialog, null); + + mValueText = (TextView) view.findViewById(R.id.value); + + mSeekBar = (SeekBar) view.findViewById(R.id.seekbar); + mSeekBar.setOnSeekBarChangeListener(this); + mSeekBar.setMax(mMax - mMin); + mSeekBar.setProgress(getPersistedInt(mDefault) - mMin); + + mValueText.setText(mPrefix + getPersistedInt(mDefault) + mSuffix); + + return view; + } + + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + mValueText.setText(mPrefix + (progress + mMin) + mSuffix); + } + + public void onStartTrackingTouch(SeekBar seekBar) {} + public void onStopTrackingTouch(SeekBar seekBar) {} + + @Override + protected void onDialogClosed(boolean positiveResult) { + if (positiveResult) { + persistInt(mSeekBar.getProgress() + mMin); + } + } + +}
\ No newline at end of file |