mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
refactor preferences into multiple PreferenceFragments
This commit is contained in:
parent
8149af22ec
commit
2f6cefca8a
5
res/color/text_color_dark_theme.xml
Normal file
5
res/color/text_color_dark_theme.xml
Normal file
@ -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>
|
5
res/color/text_color_light_theme.xml
Normal file
5
res/color/text_color_light_theme.xml
Normal file
@ -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>
|
5
res/color/text_color_secondary_dark_theme.xml
Normal file
5
res/color/text_color_secondary_dark_theme.xml
Normal file
@ -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>
|
5
res/color/text_color_secondary_light_theme.xml
Normal file
5
res/color/text_color_secondary_light_theme.xml
Normal file
@ -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>
|
@ -5,6 +5,9 @@
|
||||
<color name="black">#ff000000</color>
|
||||
<color name="gray5">#ffeeeeee</color>
|
||||
<color name="gray10">#ffdddddd</color>
|
||||
<color name="gray13">#ffababab</color>
|
||||
<color name="gray27">#ffbbbbbb</color>
|
||||
<color name="gray50">#ff808080</color>
|
||||
<color name="gray95">#ff111111</color>
|
||||
|
||||
<color name="gray95_transparent50">#7F111111</color>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<!-- ApplicationPreferencesActivity -->
|
||||
<string name="ApplicationPreferencesActivity_currently_s">Currently: %s</string>
|
||||
<string name="ApplicationPreferenceActivity_you_havent_set_a_passphrase_yet">You haven\'t set a passphrase yet!</string>
|
||||
<string name="ApplicationPreferencesActivity_messages_per_conversation">messages per conversation</string>
|
||||
<string name="ApplicationPreferencesActivity_messages_per_conversation">%s messages per conversation</string>
|
||||
<string name="ApplicationPreferencesActivity_delete_all_old_messages_now">Delete all old messages now?</string>
|
||||
<string name="ApplicationPreferencesActivity_are_you_sure_you_would_like_to_immediately_trim_all_conversation_threads_to_the_s_most_recent_messages">Are you sure you would like to immediately trim all conversation threads to the %s most recent messages?</string>
|
||||
<string name="ApplicationPreferencesActivity_delete">Delete</string>
|
||||
@ -31,6 +31,15 @@
|
||||
<string name="ApplicationPreferencesActivity_touch_to_change_your_default_sms_app">Touch to change your default SMS app</string>
|
||||
<string name="ApplicationPreferencesActivity_sms_disabled">Incoming SMS Disabled</string>
|
||||
<string name="ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app">Touch to make TextSecure your default SMS app</string>
|
||||
<string name="ApplicationPreferencesActivity_on">on</string>
|
||||
<string name="ApplicationPreferencesActivity_On">On</string>
|
||||
<string name="ApplicationPreferencesActivity_off">off</string>
|
||||
<string name="ApplicationPreferencesActivity_Off">Off</string>
|
||||
<string name="ApplicationPreferencesActivity_partial">partial</string>
|
||||
<string name="ApplicationPreferencesActivity_sms">SMS</string>
|
||||
<string name="ApplicationPreferencesActivity_mms">MMS</string>
|
||||
<string name="ApplicationPreferencesActivity_incoming_sms">Incoming SMS</string>
|
||||
<string name="ApplicationPreferencesActivity_outgoing_sms">outgoing SMS</string>
|
||||
|
||||
<!-- AttchmentManager -->
|
||||
<string name="AttachmentManager_cant_open_media_selection">Can\'t find an app to select media.</string>
|
||||
@ -463,8 +472,10 @@
|
||||
<string name="import_fragment__import_a_plaintext_backup_file">
|
||||
Import a plaintext backup file. Compatible with \'SMSBackup And Restore.\'</string>
|
||||
|
||||
<!-- mms_preferences_activity -->
|
||||
<string name="mms_preferences_activity__manual_mms_settings_are_required">Manual MMS settings are required for your phone.</string>
|
||||
<!-- MmsPreferencesFragment -->
|
||||
<string name="MmsPreferencesFragment__manual_mms_settings_are_required">Manual MMS settings are required for your phone.</string>
|
||||
<string name="MmsPreferencesFragment__enabled">Enabled</string>
|
||||
<string name="MmsPreferencesFragment__disabled">Disabled</string>
|
||||
|
||||
<!-- prompt_passphrase_activity -->
|
||||
<string name="prompt_passphrase_activity__unlock">Unlock</string>
|
||||
@ -583,6 +594,8 @@
|
||||
<string name="arrays__my_identity_key">My identity key</string>
|
||||
|
||||
<!-- preferences.xml -->
|
||||
<string name="preferences__general">General</string>
|
||||
<string name="preferences__sms_mms">SMS and MMS</string>
|
||||
<string name="preferences__push_sms_category">Push and SMS</string>
|
||||
<string name="preferences__pref_all_sms_title">Receive all SMS</string>
|
||||
<string name="preferences__pref_all_mms_title">Receive all MMS</string>
|
||||
@ -599,8 +612,8 @@
|
||||
<string name="preferences__change_passphrase">Change passphrase</string>
|
||||
<string name="preferences__change_my_passphrase">Change my passphrase</string>
|
||||
<string name="preferences__complete_key_exchanges">Complete key exchanges</string>
|
||||
<string name="preferences__disable_passphrase">Disable passphrase</string>
|
||||
<string name="preferences__disable_local_encryption_of_messages_and_keys">Disable local encryption of messages and keys</string>
|
||||
<string name="preferences__enable_passphrase">Enable passphrase</string>
|
||||
<string name="preferences__enable_local_encryption_of_messages_and_keys">Enable local encryption of messages and keys</string>
|
||||
<string name="preferences__screen_security">Screen security</string>
|
||||
<string name="preferences__automatically_complete_key_exchanges_for_new_sessions_or_for_existing_sessions_with_the_same_identity_key">Automatically complete key exchanges for new sessions or for existing sessions with the same identity key</string>
|
||||
<string name="preferences__disable_screen_security_to_allow_screen_shots">Block screenshots in the recents list and inside the app</string>
|
||||
@ -612,6 +625,7 @@
|
||||
<string name="preferences__notifications">Notifications</string>
|
||||
<string name="preferences__display_message_notifications_in_status_bar">Display message notifications in status bar</string>
|
||||
<string name="preferences__led_color">LED color</string>
|
||||
<string name="preferences__led_color_unknown">Unknown</string>
|
||||
<string name="preferences__pref_led_blink_title">LED blink pattern</string>
|
||||
<string name="preferences__pref_led_blink_custom_pattern_title">Set custom LED blink pattern</string>
|
||||
<string name="preferences__pref_led_blink_custom_pattern_on_for">On for:</string>
|
||||
@ -638,9 +652,9 @@
|
||||
<string name="preferences__slow">Slow</string>
|
||||
<string name="preferences__custom">Custom</string>
|
||||
<string name="preferences__advanced">Advanced</string>
|
||||
<string name="preferences__passphrase">Passphrase</string>
|
||||
<string name="preferences__advanced_mms_access_point_names">MMS preferences</string>
|
||||
<string name="preferences__enable_manual_mms">Enable manual MMS</string>
|
||||
<string name="preferences__app_protection">App protection</string>
|
||||
<string name="preferences__advanced_mms_access_point_names">Manual MMS settings</string>
|
||||
<string name="preferences__enable_manual_mms">Use manual MMS settings</string>
|
||||
<string name="preferences__override_system_mms_settings">Override system MMS settings with the information below.</string>
|
||||
<string name="preferences__mmsc_url_required">MMSC URL (Required)</string>
|
||||
<string name="preferences__mms_proxy_host_optional">MMS Proxy Host (Optional)</string>
|
||||
@ -651,7 +665,6 @@
|
||||
<string name="preferences__request_a_delivery_report_for_each_sms_message_you_send">Request a delivery report for each SMS message you send</string>
|
||||
<string name="preferences__automatically_delete_older_messages_once_a_conversation_thread_exceeds_a_specified_length">Automatically delete older messages once a conversation thread exceeds a specified length</string>
|
||||
<string name="preferences__delete_old_messages">Delete old messages</string>
|
||||
<string name="preferences__storage">Storage</string>
|
||||
<string name="preferences__conversation_length_limit">Conversation length limit</string>
|
||||
<string name="preferences__trim_all_threads_now">Trim all threads now</string>
|
||||
<string name="preferences__scan_through_all_conversation_threads_and_enforce_conversation_length_limits">Scan through all conversation threads and enforce conversation length limits</string>
|
||||
|
@ -11,6 +11,8 @@
|
||||
<item name="android:logo">@drawable/actionbar_icon_holo_light</item>
|
||||
<item name="android:actionBarStyle">@style/TextSecure.LightActionBar</item>
|
||||
<item name="actionBarStyle">@style/TextSecure.LightActionBar</item>
|
||||
<item name="android:textColor">@color/text_color_light_theme</item>
|
||||
<item name="android:textColorSecondary">@color/text_color_secondary_light_theme</item>
|
||||
<item name="conversation_list_item_background_read">@drawable/conversation_list_item_background_read_light</item>
|
||||
<item name="conversation_list_item_background_unread">@drawable/conversation_list_item_background_unread_light</item>
|
||||
<item name="conversation_list_item_background_selected">@drawable/list_selected_holo_light</item>
|
||||
@ -88,6 +90,8 @@
|
||||
|
||||
<item name="android:actionBarStyle">@style/TextSecure.DarkActionBar</item>
|
||||
<item name="actionBarStyle">@style/TextSecure.DarkActionBar</item>
|
||||
<item name="android:textColor">@color/text_color_dark_theme</item>
|
||||
<item name="android:textColorSecondary">@color/text_color_secondary_dark_theme</item>
|
||||
<item name="conversation_list_item_background_read">@drawable/conversation_list_item_background_read_dark</item>
|
||||
<item name="conversation_list_item_background_unread">@drawable/conversation_list_item_background_unread_dark</item>
|
||||
<item name="conversation_list_item_background_selected">@drawable/list_selected_holo_dark</item>
|
||||
|
@ -1,177 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<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"
|
||||
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" />
|
||||
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"/>
|
||||
|
||||
<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="preference_category_sms_mms"
|
||||
android:title="@string/preferences__sms_mms"/>
|
||||
|
||||
<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" />
|
||||
<Preference android:key="preference_category_notifications"
|
||||
android:title="@string/preferences__notifications"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
<Preference android:key="preference_category_app_protection"
|
||||
android:title="@string/preferences__app_protection"/>
|
||||
|
||||
<PreferenceCategory android:title="@string/preferences__display_settings" android:key="pref_display_category">
|
||||
<Preference android:key="preference_category_appearance"
|
||||
android:title="@string/preferences__appearance"/>
|
||||
|
||||
<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="preference_category_storage"
|
||||
android:title="@string/preferences__delete_old_messages"/>
|
||||
|
||||
</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>
|
||||
|
||||
<PreferenceCategory android:key="advanced_category" android:title="@string/preferences__advanced">
|
||||
<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" />
|
||||
|
||||
<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" />
|
||||
|
||||
<Preference android:key="pref_mms_preferences"
|
||||
android:title="@string/preferences__advanced_mms_access_point_names"/>
|
||||
|
||||
<Preference android:key="pref_submit_debug_logs"
|
||||
android:title="@string/preferences__submit_debug_log"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
<Preference android:key="preference_category_advanced"
|
||||
android:title="@string/preferences__advanced"/>
|
||||
</PreferenceScreen>
|
||||
|
21
res/xml/preferences_advanced.xml
Normal file
21
res/xml/preferences_advanced.xml
Normal file
@ -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>
|
32
res/xml/preferences_app_protection.xml
Normal file
32
res/xml/preferences_app_protection.xml
Normal file
@ -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>
|
16
res/xml/preferences_appearance.xml
Normal file
16
res/xml/preferences_appearance.xml
Normal file
@ -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>
|
43
res/xml/preferences_notifications.xml
Normal file
43
res/xml/preferences_notifications.xml
Normal file
@ -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>
|
35
res/xml/preferences_sms_mms.xml
Normal file
35
res/xml/preferences_sms_mms.xml
Normal file
@ -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>
|
20
res/xml/preferences_storage.xml
Normal file
20
res/xml/preferences_storage.xml
Normal file
@ -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>
|
@ -16,55 +16,40 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.provider.ContactsContract;
|
||||
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 android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.gcm.GoogleCloudMessaging;
|
||||
|
||||
import org.thoughtcrime.securesms.components.OutgoingSmsPreference;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||
import org.thoughtcrime.securesms.contacts.ContactIdentityManager;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.AppearancePreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.SmsMmsPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.StoragePreferenceFragment;
|
||||
import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.Dialogs;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Trimmer;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
import org.whispersystems.textsecure.api.TextSecureAccountManager;
|
||||
import org.whispersystems.textsecure.api.push.exceptions.AuthorizationFailedException;
|
||||
@ -81,17 +66,16 @@ import java.io.IOException;
|
||||
public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarActivity
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
{
|
||||
private static final String TAG = "Preferences";
|
||||
private static final String TAG = ApplicationPreferencesActivity.class.getSimpleName();
|
||||
|
||||
private static final int PICK_IDENTITY_CONTACT = 1;
|
||||
private static final int ENABLE_PASSPHRASE_ACTIVITY = 2;
|
||||
private static final String PREFERENCE_CATEGORY_SMS_MMS = "preference_category_sms_mms";
|
||||
private static final String PREFERENCE_CATEGORY_NOTIFICATIONS = "preference_category_notifications";
|
||||
private static final String PREFERENCE_CATEGORY_APP_PROTECTION = "preference_category_app_protection";
|
||||
private static final String PREFERENCE_CATEGORY_APPEARANCE = "preference_category_appearance";
|
||||
private static final String PREFERENCE_CATEGORY_STORAGE = "preference_category_storage";
|
||||
private static final String PREFERENCE_CATEGORY_ADVANCED = "preference_category_advanced";
|
||||
|
||||
private static final String DISPLAY_CATEGORY_PREF = "pref_display_category";
|
||||
private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging";
|
||||
private static final String MMS_PREF = "pref_mms_preferences";
|
||||
private static final String KITKAT_DEFAULT_PREF = "pref_set_default";
|
||||
private static final String SUBMIT_DEBUG_LOG_PREF = "pref_submit_debug_logs";
|
||||
private static final String OUTGOING_SMS_PREF = "pref_outgoing_sms";
|
||||
private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging";
|
||||
|
||||
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||
@ -126,6 +110,20 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
||||
fragment.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (fragmentManager.getBackStackEntryCount() > 0) {
|
||||
fragmentManager.popBackStack();
|
||||
} else {
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
MemoryCleaner.clean((MasterSecret) getIntent().getParcelableExtra("master_secret"));
|
||||
@ -141,491 +139,186 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class ApplicationPreferenceFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
initializePushMessagingToggle();
|
||||
|
||||
initializeIdentitySelection();
|
||||
initializePushMessagingToggle();
|
||||
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
|
||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_SMS_MMS));
|
||||
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
|
||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_NOTIFICATIONS));
|
||||
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
|
||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_APP_PROTECTION));
|
||||
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
|
||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_APPEARANCE));
|
||||
this.findPreference(PREFERENCE_CATEGORY_STORAGE)
|
||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_STORAGE));
|
||||
this.findPreference(PREFERENCE_CATEGORY_ADVANCED)
|
||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_ADVANCED));
|
||||
}
|
||||
|
||||
this.findPreference(TextSecurePreferences.CHANGE_PASSPHRASE_PREF)
|
||||
.setOnPreferenceClickListener(new ChangePassphraseClickListener());
|
||||
this.findPreference(TextSecurePreferences.THREAD_TRIM_NOW)
|
||||
.setOnPreferenceClickListener(new TrimNowClickListener());
|
||||
this.findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH)
|
||||
.setOnPreferenceChangeListener(new TrimLengthValidationListener());
|
||||
this.findPreference(TextSecurePreferences.DISABLE_PASSPHRASE_PREF)
|
||||
.setOnPreferenceChangeListener(new DisablePassphraseClickListener());
|
||||
this.findPreference(MMS_PREF)
|
||||
.setOnPreferenceClickListener(new ApnPreferencesClickListener());
|
||||
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());
|
||||
this.findPreference(SUBMIT_DEBUG_LOG_PREF)
|
||||
.setOnPreferenceClickListener(new SubmitDebugLogListener());
|
||||
this.findPreference(OUTGOING_SMS_PREF)
|
||||
.setOnPreferenceChangeListener(new OutgoingSmsPreferenceListener());
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.text_secure_normal__menu_settings);
|
||||
setCategorySummaries();
|
||||
}
|
||||
|
||||
initializeOutgoingSmsSummary((OutgoingSmsPreference) findPreference(OUTGOING_SMS_PREF));
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
|
||||
initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||
}
|
||||
private void setCategorySummaries() {
|
||||
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
|
||||
.setSummary(SmsMmsPreferenceFragment.getSummary(getActivity()));
|
||||
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
|
||||
.setSummary(NotificationsPreferenceFragment.getSummary(getActivity()));
|
||||
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
|
||||
.setSummary(AppProtectionPreferenceFragment.getSummary(getActivity()));
|
||||
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
|
||||
.setSummary(AppearancePreferenceFragment.getSummary(getActivity()));
|
||||
this.findPreference(PREFERENCE_CATEGORY_STORAGE)
|
||||
.setSummary(StoragePreferenceFragment.getSummary(getActivity()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener((ApplicationPreferencesActivity)getActivity());
|
||||
}
|
||||
private class CategoryClickListener implements Preference.OnPreferenceClickListener {
|
||||
private String category;
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
initializePlatformSpecificOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener((ApplicationPreferencesActivity)getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int reqCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(reqCode, resultCode, data);
|
||||
|
||||
Log.w("ApplicationPreferencesActivity", "Got result: " + resultCode + " for req: " + reqCode);
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
switch (reqCode) {
|
||||
case PICK_IDENTITY_CONTACT: handleIdentitySelection(data); break;
|
||||
case ENABLE_PASSPHRASE_ACTIVITY: getActivity().finish(); break;
|
||||
public CategoryClickListener(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializePlatformSpecificOptions() {
|
||||
PreferenceGroup pushSmsCategory = (PreferenceGroup) findPreference("push_sms_category");
|
||||
PreferenceGroup advancedCategory = (PreferenceGroup) findPreference("advanced_category");
|
||||
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
|
||||
Preference allSmsPreference = findPreference(TextSecurePreferences.ALL_SMS_PREF);
|
||||
Preference allMmsPreference = findPreference(TextSecurePreferences.ALL_MMS_PREF);
|
||||
Preference screenSecurityPreference = findPreference(TextSecurePreferences.SCREEN_SECURITY_PREF);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && pushSmsCategory != null) {
|
||||
if (allSmsPreference != null) pushSmsCategory.removePreference(allSmsPreference);
|
||||
if (allMmsPreference != null) pushSmsCategory.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 (pushSmsCategory != null && defaultPreference != null) {
|
||||
pushSmsCategory.removePreference(defaultPreference);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
|
||||
advancedCategory != null &&
|
||||
screenSecurityPreference != null)
|
||||
{
|
||||
advancedCategory.removePreference(screenSecurityPreference);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeEditTextSummary(final EditTextPreference preference) {
|
||||
if (preference.getText() == null) {
|
||||
preference.setSummary("Not set");
|
||||
} else {
|
||||
preference.setSummary(preference.getText());
|
||||
}
|
||||
|
||||
preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference pref, Object newValue) {
|
||||
preference.setSummary(newValue == null ? "Not set" : ((String) newValue));
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Fragment fragment;
|
||||
|
||||
switch (category) {
|
||||
case PREFERENCE_CATEGORY_SMS_MMS:
|
||||
fragment = new SmsMmsPreferenceFragment();
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_NOTIFICATIONS:
|
||||
fragment = new NotificationsPreferenceFragment();
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_APP_PROTECTION:
|
||||
fragment = new AppProtectionPreferenceFragment();
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_APPEARANCE:
|
||||
fragment = new AppearancePreferenceFragment();
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_STORAGE:
|
||||
fragment = new StoragePreferenceFragment();
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_ADVANCED:
|
||||
fragment = new AdvancedPreferenceFragment();
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(android.R.id.content, fragment);
|
||||
fragmentTransaction.addToBackStack(null);
|
||||
fragmentTransaction.commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initializePushMessagingToggle() {
|
||||
CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);
|
||||
preference.setChecked(TextSecurePreferences.isPushRegistered(getActivity()));
|
||||
preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
|
||||
}
|
||||
|
||||
private void initializeIdentitySelection() {
|
||||
ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity());
|
||||
|
||||
if (identity.isSelfIdentityAutoDetected()) {
|
||||
Preference preference = this.findPreference(DISPLAY_CATEGORY_PREF);
|
||||
this.getPreferenceScreen().removePreference(preference);
|
||||
} else {
|
||||
Uri contactUri = identity.getSelfIdentityUri();
|
||||
|
||||
if (contactUri != null) {
|
||||
String contactName = ContactAccessor.getInstance().getNameFromContact(getActivity(), contactUri);
|
||||
this.findPreference(TextSecurePreferences.IDENTITY_PREF)
|
||||
.setSummary(String.format(getString(R.string.ApplicationPreferencesActivity_currently_s),
|
||||
contactName));
|
||||
}
|
||||
|
||||
this.findPreference(TextSecurePreferences.IDENTITY_PREF)
|
||||
.setOnPreferenceClickListener(new IdentityPreferenceClickListener());
|
||||
}
|
||||
}
|
||||
|
||||
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(), ""));
|
||||
}
|
||||
|
||||
private void initializeOutgoingSmsSummary(OutgoingSmsPreference pref) {
|
||||
pref.setSummary(buildOutgoingSmsDescription());
|
||||
}
|
||||
|
||||
private void handleIdentitySelection(Intent data) {
|
||||
Uri contactUri = data.getData();
|
||||
|
||||
if (contactUri != null) {
|
||||
TextSecurePreferences.setIdentityContactUri(getActivity(), contactUri.toString());
|
||||
initializeIdentitySelection();
|
||||
private void initializePushMessagingToggle() {
|
||||
CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);
|
||||
preference.setChecked(TextSecurePreferences.isPushRegistered(getActivity()));
|
||||
preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
|
||||
}
|
||||
}
|
||||
|
||||
private class PushMessagingClickListener implements Preference.OnPreferenceChangeListener {
|
||||
private class PushMessagingClickListener implements Preference.OnPreferenceChangeListener {
|
||||
private static final int SUCCESS = 0;
|
||||
private static final int NETWORK_ERROR = 1;
|
||||
|
||||
private static final int SUCCESS = 0;
|
||||
private static final int NETWORK_ERROR = 1;
|
||||
private class DisablePushMessagesTask extends ProgressDialogAsyncTask<Void, Void, Integer> {
|
||||
private final CheckBoxPreference checkBoxPreference;
|
||||
|
||||
private class DisablePushMessagesTask extends AsyncTask<Void, Void, Integer> {
|
||||
private ProgressDialog dialog;
|
||||
private final Preference preference;
|
||||
public DisablePushMessagesTask(final CheckBoxPreference checkBoxPreference) {
|
||||
super(getActivity(), R.string.ApplicationPreferencesActivity_unregistering, R.string.ApplicationPreferencesActivity_unregistering_for_data_based_communication);
|
||||
this.checkBoxPreference = checkBoxPreference;
|
||||
}
|
||||
|
||||
public DisablePushMessagesTask(final Preference preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
dialog = ProgressDialog.show(getActivity(),
|
||||
getString(R.string.ApplicationPreferencesActivity_unregistering),
|
||||
getString(R.string.ApplicationPreferencesActivity_unregistering_for_data_based_communication),
|
||||
true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer result) {
|
||||
if (dialog != null)
|
||||
dialog.dismiss();
|
||||
|
||||
switch (result) {
|
||||
@Override
|
||||
protected void onPostExecute(Integer result) {
|
||||
super.onPostExecute(result);
|
||||
switch (result) {
|
||||
case NETWORK_ERROR:
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.ApplicationPreferencesActivity_error_connecting_to_server),
|
||||
R.string.ApplicationPreferencesActivity_error_connecting_to_server,
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case SUCCESS:
|
||||
((CheckBoxPreference)preference).setChecked(false);
|
||||
checkBoxPreference.setChecked(false);
|
||||
TextSecurePreferences.setPushRegistered(getActivity(), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(Void... params) {
|
||||
try {
|
||||
Context context = getActivity();
|
||||
TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
|
||||
|
||||
accountManager.setGcmId(Optional.<String>absent());
|
||||
GoogleCloudMessaging.getInstance(context).unregister();
|
||||
|
||||
return SUCCESS;
|
||||
} catch (AuthorizationFailedException afe) {
|
||||
Log.w(TAG, afe);
|
||||
return SUCCESS;
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, ioe);
|
||||
return NETWORK_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(Void... params) {
|
||||
try {
|
||||
Context context = getActivity();
|
||||
TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
|
||||
public boolean onPreferenceChange(final Preference preference, Object newValue) {
|
||||
if (((CheckBoxPreference)preference).isChecked()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_info_icon));
|
||||
builder.setTitle(R.string.ApplicationPreferencesActivity_disable_push_messages);
|
||||
builder.setMessage(R.string.ApplicationPreferencesActivity_this_will_disable_push_messages);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new DisablePushMessagesTask((CheckBoxPreference)preference).execute();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
} else {
|
||||
Intent nextIntent = new Intent(getActivity(), ApplicationPreferencesActivity.class);
|
||||
nextIntent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
|
||||
|
||||
accountManager.setGcmId(Optional.<String>absent());
|
||||
GoogleCloudMessaging.getInstance(context).unregister();
|
||||
|
||||
return SUCCESS;
|
||||
} catch (AuthorizationFailedException afe) {
|
||||
Log.w("ApplicationPreferencesActivity", afe);
|
||||
return SUCCESS;
|
||||
} catch (IOException ioe) {
|
||||
Log.w("ApplicationPreferencesActivity", ioe);
|
||||
return NETWORK_ERROR;
|
||||
Intent intent = new Intent(getActivity(), RegistrationActivity.class);
|
||||
intent.putExtra("cancel_button", true);
|
||||
intent.putExtra("next_intent", nextIntent);
|
||||
intent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(final Preference preference, Object newValue) {
|
||||
if (((CheckBoxPreference)preference).isChecked()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_info_icon));
|
||||
builder.setTitle(getString(R.string.ApplicationPreferencesActivity_disable_push_messages));
|
||||
builder.setMessage(getString(R.string.ApplicationPreferencesActivity_this_will_disable_push_messages));
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new DisablePushMessagesTask(preference).execute();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
} else {
|
||||
Intent intent = new Intent(getActivity(), RegistrationActivity.class);
|
||||
intent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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 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 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(String.format(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 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(true);
|
||||
|
||||
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);
|
||||
startActivityForResult(intent, ENABLE_PASSPHRASE_ACTIVITY);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class TrimLengthValidationListener implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
public TrimLengthValidationListener() {
|
||||
EditTextPreference preference = (EditTextPreference)findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH);
|
||||
preference.setSummary(preference.getText() + " " + getString(R.string.ApplicationPreferencesActivity_messages_per_conversation));
|
||||
}
|
||||
|
||||
@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("ApplicationPreferencesActivity", nfe);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Integer.parseInt((String)newValue) < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
preference.setSummary(newValue + " " +
|
||||
getString(R.string.ApplicationPreferencesActivity_messages_per_conversation));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ApnPreferencesClickListener implements Preference.OnPreferenceClickListener {
|
||||
|
||||
/* http://code.google.com/p/android/issues/detail?id=4611#c35 */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
startActivity(new Intent(getActivity(), MmsPreferencesActivity.class));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class ListSummaryListener implements Preference.OnPreferenceChangeListener {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
ListPreference asList = (ListPreference) preference;
|
||||
|
||||
int index = 0;
|
||||
for (; index < asList.getEntryValues().length; index++) {
|
||||
if (value.equals(asList.getEntryValues()[index])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
asList.setSummary(asList.getEntries()[index]);
|
||||
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 class SubmitDebugLogListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
final Intent intent = new Intent(getActivity(), LogSubmitActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class OutgoingSmsPreferenceListener implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(final Preference preference, Object newValue) {
|
||||
|
||||
preference.setSummary(buildOutgoingSmsDescription());
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
|
||||
{
|
||||
super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
if (preference != null && preference instanceof PreferenceScreen && ((PreferenceScreen)preference).getDialog() != null)
|
||||
((PreferenceScreen) preference).getDialog().getWindow().getDecorView().setBackgroundDrawable(getActivity().getWindow().getDecorView().getBackground().getConstantState().newDrawable());
|
||||
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();
|
||||
}
|
||||
|
||||
/* http://code.google.com/p/android/issues/detail?id=4611#c35 */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
|
||||
{
|
||||
super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
if (preference!=null)
|
||||
if (preference instanceof PreferenceScreen)
|
||||
if (((PreferenceScreen)preference).getDialog()!=null)
|
||||
((PreferenceScreen)preference).getDialog().getWindow().getDecorView().setBackgroundDrawable(getActivity().getWindow().getDecorView().getBackground().getConstantState().newDrawable());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
@ -33,15 +34,18 @@ public class MmsPreferencesFragment extends PreferenceFragment {
|
||||
super.onCreate(paramBundle);
|
||||
initializePreferences();
|
||||
initializeEditTextSummaries();
|
||||
((PassphraseRequiredActionBarActivity) getActivity()).getSupportActionBar()
|
||||
.setTitle(R.string.preferences__advanced_mms_access_point_names);
|
||||
}
|
||||
|
||||
private void initializePreferences() {
|
||||
if (!OutgoingMmsConnection.isConnectionPossible(getActivity())) {
|
||||
TextSecurePreferences.setUseLocalApnsEnabled(getActivity(), true);
|
||||
addPreferencesFromResource(R.xml.mms_preferences);
|
||||
this.findPreference(TextSecurePreferences.ENABLE_MANUAL_MMS_PREF).setOnPreferenceChangeListener(new OverrideMmsChangeListener());
|
||||
addPreferencesFromResource(R.xml.preferences_manual_mms);
|
||||
this.findPreference(TextSecurePreferences.ENABLE_MANUAL_MMS_PREF)
|
||||
.setOnPreferenceChangeListener(new OverrideMmsChangeListener());
|
||||
} else {
|
||||
addPreferencesFromResource(R.xml.mms_preferences);
|
||||
addPreferencesFromResource(R.xml.preferences_manual_mms);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,8 +77,16 @@ public class MmsPreferencesFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
TextSecurePreferences.setUseLocalApnsEnabled(getActivity(), true);
|
||||
Toast.makeText(getActivity(), R.string.mms_preferences_activity__manual_mms_settings_are_required, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getActivity(), R.string.MmsPreferencesFragment__manual_mms_settings_are_required,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context) {
|
||||
final int enabledResId = R.string.MmsPreferencesFragment__enabled;
|
||||
final int disabledResId = R.string.MmsPreferencesFragment__disabled;
|
||||
|
||||
return context.getString(TextSecurePreferences.isUseLocalApnsEnabled(context) ? enabledResId : disabledResId);
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ public class RegistrationActivity extends ActionBarActivity {
|
||||
this.number.addTextChangedListener(new NumberChangedListener());
|
||||
this.createButton.setOnClickListener(new CreateButtonListener());
|
||||
this.skipButton.setOnClickListener(new CancelButtonListener());
|
||||
|
||||
if (getIntent().getBooleanExtra("cancel_button", false)) {
|
||||
this.skipButton.setText(android.R.string.cancel);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeSpinner() {
|
||||
|
@ -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…
x
Reference in New Issue
Block a user