mirror of
https://github.com/gsantner/dandelion
synced 2024-11-24 21:32:07 +01:00
save
This commit is contained in:
parent
2b79c0ea8c
commit
d0c699d869
8 changed files with 226 additions and 14 deletions
|
@ -21,6 +21,7 @@ import android.content.SharedPreferences;
|
||||||
import com.github.dfa.diaspora_android.R;
|
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;
|
||||||
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl;
|
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 com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -463,4 +464,13 @@ public class AppSettings {
|
||||||
public void setExtendedNotifications(boolean b) {
|
public void setExtendedNotifications(boolean b) {
|
||||||
setBool(prefApp, R.string.pref_key__extended_notifications, 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
|
||||||
@BindView(R.id.settings_activity__font_size)
|
@BindView(R.id.settings_activity__font_size)
|
||||||
protected LinearLayout optionFontSize;
|
protected LinearLayout optionFontSize;
|
||||||
|
|
||||||
@BindView(R.id.settings_activity__intellihide_toolbars)
|
//@BindView(R.id.settings_activity__intellihide_toolbars)
|
||||||
protected RelativeLayout optionIntellihideToolbars;
|
protected RelativeLayout optionIntellihideToolbars;
|
||||||
|
|
||||||
@BindView(R.id.settings_activity__extended_notifications)
|
@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)
|
@BindView(R.id.settings_activity__font_size_hint)
|
||||||
protected TextView hintFontSize;
|
protected TextView hintFontSize;
|
||||||
|
|
||||||
@BindView(R.id.settings_activity__intellihide_toolbars_checkbox)
|
//@BindView(R.id.settings_activity__intellihide_toolbars_checkbox)
|
||||||
protected CheckBox checkboxIntellihide;
|
protected CheckBox checkboxIntellihide;
|
||||||
|
|
||||||
@BindView(R.id.settings_activity__extended_notifications_checkbox)
|
@BindView(R.id.settings_activity__extended_notifications_checkbox)
|
||||||
|
@ -148,7 +148,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
|
||||||
|
|
||||||
protected void applySettingsToViews() {
|
protected void applySettingsToViews() {
|
||||||
hintFontSize.setText(getAppSettings().getMinimumFontSizeString());
|
hintFontSize.setText(getAppSettings().getMinimumFontSizeString());
|
||||||
checkboxIntellihide.setChecked(getAppSettings().isIntellihideToolbars());
|
//checkboxIntellihide.setChecked(getAppSettings().isIntellihideToolbars());
|
||||||
checkboxExtendedNotifications.setChecked(getAppSettings().isExtendedNotifications());
|
checkboxExtendedNotifications.setChecked(getAppSettings().isExtendedNotifications());
|
||||||
checkboxAppendSharedViaApp.setChecked(getAppSettings().isAppendSharedViaApp());
|
checkboxAppendSharedViaApp.setChecked(getAppSettings().isAppendSharedViaApp());
|
||||||
checkboxCustomTabs.setChecked(getAppSettings().isChromeCustomTabsEnabled());
|
checkboxCustomTabs.setChecked(getAppSettings().isChromeCustomTabsEnabled());
|
||||||
|
@ -160,8 +160,8 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
|
||||||
optionThemeColors.setOnClickListener(this);
|
optionThemeColors.setOnClickListener(this);
|
||||||
optionNavigationSlider.setOnClickListener(this);
|
optionNavigationSlider.setOnClickListener(this);
|
||||||
optionFontSize.setOnClickListener(this);
|
optionFontSize.setOnClickListener(this);
|
||||||
optionIntellihideToolbars.setOnClickListener(this);
|
//optionIntellihideToolbars.setOnClickListener(this);
|
||||||
checkboxIntellihide.setOnClickListener(this);
|
//checkboxIntellihide.setOnClickListener(this);
|
||||||
optionExtendedNotifications.setOnClickListener(this);
|
optionExtendedNotifications.setOnClickListener(this);
|
||||||
checkboxExtendedNotifications.setOnClickListener(this);
|
checkboxExtendedNotifications.setOnClickListener(this);
|
||||||
optionAppendSharedViaApp.setOnClickListener(this);
|
optionAppendSharedViaApp.setOnClickListener(this);
|
||||||
|
@ -192,7 +192,7 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
|
||||||
ThemeHelper.updateTitleColor(titleNetwork);
|
ThemeHelper.updateTitleColor(titleNetwork);
|
||||||
ThemeHelper.updateTitleColor(titleMore);
|
ThemeHelper.updateTitleColor(titleMore);
|
||||||
//Checkboxes
|
//Checkboxes
|
||||||
ThemeHelper.updateCheckBoxColor(checkboxIntellihide);
|
//ThemeHelper.updateCheckBoxColor(checkboxIntellihide);
|
||||||
ThemeHelper.updateCheckBoxColor(checkboxExtendedNotifications);
|
ThemeHelper.updateCheckBoxColor(checkboxExtendedNotifications);
|
||||||
ThemeHelper.updateCheckBoxColor(checkboxAppendSharedViaApp);
|
ThemeHelper.updateCheckBoxColor(checkboxAppendSharedViaApp);
|
||||||
ThemeHelper.updateCheckBoxColor(checkboxCustomTabs);
|
ThemeHelper.updateCheckBoxColor(checkboxCustomTabs);
|
||||||
|
@ -248,11 +248,11 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment {
|
||||||
case R.id.settings_activity__font_size:
|
case R.id.settings_activity__font_size:
|
||||||
showFontSizeDialog();
|
showFontSizeDialog();
|
||||||
break;
|
break;
|
||||||
case R.id.settings_activity__intellihide_toolbars:
|
//case R.id.settings_activity__intellihide_toolbars:
|
||||||
case R.id.settings_activity__intellihide_toolbars_checkbox:
|
//case R.id.settings_activity__intellihide_toolbars_checkbox:
|
||||||
checkboxIntellihide.setChecked(!getAppSettings().isIntellihideToolbars());
|
// checkboxIntellihide.setChecked(!getAppSettings().isIntellihideToolbars());
|
||||||
getAppSettings().setIntellihideToolbars(!getAppSettings().isIntellihideToolbars());
|
// getAppSettings().setIntellihideToolbars(!getAppSettings().isIntellihideToolbars());
|
||||||
break;
|
// break;
|
||||||
case R.id.settings_activity__extended_notifications:
|
case R.id.settings_activity__extended_notifications:
|
||||||
case R.id.settings_activity__extended_notifications_checkbox:
|
case R.id.settings_activity__extended_notifications_checkbox:
|
||||||
checkboxExtendedNotifications.setChecked(!getAppSettings().isExtendedNotifications());
|
checkboxExtendedNotifications.setChecked(!getAppSettings().isExtendedNotifications());
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
32
app/src/main/res/layout/preference__themed_checkbox.xml
Normal file
32
app/src/main/res/layout/preference__themed_checkbox.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/preference__themed_checkbox__root"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:layout_marginTop="@dimen/activity_vertical_margin">
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/preference__themed_checkbox__text_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_toStartOf="@+id/preference__themed_checkbox__checkbox">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/preference__themed_checkbox__title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/preference__themed_checkbox__summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/preference__themed_checkbox__checkbox"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"/>
|
||||||
|
</RelativeLayout>
|
27
app/src/main/res/layout/preference__themed_checkbox2.xml
Normal file
27
app/src/main/res/layout/preference__themed_checkbox2.xml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:layout_gravity="center_vertical">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
android:id="@+id/preference__themed_checkbox__title"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/preference__themed_checkbox__summary"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/preference__themed_checkbox__checkbox"/>
|
||||||
|
</merge>
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="@dimen/activity_horizontal_margin_half">
|
android:layout_margin="@dimen/activity_horizontal_margin_half">
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -71,7 +73,15 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Intellihide toolbars -->
|
<!-- Intellihide toolbars -->
|
||||||
<RelativeLayout
|
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:titleText="@string/pref_title__intellihide_toolbars"
|
||||||
|
app:summaryText="@string/pref_desc__intellihide_toolbars"
|
||||||
|
app:prefKey="@string/pref_key__intellihide_toolbars"
|
||||||
|
app:defaultValue="true"/>
|
||||||
|
|
||||||
|
<!--<RelativeLayout
|
||||||
android:id="@+id/settings_activity__intellihide_toolbars"
|
android:id="@+id/settings_activity__intellihide_toolbars"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -101,6 +111,8 @@
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_centerVertical="true"/>
|
android:layout_centerVertical="true"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
<!-- Dropdown Notifications -->
|
<!-- Dropdown Notifications -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
|
@ -29,5 +29,4 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/pref_desc__sub_logging"/>
|
android:text="@string/pref_desc__sub_logging"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
9
app/src/main/res/values/attrs.xml
Normal file
9
app/src/main/res/values/attrs.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<declare-styleable name="ThemedCheckBoxPreference">
|
||||||
|
<attr name="titleText" format="string" />
|
||||||
|
<attr name="summaryText" format="string" />
|
||||||
|
<attr name="prefKey" format="string" />
|
||||||
|
<attr name="defaultValue" format="boolean" />
|
||||||
|
</declare-styleable>
|
||||||
|
</resources>
|
Loading…
Reference in a new issue