From 8466c279bb62e6c327cd914cb3eddf815988a32c Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Thu, 16 Jun 2016 21:18:42 +0200 Subject: [PATCH] Add isLoadDesktopPage to Preferences, make SettingsActivity list changed settings in Intent --- .../activity/SettingsActivity.java | 16 +++++++++++++++- .../dfa/diaspora_android/data/AppSettings.java | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 660ef3fa..27af6bd7 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,5 +1,6 @@ package com.github.dfa.diaspora_android.activity; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.EditTextPreference; @@ -7,6 +8,7 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; +import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import com.github.dfa.diaspora_android.App; @@ -17,12 +19,16 @@ import com.github.dfa.diaspora_android.data.AppSettings; * @author vanitas */ public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { + + private Intent settingsChangedIntent; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); setEditTextPreferenceSummaries(); + settingsChangedIntent = new Intent("SettingsChanged"); } private void setEditTextPreferenceSummaries() { @@ -36,7 +42,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { updatePreference(findPreference(key), key); - + settingsChangedIntent.putExtra(key, true); switch (key) { case AppSettings.PREF.MINIMUM_FONT_SIZE: int newFontSize = Integer.parseInt(((ListPreference)findPreference(key)).getValue().substring(1)); @@ -57,4 +63,12 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer return; } } + + @Override + public void finish() { + Log.d(App.TAG, "finish()"); //TODO: remove + LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this); + broadcastManager.sendBroadcast(settingsChangedIntent); + super.finish(); + } } \ No newline at end of file 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 4e763b88..b191a422 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 @@ -70,6 +70,7 @@ public class AppSettings { public static final String PODUSERPROFILE_ID = "podUserProfile_guid"; public static final String PODDOMAIN = "podDomain"; public static final String PODUSERPROFILE_ASPECTS = "podUserProfile_aspects"; + public static final String IS_LOAD_DESKTOP_PAGE = "pref_key_desktop_mode"; } @@ -89,6 +90,10 @@ public class AppSettings { return prefApp.getBoolean(PREF.IS_LOAD_IMAGES, true); } + public boolean isLoadDesktopPage() { + return prefApp.getBoolean(PREF.IS_LOAD_DESKTOP_PAGE, false); + } + public int getMinimumFontSize() { return prefApp.getInt(PREF.MINIMUM_FONT_SIZE, 8); }