diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java
index 5bec4ebf..57daf5a1 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java
@@ -21,6 +21,7 @@ import android.content.SharedPreferences;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl;
+import com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference;
import com.github.dfa.diaspora_android.util.ProxyHandler;
import org.json.JSONException;
@@ -463,4 +464,13 @@ public class AppSettings {
public void setExtendedNotifications(boolean b) {
setBool(prefApp, R.string.pref_key__extended_notifications, b);
}
+
+ public boolean getThemedCheckboxPreferenceBoolean(ThemedCheckBoxPreference t) {
+ return prefApp.getBoolean(t.getPrefKey(), t.getDefaultValue());
+ //return getBoolean(prefApp, t.getPrefKey(), t.getDefaultValue());
+ }
+
+ public void setThemedCheckboxPreferenceBoolean(ThemedCheckBoxPreference t, boolean b) {
+ prefApp.edit().putBoolean(t.getPrefKey(), b).apply();
+ }
}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java
index 3b3a82ff..3fe1d5a6 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java
@@ -64,7 +64,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
@BindView(R.id.settings_activity__font_size)
protected LinearLayout optionFontSize;
- @BindView(R.id.settings_activity__intellihide_toolbars)
+ //@BindView(R.id.settings_activity__intellihide_toolbars)
protected RelativeLayout optionIntellihideToolbars;
@BindView(R.id.settings_activity__extended_notifications)
@@ -79,7 +79,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
@BindView(R.id.settings_activity__font_size_hint)
protected TextView hintFontSize;
- @BindView(R.id.settings_activity__intellihide_toolbars_checkbox)
+ //@BindView(R.id.settings_activity__intellihide_toolbars_checkbox)
protected CheckBox checkboxIntellihide;
@BindView(R.id.settings_activity__extended_notifications_checkbox)
@@ -148,7 +148,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
protected void applySettingsToViews() {
hintFontSize.setText(getAppSettings().getMinimumFontSizeString());
- checkboxIntellihide.setChecked(getAppSettings().isIntellihideToolbars());
+ //checkboxIntellihide.setChecked(getAppSettings().isIntellihideToolbars());
checkboxExtendedNotifications.setChecked(getAppSettings().isExtendedNotifications());
checkboxAppendSharedViaApp.setChecked(getAppSettings().isAppendSharedViaApp());
checkboxCustomTabs.setChecked(getAppSettings().isChromeCustomTabsEnabled());
@@ -160,8 +160,8 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
optionThemeColors.setOnClickListener(this);
optionNavigationSlider.setOnClickListener(this);
optionFontSize.setOnClickListener(this);
- optionIntellihideToolbars.setOnClickListener(this);
- checkboxIntellihide.setOnClickListener(this);
+ //optionIntellihideToolbars.setOnClickListener(this);
+ //checkboxIntellihide.setOnClickListener(this);
optionExtendedNotifications.setOnClickListener(this);
checkboxExtendedNotifications.setOnClickListener(this);
optionAppendSharedViaApp.setOnClickListener(this);
@@ -192,7 +192,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
ThemeHelper.updateTitleColor(titleNetwork);
ThemeHelper.updateTitleColor(titleMore);
//Checkboxes
- ThemeHelper.updateCheckBoxColor(checkboxIntellihide);
+ //ThemeHelper.updateCheckBoxColor(checkboxIntellihide);
ThemeHelper.updateCheckBoxColor(checkboxExtendedNotifications);
ThemeHelper.updateCheckBoxColor(checkboxAppendSharedViaApp);
ThemeHelper.updateCheckBoxColor(checkboxCustomTabs);
@@ -248,11 +248,11 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
case R.id.settings_activity__font_size:
showFontSizeDialog();
break;
- case R.id.settings_activity__intellihide_toolbars:
- case R.id.settings_activity__intellihide_toolbars_checkbox:
- checkboxIntellihide.setChecked(!getAppSettings().isIntellihideToolbars());
- getAppSettings().setIntellihideToolbars(!getAppSettings().isIntellihideToolbars());
- break;
+ //case R.id.settings_activity__intellihide_toolbars:
+ //case R.id.settings_activity__intellihide_toolbars_checkbox:
+ // checkboxIntellihide.setChecked(!getAppSettings().isIntellihideToolbars());
+ // getAppSettings().setIntellihideToolbars(!getAppSettings().isIntellihideToolbars());
+ // break;
case R.id.settings_activity__extended_notifications:
case R.id.settings_activity__extended_notifications_checkbox:
checkboxExtendedNotifications.setChecked(!getAppSettings().isExtendedNotifications());
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java
new file mode 100644
index 00000000..cfe237da
--- /dev/null
+++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java
@@ -0,0 +1,123 @@
+package com.github.dfa.diaspora_android.ui;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.github.dfa.diaspora_android.R;
+import com.github.dfa.diaspora_android.data.AppSettings;
+import com.github.dfa.diaspora_android.util.AppLog;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+/**
+ * Customizable CheckboxPreference-like widget
+ * Created by vanitas on 23.10.16.
+ */
+
+public class ThemedCheckBoxPreference extends RelativeLayout {
+
+ @BindView(R.id.preference__themed_checkbox__title)
+ protected TextView title;
+ @BindView(R.id.preference__themed_checkbox__summary)
+ protected TextView summary;
+ @BindView(R.id.preference__themed_checkbox__checkbox)
+ protected CheckBox checkBox;
+
+ protected String prefKey;
+ protected boolean defaultValue;
+
+ public ThemedCheckBoxPreference(Context context) {
+ super(context);
+ init(context, null);
+ }
+
+ public ThemedCheckBoxPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context, attrs);
+ }
+
+ public ThemedCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init(context, attrs);
+ }
+
+ protected void init(Context context, AttributeSet attrs) {
+ View.inflate(context, R.layout.preference__themed_checkbox, this);
+ ButterKnife.bind(this);
+ setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ checkBox.performClick();
+ }
+ });
+
+ // Assign custom attributes
+ if (attrs != null) {
+ TypedArray a = context.getTheme().obtainStyledAttributes(
+ attrs,
+ R.styleable.ThemedCheckBoxPreference,
+ 0, 0);
+
+ String titleText = "";
+ String summaryText = "";
+
+ try {
+ titleText = a.getString(R.styleable.ThemedCheckBoxPreference_titleText);
+ summaryText = a.getString(R.styleable.ThemedCheckBoxPreference_summaryText);
+ prefKey = a.getString(R.styleable.ThemedCheckBoxPreference_prefKey);
+ defaultValue = a.getBoolean(R.styleable.ThemedCheckBoxPreference_defaultValue, false);
+ } catch (Exception e) {
+ AppLog.e(this, "There was an error loading attributes.");
+ } finally {
+ a.recycle();
+ }
+
+ final AppSettings appSettings = new AppSettings(context);
+
+ setTitleText(titleText);
+ setSummaryText(summaryText);
+ setChecked(appSettings.getThemedCheckboxPreferenceBoolean(this));
+ setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ appSettings.setThemedCheckboxPreferenceBoolean(ThemedCheckBoxPreference.this, b);
+ }
+ });
+ }
+ }
+
+ public void setTitleText(String text) {
+ title.setText(text);
+ }
+
+ public void setSummaryText(String text) {
+ summary.setText(text);
+ }
+
+ public void setChecked(boolean checked) {
+ checkBox.setChecked(checked);
+ }
+
+
+ public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener) {
+ checkBox.setOnCheckedChangeListener(listener);
+ }
+
+ public String getPrefKey() {
+ return this.prefKey;
+ }
+
+ public boolean getDefaultValue() {
+ return this.defaultValue;
+ }
+}
diff --git a/app/src/main/res/layout/preference__themed_checkbox.xml b/app/src/main/res/layout/preference__themed_checkbox.xml
new file mode 100644
index 00000000..f9602416
--- /dev/null
+++ b/app/src/main/res/layout/preference__themed_checkbox.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/preference__themed_checkbox2.xml b/app/src/main/res/layout/preference__themed_checkbox2.xml
new file mode 100644
index 00000000..8bceb4ed
--- /dev/null
+++ b/app/src/main/res/layout/preference__themed_checkbox2.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/settings_activity__section_appearance.xml b/app/src/main/res/layout/settings_activity__section_appearance.xml
index c6445747..7b61a7f7 100644
--- a/app/src/main/res/layout/settings_activity__section_appearance.xml
+++ b/app/src/main/res/layout/settings_activity__section_appearance.xml
@@ -1,6 +1,8 @@
-
+
+
+
-
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
new file mode 100644
index 00000000..bd7f03aa
--- /dev/null
+++ b/app/src/main/res/values/attrs.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file