From 5cfcd65b38aa6a24c8f9d390d9a8f3d0f6fd6764 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 4 Feb 2022 17:29:31 +0100 Subject: [PATCH 1/7] Create a new resource in config file for default setting value. First case: message bubbles --- .../im/vector/app/features/settings/VectorPreferences.kt | 5 ++++- vector/src/main/res/values/config.xml | 5 +++++ vector/src/main/res/xml/vector_settings_preferences.xml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 6a4b5484eb..352c5768fb 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -20,6 +20,7 @@ import android.content.SharedPreferences import android.media.RingtoneManager import android.net.Uri import android.provider.MediaStore +import androidx.annotation.BoolRes import androidx.core.content.edit import com.squareup.seismic.ShakeDetector import im.vector.app.BuildConfig @@ -300,6 +301,8 @@ class VectorPreferences @Inject constructor(private val context: Context) { } } + private fun getDefault(@BoolRes resId: Int) = context.resources.getBoolean(resId) + fun areNotificationEnabledForDevice(): Boolean { return defaultPrefs.getBoolean(SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY, true) } @@ -856,7 +859,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { * @return true to show timeline message in bubble. */ fun useMessageBubblesLayout(): Boolean { - return defaultPrefs.getBoolean(SETTINGS_INTERFACE_BUBBLE_KEY, false) + return defaultPrefs.getBoolean(SETTINGS_INTERFACE_BUBBLE_KEY, getDefault(R.bool.settings_interface_bubble_default)) } /** diff --git a/vector/src/main/res/values/config.xml b/vector/src/main/res/values/config.xml index 78b92cbfa4..b419477c1f 100755 --- a/vector/src/main/res/values/config.xml +++ b/vector/src/main/res/values/config.xml @@ -40,4 +40,9 @@ riot.im + + + + false + diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index 061674c049..b782a60749 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -83,7 +83,7 @@ From b12c8901917d489a9459f83c8cdf005ed1d887f3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 14 Feb 2022 15:37:14 +0100 Subject: [PATCH 2/7] Also add a way to hide the setting to the user --- vector/src/main/res/values/config.xml | 4 +++- vector/src/main/res/xml/vector_settings_preferences.xml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vector/src/main/res/values/config.xml b/vector/src/main/res/values/config.xml index b419477c1f..b18a0a0d4f 100755 --- a/vector/src/main/res/values/config.xml +++ b/vector/src/main/res/values/config.xml @@ -42,7 +42,9 @@ - + + true + false diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index b782a60749..78bd64111c 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -85,7 +85,8 @@ + android:title="@string/message_bubbles" + app:isPreferenceVisible="@bool/settings_interface_bubble_visible" /> Date: Wed, 23 Feb 2022 18:08:04 +0100 Subject: [PATCH 3/7] Create module vector-config --- settings.gradle | 1 + vector-config/.gitignore | 1 + vector-config/build.gradle | 20 ++++++++++++++++++++ vector-config/src/main/AndroidManifest.xml | 2 ++ 4 files changed, 24 insertions(+) create mode 100644 vector-config/.gitignore create mode 100644 vector-config/build.gradle create mode 100644 vector-config/src/main/AndroidManifest.xml diff --git a/settings.gradle b/settings.gradle index fe97b4096b..782d2caf4a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,5 @@ include ':vector' +include ':vector-config' include ':matrix-sdk-android' include ':library:core-utils' include ':library:ui-styles' diff --git a/vector-config/.gitignore b/vector-config/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/vector-config/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/vector-config/build.gradle b/vector-config/build.gradle new file mode 100644 index 0000000000..4156e74274 --- /dev/null +++ b/vector-config/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' +} + +android { + compileSdk versions.compileSdk + + defaultConfig { + minSdk versions.minSdk + targetSdk versions.targetSdk + } + compileOptions { + sourceCompatibility versions.sourceCompat + targetCompatibility versions.targetCompat + } + kotlinOptions { + jvmTarget = "11" + } +} diff --git a/vector-config/src/main/AndroidManifest.xml b/vector-config/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..4d6cf1535f --- /dev/null +++ b/vector-config/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + From 96c2c6f4a4e9d6ad062eca0213e87acc16e7559b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 23 Feb 2022 18:10:08 +0100 Subject: [PATCH 4/7] Move file config.xml to the module vector-config --- {vector => vector-config}/src/main/res/values/config.xml | 0 vector/build.gradle | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {vector => vector-config}/src/main/res/values/config.xml (100%) diff --git a/vector/src/main/res/values/config.xml b/vector-config/src/main/res/values/config.xml similarity index 100% rename from vector/src/main/res/values/config.xml rename to vector-config/src/main/res/values/config.xml diff --git a/vector/build.gradle b/vector/build.gradle index 613deeb87d..0dc6e1bc15 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -332,7 +332,7 @@ android { } dependencies { - + implementation project(":vector-config") implementation project(":matrix-sdk-android") implementation project(":matrix-sdk-android-flow") implementation project(":library:jsonviewer") From 830fca731c5c06d44c1d550c97d1f2e637f9238c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 23 Feb 2022 18:10:56 +0100 Subject: [PATCH 5/7] Move setting for preference in a dedicated file --- vector-config/src/main/res/values/config-settings.xml | 11 +++++++++++ vector-config/src/main/res/values/config.xml | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100755 vector-config/src/main/res/values/config-settings.xml diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml new file mode 100755 index 0000000000..1feee73074 --- /dev/null +++ b/vector-config/src/main/res/values/config-settings.xml @@ -0,0 +1,11 @@ + + + + + + + true + + false + + diff --git a/vector-config/src/main/res/values/config.xml b/vector-config/src/main/res/values/config.xml index b18a0a0d4f..78b92cbfa4 100755 --- a/vector-config/src/main/res/values/config.xml +++ b/vector-config/src/main/res/values/config.xml @@ -40,11 +40,4 @@ riot.im - - - - true - - false - From 03a6a348c09cdfc7aefa88240cd91b1cd9af94f4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 23 Feb 2022 18:19:24 +0100 Subject: [PATCH 6/7] Add boolean for visibility of all settings at root level --- .../src/main/res/values/config-settings.xml | 36 ++++++++++++++++++- .../src/main/res/xml/vector_settings_root.xml | 30 ++++++++++------ 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml index 1feee73074..c7c7cb0ea5 100755 --- a/vector-config/src/main/res/values/config-settings.xml +++ b/vector-config/src/main/res/values/config-settings.xml @@ -1,11 +1,45 @@ - + + + + + true + true + true + true + true + true + true + true + true + true + + + + + + true false + + + + + + + + + + + + + + + diff --git a/vector/src/main/res/xml/vector_settings_root.xml b/vector/src/main/res/xml/vector_settings_root.xml index 520c4595ca..744694cf5f 100644 --- a/vector/src/main/res/xml/vector_settings_root.xml +++ b/vector/src/main/res/xml/vector_settings_root.xml @@ -5,7 +5,8 @@ + app:fragment="im.vector.app.features.settings.VectorSettingsGeneralFragment" + app:isPreferenceVisible="@bool/settings_root_general_visible" /> + app:fragment="im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment" + app:isPreferenceVisible="@bool/settings_root_notification_visible" /> + app:fragment="im.vector.app.features.settings.VectorSettingsPreferencesFragment" + app:isPreferenceVisible="@bool/settings_root_preferences_visible" /> + app:fragment="im.vector.app.features.settings.VectorSettingsVoiceVideoFragment" + app:isPreferenceVisible="@bool/settings_root_voice_video_visible" /> + app:fragment="im.vector.app.features.settings.ignored.VectorSettingsIgnoredUsersFragment" + app:isPreferenceVisible="@bool/settings_root_ignored_users_visible" /> + app:fragment="im.vector.app.features.settings.VectorSettingsSecurityPrivacyFragment" + app:isPreferenceVisible="@bool/settings_root_security_privacy_visible" /> + app:fragment="im.vector.app.features.settings.VectorSettingsLabsFragment" + app:isPreferenceVisible="@bool/settings_root_labs_visible" /> + app:fragment="im.vector.app.features.settings.VectorSettingsAdvancedSettingsFragment" + app:isPreferenceVisible="@bool/settings_root_advanced_visible" /> + app:fragment="im.vector.app.features.settings.VectorSettingsHelpAboutFragment" + app:isPreferenceVisible="@bool/settings_root_help_about_visible" /> + app:fragment="im.vector.app.features.settings.legals.LegalsFragment" + app:isPreferenceVisible="@bool/settings_root_legals_visible" /> \ No newline at end of file From 0087f723091491e1b4d61979d0b3f1ae3f7090cb Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 23 Feb 2022 18:28:08 +0100 Subject: [PATCH 7/7] Improve doc --- vector-config/src/main/res/values/config-settings.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml index c7c7cb0ea5..0121ee9ae7 100755 --- a/vector-config/src/main/res/values/config-settings.xml +++ b/vector-config/src/main/res/values/config-settings.xml @@ -1,7 +1,11 @@ - + @@ -22,9 +26,7 @@ - true - false