diff options
-rw-r--r-- | res/layout/seekbar_dialog.xml | 36 | ||||
-rw-r--r-- | res/values/attrs.xml | 7 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | res/xml/preferences_dock.xml | 6 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/CellLayout.java | 21 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Hotseat.java | 6 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java | 3 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/SeekBarDialogPreference.java | 82 |
8 files changed, 148 insertions, 15 deletions
diff --git a/res/layout/seekbar_dialog.xml b/res/layout/seekbar_dialog.xml new file mode 100644 index 0000000..254a4ec --- /dev/null +++ b/res/layout/seekbar_dialog.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:gravity="center_horizontal"> + + <TextView android:id="@+id/value" + android:layout_centerInParent="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingTop="5dip" + android:textAppearance="?android:textAppearanceLarge" /> + + <SeekBar android:id="@+id/seekbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="20dip" + android:paddingTop="5dip" /> + +</LinearLayout> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 88f6e03..f03a342 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -178,6 +178,13 @@ <attr name="pickerTitle2" format="string" /> </declare-styleable> + <declare-styleable name="SeekBarDialogPreference"> + <attr name="max" /> + <attr name="min" /> + <attr name="prefix" format="string" /> + <attr name="suffix" format="string" /> + </declare-styleable> + <declare-styleable name="EcoGallery"> <attr name="gravity" format="integer" /> <attr name="animationDuration" format="integer" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 9d9172d..899ee3e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -390,6 +390,8 @@ s --> <string name="preferences_interface_dock_default_page_summary">Choose the default page</string> <string name="preferences_interface_dock_icons_title">Icons</string> <string name="preferences_interface_dock_icons_summary">Number of icons/columns in the dock</string> + <string name="preferences_interface_dock_icon_scale_title">Icon scale</string> + <string name="preferences_interface_dock_icon_scale_summary">Scale of icons in the dock</string> <string name="preferences_interface_dock_divider_title">Show dock divider</string> <string name="preferences_interface_dock_divider_summary">Show divider between homescreen and dock</string> diff --git a/res/xml/preferences_dock.xml b/res/xml/preferences_dock.xml index 3e85c95..54c7d6c 100644 --- a/res/xml/preferences_dock.xml +++ b/res/xml/preferences_dock.xml @@ -37,6 +37,12 @@ android:defaultValue="@integer/hotseat_cell_count" launcher:max="@integer/hotseat_cell_count" launcher:min="3" /> + <com.cyanogenmod.trebuchet.preference.SeekBarDialogPreference android:key="ui_dock_icon_scale" + android:title="@string/preferences_interface_dock_icon_scale_title" + android:summary="@string/preferences_interface_dock_icon_scale_summary" + launcher:min="80" + launcher:max="100" + android:defaultValue="@integer/hotseat_item_scale_percentage" /> <CheckBoxPreference android:key="ui_dock_divider" android:title="@string/preferences_interface_dock_divider_title" android:summary="@string/preferences_interface_dock_divider_summary" diff --git a/src/com/cyanogenmod/trebuchet/CellLayout.java b/src/com/cyanogenmod/trebuchet/CellLayout.java index 0521ef7..4029ed1 100644 --- a/src/com/cyanogenmod/trebuchet/CellLayout.java +++ b/src/com/cyanogenmod/trebuchet/CellLayout.java @@ -138,8 +138,7 @@ public class CellLayout extends ViewGroup { private TimeInterpolator mEaseOutInterpolator; private ShortcutAndWidgetContainer mShortcutsAndWidgets; - private boolean mIsHotseat = false; - private float mHotseatScale = 1f; + private float mChildrenScale = 1f; public static final int MODE_DRAG_OVER = 0; public static final int MODE_ON_DROP = 1; @@ -202,8 +201,6 @@ public class CellLayout extends ViewGroup { setAlwaysDrawnWithCacheEnabled(false); final Resources res = getResources(); - mHotseatScale = (res.getInteger(R.integer.hotseat_item_scale_percentage) / 100f); - mNormalBackground = res.getDrawable(R.drawable.homescreen_blue_normal_holo); mActiveGlowBackground = res.getDrawable(R.drawable.homescreen_blue_strong_holo); @@ -326,8 +323,12 @@ public class CellLayout extends ViewGroup { mShortcutsAndWidgets.buildLayer(); } + public void setChildrenScale(float childrenScale) { + mChildrenScale = childrenScale; + } + public float getChildrenScale() { - return mIsHotseat ? mHotseatScale : 1.0f; + return mChildrenScale; } public void setGridSize(int x, int y) { @@ -609,10 +610,6 @@ public class CellLayout extends ViewGroup { return mCountY; } - public void setIsHotseat(boolean isHotseat) { - mIsHotseat = isHotseat; - } - public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params, boolean markCells) { final LayoutParams lp = params; @@ -622,11 +619,7 @@ public class CellLayout extends ViewGroup { BubbleTextView bubbleChild = (BubbleTextView) child; Resources res = getResources(); - if (mIsHotseat) { - bubbleChild.setTextColor(res.getColor(android.R.color.transparent)); - } else { - bubbleChild.setTextColor(res.getColor(R.color.workspace_icon_text_color)); - } + bubbleChild.setTextColor(res.getColor(R.color.workspace_icon_text_color)); } child.setScaleX(getChildrenScale()); diff --git a/src/com/cyanogenmod/trebuchet/Hotseat.java b/src/com/cyanogenmod/trebuchet/Hotseat.java index 38a826e..77ec2cc 100644 --- a/src/com/cyanogenmod/trebuchet/Hotseat.java +++ b/src/com/cyanogenmod/trebuchet/Hotseat.java @@ -74,11 +74,15 @@ public class Hotseat extends PagedView { mVertical = hasVerticalHotseat(); + + float childrenScale = PreferencesProvider.Interface.Dock.getIconScale( + getResources().getInteger(R.integer.hotseat_item_scale_percentage)) / 100f; + LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < hotseatPages; i++) { CellLayout cl = (CellLayout) inflater.inflate(R.layout.hotseat_page, null); - cl.setIsHotseat(true); + cl.setChildrenScale(childrenScale); cl.setGridSize((!hasVerticalHotseat() ? mCellCount : 1), (hasVerticalHotseat() ? mCellCount : 1)); addView(cl); } 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 |