mirror of
https://github.com/gsantner/dandelion
synced 2024-11-25 22:02:08 +01:00
Added some strings and started to integrate settingsActivity into the app
This commit is contained in:
parent
ec922f139f
commit
8996d4a73a
5 changed files with 38 additions and 19 deletions
|
@ -42,7 +42,7 @@
|
||||||
android:label="@string/diaspora">
|
android:label="@string/diaspora">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.github.dfa.diaspora_android.activity.SettingsActivity"
|
android:name=".activity.SettingsActivity"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:label="@string/jb_settings">
|
android:label="@string/jb_settings">
|
||||||
|
|
|
@ -6,8 +6,12 @@ import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
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.util.Log;
|
||||||
|
|
||||||
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author vanitas
|
* @author vanitas
|
||||||
|
@ -18,11 +22,26 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||||
|
setEditTextPreferenceSummaries();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEditTextPreferenceSummaries() {
|
||||||
|
String[] prefKeys = new String[]{"pref_key_proxy_host", "pref_key_proxy_port"};
|
||||||
|
for(String key : prefKeys) {
|
||||||
|
EditTextPreference p = (EditTextPreference) findPreference(key);
|
||||||
|
p.setSummary(p.getText());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
updatePreference(findPreference(key), key);
|
updatePreference(findPreference(key), key);
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case AppSettings.PREF.MINIMUM_FONT_SIZE:
|
||||||
|
int newFontSize = Integer.parseInt(((ListPreference)findPreference(key)).getValue().substring(1));
|
||||||
|
Log.d(App.TAG, newFontSize+"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePreference(Preference preference, String key) {
|
private void updatePreference(Preference preference, String key) {
|
||||||
|
|
|
@ -62,14 +62,14 @@ public class AppSettings {
|
||||||
// Preferences
|
// Preferences
|
||||||
*/
|
*/
|
||||||
public static class PREF {
|
public static class PREF {
|
||||||
private static final String PREVIOUS_PODLIST = "previousPodlist";
|
public static final String PREVIOUS_PODLIST = "previousPodlist";
|
||||||
private static final String IS_LOAD_IMAGES = "loadImages";
|
public static final String IS_LOAD_IMAGES = "pref_key_load_images";
|
||||||
private static final String MINIMUM_FONT_SIZE = "minimumFontSize";
|
public static final String MINIMUM_FONT_SIZE = "pref_key_font_size";
|
||||||
private static final String PODUSERPROFILE_AVATAR_URL = "podUserProfile_avatar";
|
public static final String PODUSERPROFILE_AVATAR_URL = "podUserProfile_avatar";
|
||||||
private static final String PODUSERPROFILE_NAME = "podUserProfile_name";
|
public static final String PODUSERPROFILE_NAME = "podUserProfile_name";
|
||||||
private static final String PODUSERPROFILE_ID = "podUserProfile_guid";
|
public static final String PODUSERPROFILE_ID = "podUserProfile_guid";
|
||||||
private static final String PODDOMAIN = "podDomain";
|
public static final String PODDOMAIN = "podDomain";
|
||||||
private static final String PODUSERPROFILE_ASPECTS = "podUserProfile_aspects";
|
public static final String PODUSERPROFILE_ASPECTS = "podUserProfile_aspects";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,11 +89,6 @@ public class AppSettings {
|
||||||
return prefApp.getBoolean(PREF.IS_LOAD_IMAGES, true);
|
return prefApp.getBoolean(PREF.IS_LOAD_IMAGES, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadImages(boolean loadImages) {
|
|
||||||
setBool(prefApp, PREF.IS_LOAD_IMAGES, loadImages);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getMinimumFontSize() {
|
public int getMinimumFontSize() {
|
||||||
return prefApp.getInt(PREF.MINIMUM_FONT_SIZE, 8);
|
return prefApp.getInt(PREF.MINIMUM_FONT_SIZE, 8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
<item>Large</item>
|
<item>Large</item>
|
||||||
<item>Huge</item>
|
<item>Huge</item>
|
||||||
</array>
|
</array>
|
||||||
|
<!-- prefix 's' is needed to make this a string array. Otherwise ListPreference would crash -->
|
||||||
<array name="pref_entry_values_font_size" translatable="false">
|
<array name="pref_entry_values_font_size" translatable="false">
|
||||||
<item>normal</item>
|
<item>s8</item>
|
||||||
<item>big</item>
|
<item>s16</item>
|
||||||
<item>huge</item>
|
<item>s20</item>
|
||||||
</array>
|
</array>
|
||||||
<!-- Mobile/Desktop view -->
|
<!-- Mobile/Desktop view -->
|
||||||
<string name="pref_title_desktop_view">Desktop mode</string>
|
<string name="pref_title_desktop_view">Desktop mode</string>
|
||||||
|
@ -23,10 +24,11 @@
|
||||||
|
|
||||||
<!-- Load images -->
|
<!-- Load images -->
|
||||||
<string name="pref_title_load_images">Load images</string>
|
<string name="pref_title_load_images">Load images</string>
|
||||||
<string name="pref_desc_load_images">You can disable image loading to safe mobile data</string>
|
<string name="pref_desc_load_images">Disable image loading to safe mobile data</string>
|
||||||
|
|
||||||
<!-- Proxy -->
|
<!-- Proxy -->
|
||||||
<string name="pref_title_proxy_enabled">Enable Proxy</string>
|
<string name="pref_title_proxy_enabled">Enable Proxy</string>
|
||||||
|
<string name="pref_desc_proxy_enabled">Proxy Diaspora\'s traffic to circumvent firewalls.\nMay require restart</string>
|
||||||
<string name="pref_title_proxy_host">Host</string>
|
<string name="pref_title_proxy_host">Host</string>
|
||||||
<string name="pref_title_proxy_port">Port</string>
|
<string name="pref_title_proxy_port">Port</string>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:title="@string/pref_title_font_size"
|
android:title="@string/pref_title_font_size"
|
||||||
android:key="pref_key_font_size"
|
android:key="pref_key_font_size"
|
||||||
|
android:summary="%s"
|
||||||
android:dialogTitle="@string/pref_title_font_size"
|
android:dialogTitle="@string/pref_title_font_size"
|
||||||
android:entries="@array/pref_entries_font_size"
|
android:entries="@array/pref_entries_font_size"
|
||||||
android:entryValues="@array/pref_entry_values_font_size" />
|
android:entryValues="@array/pref_entry_values_font_size" />
|
||||||
|
@ -28,11 +29,13 @@
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/pref_title_proxy_enabled"
|
android:title="@string/pref_title_proxy_enabled"
|
||||||
android:key="pref_key_proxy_enabled"
|
android:key="pref_key_proxy_enabled"
|
||||||
|
android:summary="@string/pref_desc_proxy_enabled"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_title_proxy_host"
|
android:title="@string/pref_title_proxy_host"
|
||||||
android:key="pref_key_proxy_host"
|
android:key="pref_key_proxy_host"
|
||||||
android:dependency="pref_key_proxy_enabled" />
|
android:dependency="pref_key_proxy_enabled"
|
||||||
|
android:inputType="textNoSuggestions"/>
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_title_proxy_port"
|
android:title="@string/pref_title_proxy_port"
|
||||||
android:key="pref_key_proxy_port"
|
android:key="pref_key_proxy_port"
|
||||||
|
|
Loading…
Reference in a new issue