mirror of
https://github.com/gsantner/dandelion
synced 2024-11-25 22:02:08 +01:00
Add isLoadDesktopPage to Preferences, make SettingsActivity list changed settings in Intent
This commit is contained in:
parent
8996d4a73a
commit
8466c279bb
2 changed files with 20 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.github.dfa.diaspora_android.activity;
|
package com.github.dfa.diaspora_android.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
|
@ -7,6 +8,7 @@ import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
|
@ -17,12 +19,16 @@ import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
* @author vanitas
|
* @author vanitas
|
||||||
*/
|
*/
|
||||||
public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
|
private Intent settingsChangedIntent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||||
setEditTextPreferenceSummaries();
|
setEditTextPreferenceSummaries();
|
||||||
|
settingsChangedIntent = new Intent("SettingsChanged");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditTextPreferenceSummaries() {
|
private void setEditTextPreferenceSummaries() {
|
||||||
|
@ -36,7 +42,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
updatePreference(findPreference(key), key);
|
updatePreference(findPreference(key), key);
|
||||||
|
settingsChangedIntent.putExtra(key, true);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case AppSettings.PREF.MINIMUM_FONT_SIZE:
|
case AppSettings.PREF.MINIMUM_FONT_SIZE:
|
||||||
int newFontSize = Integer.parseInt(((ListPreference)findPreference(key)).getValue().substring(1));
|
int newFontSize = Integer.parseInt(((ListPreference)findPreference(key)).getValue().substring(1));
|
||||||
|
@ -57,4 +63,12 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
Log.d(App.TAG, "finish()"); //TODO: remove
|
||||||
|
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
|
||||||
|
broadcastManager.sendBroadcast(settingsChangedIntent);
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -70,6 +70,7 @@ public class AppSettings {
|
||||||
public static final String PODUSERPROFILE_ID = "podUserProfile_guid";
|
public static final String PODUSERPROFILE_ID = "podUserProfile_guid";
|
||||||
public static final String PODDOMAIN = "podDomain";
|
public static final String PODDOMAIN = "podDomain";
|
||||||
public static final String PODUSERPROFILE_ASPECTS = "podUserProfile_aspects";
|
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);
|
return prefApp.getBoolean(PREF.IS_LOAD_IMAGES, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLoadDesktopPage() {
|
||||||
|
return prefApp.getBoolean(PREF.IS_LOAD_DESKTOP_PAGE, false);
|
||||||
|
}
|
||||||
|
|
||||||
public int getMinimumFontSize() {
|
public int getMinimumFontSize() {
|
||||||
return prefApp.getInt(PREF.MINIMUM_FONT_SIZE, 8);
|
return prefApp.getInt(PREF.MINIMUM_FONT_SIZE, 8);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue