1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-22 19:08:03 +01:00

Added ThemedVisibilityPreference and set it in NavSlider Preference Screen

This commit is contained in:
vanitasvitae 2016-10-25 21:29:16 +02:00
parent c0f4fcd62f
commit 532b80ea84
Signed by: vanitasvitae
GPG key ID: DCCFB3302C9E4615
7 changed files with 94 additions and 15 deletions

View file

@ -272,16 +272,17 @@ public class AppSettings {
*/
public int getProxyHttpPort() {
try {
return getInt(prefApp, R.string.pref_key__http_proxy_port, 0);
} catch(Exception _anything){
//TODO: Backward Compatibility for older versions. REMOVE after App v1.7.0
String str = getString(prefApp, R.string.pref_key__http_proxy_port, "0");
return Integer.parseInt(str);
} catch (ClassCastException e) {
int port = getInt(prefApp, R.string.pref_key__http_proxy_port, 0);
setProxyHttpPort(port);
return port;
}
}
public void setProxyHttpPort(int value) {
setInt(prefApp, R.string.pref_key__http_proxy_port, value);
setString(prefApp, R.string.pref_key__http_proxy_port, Integer.toString(value));
}
public ProxyHandler.ProxySettings getProxySettings() {

View file

@ -7,6 +7,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;

View file

@ -0,0 +1,36 @@
package com.github.dfa.diaspora_android.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.CheckBox;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
/**
* ThemedCheckBoxPreference with visibility icons instead of checkbox. TODO: Make more flexible?
* Created by vanitas on 25.10.16.
*/
public class ThemedVisibilityPreference extends ThemedCheckBoxPreference {
public ThemedVisibilityPreference(Context context) {
super(context);
}
public ThemedVisibilityPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ThemedVisibilityPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void setColors() {
CheckBox checkBox = (CheckBox) rootLayout.findViewById(android.R.id.checkbox);
checkBox.setButtonDrawable(R.drawable.ic_visibility_selector);
ThemeHelper.getInstance(new AppSettings(getContext()));
ThemeHelper.updateCheckBoxColor(checkBox);
}
}

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89
3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74 .25 -3.98 .7 l2.16 2.16C10.74 7.13
11.35 7 12 7zM2 4.27l2.28 2.28 .46 .46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5
11 7.5 1.55 0 3.03-.3 4.38-.84l.42 .42 L19.73 22 21 20.73 3.27 3 2 4.27zM7.53
9.8l1.55 1.55c-.05 .21 -.08 .43 -.08 .65 0 1.66 1.34 3 3 3 .22 0 .44-.03 .65
-.08l1.55 1.55c-.67 .33 -1.41 .53 -2.2 .53 -2.76 0-5-2.24-5-5 0-.79 .2 -1.53 .53
-2.2zm4.31-.78l3.15 3.15 .02 -.16c0-1.66-1.34-3-3-3l-.17 .01 z" />
</vector>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11
11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5
5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" />
</vector>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/ic_visibility_off_black_24px" />
<item android:state_checked="true"
android:drawable="@drawable/ic_visibility_on_black_24px" />
</selector>

View file

@ -5,47 +5,47 @@
android:key="@string/pref_key__title__visibility_nav"
android:title="@string/pref_cat__visibility_nav_items">
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__profile"
android:title="@string/nav_profile"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__followed_tags"
android:title="@string/nav_followed_tags"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__aspects"
android:title="@string/nav_aspects"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__contacts"
android:title="@string/nav_contacts" />
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__activities"
android:title="@string/nav_activities"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__liked"
android:title="@string/nav_liked"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__commented"
android:title="@string/nav_commented"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__mentions"
android:title="@string/nav_mentions"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__public_activities"
android:title="@string/nav_public_activities"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__exit"
android:title="@string/action_exit_app"/>
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
<com.github.dfa.diaspora_android.ui.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__help_license"
android:title="@string/nav_help_license"/>