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

Add isLoadDesktopPage to Preferences, make SettingsActivity list changed settings in Intent

This commit is contained in:
vanitasvitae 2016-06-16 21:18:42 +02:00
parent 8996d4a73a
commit 8466c279bb
2 changed files with 20 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -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);
}