From a55d5b926342f099c404692620ba116e1c268a52 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 9 Jan 2020 14:15:43 +1100 Subject: [PATCH] Implement detailed settings screen redesign --- AndroidManifest.xml | 6 + res/layout/activity_fragment_wrapper.xml | 6 + res/layout/preference_divider.xml | 18 ++- .../preference_right_summary_widget.xml | 23 ++-- res/values/styles.xml | 7 +- res/values/themes.xml | 4 + res/xml/preferences_app_protection.xml | 85 ++++++------ res/xml/preferences_chats.xml | 127 ++++++++++-------- res/xml/preferences_notifications.xml | 80 +++++------ .../activities/ChatSettingsActivity.kt | 19 +++ .../NotificationSettingsActivity.kt | 19 +++ .../activities/PrivacySettingsActivity.kt | 19 +++ .../redesign/activities/SettingsActivity.kt | 15 ++- .../AppProtectionPreferenceFragment.java | 5 - .../preferences/ChatsPreferenceFragment.java | 5 +- .../NotificationsPreferenceFragment.java | 10 -- 16 files changed, 268 insertions(+), 180 deletions(-) create mode 100644 res/layout/activity_fragment_wrapper.xml create mode 100644 src/org/thoughtcrime/securesms/loki/redesign/activities/ChatSettingsActivity.kt create mode 100644 src/org/thoughtcrime/securesms/loki/redesign/activities/NotificationSettingsActivity.kt create mode 100644 src/org/thoughtcrime/securesms/loki/redesign/activities/PrivacySettingsActivity.kt diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8deb3f89aa..2528296c0b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -154,6 +154,12 @@ android:windowSoftInputMode="adjustResize" /> + + + + \ No newline at end of file diff --git a/res/layout/preference_divider.xml b/res/layout/preference_divider.xml index 045cf65e49..0e3053ee9c 100644 --- a/res/layout/preference_divider.xml +++ b/res/layout/preference_divider.xml @@ -1,14 +1,12 @@ - + + android:layout_width="match_parent" + android:layout_height="@dimen/medium_spacing" + android:background="@color/cell_background" /> \ No newline at end of file diff --git a/res/layout/preference_right_summary_widget.xml b/res/layout/preference_right_summary_widget.xml index 56a908e79c..3a05234588 100644 --- a/res/layout/preference_right_summary_widget.xml +++ b/res/layout/preference_right_summary_widget.xml @@ -1,15 +1,16 @@ - + - + \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml index 88a1725dff..05b0508599 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -140,6 +140,12 @@ @color/text 20dp + + - diff --git a/res/values/themes.xml b/res/values/themes.xml index dffda525b1..da230bcc7a 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -10,6 +10,8 @@ @color/navigation_bar_background @style/Session.AlertDialog @drawable/default_session_background + @style/Session.SettingsTheme + @color/accent diff --git a/res/xml/preferences_app_protection.xml b/res/xml/preferences_app_protection.xml index 7f402e4638..488f1c3616 100644 --- a/res/xml/preferences_app_protection.xml +++ b/res/xml/preferences_app_protection.xml @@ -1,68 +1,73 @@ + + android:key="pref_android_screen_lock" + android:defaultValue="false" + android:title="@string/preferences_app_protection__screen_lock" + android:summary="@string/preferences_app_protection__lock_signal_access_with_android_screen_lock_or_fingerprint" /> - + + android:key="pref_enable_passphrase_temporary" + android:defaultValue="true" + android:title="@string/preferences__enable_passphrase" + android:summary="@string/preferences__lock_signal_and_message_notifications_with_a_passphrase" /> - + + android:defaultValue="false" + android:key="pref_timeout_passphrase" + android:title="@string/preferences__inactivity_timeout_passphrase" + android:summary="@string/preferences__auto_lock_signal_after_a_specified_time_interval_of_inactivity" + android:dependency="pref_enable_passphrase_temporary" /> - + + android:defaultValue="false" + android:key="pref_screen_security" + android:title="@string/preferences__screen_security" + android:summary="@string/preferences__disable_screen_security_to_allow_screen_shots" /> + - + + android:defaultValue="false" + android:key="pref_turn_only" + android:title="@string/preferences_advanced__always_relay_calls" + android:summary="@string/preferences_advanced__relay_all_calls_through_the_signal_server_to_avoid_revealing_your_ip_address"/> --> + android:defaultValue="false" + android:key="pref_read_receipts" + android:title="@string/preferences__read_receipts" + android:summary="@string/preferences__if_read_receipts_are_disabled_you_wont_be_able_to_see_read_receipts"/> + android:defaultValue="false" + android:key="pref_registration_lock" + android:title="@string/preferences_app_protection__registration_lock_pin" + android:summary="@string/preferences_app_protection__enable_a_registration_lock_pin_that_will_be_required"/> --> diff --git a/res/xml/preferences_chats.xml b/res/xml/preferences_chats.xml index 623b16a03d..9d0cac23f9 100644 --- a/res/xml/preferences_chats.xml +++ b/res/xml/preferences_chats.xml @@ -1,100 +1,109 @@ - + + - - + + + android:defaultValue="true" + android:key="pref_show_invite_reminder" + android:title="@string/preferences_chats__show_invitation_prompts" + android:summary="@string/preferences_chats__display_invitation_prompts_for_contacts_without_signal" /> --> + android:defaultValue="false" + android:key="pref_system_emoji" + android:title="@string/preferences_advanced__use_system_emoji" + android:summary="@string/preferences_advanced__disable_signal_built_in_emoji_support" /> + 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:defaultValue="false" + android:key="pref_backup_enabled" + android:title="@string/preferences_chats__chat_backups" + android:summary="@string/preferences_chats__backup_chats_to_external_storage" /> + android:key="pref_backup_create" + android:title="@string/preferences_chats__create_backup" + android:persistent="false" + android:dependency="pref_backup_enabled" + tools:summary="Last backup: 3 days ago" /> diff --git a/res/xml/preferences_notifications.xml b/res/xml/preferences_notifications.xml index f337d4fcb2..12dafb675a 100644 --- a/res/xml/preferences_notifications.xml +++ b/res/xml/preferences_notifications.xml @@ -2,37 +2,39 @@ - + - + - + - + + + + android:dependency="pref_key_enable_notifications" + android:key="pref_key_ringtone" + android:title="@string/preferences__sound" + android:persistent="false" + android:defaultValue="content://settings/system/notification_sound" /> + android:dependency="pref_key_enable_notifications" + android:key="pref_key_vibrate" + android:defaultValue="true" + android:title="@string/preferences__vibrate" /> + android:key="pref_key_inthread_notifications" + android:title="@string/preferences_notifications__in_chat_sounds" + android:dependency="pref_key_enable_notifications" + android:defaultValue="true" /> + android:key="pref_repeat_alerts" + android:defaultValue="0" + android:title="@string/preferences__repeat_alerts" + android:dependency="pref_key_enable_notifications" + android:entries="@array/pref_repeat_alerts_entries" + android:entryValues="@array/pref_repeat_alerts_values" /> - + + android:key="pref_notification_privacy" + android:title="@string/preferences_notifications__show" + android:dependency="pref_key_enable_notifications" + android:defaultValue="all" + android:entries="@array/pref_notification_privacy_entries" + android:entryValues="@array/pref_notification_privacy_values" /> diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/ChatSettingsActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/ChatSettingsActivity.kt new file mode 100644 index 0000000000..73ff12be3d --- /dev/null +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/ChatSettingsActivity.kt @@ -0,0 +1,19 @@ +package org.thoughtcrime.securesms.loki.redesign.activities + +import android.os.Bundle +import network.loki.messenger.R +import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity +import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment + +class ChatSettingsActivity : PassphraseRequiredActionBarActivity() { + + override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { + super.onCreate(savedInstanceState, isReady) + setContentView(R.layout.activity_fragment_wrapper) + supportActionBar!!.title = "Chats" + val fragment = ChatsPreferenceFragment() + val transaction = supportFragmentManager.beginTransaction() + transaction.replace(R.id.fragmentContainer, fragment) + transaction.commit() + } +} \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/NotificationSettingsActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/NotificationSettingsActivity.kt new file mode 100644 index 0000000000..63f42b8a82 --- /dev/null +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/NotificationSettingsActivity.kt @@ -0,0 +1,19 @@ +package org.thoughtcrime.securesms.loki.redesign.activities + +import android.os.Bundle +import network.loki.messenger.R +import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity +import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment + +class NotificationSettingsActivity : PassphraseRequiredActionBarActivity() { + + override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { + super.onCreate(savedInstanceState, isReady) + setContentView(R.layout.activity_fragment_wrapper) + supportActionBar!!.title = "Notifications" + val fragment = NotificationsPreferenceFragment() + val transaction = supportFragmentManager.beginTransaction() + transaction.replace(R.id.fragmentContainer, fragment) + transaction.commit() + } +} \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/PrivacySettingsActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/PrivacySettingsActivity.kt new file mode 100644 index 0000000000..82a9d79dff --- /dev/null +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/PrivacySettingsActivity.kt @@ -0,0 +1,19 @@ +package org.thoughtcrime.securesms.loki.redesign.activities + +import android.os.Bundle +import network.loki.messenger.R +import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity +import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment + +class PrivacySettingsActivity : PassphraseRequiredActionBarActivity() { + + override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { + super.onCreate(savedInstanceState, isReady) + setContentView(R.layout.activity_fragment_wrapper) + supportActionBar!!.title = "Privacy" + val fragment = AppProtectionPreferenceFragment() + val transaction = supportFragmentManager.beginTransaction() + transaction.replace(R.id.fragmentContainer, fragment) + transaction.commit() + } +} \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt index 18ddec301c..8eac97e993 100644 --- a/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt @@ -23,7 +23,6 @@ import nl.komponents.kovenant.all import nl.komponents.kovenant.deferred import nl.komponents.kovenant.ui.alwaysUi import org.thoughtcrime.securesms.ApplicationContext -import org.thoughtcrime.securesms.ApplicationPreferencesActivity import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.avatar.AvatarSelection import org.thoughtcrime.securesms.crypto.ProfileKeyUtil @@ -89,6 +88,8 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { seedButton.visibility = View.GONE } privacyButton.setOnClickListener { showPrivacySettings() } + notificationsButton.setOnClickListener { showNotificationSettings() } + chatsButton.setOnClickListener { showChatSettings() } seedButton.setOnClickListener { showSeed() } clearAllDataButton.setOnClickListener { clearAllData() } } @@ -250,7 +251,17 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } private fun showPrivacySettings() { - val intent = Intent(this, ApplicationPreferencesActivity::class.java) + val intent = Intent(this, PrivacySettingsActivity::class.java) + push(intent) + } + + private fun showNotificationSettings() { + val intent = Intent(this, NotificationSettingsActivity::class.java) + push(intent) + } + + private fun showChatSettings() { + val intent = Intent(this, ChatSettingsActivity::class.java) push(intent) } diff --git a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java index f0407c15b7..e511b230e6 100644 --- a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java @@ -12,7 +12,6 @@ import android.support.v7.preference.Preference; import android.widget.Toast; import org.thoughtcrime.securesms.ApplicationContext; -import org.thoughtcrime.securesms.ApplicationPreferencesActivity; import org.thoughtcrime.securesms.BlockedContactsActivity; import org.thoughtcrime.securesms.PassphraseChangeActivity; import org.thoughtcrime.securesms.components.SwitchPreferenceCompat; @@ -72,8 +71,6 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment disablePassphrase.setOnPreferenceChangeListener(new DisablePassphraseClickListener()); initializeVisibility(); - - Analytics.Companion.getShared().track("Privacy Settings Opened"); } @Override @@ -84,8 +81,6 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment @Override public void onResume() { super.onResume(); - ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__privacy); - if (!TextSecurePreferences.isPasswordDisabled(getContext())) initializePassphraseTimeoutSummary(); else initializeScreenLockTimeoutSummary(); diff --git a/src/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java index 99fa160747..c3a092cf1b 100644 --- a/src/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java @@ -17,8 +17,6 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.thoughtcrime.securesms.ApplicationContext; -import org.thoughtcrime.securesms.ApplicationPreferencesActivity; -import network.loki.messenger.R; import org.thoughtcrime.securesms.backup.BackupDialog; import org.thoughtcrime.securesms.backup.FullBackupBase.BackupEvent; import org.thoughtcrime.securesms.components.SwitchPreferenceCompat; @@ -35,6 +33,8 @@ import java.util.List; import java.util.Locale; import java.util.Set; +import network.loki.messenger.R; + public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment { private static final String TAG = ChatsPreferenceFragment.class.getSimpleName(); @@ -76,7 +76,6 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment { @Override public void onResume() { super.onResume(); - ((ApplicationPreferencesActivity)getActivity()).getSupportActionBar().setTitle(R.string.preferences__chats); setMediaDownloadSummaries(); setBackupSummary(); } diff --git a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java index 01f014b8f0..fd58d1d4b2 100644 --- a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java @@ -14,12 +14,10 @@ import android.support.v7.preference.ListPreference; import android.support.v7.preference.Preference; import android.text.TextUtils; -import org.thoughtcrime.securesms.ApplicationPreferencesActivity; import org.thoughtcrime.securesms.components.SwitchPreferenceCompat; import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.thoughtcrime.securesms.util.TextSecurePreferences; -import org.whispersystems.signalservice.loki.utilities.Analytics; import network.loki.messenger.R; @@ -121,8 +119,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme // initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF)); initializeMessageVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.VIBRATE_PREF)); // initializeCallVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.CALL_VIBRATE_PREF)); - - Analytics.Companion.getShared().track("Notification Settings Opened"); } @Override @@ -130,12 +126,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme addPreferencesFromResource(R.xml.preferences_notifications); } - @Override - public void onResume() { - super.onResume(); - ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__notifications); - } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1 && resultCode == RESULT_OK && data != null) {