Move Preferences to Iconics
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package i2p.bote.android.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.mikepenz.iconics.IconicsDrawable;
|
||||
|
||||
import i2p.bote.android.R;
|
||||
|
||||
public class IconicsPreference extends Preference {
|
||||
public IconicsPreference(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public IconicsPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs);
|
||||
|
||||
// Icons only work on API 11+
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
|
||||
return;
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.IconicsPreference, defStyle, 0);
|
||||
String iconName = a.getString(R.styleable.IconicsPreference_ip_icon);
|
||||
if (iconName == null)
|
||||
return;
|
||||
|
||||
IconicsDrawable icon = new IconicsDrawable(context, iconName);
|
||||
int color = a.getColor(R.styleable.IconicsPreference_ip_color, 0);
|
||||
if (color != 0)
|
||||
icon.color(color);
|
||||
int size = a.getDimensionPixelSize(R.styleable.IconicsPreference_ip_size, 0);
|
||||
if (size != 0)
|
||||
icon.sizePx(size);
|
||||
|
||||
a.recycle();
|
||||
setIcon(icon);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
<resources>
|
||||
|
||||
<declare-styleable name="IconicsPreference">
|
||||
<attr name="ip_icon" format="string"/>
|
||||
<attr name="ip_color" format="color"/>
|
||||
<attr name="ip_size" format="dimension"/>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Declare custom theme attributes that allow changing which styles are
|
||||
used for button bars depending on the API level.
|
||||
?android:attr/buttonBarStyle is new as of API 11 so this is
|
||||
necessary to support previous API levels. -->
|
||||
<declare-styleable name="ButtonBarContainerTheme">
|
||||
<attr name="metaButtonBarStyle" format="reference" />
|
||||
<attr name="metaButtonBarButtonStyle" format="reference" />
|
||||
<attr name="metaButtonBarStyle" format="reference"/>
|
||||
<attr name="metaButtonBarButtonStyle" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
|
||||
<color name="black_semi_transparent">#B2000000</color>
|
||||
|
||||
<color name="pref_icon">@android:color/black</color>
|
||||
</resources>
|
||||
|
||||
@@ -37,4 +37,6 @@
|
||||
<dimen name="qr_code_size">200dp</dimen>
|
||||
|
||||
<dimen name="pie_size">300dp</dimen>
|
||||
|
||||
<dimen name="pref_icon">30dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -1,27 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings_ethernet_black_36dp"
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<i2p.bote.android.util.IconicsPreference
|
||||
android:key="preference_category_network"
|
||||
android:title="@string/settings_label_network"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_account_box_black_36dp"
|
||||
android:title="@string/settings_label_network"
|
||||
app:ip_color="@color/pref_icon"
|
||||
app:ip_icon="gmd-settings-ethernet"
|
||||
app:ip_size="@dimen/pref_icon"/>
|
||||
<i2p.bote.android.util.IconicsPreference
|
||||
android:key="preference_category_identities"
|
||||
android:title="@string/pref_title_identities"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_visibility_black_36dp"
|
||||
android:title="@string/pref_title_identities"
|
||||
app:ip_color="@color/pref_icon"
|
||||
app:ip_icon="gmd-account-box"
|
||||
app:ip_size="@dimen/pref_icon"/>
|
||||
<i2p.bote.android.util.IconicsPreference
|
||||
android:key="preference_category_privacy"
|
||||
android:title="@string/pref_title_privacy"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_lock_black_36dp"
|
||||
android:title="@string/pref_title_privacy"
|
||||
app:ip_color="@color/pref_icon"
|
||||
app:ip_icon="gmd-visibility"
|
||||
app:ip_size="@dimen/pref_icon"/>
|
||||
<i2p.bote.android.util.IconicsPreference
|
||||
android:key="preference_category_app_protection"
|
||||
android:title="@string/settings_label_app_protection"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings_display_black_36dp"
|
||||
android:title="@string/settings_label_app_protection"
|
||||
app:ip_color="@color/pref_icon"
|
||||
app:ip_icon="gmd-lock"
|
||||
app:ip_size="@dimen/pref_icon"/>
|
||||
<i2p.bote.android.util.IconicsPreference
|
||||
android:key="preference_category_appearance"
|
||||
android:title="@string/settings_label_appearance"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings_black_36dp"
|
||||
android:title="@string/settings_label_appearance"
|
||||
app:ip_color="@color/pref_icon"
|
||||
app:ip_icon="gmd-settings-display"
|
||||
app:ip_size="@dimen/pref_icon"/>
|
||||
<i2p.bote.android.util.IconicsPreference
|
||||
android:key="preference_category_advanced"
|
||||
android:title="@string/settings_label_advanced"/>
|
||||
android:title="@string/settings_label_advanced"
|
||||
app:ip_color="@color/pref_icon"
|
||||
app:ip_icon="gmd-settings"
|
||||
app:ip_size="@dimen/pref_icon"/>
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user