diff --git a/app/src/main/java/im/conversations/android/ui/fragment/settings/InterfaceSettingsFragment.java b/app/src/main/java/im/conversations/android/ui/fragment/settings/InterfaceSettingsFragment.java index d06baa9df..7e225fa34 100644 --- a/app/src/main/java/im/conversations/android/ui/fragment/settings/InterfaceSettingsFragment.java +++ b/app/src/main/java/im/conversations/android/ui/fragment/settings/InterfaceSettingsFragment.java @@ -36,6 +36,12 @@ public class InterfaceSettingsFragment extends PreferenceFragmentCompat { }); } + @Override + public void onStart() { + super.onStart(); + requireActivity().setTitle(R.string.pref_title_interface); + } + public SettingsActivity requireSettingsActivity() { final var activity = requireActivity(); if (activity instanceof SettingsActivity) { diff --git a/app/src/main/java/im/conversations/android/ui/fragment/settings/MainSettingsFragment.java b/app/src/main/java/im/conversations/android/ui/fragment/settings/MainSettingsFragment.java index dd6723206..a96a7ebe0 100644 --- a/app/src/main/java/im/conversations/android/ui/fragment/settings/MainSettingsFragment.java +++ b/app/src/main/java/im/conversations/android/ui/fragment/settings/MainSettingsFragment.java @@ -11,4 +11,10 @@ public class MainSettingsFragment extends PreferenceFragmentCompat { public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { setPreferencesFromResource(R.xml.preferences_main, rootKey); } + + @Override + public void onStart() { + super.onStart(); + requireActivity().setTitle(R.string.title_activity_settings); + } } diff --git a/app/src/main/java/im/conversations/android/ui/fragment/settings/SecuritySettingsFragment.java b/app/src/main/java/im/conversations/android/ui/fragment/settings/SecuritySettingsFragment.java new file mode 100644 index 000000000..72179422b --- /dev/null +++ b/app/src/main/java/im/conversations/android/ui/fragment/settings/SecuritySettingsFragment.java @@ -0,0 +1,49 @@ +package im.conversations.android.ui.fragment.settings; + +import android.os.Bundle; +import androidx.annotation.Nullable; +import androidx.preference.PreferenceFragmentCompat; +import com.google.common.base.Strings; +import im.conversations.android.R; + +public class SecuritySettingsFragment extends PreferenceFragmentCompat { + + @Override + public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { + setPreferencesFromResource(R.xml.preferences_security, rootKey); + final var omemo = findPreference("omemo"); + if (omemo == null) { + throw new IllegalStateException("The preference resource file did not contain omemo"); + } + omemo.setSummaryProvider( + preference -> { + final var sharedPreferences = preference.getSharedPreferences(); + final String value; + if (sharedPreferences == null) { + value = null; + } else { + value = + sharedPreferences.getString( + preference.getKey(), + requireContext().getString(R.string.omemo_setting_default)); + } + switch (Strings.nullToEmpty(value)) { + case "always": + return requireContext() + .getString(R.string.pref_omemo_setting_summary_always); + case "default_off": + return requireContext() + .getString(R.string.pref_omemo_setting_summary_default_off); + default: + return requireContext() + .getString(R.string.pref_omemo_setting_summary_default_on); + } + }); + } + + @Override + public void onStart() { + super.onStart(); + requireActivity().setTitle(R.string.pref_title_security); + } +} diff --git a/app/src/main/res/drawable/ic_lock_24dp.xml b/app/src/main/res/drawable/ic_lock_24dp.xml new file mode 100644 index 000000000..8f13e378b --- /dev/null +++ b/app/src/main/res/drawable/ic_lock_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_verified_user_24dp.xml b/app/src/main/res/drawable/ic_verified_user_24dp.xml new file mode 100644 index 000000000..78051816d --- /dev/null +++ b/app/src/main/res/drawable/ic_verified_user_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index c2f463293..0cb62bebe 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -31,7 +31,6 @@ android:id="@+id/material_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - app:title="@string/title_activity_settings" app:navigationIcon="@drawable/ic_arrow_back_24dp"/> true false true - \ No newline at end of file + true + default_on + diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml new file mode 100644 index 000000000..7b01760cb --- /dev/null +++ b/app/src/main/res/values/settings.xml @@ -0,0 +1,15 @@ + + + + + always + default_on + default_off + + + @string/always + @string/default_on + @string/default_off + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c42360f3..8c4c943ba 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1026,5 +1026,9 @@ Light/dark mode Appearance Allow screenshots + End-to-end encryption + Server connection + Require channel binding + Channel binding can detect some machine-in-the-middle attacks diff --git a/app/src/main/res/xml/preferences_main.xml b/app/src/main/res/xml/preferences_main.xml index dab1626ea..c60d4b281 100644 --- a/app/src/main/res/xml/preferences_main.xml +++ b/app/src/main/res/xml/preferences_main.xml @@ -10,7 +10,7 @@ app:title="@string/pref_title_security" app:summary="@string/pref_summary_security" android:icon="@drawable/ic_security_24dp" - app:fragment="im.conversations.android.ui.fragment.MainSettingsFragment"/> + app:fragment="im.conversations.android.ui.fragment.settings.SecuritySettingsFragment"/> + + + + + + + + + + + \ No newline at end of file