Migrate settings to PreferenceFragmentCompat

Includes code from https://github.com/consp1racy/android-support-preference
License: Apache License v2.0
This commit is contained in:
str4d
2016-01-20 23:33:53 +00:00
parent e458853f34
commit 770d9ddc5f
12 changed files with 485 additions and 281 deletions

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="org.briarproject.android.fragment.SettingsFragment"/>
</FrameLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="boolean_array">
<item>true</item>
<item>false</item>
</string-array>
<string-array name="bt_setting_names">
<item>@string/bluetooth_setting_enabled</item>
<item>@string/bluetooth_setting_disabled</item>
</string-array>
<string-array name="tor_mobile_setting_names">
<item>@string/tor_mobile_setting_enabled</item>
<item>@string/tor_mobile_setting_disabled</item>
</string-array>
</resources>

View File

@@ -17,11 +17,12 @@
<color name="briar_primary">#2D3E50</color>
<color name="briar_primary_dark">#0f1720</color>
<color name="briar_accent">#2D3E50</color>
<color name="briar_accent_dark">#0f1720</color>
<color name="briar_text_link">#75ab0d</color>
<color name="briar_green_light">#95d220</color>
<color name="briar_green_dark">#75ab0d</color>
<color name="briar_text_primary">#333333</color>
<color name="briar_text_primary">#808080</color>
<color name="briar_text_primary_inverse">#ffffff</color>
<!-- this is needed as preference_category_material layout uses this color as the text color -->

View File

@@ -96,18 +96,17 @@
<item quantity="other">%d new forum posts.</item>
</plurals>
<string name="settings_title">Settings</string>
<string name="bluetooth_setting_title">BLUETOOTH</string>
<string name="network_settings_title">Networks</string>
<string name="bluetooth_setting">Connect via Bluetooth</string>
<string name="bluetooth_setting_enabled">Whenever contacts are nearby</string>
<string name="bluetooth_setting_disabled">Only when adding contacts</string>
<string name="tor_wifi_setting_title">TOR</string>
<string name="tor_wifi_setting">Connect via Tor</string>
<string name="tor_wifi_setting_enabled">Only when using Wi-Fi</string>
<string name="tor_wifi_setting_disabled">When using Wi-Fi or mobile data</string>
<string name="panic_setting">Panic Button Setup</string>
<string name="panic_setting_title">PANIC BUTTON</string>
<string name="tor_mobile_setting">Connect via Tor</string>
<string name="tor_mobile_setting_enabled">When using Wi-Fi or mobile data</string>
<string name="tor_mobile_setting_disabled">Only when using Wi-Fi</string>
<string name="panic_setting">Panic button setup</string>
<string name="panic_setting_title">Panic button</string>
<string name="panic_setting_hint">Configure how Briar will react when you use a panic button app</string>
<string name="notification_settings_title">NOTIFICATIONS</string>
<string name="notification_settings_title">Notifications</string>
<string name="notify_private_messages_setting">Show alerts for private messages</string>
<string name="notify_forum_posts_setting">Show alerts for forum posts</string>
<string name="notify_vibration_setting">Vibrate</string>

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/network_settings_title">
<ListPreference
android:defaultValue="false"
android:entries="@array/bt_setting_names"
android:entryValues="@array/boolean_array"
android:key="pref_key_bluetooth"
android:persistent="false"
android:summary="%s"
android:title="@string/bluetooth_setting"/>
<ListPreference
android:defaultValue="true"
android:entries="@array/tor_mobile_setting_names"
android:entryValues="@array/boolean_array"
android:key="pref_key_tor_mobile"
android:persistent="false"
android:summary="%s"
android:title="@string/tor_mobile_setting"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/panic_setting_title">
<Preference
android:summary="@string/panic_setting_hint"
android:title="@string/panic_setting">
<intent
android:targetClass="org.briarproject.android.panic.PanicPreferencesActivity"
android:targetPackage="org.briarproject"/>
</Preference>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/notification_settings_title">
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_key_notify_private_messages"
android:persistent="false"
android:title="@string/notify_private_messages_setting"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_key_notify_forum_posts"
android:persistent="false"
android:title="@string/notify_forum_posts_setting"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_key_notify_vibration"
android:persistent="false"
android:title="@string/notify_vibration_setting"/>
<Preference
android:key="pref_key_notify_sound"
android:title="@string/notify_sound_setting"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Debug">
<Preference
android:title="Debug information">
<intent
android:targetClass="org.briarproject.android.TestingActivity"
android:targetPackage="org.briarproject"/>
</Preference>
</PreferenceCategory>
</PreferenceScreen>