refactor preferences into multiple PreferenceFragments
parent
8149af22ec
commit
2f6cefca8a
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item android:state_enabled="false" android:color="@color/gray50"/>
|
||||||
|
<item android:color="@color/gray5"/>
|
||||||
|
</selector>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item android:state_enabled="false" android:color="@color/gray27"/>
|
||||||
|
<item android:color="@color/gray95"/>
|
||||||
|
</selector>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item android:state_enabled="false" android:color="@color/gray50"/>
|
||||||
|
<item android:color="@color/gray13"/>
|
||||||
|
</selector>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item android:state_enabled="false" android:color="@color/gray27"/>
|
||||||
|
<item android:color="@color/gray50"/>
|
||||||
|
</selector>
|
@ -1,177 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceCategory android:key="push_sms_category" android:title="@string/preferences__push_sms_category">
|
|
||||||
<CheckBoxPreference android:defaultValue="false"
|
|
||||||
android:key="pref_toggle_push_messaging"
|
|
||||||
android:title="@string/preferences__use_data_channel"
|
|
||||||
android:summary="@string/preferences__use_the_data_channel_for_communication_with_other_textsecure_users"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference android:defaultValue="true"
|
|
||||||
android:key="pref_all_sms"
|
|
||||||
android:summary="@string/preferences__use_textsecure_for_viewing_and_storing_all_incoming_text_messages"
|
|
||||||
android:title="@string/preferences__pref_all_sms_title" />
|
|
||||||
|
|
||||||
<CheckBoxPreference android:defaultValue="true"
|
|
||||||
android:key="pref_all_mms"
|
|
||||||
android:summary="@string/preferences__use_textsecure_for_viewing_and_storing_all_incoming_multimedia_messages"
|
|
||||||
android:title="@string/preferences__pref_all_mms_title" />
|
|
||||||
|
|
||||||
<Preference android:key="pref_set_default"
|
|
||||||
android:title="@string/preferences__make_default_sms_app"
|
|
||||||
android:summary="@string/preferences__make_textsecure_the_default_sms_mms_app" />
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.OutgoingSmsPreference
|
|
||||||
android:key="pref_outgoing_sms"
|
|
||||||
android:title="@string/preferences__allow_sms_fallback" />
|
|
||||||
|
|
||||||
<CheckBoxPreference android:defaultValue="false"
|
|
||||||
android:key="pref_delivery_report_sms"
|
|
||||||
android:summary="@string/preferences__request_a_delivery_report_for_each_sms_message_you_send"
|
|
||||||
android:title="@string/preferences__sms_delivery_reports" />
|
|
||||||
</PreferenceCategory>
|
|
||||||
<PreferenceCategory android:title="@string/preferences__notifications">
|
|
||||||
<CheckBoxPreference android:key="pref_key_enable_notifications"
|
|
||||||
android:title="@string/preferences__notifications"
|
|
||||||
android:summary="@string/preferences__display_message_notifications_in_status_bar"
|
|
||||||
android:defaultValue="true" />
|
|
||||||
<ListPreference
|
|
||||||
android:key="pref_led_color"
|
|
||||||
android:defaultValue="green"
|
|
||||||
android:title="@string/preferences__led_color"
|
|
||||||
android:dependency="pref_key_enable_notifications"
|
|
||||||
android:entries="@array/pref_led_color_entries"
|
|
||||||
android:entryValues="@array/pref_led_color_values" />
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.preferences.LedBlinkPatternListPreference
|
|
||||||
android:key="pref_led_blink"
|
|
||||||
android:defaultValue="500,2000"
|
|
||||||
android:title="@string/preferences__pref_led_blink_title"
|
|
||||||
android:dependency="pref_key_enable_notifications"
|
|
||||||
android:entries="@array/pref_led_blink_pattern_entries"
|
|
||||||
android:entryValues="@array/pref_led_blink_pattern_values" />
|
|
||||||
|
|
||||||
<RingtonePreference android:dependency="pref_key_enable_notifications"
|
|
||||||
android:key="pref_key_ringtone"
|
|
||||||
android:title="@string/preferences__sound"
|
|
||||||
android:summary="@string/preferences__change_notification_sound"
|
|
||||||
android:ringtoneType="notification"
|
|
||||||
android:defaultValue="content://settings/system/notification_sound" />
|
|
||||||
|
|
||||||
<CheckBoxPreference android:key="pref_key_inthread_notifications"
|
|
||||||
android:title="@string/preferences__inthread_notifications"
|
|
||||||
android:summary="@string/preferences__play_inthread_notifications"
|
|
||||||
android:dependency="pref_key_enable_notifications"
|
|
||||||
android:defaultValue="true" />
|
|
||||||
|
|
||||||
<CheckBoxPreference android:dependency="pref_key_enable_notifications"
|
|
||||||
android:key="pref_key_vibrate"
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:title="@string/preferences__vibrate"
|
|
||||||
android:summary="@string/preferences__also_vibrate_when_notified" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences__input_settings">
|
|
||||||
<CheckBoxPreference android:defaultValue="false"
|
|
||||||
android:key="pref_enter_key"
|
|
||||||
android:title="@string/preferences__enable_enter_key_title"
|
|
||||||
android:summary="@string/preferences__replace_smiley_with_enter_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference android:defaultValue="false"
|
|
||||||
android:key="pref_enter_sends"
|
|
||||||
android:summary="@string/preferences__pressing_the_enter_key_will_send_text_messages"
|
|
||||||
android:title="@string/preferences__pref_enter_sends_title" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences__appearance">
|
|
||||||
<ListPreference android:key="pref_theme"
|
|
||||||
android:title="@string/preferences__theme"
|
|
||||||
android:entries="@array/pref_theme_entries"
|
|
||||||
android:entryValues="@array/pref_theme_values"
|
|
||||||
android:defaultValue="light">
|
|
||||||
</ListPreference>
|
|
||||||
|
|
||||||
<ListPreference android:key="pref_language"
|
|
||||||
android:title="@string/preferences__language"
|
|
||||||
android:entries="@array/language_entries"
|
|
||||||
android:entryValues="@array/language_values"
|
|
||||||
android:defaultValue="zz"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences__storage">
|
|
||||||
<CheckBoxPreference android:defaultValue="false"
|
<CheckBoxPreference android:defaultValue="false"
|
||||||
android:key="pref_trim_threads"
|
android:key="pref_toggle_push_messaging"
|
||||||
android:summary="@string/preferences__automatically_delete_older_messages_once_a_conversation_thread_exceeds_a_specified_length"
|
android:title="@string/preferences__use_data_channel"
|
||||||
android:title="@string/preferences__delete_old_messages" />
|
android:summary="@string/preferences__use_the_data_channel_for_communication_with_other_textsecure_users"/>
|
||||||
|
|
||||||
<EditTextPreference android:defaultValue="500"
|
|
||||||
android:key="pref_trim_length"
|
|
||||||
android:title="@string/preferences__conversation_length_limit"
|
|
||||||
android:inputType="number"
|
|
||||||
android:dependency="pref_trim_threads" />
|
|
||||||
|
|
||||||
<Preference android:key="pref_trim_now"
|
|
||||||
android:title="@string/preferences__trim_all_threads_now"
|
|
||||||
android:summary="@string/preferences__scan_through_all_conversation_threads_and_enforce_conversation_length_limits"
|
|
||||||
android:dependency="pref_trim_threads" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences__display_settings" android:key="pref_display_category">
|
|
||||||
|
|
||||||
<Preference android:key="pref_choose_identity"
|
|
||||||
android:title="@string/preferences__choose_identity"
|
|
||||||
android:summary="@string/preferences__choose_your_contact_entry_from_the_contacts_list"/>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences__passphrase">
|
|
||||||
|
|
||||||
<Preference android:key="pref_change_passphrase"
|
|
||||||
android:title="@string/preferences__change_passphrase"
|
|
||||||
android:summary="@string/preferences__change_my_passphrase"
|
|
||||||
android:dependency="pref_disable_passphrase"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference android:key="pref_disable_passphrase"
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:title="@string/preferences__disable_passphrase"
|
|
||||||
android:summary="@string/preferences__disable_local_encryption_of_messages_and_keys"
|
|
||||||
android:disableDependentsState="true"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference android:defaultValue="false"
|
|
||||||
android:key="pref_timeout_passphrase"
|
|
||||||
android:title="@string/preferences__timeout_passphrase"
|
|
||||||
android:summary="@string/preferences__forget_passphrase_from_memory_after_some_interval"
|
|
||||||
android:dependency="pref_disable_passphrase"/>
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.preferences.PassphraseTimeoutPreference
|
|
||||||
android:key="pref_timeout_interval"
|
|
||||||
android:defaultValue="300"
|
|
||||||
android:title="@string/preferences__pref_timeout_interval_title"
|
|
||||||
android:summary="@string/preferences__the_amount_of_time_to_wait_before_forgetting_passphrase"
|
|
||||||
android:dependency="pref_timeout_passphrase"
|
|
||||||
android:dialogTitle="@string/preferences__pref_timeout_interval_dialogtitle" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
<Preference android:key="preference_category_sms_mms"
|
||||||
|
android:title="@string/preferences__sms_mms"/>
|
||||||
|
|
||||||
<PreferenceCategory android:key="advanced_category" android:title="@string/preferences__advanced">
|
<Preference android:key="preference_category_notifications"
|
||||||
<CheckBoxPreference android:defaultValue="true"
|
android:title="@string/preferences__notifications"/>
|
||||||
android:key="pref_auto_complete_key_exchange"
|
|
||||||
android:title="@string/preferences__complete_key_exchanges"
|
|
||||||
android:summary="@string/preferences__automatically_complete_key_exchanges_for_new_sessions_or_for_existing_sessions_with_the_same_identity_key" />
|
|
||||||
|
|
||||||
<CheckBoxPreference android:defaultValue="true"
|
<Preference android:key="preference_category_app_protection"
|
||||||
android:key="pref_screen_security"
|
android:title="@string/preferences__app_protection"/>
|
||||||
android:title="@string/preferences__screen_security"
|
|
||||||
android:summary="@string/preferences__disable_screen_security_to_allow_screen_shots" />
|
|
||||||
|
|
||||||
<Preference android:key="pref_mms_preferences"
|
<Preference android:key="preference_category_appearance"
|
||||||
android:title="@string/preferences__advanced_mms_access_point_names"/>
|
android:title="@string/preferences__appearance"/>
|
||||||
|
|
||||||
<Preference android:key="pref_submit_debug_logs"
|
<Preference android:key="preference_category_storage"
|
||||||
android:title="@string/preferences__submit_debug_log"/>
|
android:title="@string/preferences__delete_old_messages"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
<Preference android:key="preference_category_advanced"
|
||||||
|
android:title="@string/preferences__advanced"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:defaultValue="false"
|
||||||
|
android:key="pref_enter_key"
|
||||||
|
android:title="@string/preferences__enable_enter_key_title"
|
||||||
|
android:summary="@string/preferences__replace_smiley_with_enter_key"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference android:defaultValue="false"
|
||||||
|
android:key="pref_enter_sends"
|
||||||
|
android:summary="@string/preferences__pressing_the_enter_key_will_send_text_messages"
|
||||||
|
android:title="@string/preferences__pref_enter_sends_title"
|
||||||
|
android:dependency="pref_enter_key"/>
|
||||||
|
|
||||||
|
<Preference android:key="pref_choose_identity"
|
||||||
|
android:title="@string/preferences__choose_identity"
|
||||||
|
android:summary="@string/preferences__choose_your_contact_entry_from_the_contacts_list"/>
|
||||||
|
|
||||||
|
<Preference android:key="pref_submit_debug_logs"
|
||||||
|
android:title="@string/preferences__submit_debug_log"/>
|
||||||
|
</PreferenceScreen>
|
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:key="pref_enable_passphrase_temporary"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="@string/preferences__enable_passphrase"
|
||||||
|
android:summary="@string/preferences__enable_local_encryption_of_messages_and_keys"/>
|
||||||
|
|
||||||
|
<Preference android:key="pref_change_passphrase"
|
||||||
|
android:title="@string/preferences__change_passphrase"
|
||||||
|
android:summary="@string/preferences__change_my_passphrase"
|
||||||
|
android:dependency="pref_enable_passphrase_temporary"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference android:defaultValue="false"
|
||||||
|
android:key="pref_timeout_passphrase"
|
||||||
|
android:title="@string/preferences__timeout_passphrase"
|
||||||
|
android:summary="@string/preferences__forget_passphrase_from_memory_after_some_interval"
|
||||||
|
android:dependency="pref_enable_passphrase_temporary"/>
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.preferences.PassphraseTimeoutPreference
|
||||||
|
android:key="pref_timeout_interval"
|
||||||
|
android:defaultValue="300"
|
||||||
|
android:title="@string/preferences__pref_timeout_interval_title"
|
||||||
|
android:summary="@string/preferences__the_amount_of_time_to_wait_before_forgetting_passphrase"
|
||||||
|
android:dependency="pref_timeout_passphrase"
|
||||||
|
android:dialogTitle="@string/preferences__pref_timeout_interval_dialogtitle" />
|
||||||
|
|
||||||
|
<CheckBoxPreference android:defaultValue="true"
|
||||||
|
android:key="pref_screen_security"
|
||||||
|
android:title="@string/preferences__screen_security"
|
||||||
|
android:summary="@string/preferences__disable_screen_security_to_allow_screen_shots" />
|
||||||
|
</PreferenceScreen>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<ListPreference android:key="pref_theme"
|
||||||
|
android:title="@string/preferences__theme"
|
||||||
|
android:entries="@array/pref_theme_entries"
|
||||||
|
android:entryValues="@array/pref_theme_values"
|
||||||
|
android:defaultValue="light">
|
||||||
|
</ListPreference>
|
||||||
|
|
||||||
|
<ListPreference android:key="pref_language"
|
||||||
|
android:title="@string/preferences__language"
|
||||||
|
android:entries="@array/language_entries"
|
||||||
|
android:entryValues="@array/language_values"
|
||||||
|
android:defaultValue="zz"/>
|
||||||
|
</PreferenceScreen>
|
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:key="pref_key_enable_notifications"
|
||||||
|
android:title="@string/preferences__notifications"
|
||||||
|
android:summary="@string/preferences__display_message_notifications_in_status_bar"
|
||||||
|
android:defaultValue="true" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="pref_led_color"
|
||||||
|
android:defaultValue="green"
|
||||||
|
android:title="@string/preferences__led_color"
|
||||||
|
android:dependency="pref_key_enable_notifications"
|
||||||
|
android:entries="@array/pref_led_color_entries"
|
||||||
|
android:entryValues="@array/pref_led_color_values" />
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.preferences.LedBlinkPatternListPreference
|
||||||
|
android:key="pref_led_blink"
|
||||||
|
android:defaultValue="500,2000"
|
||||||
|
android:title="@string/preferences__pref_led_blink_title"
|
||||||
|
android:dependency="pref_key_enable_notifications"
|
||||||
|
android:entries="@array/pref_led_blink_pattern_entries"
|
||||||
|
android:entryValues="@array/pref_led_blink_pattern_values" />
|
||||||
|
|
||||||
|
<RingtonePreference android:dependency="pref_key_enable_notifications"
|
||||||
|
android:key="pref_key_ringtone"
|
||||||
|
android:title="@string/preferences__sound"
|
||||||
|
android:summary="@string/preferences__change_notification_sound"
|
||||||
|
android:ringtoneType="notification"
|
||||||
|
android:defaultValue="content://settings/system/notification_sound" />
|
||||||
|
|
||||||
|
<CheckBoxPreference android:key="pref_key_inthread_notifications"
|
||||||
|
android:title="@string/preferences__inthread_notifications"
|
||||||
|
android:summary="@string/preferences__play_inthread_notifications"
|
||||||
|
android:dependency="pref_key_enable_notifications"
|
||||||
|
android:defaultValue="true" />
|
||||||
|
|
||||||
|
<CheckBoxPreference android:dependency="pref_key_enable_notifications"
|
||||||
|
android:key="pref_key_vibrate"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="@string/preferences__vibrate"
|
||||||
|
android:summary="@string/preferences__also_vibrate_when_notified" />
|
||||||
|
</PreferenceScreen>
|
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:defaultValue="true"
|
||||||
|
android:key="pref_all_sms"
|
||||||
|
android:summary="@string/preferences__use_textsecure_for_viewing_and_storing_all_incoming_text_messages"
|
||||||
|
android:title="@string/preferences__pref_all_sms_title" />
|
||||||
|
|
||||||
|
<CheckBoxPreference android:defaultValue="true"
|
||||||
|
android:key="pref_all_mms"
|
||||||
|
android:summary="@string/preferences__use_textsecure_for_viewing_and_storing_all_incoming_multimedia_messages"
|
||||||
|
android:title="@string/preferences__pref_all_mms_title" />
|
||||||
|
|
||||||
|
<Preference android:key="pref_set_default"
|
||||||
|
android:title="@string/preferences__make_default_sms_app"
|
||||||
|
android:summary="@string/preferences__make_textsecure_the_default_sms_mms_app" />
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.components.OutgoingSmsPreference
|
||||||
|
android:key="pref_outgoing_sms"
|
||||||
|
android:title="@string/preferences__allow_sms_fallback" />
|
||||||
|
|
||||||
|
<CheckBoxPreference android:defaultValue="false"
|
||||||
|
android:key="pref_delivery_report_sms"
|
||||||
|
android:summary="@string/preferences__request_a_delivery_report_for_each_sms_message_you_send"
|
||||||
|
android:title="@string/preferences__sms_delivery_reports" />
|
||||||
|
|
||||||
|
<Preference android:key="pref_mms_preferences"
|
||||||
|
android:title="@string/preferences__advanced_mms_access_point_names"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference android:defaultValue="true"
|
||||||
|
android:key="pref_auto_complete_key_exchange"
|
||||||
|
android:title="@string/preferences__complete_key_exchanges"
|
||||||
|
android:summary="@string/preferences__automatically_complete_key_exchanges_for_new_sessions_or_for_existing_sessions_with_the_same_identity_key" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:defaultValue="false"
|
||||||
|
android:key="pref_trim_threads"
|
||||||
|
android:summary="@string/preferences__automatically_delete_older_messages_once_a_conversation_thread_exceeds_a_specified_length"
|
||||||
|
android:title="@string/preferences__delete_old_messages" />
|
||||||
|
|
||||||
|
<EditTextPreference android:defaultValue="500"
|
||||||
|
android:key="pref_trim_length"
|
||||||
|
android:title="@string/preferences__conversation_length_limit"
|
||||||
|
android:inputType="number"
|
||||||
|
android:dependency="pref_trim_threads" />
|
||||||
|
|
||||||
|
<Preference android:key="pref_trim_now"
|
||||||
|
android:title="@string/preferences__trim_all_threads_now"
|
||||||
|
android:summary="@string/preferences__scan_through_all_conversation_threads_and_enforce_conversation_length_limits"
|
||||||
|
android:dependency="pref_trim_threads" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@ -0,0 +1,100 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.LogSubmitActivity;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||||
|
import org.thoughtcrime.securesms.contacts.ContactIdentityManager;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
|
public class AdvancedPreferenceFragment extends PreferenceFragment {
|
||||||
|
private static final String TAG = AdvancedPreferenceFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final String SUBMIT_DEBUG_LOG_PREF = "pref_submit_debug_logs";
|
||||||
|
|
||||||
|
private static final int PICK_IDENTITY_CONTACT = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle paramBundle) {
|
||||||
|
super.onCreate(paramBundle);
|
||||||
|
addPreferencesFromResource(R.xml.preferences_advanced);
|
||||||
|
|
||||||
|
initializeIdentitySelection();
|
||||||
|
|
||||||
|
this.findPreference(SUBMIT_DEBUG_LOG_PREF)
|
||||||
|
.setOnPreferenceClickListener(new SubmitDebugLogListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__advanced);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int reqCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(reqCode, resultCode, data);
|
||||||
|
|
||||||
|
Log.w(TAG, "Got result: " + resultCode + " for req: " + reqCode);
|
||||||
|
if (resultCode == Activity.RESULT_OK && reqCode == PICK_IDENTITY_CONTACT) {
|
||||||
|
handleIdentitySelection(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeIdentitySelection() {
|
||||||
|
ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity());
|
||||||
|
|
||||||
|
Preference preference = this.findPreference(TextSecurePreferences.IDENTITY_PREF);
|
||||||
|
|
||||||
|
if (identity.isSelfIdentityAutoDetected()) {
|
||||||
|
this.getPreferenceScreen().removePreference(preference);
|
||||||
|
} else {
|
||||||
|
Uri contactUri = identity.getSelfIdentityUri();
|
||||||
|
|
||||||
|
if (contactUri != null) {
|
||||||
|
String contactName = ContactAccessor.getInstance().getNameFromContact(getActivity(), contactUri);
|
||||||
|
preference.setSummary(String.format(getString(R.string.ApplicationPreferencesActivity_currently_s),
|
||||||
|
contactName));
|
||||||
|
}
|
||||||
|
|
||||||
|
preference.setOnPreferenceClickListener(new IdentityPreferenceClickListener());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class IdentityPreferenceClickListener implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_PICK);
|
||||||
|
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
|
||||||
|
startActivityForResult(intent, PICK_IDENTITY_CONTACT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleIdentitySelection(Intent data) {
|
||||||
|
Uri contactUri = data.getData();
|
||||||
|
|
||||||
|
if (contactUri != null) {
|
||||||
|
TextSecurePreferences.setIdentityContactUri(getActivity(), contactUri.toString());
|
||||||
|
initializeIdentitySelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SubmitDebugLogListener implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
final Intent intent = new Intent(getActivity(), LogSubmitActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.PassphraseChangeActivity;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||||
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
|
import org.thoughtcrime.securesms.util.Dialogs;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
|
public class AppProtectionPreferenceFragment extends PreferenceFragment {
|
||||||
|
private CheckBoxPreference disablePassphrase;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle paramBundle) {
|
||||||
|
super.onCreate(paramBundle);
|
||||||
|
addPreferencesFromResource(R.xml.preferences_app_protection);
|
||||||
|
|
||||||
|
disablePassphrase = (CheckBoxPreference) this.findPreference("pref_enable_passphrase_temporary");
|
||||||
|
|
||||||
|
this.findPreference(TextSecurePreferences.CHANGE_PASSPHRASE_PREF)
|
||||||
|
.setOnPreferenceClickListener(new ChangePassphraseClickListener());
|
||||||
|
disablePassphrase
|
||||||
|
.setOnPreferenceChangeListener(new DisablePassphraseClickListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__app_protection);
|
||||||
|
initializePlatformSpecificOptions();
|
||||||
|
|
||||||
|
disablePassphrase.setChecked(!TextSecurePreferences.isPasswordDisabled(getActivity()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializePlatformSpecificOptions() {
|
||||||
|
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
Preference screenSecurityPreference = findPreference(TextSecurePreferences.SCREEN_SECURITY_PREF);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
|
||||||
|
screenSecurityPreference != null) {
|
||||||
|
preferenceScreen.removePreference(screenSecurityPreference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChangePassphraseClickListener implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
if (MasterSecretUtil.isPassphraseInitialized(getActivity())) {
|
||||||
|
startActivity(new Intent(getActivity(), PassphraseChangeActivity.class));
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getActivity(),
|
||||||
|
R.string.ApplicationPreferenceActivity_you_havent_set_a_passphrase_yet,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DisablePassphraseClickListener implements Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(final Preference preference, Object newValue) {
|
||||||
|
if (((CheckBoxPreference)preference).isChecked()) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle(R.string.ApplicationPreferencesActivity_disable_storage_encryption);
|
||||||
|
builder.setMessage(R.string.ApplicationPreferencesActivity_warning_this_will_disable_storage_encryption_for_all_messages);
|
||||||
|
builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon));
|
||||||
|
builder.setPositiveButton(R.string.ApplicationPreferencesActivity_disable, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
MasterSecret masterSecret = getActivity().getIntent().getParcelableExtra("master_secret");
|
||||||
|
MasterSecretUtil.changeMasterSecretPassphrase(getActivity(),
|
||||||
|
masterSecret,
|
||||||
|
MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
||||||
|
|
||||||
|
|
||||||
|
TextSecurePreferences.setPasswordDisabled(getActivity(), true);
|
||||||
|
((CheckBoxPreference)preference).setChecked(false);
|
||||||
|
|
||||||
|
Intent intent = new Intent(getActivity(), KeyCachingService.class);
|
||||||
|
intent.setAction(KeyCachingService.DISABLE_ACTION);
|
||||||
|
getActivity().startService(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(android.R.string.cancel, null);
|
||||||
|
builder.show();
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(getActivity(), PassphraseChangeActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence getSummary(Context context) {
|
||||||
|
final int onCapsResId = R.string.ApplicationPreferencesActivity_On;
|
||||||
|
final int offCapsResId = R.string.ApplicationPreferencesActivity_Off;
|
||||||
|
|
||||||
|
return context.getString(TextSecurePreferences.isPasswordDisabled(context) ? offCapsResId : onCapsResId);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
|
public class AppearancePreferenceFragment extends PreferenceFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle paramBundle) {
|
||||||
|
super.onCreate(paramBundle);
|
||||||
|
addPreferencesFromResource(R.xml.preferences_appearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener((ApplicationPreferencesActivity)getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__appearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener((ApplicationPreferencesActivity) getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence getSummary(Context context) {
|
||||||
|
String[] languageEntries = context.getResources().getStringArray(R.array.language_entries);
|
||||||
|
String[] languageEntryValues = context.getResources().getStringArray(R.array.language_values);
|
||||||
|
String[] themeEntries = context.getResources().getStringArray(R.array.pref_theme_entries);
|
||||||
|
String[] themeEntryValues = context.getResources().getStringArray(R.array.pref_theme_values);
|
||||||
|
|
||||||
|
Integer langIndex = findIndexOfValue(TextSecurePreferences.getLanguage(context), languageEntryValues);
|
||||||
|
Integer themeIndex = findIndexOfValue(TextSecurePreferences.getTheme(context), themeEntryValues);
|
||||||
|
|
||||||
|
return context.getString(R.string.preferences__theme) + ": " + themeEntries[themeIndex] + ", " +
|
||||||
|
context.getString(R.string.preferences__language) + ": " + languageEntries[langIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy from ListPreference
|
||||||
|
private static int findIndexOfValue(String value, CharSequence[] mEntryValues) {
|
||||||
|
if (value != null && mEntryValues != null) {
|
||||||
|
for (int i = mEntryValues.length - 1; i >= 0; i--) {
|
||||||
|
if (mEntryValues[i].equals(value)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.media.Ringtone;
|
||||||
|
import android.media.RingtoneManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.preference.RingtonePreference;
|
||||||
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class NotificationsPreferenceFragment extends PreferenceFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle paramBundle) {
|
||||||
|
super.onCreate(paramBundle);
|
||||||
|
addPreferencesFromResource(R.xml.preferences_notifications);
|
||||||
|
|
||||||
|
this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
|
||||||
|
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||||
|
this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
|
||||||
|
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||||
|
this.findPreference(TextSecurePreferences.RINGTONE_PREF)
|
||||||
|
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
|
||||||
|
|
||||||
|
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
|
||||||
|
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
|
||||||
|
initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__notifications);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ListSummaryListener implements Preference.OnPreferenceChangeListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||||
|
ListPreference listPref = (ListPreference) preference;
|
||||||
|
|
||||||
|
final int entryIndex = Arrays.asList(listPref.getEntryValues()).indexOf(value);
|
||||||
|
listPref.setSummary(entryIndex >= 0 && entryIndex < listPref.getEntries().length
|
||||||
|
? listPref.getEntries()[entryIndex]
|
||||||
|
: getString(R.string.preferences__led_color_unknown));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RingtoneSummaryListener implements Preference.OnPreferenceChangeListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
String value = (String) newValue;
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(value)) {
|
||||||
|
preference.setSummary(R.string.preferences__default);
|
||||||
|
} else {
|
||||||
|
Ringtone tone = RingtoneManager.getRingtone(getActivity(), Uri.parse(value));
|
||||||
|
if (tone != null) {
|
||||||
|
preference.setSummary(tone.getTitle(getActivity()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeListSummary(ListPreference pref) {
|
||||||
|
pref.setSummary(pref.getEntry());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeRingtoneSummary(RingtonePreference pref) {
|
||||||
|
RingtoneSummaryListener listener =
|
||||||
|
(RingtoneSummaryListener) pref.getOnPreferenceChangeListener();
|
||||||
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
|
||||||
|
listener.onPreferenceChange(pref, sharedPreferences.getString(pref.getKey(), ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence getSummary(Context context) {
|
||||||
|
final int onCapsResId = R.string.ApplicationPreferencesActivity_On;
|
||||||
|
final int offCapsResId = R.string.ApplicationPreferencesActivity_Off;
|
||||||
|
|
||||||
|
return context.getString(TextSecurePreferences.isNotificationsEnabled(context) ? onCapsResId : offCapsResId);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.provider.Telephony;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.MmsPreferencesFragment;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.components.OutgoingSmsPreference;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
|
public class SmsMmsPreferenceFragment extends PreferenceFragment {
|
||||||
|
private static final String KITKAT_DEFAULT_PREF = "pref_set_default";
|
||||||
|
private static final String OUTGOING_SMS_PREF = "pref_outgoing_sms";
|
||||||
|
private static final String MMS_PREF = "pref_mms_preferences";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle paramBundle) {
|
||||||
|
super.onCreate(paramBundle);
|
||||||
|
addPreferencesFromResource(R.xml.preferences_sms_mms);
|
||||||
|
|
||||||
|
this.findPreference(OUTGOING_SMS_PREF)
|
||||||
|
.setOnPreferenceChangeListener(new OutgoingSmsPreferenceListener());
|
||||||
|
this.findPreference(MMS_PREF)
|
||||||
|
.setOnPreferenceClickListener(new ApnPreferencesClickListener());
|
||||||
|
|
||||||
|
initializeOutgoingSmsSummary((OutgoingSmsPreference) findPreference(OUTGOING_SMS_PREF));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__sms_mms);
|
||||||
|
this.findPreference(MMS_PREF)
|
||||||
|
.setSummary(MmsPreferencesFragment.getSummary(getActivity()));
|
||||||
|
|
||||||
|
initializePlatformSpecificOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializePlatformSpecificOptions() {
|
||||||
|
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
|
||||||
|
Preference allSmsPreference = findPreference(TextSecurePreferences.ALL_SMS_PREF);
|
||||||
|
Preference allMmsPreference = findPreference(TextSecurePreferences.ALL_MMS_PREF);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ) {
|
||||||
|
if (allSmsPreference != null) preferenceScreen.removePreference(allSmsPreference);
|
||||||
|
if (allMmsPreference != null) preferenceScreen.removePreference(allMmsPreference);
|
||||||
|
|
||||||
|
if (Util.isDefaultSmsProvider(getActivity())) {
|
||||||
|
defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
|
||||||
|
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
|
||||||
|
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app));
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
|
||||||
|
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName());
|
||||||
|
defaultPreference.setIntent(intent);
|
||||||
|
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
|
||||||
|
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app));
|
||||||
|
}
|
||||||
|
} else if (defaultPreference != null) {
|
||||||
|
preferenceScreen.removePreference(defaultPreference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeOutgoingSmsSummary(OutgoingSmsPreference pref) {
|
||||||
|
pref.setSummary(buildOutgoingSmsDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class OutgoingSmsPreferenceListener implements Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(final Preference preference, Object newValue) {
|
||||||
|
|
||||||
|
preference.setSummary(buildOutgoingSmsDescription());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildOutgoingSmsDescription() {
|
||||||
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
final boolean dataFallback = TextSecurePreferences.isFallbackSmsAllowed(getActivity());
|
||||||
|
final boolean dataFallbackAsk = TextSecurePreferences.isFallbackSmsAskRequired(getActivity());
|
||||||
|
final boolean nonData = TextSecurePreferences.isDirectSmsAllowed(getActivity());
|
||||||
|
|
||||||
|
if (dataFallback) {
|
||||||
|
builder.append(getString(R.string.preferences__sms_outgoing_push_users));
|
||||||
|
if (dataFallbackAsk) builder.append(" ").append(getString(R.string.preferences__sms_fallback_push_users_ask));
|
||||||
|
}
|
||||||
|
if (nonData) {
|
||||||
|
if (dataFallback) builder.append(", ");
|
||||||
|
builder.append(getString(R.string.preferences__sms_fallback_non_push_users));
|
||||||
|
}
|
||||||
|
if (!dataFallback && !nonData) {
|
||||||
|
builder.append(getString(R.string.preferences__sms_fallback_nobody));
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ApnPreferencesClickListener implements Preference.OnPreferenceClickListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Fragment fragment = new MmsPreferencesFragment();
|
||||||
|
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
|
||||||
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
|
fragmentTransaction.replace(android.R.id.content, fragment);
|
||||||
|
fragmentTransaction.addToBackStack(null);
|
||||||
|
fragmentTransaction.commit();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence getSummary(Context context) {
|
||||||
|
return getIncomingSmsSummary(context) + ", " + getOutgoingSmsSummary(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CharSequence getIncomingSmsSummary(Context context) {
|
||||||
|
final int onResId = R.string.ApplicationPreferencesActivity_on;
|
||||||
|
final int offResId = R.string.ApplicationPreferencesActivity_off;
|
||||||
|
final int smsResId = R.string.ApplicationPreferencesActivity_sms;
|
||||||
|
final int mmsResId = R.string.ApplicationPreferencesActivity_mms;
|
||||||
|
final int incomingSmsResId = R.string.ApplicationPreferencesActivity_incoming_sms;
|
||||||
|
|
||||||
|
final int incomingSmsSummary;
|
||||||
|
boolean postKitkatSMS = Util.isDefaultSmsProvider(context);
|
||||||
|
boolean preKitkatSMS = TextSecurePreferences.isInterceptAllSmsEnabled(context);
|
||||||
|
boolean preKitkatMMS = TextSecurePreferences.isInterceptAllMmsEnabled(context);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
if (postKitkatSMS) incomingSmsSummary = onResId;
|
||||||
|
else incomingSmsSummary = offResId;
|
||||||
|
} else {
|
||||||
|
if (preKitkatSMS && preKitkatMMS) incomingSmsSummary = onResId;
|
||||||
|
else if (preKitkatSMS && !preKitkatMMS) incomingSmsSummary = smsResId;
|
||||||
|
else if (!preKitkatSMS && preKitkatMMS) incomingSmsSummary = mmsResId;
|
||||||
|
else incomingSmsSummary = offResId;
|
||||||
|
}
|
||||||
|
return context.getString(incomingSmsResId) + ": " + context.getString(incomingSmsSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CharSequence getOutgoingSmsSummary(Context context) {
|
||||||
|
final int onResId = R.string.ApplicationPreferencesActivity_on;
|
||||||
|
final int offResId = R.string.ApplicationPreferencesActivity_off;
|
||||||
|
final int partialResId = R.string.ApplicationPreferencesActivity_partial;
|
||||||
|
final int outgoingSmsResId = R.string.ApplicationPreferencesActivity_outgoing_sms;
|
||||||
|
|
||||||
|
final int outgoingSmsSummary;
|
||||||
|
if (TextSecurePreferences.isFallbackSmsAllowed(context) && TextSecurePreferences.isDirectSmsAllowed(context)) {
|
||||||
|
outgoingSmsSummary = onResId;
|
||||||
|
} else if (TextSecurePreferences.isFallbackSmsAllowed(context) ^ TextSecurePreferences.isDirectSmsAllowed(context)) {
|
||||||
|
outgoingSmsSummary = partialResId;
|
||||||
|
} else {
|
||||||
|
outgoingSmsSummary = offResId;
|
||||||
|
}
|
||||||
|
return context.getString(outgoingSmsResId) + ": " + context.getString(outgoingSmsSummary);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.Trimmer;
|
||||||
|
|
||||||
|
public class StoragePreferenceFragment extends PreferenceFragment {
|
||||||
|
private static final String TAG = StoragePreferenceFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle paramBundle) {
|
||||||
|
super.onCreate(paramBundle);
|
||||||
|
addPreferencesFromResource(R.xml.preferences_storage);
|
||||||
|
|
||||||
|
this.findPreference(TextSecurePreferences.THREAD_TRIM_NOW)
|
||||||
|
.setOnPreferenceClickListener(new TrimNowClickListener());
|
||||||
|
this.findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH)
|
||||||
|
.setOnPreferenceChangeListener(new TrimLengthValidationListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__delete_old_messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TrimNowClickListener implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
final int threadLengthLimit = TextSecurePreferences.getThreadTrimLength(getActivity());
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle(R.string.ApplicationPreferencesActivity_delete_all_old_messages_now);
|
||||||
|
builder.setMessage(getString(R.string.ApplicationPreferencesActivity_are_you_sure_you_would_like_to_immediately_trim_all_conversation_threads_to_the_s_most_recent_messages,
|
||||||
|
threadLengthLimit));
|
||||||
|
builder.setPositiveButton(R.string.ApplicationPreferencesActivity_delete,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Trimmer.trimAllThreads(getActivity(), threadLengthLimit);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton(android.R.string.cancel, null);
|
||||||
|
builder.show();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TrimLengthValidationListener implements Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
public TrimLengthValidationListener() {
|
||||||
|
EditTextPreference preference = (EditTextPreference)findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH);
|
||||||
|
preference.setSummary(getString(R.string.ApplicationPreferencesActivity_messages_per_conversation, preference.getText()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
if (newValue == null || ((String)newValue).trim().length() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Integer.parseInt((String)newValue);
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, nfe);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Integer.parseInt((String)newValue) < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
preference.setSummary(getString(R.string.ApplicationPreferencesActivity_messages_per_conversation, newValue));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence getSummary(Context context) {
|
||||||
|
final int onCapsResId = R.string.ApplicationPreferencesActivity_On;
|
||||||
|
final int offCapsResId = R.string.ApplicationPreferencesActivity_Off;
|
||||||
|
|
||||||
|
return context.getString(TextSecurePreferences.isThreadLengthTrimmingEnabled(context) ? onCapsResId : offCapsResId);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue