diff --git a/app/src/main/java/com/github/dfa/diaspora_android/App.java b/app/src/main/java/com/github/dfa/diaspora_android/App.java
index 0453e4fe..7ca0115f 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/App.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/App.java
@@ -76,7 +76,7 @@ public class App extends Application {
// Clear avatar image
new AvatarImageLoader(this).clearAvatarImage();
- // Clear preferences
+ // Clear preferences__master
appSettings.clearPodSettings();
// Clear cookies
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java
index 85c4dd32..48a00d90 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java
@@ -174,7 +174,7 @@ public class AboutActivity extends ThemedActivity
@Override
protected void applyColorToViews() {
- ThemeHelper.updateTextViewColor(aboutText);
+ ThemeHelper.updateTextViewLinkColor(aboutText);
}
@Override
@@ -258,8 +258,8 @@ public class AboutActivity extends ThemedActivity
@Override
protected void applyColorToViews() {
- ThemeHelper.updateTextViewColor(textLicense3partyBox);
- ThemeHelper.updateTextViewColor(textLicenseBox);
+ ThemeHelper.updateTextViewLinkColor(textLicense3partyBox);
+ ThemeHelper.updateTextViewLinkColor(textLicenseBox);
}
@Override
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java
index dd0032d7..74ef19ee 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java
@@ -1,21 +1,8 @@
-/*
- This file is part of the Diaspora for Android.
- Diaspora for Android is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- Diaspora for Android is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with the Diaspora for Android.
- If not, see .
- */
package com.github.dfa.diaspora_android.activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
+import android.app.FragmentTransaction;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
@@ -23,24 +10,20 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
-import android.preference.EditTextPreference;
-import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
-import android.view.MenuItem;
import android.view.View;
-import android.view.Window;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
-import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener;
+import com.github.dfa.diaspora_android.fragment.ThemedPreferenceFragment;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.ProxyHandler;
@@ -53,9 +36,13 @@ import uz.shift.colorpicker.LineColorPicker;
import uz.shift.colorpicker.OnColorChangedListener;
/**
- * @author vanitas
+ * SettingsActivity
+ * Created by vanitas on 24.10.16.
*/
-public class SettingsActivity extends ThemedActivity implements IntellihideToolbarActivityListener {
+
+public class SettingsActivity extends ThemedActivity {
+
+ //Toolbar
@BindView(R.id.settings__appbar)
protected AppBarLayout appBarLayout;
@@ -64,13 +51,13 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
private ProxyHandler.ProxySettings oldProxySettings;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public void onCreate(Bundle b) {
+ super.onCreate(b);
setContentView(R.layout.settings__activity);
ButterKnife.bind(this);
+ toolbar.setTitle(R.string.settings);
setSupportActionBar(toolbar);
+
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
@@ -78,139 +65,131 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
SettingsActivity.this.onBackPressed();
}
});
+
oldProxySettings = getAppSettings().getProxySettings();
- getFragmentManager().beginTransaction().replace(R.id.settings__fragment_container, new SettingsFragment()).commit();
+ showFragment(SettingsFragmentMaster.TAG, false);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- switch (menuItem.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(menuItem);
+ protected void showFragment(String tag, boolean addToBackStack) {
+ PreferenceFragment fragment = (PreferenceFragment) getFragmentManager().findFragmentByTag(tag);
+ if(fragment == null) {
+ switch (tag) {
+ case SettingsFragmentThemes.TAG:
+ fragment = new SettingsFragmentThemes();
+ break;
+ case SettingsFragmentNavSlider.TAG:
+ fragment = new SettingsFragmentNavSlider();
+ break;
+ case SettingsFragmentProxy.TAG:
+ fragment = new SettingsFragmentProxy();
+ break;
+ case SettingsFragmentDebugging.TAG:
+ fragment = new SettingsFragmentDebugging();
+ break;
+ case SettingsFragmentMaster.TAG:
+ default:
+ fragment = new SettingsFragmentMaster();
+ break;
+ }
}
+ FragmentTransaction t = getFragmentManager().beginTransaction();
+ if(addToBackStack) {
+ t.addToBackStack(tag);
+ }
+ t.replace(R.id.settings__fragment_container, fragment, tag).commit();
}
@Override
- protected void applyColorToViews() {
+ public void applyColorToViews() {
+ //Toolbar
ThemeHelper.updateToolbarColor(toolbar);
}
@Override
- public void enableToolbarHiding() {
- AppLog.d(this, "Enable Intellihide");
- AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
- //scroll|enterAlways|snap
- params.setScrollFlags(toolbarDefaultScrollFlags);
- appBarLayout.setExpanded(true, true);
+ protected void onStop() {
+ ProxyHandler.ProxySettings newProxySettings = getAppSettings().getProxySettings();
+ if (!oldProxySettings.equals(newProxySettings)) {
+ AppLog.d(this, "ProxySettings changed.");
+ //Proxy on-off? => Restart app
+ if (oldProxySettings.isEnabled() && !newProxySettings.isEnabled()) {
+ AppLog.d(this, "Proxy deactivated. Restarting app...");
+ Intent restartActivity = new Intent(SettingsActivity.this, MainActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(SettingsActivity.this, 12374, restartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
+ AlarmManager mgr = (AlarmManager) SettingsActivity.this.getSystemService(Context.ALARM_SERVICE);
+ mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent);
+ System.exit(0);
+ } //Proxy changed? => Update
+ else {
+ ProxyHandler.getInstance().updateProxySettings(this);
+ }
+ }
+ super.onStop();
}
- @Override
- public void disableToolbarHiding() {
- AppLog.d(this, "Disable Intellihide");
- AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
- params.setScrollFlags(0); // clear all scroll flags
- appBarLayout.setExpanded(true, true);
- }
-
- public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
- private SharedPreferences sharedPreferences;
+ public static class SettingsFragmentMaster extends ThemedPreferenceFragment {
+ public static final String TAG = "com.github.dfa.diaspora_android.settings.SettingsFragmentMaster";
public void onCreate(Bundle savedInstances) {
super.onCreate(savedInstances);
getPreferenceManager().setSharedPreferencesName("app");
- addPreferencesFromResource(R.xml.preferences);
- sharedPreferences = getPreferenceScreen().getSharedPreferences();
- sharedPreferences.registerOnSharedPreferenceChangeListener(this);
- setPreferenceSummaries();
- sharedPreferences.edit().putBoolean(getString(R.string.pref_key__proxy_was_enabled),
- sharedPreferences.getBoolean(getString(R.string.pref_key__http_proxy_enabled), false)).apply();
- }
-
- private void setPreferenceSummaries() {
- String[] editTextKeys = new String[]{
- getString(R.string.pref_key__http_proxy_host), getString(R.string.pref_key__http_proxy_port)
- };
- for (String key : editTextKeys) {
- EditTextPreference p = (EditTextPreference) findPreference(key);
- p.setSummary(p.getText());
- }
+ addPreferencesFromResource(R.xml.preferences__master);
}
@Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- updatePreference(findPreference(key));
- if(isAdded()) {
- if (key.equals(getString(R.string.pref_key__intellihide_toolbars))) {
- if (sharedPreferences.getBoolean(getString(R.string.pref_key__intellihide_toolbars), false)) {
- ((SettingsActivity) getActivity()).enableToolbarHiding();
- } else {
- ((SettingsActivity) getActivity()).disableToolbarHiding();
- }
- }
- }
- }
+ public void updateViewColors() {
- private void updatePreference(Preference preference) {
- if (preference == null) {
- return;
- }
- if (preference instanceof EditTextPreference) {
- EditTextPreference textPref = (EditTextPreference) preference;
- textPref.setSummary(textPref.getText());
- return;
- }
- if (preference instanceof ListPreference) {
- ListPreference listPref = (ListPreference) preference;
- listPref.setSummary(listPref.getEntry());
- }
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
- App app = ((App) getActivity().getApplication());
- AppSettings appSettings = app.getSettings();
- if (Build.VERSION.SDK_INT >= 21) {
- if (preference instanceof PreferenceScreen && ((PreferenceScreen) preference).getDialog() != null) {
- Window window = ((PreferenceScreen) preference).getDialog().getWindow();
- if (window != null) {
- window.setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
- }
+ if(isAdded() && preference.hasKey()) {
+ DiasporaUrlHelper diasporaUrlHelper = new DiasporaUrlHelper(((App)getActivity().getApplication()).getSettings());
+ String key = preference.getKey();
+ /** Sub-Categories */
+ if(key.equals(getString(R.string.pref_key__cat_themes))) {
+ ((SettingsActivity) getActivity()).showFragment(SettingsFragmentThemes.TAG, true);
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__cat_nav_slider))) {
+ ((SettingsActivity) getActivity()).showFragment(SettingsFragmentNavSlider.TAG, true);
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__cat_proxy))) {
+ ((SettingsActivity)getActivity()).showFragment(SettingsFragmentProxy.TAG, true);
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__cat_debugging))) {
+ ((SettingsActivity)getActivity()).showFragment(SettingsFragmentDebugging.TAG, true);
+ return true;
}
- }
-
- Intent intent = new Intent(getActivity(), MainActivity.class);
- DiasporaUrlHelper diasporaUrlHelper = new DiasporaUrlHelper(app.getSettings());
-
- switch (preference.getTitleRes()) {
- case R.string.pref_title__primary_color: {
- showColorPickerDialog(1);
- intent = null;
- break;
+ /** Network */
+ else if (key.equals(getString(R.string.pref_key__clear_cache))) {
+ Intent intent = new Intent(getActivity(), MainActivity.class);
+ intent.setAction(MainActivity.ACTION_CLEAR_CACHE);
+ startActivity(intent);
+ getActivity().finish();
+ return true;
}
- case R.string.pref_title__accent_color: {
- showColorPickerDialog(2);
- intent = null;
- break;
- }
- case R.string.pref_title__personal_settings: {
+ /** Pod Settings */
+ if (key.equals(getString(R.string.pref_key__personal_settings))) {
+ Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getPersonalSettingsUrl());
- break;
- }
- case R.string.pref_title__manage_tags: {
+ startActivity(intent);
+ getActivity().finish();
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__manage_tags))) {
+ Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getManageTagsUrl());
- break;
- }
- case R.string.pref_title__manage_contacts: {
+ startActivity(intent);
+ getActivity().finish();
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__manage_contacts))) {
+ Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getManageContactsUrl());
- break;
- }
- case R.string.pref_title__change_account: {
+ startActivity(intent);
+ getActivity().finish();
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__change_account))) {
new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.confirmation))
.setMessage(getString(R.string.pref_warning__change_account))
@@ -226,27 +205,42 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
})
.show();
return true;
- }
- case R.string.pref_title__http_proxy_load_tor_preset: {
- ((EditTextPreference) findPreference(getString(R.string.pref_key__http_proxy_host))).setText("127.0.0.1");
- ((EditTextPreference) findPreference(getString(R.string.pref_key__http_proxy_port))).setText("8118");
- return true;
- }
- case R.string.pref_title__clear_cache: {
- intent.setAction(MainActivity.ACTION_CLEAR_CACHE);
- break;
- }
-
- default: {
- intent = null;
- break;
}
}
- if (intent != null) {
- startActivity(intent);
- getActivity().finish();
- return true;
+ return super.onPreferenceTreeClick(screen, preference);
+ }
+ }
+
+ public static class SettingsFragmentThemes extends ThemedPreferenceFragment {
+ public static final String TAG = "com.github.dfa.diaspora_android.settings.SettingsFragmentThemes";
+
+ public void onCreate(Bundle savedInstances) {
+ super.onCreate(savedInstances);
+ getPreferenceManager().setSharedPreferencesName("app");
+ addPreferencesFromResource(R.xml.preferences__sub_themes);
+ }
+
+ @Override
+ public void updateViewColors() {
+ if(isAdded()) {
+ //Trigger redraw of whole preference screen in order to reflect changes
+ setPreferenceScreen(null);
+ addPreferencesFromResource(R.xml.preferences__sub_themes);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
+ if (isAdded() && preference.hasKey()) {
+ String key = preference.getKey();
+ if(key.equals(getString(R.string.pref_key__primary_color__preference_click))) {
+ showColorPickerDialog(1);
+ return true;
+ } else if (key.equals(getString(R.string.pref_key__accent_color__preference_click))) {
+ showColorPickerDialog(2);
+ return true;
+ }
}
return super.onPreferenceTreeClick(screen, preference);
}
@@ -282,12 +276,13 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
base.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
- AppLog.d(this, "Selected Base color changed: " + i);
shade.setColors(ColorPalette.getColors(context, i));
titleBackground.setBackgroundColor(i);
if (i == current[0]) {
shade.setSelectedColor(current[1]);
titleBackground.setBackgroundColor(shade.getColor());
+ } else {
+ shade.setSelectedColor(i);
}
}
});
@@ -313,38 +308,94 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
} else {
appSettings.setAccentColorSettings(base.getColor(), shade.getColor());
}
+ updateViewColors();
}
}).show();
}
}
- @Override
- protected void onPause() {
- super.onPause();
+ public static class SettingsFragmentNavSlider extends ThemedPreferenceFragment {
+ public static final String TAG = "com.github.dfa.diaspora_android.settings.SettingsFragmentNavSlider";
- // Reset logging
- AppSettings settings = new AppSettings(getApplicationContext());
- AppLog.setLoggingEnabled(settings.isLoggingEnabled());
- AppLog.setLoggingSpamEnabled(settings.isLoggingSpamEnabled());
+ public void onCreate(Bundle savedInstances) {
+ super.onCreate(savedInstances);
+ getPreferenceManager().setSharedPreferencesName("app");
+ addPreferencesFromResource(R.xml.preferences__sub_navslider_vis);
+ }
+
+ @Override
+ public void updateViewColors() {
+
+ }
}
- @Override
- protected void onStop() {
- ProxyHandler.ProxySettings newProxySettings = getAppSettings().getProxySettings();
- if (!oldProxySettings.equals(newProxySettings)) {
- AppLog.d(this, "ProxySettings changed.");
- //Proxy on-off? => Restart app
- if (oldProxySettings.isEnabled() && !newProxySettings.isEnabled()) {
- Intent restartActivity = new Intent(SettingsActivity.this, MainActivity.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(SettingsActivity.this, 12374, restartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
- AlarmManager mgr = (AlarmManager) SettingsActivity.this.getSystemService(Context.ALARM_SERVICE);
- mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent);
- System.exit(0);
- } //Proxy changed? => Update
- else {
- ProxyHandler.getInstance().updateProxySettings(this);
+ public static class SettingsFragmentProxy extends ThemedPreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
+ public static final String TAG = "com.github.dfa.diaspora_android.settings.SettingsFragmentProxy";
+
+ public void onCreate(Bundle savedInstances) {
+ super.onCreate(savedInstances);
+ getPreferenceManager().setSharedPreferencesName("app");
+ addPreferencesFromResource(R.xml.preferences__sub_proxy);
+ SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+ sharedPreferences.registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle bundle) {
+ super.onActivityCreated(bundle);
+ updateSummaries();
+ }
+
+ public void updateSummaries() {
+ if(isAdded()) {
+ AppSettings appSettings = ((App) getActivity().getApplication()).getSettings();
+ findPreference(getString(R.string.pref_key__http_proxy_host)).setSummary(appSettings.getProxyHttpHost());
+ findPreference(getString(R.string.pref_key__http_proxy_port)).setSummary(Integer.toString(appSettings.getProxyHttpPort()));
}
}
- super.onStop();
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
+ if (isAdded() && preference.hasKey()) {
+ AppSettings appSettings = ((App) getActivity().getApplication()).getSettings();
+ String key = preference.getKey();
+ if(key.equals(getString(R.string.pref_key__http_proxy_load_tor_preset))) {
+ appSettings.setProxyHttpHost("127.0.0.1");
+ appSettings.setProxyHttpPort(8118);
+ return true;
+ }
+ }
+ return super.onPreferenceTreeClick(screen, preference);
+ }
+
+ @Override
+ public void updateViewColors() {
+
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
+ if(isAdded()) {
+ if (s.equals(getString(R.string.pref_key__http_proxy_host)) ||
+ s.equals(getString(R.string.pref_key__http_proxy_port))) {
+ updateSummaries();
+ }
+ }
+ }
+ }
+
+ public static class SettingsFragmentDebugging extends ThemedPreferenceFragment {
+ public static final String TAG = "com.github.dfa.diaspora_android.settings.SettingsFragmentDebugging";
+
+ public void onCreate(Bundle savedInstances) {
+ super.onCreate(savedInstances);
+ getPreferenceManager().setSharedPreferencesName("app");
+ addPreferencesFromResource(R.xml.preferences__sub_debugging);
+ }
+
+ @Override
+ public void updateViewColors() {
+
+ }
}
}
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 bc724cd8..5117b16a 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
@@ -379,4 +379,8 @@ public class AppSettings {
public boolean isExtendedNotificationsActivated() {
return getBoolean(prefApp, R.string.pref_key__extended_notifications, false);
}
+
+ public int getColor(String key) {
+ return prefApp.getInt(key, context.getResources().getColor(R.color.primary));
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/ThemedPreferenceFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/ThemedPreferenceFragment.java
new file mode 100644
index 00000000..dd348abb
--- /dev/null
+++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/ThemedPreferenceFragment.java
@@ -0,0 +1,42 @@
+package com.github.dfa.diaspora_android.fragment;
+
+import android.os.Build;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
+import android.view.Window;
+
+import com.github.dfa.diaspora_android.App;
+import com.github.dfa.diaspora_android.data.AppSettings;
+import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
+
+/**
+ * Created by vanitas on 24.10.16.
+ */
+
+public abstract class ThemedPreferenceFragment extends PreferenceFragment {
+ public abstract void updateViewColors();
+ @Override
+ public void onResume() {
+ super.onResume();
+ updateViewColors();
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
+ if(isAdded()) {
+ App app = ((App) getActivity().getApplication());
+ AppSettings appSettings = app.getSettings();
+ if (Build.VERSION.SDK_INT >= 21) {
+ if (preference instanceof PreferenceScreen && ((PreferenceScreen) preference).getDialog() != null) {
+ Window window = ((PreferenceScreen) preference).getDialog().getWindow();
+ if (window != null) {
+ ThemeHelper.getInstance(appSettings);
+ window.setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
+ }
+ }
+ }
+ }
+ return super.onPreferenceTreeClick(screen, preference);
+ }
+}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/Themeable.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/Themeable.java
new file mode 100644
index 00000000..8d8db6fe
--- /dev/null
+++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/Themeable.java
@@ -0,0 +1,10 @@
+package com.github.dfa.diaspora_android.ui;
+
+/**
+ * Interface that allows setting Theme colors
+ * Created by vanitas on 24.10.16.
+ */
+
+public interface Themeable {
+ void setColors();
+}
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..9c042dd1
--- /dev/null
+++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java
@@ -0,0 +1,45 @@
+package com.github.dfa.diaspora_android.ui;
+
+import android.content.Context;
+import android.preference.CheckBoxPreference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+
+import com.github.dfa.diaspora_android.data.AppSettings;
+import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
+
+/**
+ * Created by vanitas on 24.10.16.
+ */
+
+public class ThemedCheckBoxPreference extends CheckBoxPreference implements Themeable {
+ protected View rootLayout;
+ @SuppressWarnings("unused")
+ public ThemedCheckBoxPreference(Context context) {
+ super(context);
+ }
+ @SuppressWarnings("unused")
+ public ThemedCheckBoxPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ @SuppressWarnings("unused")
+ public ThemedCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected View onCreateView(ViewGroup parent) {
+ rootLayout = super.onCreateView(parent);
+ setColors();
+ return rootLayout;
+ }
+
+ @Override
+ public void setColors() {
+ CheckBox checkBox = (CheckBox) rootLayout.findViewById(android.R.id.checkbox);
+ ThemeHelper.getInstance(new AppSettings(getContext()));
+ ThemeHelper.updateCheckBoxColor(checkBox);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedColorPickerPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedColorPickerPreference.java
new file mode 100644
index 00000000..90861128
--- /dev/null
+++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedColorPickerPreference.java
@@ -0,0 +1,50 @@
+package com.github.dfa.diaspora_android.ui;
+
+import android.content.Context;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.ImageView;
+
+import com.github.dfa.diaspora_android.data.AppSettings;
+
+/**
+ * Preference that shows selected Color in a circle
+ * Created by vanitas on 25.10.16.
+ */
+
+public class ThemedColorPickerPreference extends Preference implements Themeable {
+ protected ImageView colorPreview;
+ @SuppressWarnings("unused")
+ public ThemedColorPickerPreference(Context context) {
+ super(context);
+ }
+ @SuppressWarnings("unused")
+ public ThemedColorPickerPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ @SuppressWarnings("unused")
+ public ThemedColorPickerPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ colorPreview = (ImageView) view.findViewById(android.R.id.icon);
+ setColors();
+ }
+
+ @Override
+ public void setColors() {
+ AppSettings appSettings = new AppSettings(getContext());
+ if(colorPreview != null) {
+ Drawable circle = colorPreview.getDrawable();
+ if(circle != null) {
+ circle.setColorFilter(appSettings.getColor(getKey()), PorterDuff.Mode.SRC_ATOP);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceCategory.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceCategory.java
new file mode 100644
index 00000000..4ec8cb04
--- /dev/null
+++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceCategory.java
@@ -0,0 +1,49 @@
+package com.github.dfa.diaspora_android.ui;
+
+import android.content.Context;
+import android.preference.PreferenceCategory;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.github.dfa.diaspora_android.data.AppSettings;
+import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
+
+/**
+ * PreferenceCategory with a colored title
+ * Created by vanitas on 24.10.16.
+ */
+
+public class ThemedPreferenceCategory extends PreferenceCategory implements Themeable {
+ protected TextView titleTextView;
+ @SuppressWarnings("unused")
+ public ThemedPreferenceCategory(Context context) {
+ super(context);
+ }
+ @SuppressWarnings("unused")
+ public ThemedPreferenceCategory(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ @SuppressWarnings("unused")
+ public ThemedPreferenceCategory(Context context, AttributeSet attrs,
+ int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected View onCreateView(ViewGroup parent) {
+ View rootLayout = super.onCreateView(parent);
+ this.titleTextView = (TextView) rootLayout.findViewById(android.R.id.title);
+ setColors();
+ return rootLayout;
+ }
+
+ @Override
+ public void setColors() {
+ if(titleTextView != null) {
+ ThemeHelper.getInstance(new AppSettings(getContext()));
+ ThemeHelper.updateTextViewTextColor(titleTextView);
+ }
+ }
+}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java
index ff451e6c..3f5737f0 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java
@@ -22,12 +22,10 @@ package com.github.dfa.diaspora_android.util.theming;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
-import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.CompoundButtonCompat;
-import android.support.v7.app.ActionBar;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.view.View;
@@ -91,13 +89,19 @@ public class ThemeHelper {
}
}
- public static void updateTextViewColor(TextView textView) {
+ public static void updateTextViewLinkColor(TextView textView) {
if (textView != null) {
textView.setHighlightColor(getInstance().appSettings.getAccentColor());
textView.setLinkTextColor(getInstance().appSettings.getAccentColor());
}
}
+ public static void updateTextViewTextColor(TextView textView) {
+ if(textView != null) {
+ textView.setTextColor(getInstance().appSettings.getAccentColor());
+ }
+ }
+
public static void updateToolbarColor(Toolbar toolbar) {
if (toolbar != null) {
toolbar.setBackgroundColor(getInstance().appSettings.getPrimaryColor());
@@ -128,12 +132,6 @@ public class ThemeHelper {
return ColorPalette.getObscuredColor(getPrimaryColor());
}
- public static void updateActionBarColor(ActionBar actionBar) {
- if (actionBar != null) {
- actionBar.setBackgroundDrawable(new ColorDrawable(getInstance().appSettings.getPrimaryColor()));
- }
- }
-
public static void updateProgressBarColor(ProgressBar progressBar) {
if (progressBar != null && progressBar.getProgressDrawable() != null) {
progressBar.getProgressDrawable().setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN);
diff --git a/app/src/main/res/drawable/circle.xml b/app/src/main/res/drawable/circle.xml
new file mode 100644
index 00000000..eeadfaf0
--- /dev/null
+++ b/app/src/main/res/drawable/circle.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/settings__activity.xml b/app/src/main/res/layout/settings__activity.xml
index 99cd2afe..129bb787 100644
--- a/app/src/main/res/layout/settings__activity.xml
+++ b/app/src/main/res/layout/settings__activity.xml
@@ -22,7 +22,7 @@
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 35131109..cebddacb 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -15,4 +15,5 @@
11sp
+ 30dp
diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml
index dafbf2ff..f2528001 100644
--- a/app/src/main/res/values/strings-preferences.xml
+++ b/app/src/main/res/values/strings-preferences.xml
@@ -19,10 +19,10 @@
pref_key__extended_notifications
- pref_key_primary_color
+ @string/pref_key__primary_color_shade
pref_key_primary_color_base
pref_key_primary_color_shade
- pref_key_accent_color
+ @string/pref_key__accent_color_shade
pref_key_accent_color_base
pref_key_accent_color_shade
@@ -151,4 +151,18 @@
+
+ pref_key__title__appearance
+ pref_key__title__pod_settings
+ pref_key__title__network
+ pref_key__title__more
+ pref_key__title__debugging
+ pref_key__title__visibility_nav
+ pref_key__title__proxy
+ pref_key__title__themes
+
+ pref_key__cat_themes
+ pref_key__cat_nav_slider
+ pref_key__cat_proxy
+ pref_key__cat_debugging
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
deleted file mode 100644
index 4effd044..00000000
--- a/app/src/main/res/xml/preferences.xml
+++ /dev/null
@@ -1,205 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences__master.xml b/app/src/main/res/xml/preferences__master.xml
new file mode 100644
index 00000000..c6354445
--- /dev/null
+++ b/app/src/main/res/xml/preferences__master.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences__sub_debugging.xml b/app/src/main/res/xml/preferences__sub_debugging.xml
new file mode 100644
index 00000000..63414f8e
--- /dev/null
+++ b/app/src/main/res/xml/preferences__sub_debugging.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences__sub_navslider_vis.xml b/app/src/main/res/xml/preferences__sub_navslider_vis.xml
new file mode 100644
index 00000000..3a69f964
--- /dev/null
+++ b/app/src/main/res/xml/preferences__sub_navslider_vis.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences__sub_proxy.xml b/app/src/main/res/xml/preferences__sub_proxy.xml
new file mode 100644
index 00000000..72933d28
--- /dev/null
+++ b/app/src/main/res/xml/preferences__sub_proxy.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/xml/preferences__sub_themes.xml b/app/src/main/res/xml/preferences__sub_themes.xml
new file mode 100644
index 00000000..88e05d59
--- /dev/null
+++ b/app/src/main/res/xml/preferences__sub_themes.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file