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

Added first design of a SettingsActivity

This commit is contained in:
vanitasvitae 2016-06-09 22:21:49 +02:00
parent cb3fc08df6
commit ec922f139f
5 changed files with 126 additions and 1 deletions

View file

@ -41,6 +41,12 @@
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.NoActionBar"
android:label="@string/diaspora"> android:label="@string/diaspora">
</activity> </activity>
<activity
android:name="com.github.dfa.diaspora_android.activity.SettingsActivity"
android:launchMode="singleInstance"
android:theme="@style/AppTheme"
android:label="@string/jb_settings">
</activity>
<activity <activity
android:name="com.github.dfa.diaspora_android.activity.ShareActivity" android:name="com.github.dfa.diaspora_android.activity.ShareActivity"

View file

@ -945,6 +945,7 @@ public class MainActivity extends AppCompatActivity
break; break;
case R.id.nav_settings_app: { case R.id.nav_settings_app: {
/*
final CharSequence[] options = {getString(R.string.settings_font), getString(R.string.settings_view), appSettings.isLoadImages() ? final CharSequence[] options = {getString(R.string.settings_font), getString(R.string.settings_view), appSettings.isLoadImages() ?
getString(R.string.settings_images_switch_off) : getString(R.string.settings_images_switch_on), getString(R.string.jb_pod)}; getString(R.string.settings_images_switch_off) : getString(R.string.settings_images_switch_on), getString(R.string.jb_pod)};
@ -984,7 +985,8 @@ public class MainActivity extends AppCompatActivity
}).show(); }).show();
} else { } else {
Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show(); Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
} } */
startActivity(new Intent(this, SettingsActivity.class));
} }
break; break;

View file

@ -0,0 +1,41 @@
package com.github.dfa.diaspora_android.activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import com.github.dfa.diaspora_android.R;
/**
* @author vanitas
*/
public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
updatePreference(findPreference(key), key);
}
private void updatePreference(Preference preference, String key) {
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());
return;
}
}
}

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Categories -->
<string name="pref_category_visuals">Look and Feel</string>
<string name="pref_category_network">Network</string>
<!-- Visuals -->
<!-- Font size -->
<string name="pref_title_font_size">Font size</string>
<array name="pref_entries_font_size">
<item>Normal</item>
<item>Large</item>
<item>Huge</item>
</array>
<array name="pref_entry_values_font_size" translatable="false">
<item>normal</item>
<item>big</item>
<item>huge</item>
</array>
<!-- Mobile/Desktop view -->
<string name="pref_title_desktop_view">Desktop mode</string>
<string name="pref_desc_desktop_view">Load full desktop site instead of mobile view</string>
<!-- Load images -->
<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>
<!-- Proxy -->
<string name="pref_title_proxy_enabled">Enable Proxy</string>
<string name="pref_title_proxy_host">Host</string>
<string name="pref_title_proxy_port">Port</string>
</resources>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/pref_category_visuals"
android:key="pref_key_category_visuals">
<ListPreference
android:title="@string/pref_title_font_size"
android:key="pref_key_font_size"
android:dialogTitle="@string/pref_title_font_size"
android:entries="@array/pref_entries_font_size"
android:entryValues="@array/pref_entry_values_font_size" />
<CheckBoxPreference
android:title="@string/pref_title_desktop_view"
android:summary="@string/pref_desc_desktop_view"
android:key="pref_key_desktop_mode"
android:defaultValue="false"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_category_network"
android:key="pref_key_category_network">
<CheckBoxPreference
android:title="@string/pref_title_load_images"
android:key="pref_key_load_images"
android:summary="@string/pref_desc_load_images"
android:defaultValue="true" />
<CheckBoxPreference
android:title="@string/pref_title_proxy_enabled"
android:key="pref_key_proxy_enabled"
android:defaultValue="false" />
<EditTextPreference
android:title="@string/pref_title_proxy_host"
android:key="pref_key_proxy_host"
android:dependency="pref_key_proxy_enabled" />
<EditTextPreference
android:title="@string/pref_title_proxy_port"
android:key="pref_key_proxy_port"
android:dependency="pref_key_proxy_enabled"
android:inputType="number" />
</PreferenceCategory>
</PreferenceScreen>