Merge pull request #5157 from vector-im/feature/bma/config_poc
Create a new resource in config file for default setting value.
This commit is contained in:
commit
5512439d36
|
@ -1,4 +1,5 @@
|
|||
include ':vector'
|
||||
include ':vector-config'
|
||||
include ':matrix-sdk-android'
|
||||
include ':library:core-utils'
|
||||
include ':library:ui-styles'
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/build
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="im.vector.app.config" />
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- This file contains values to show or hide some settings, and default values for some settings
|
||||
- boolean keys ending with "_visible" set the visibility of the setting
|
||||
- boolean keys ending with "_default" set the default value of the setting
|
||||
When a setting is hidden, the default value still applies
|
||||
-->
|
||||
|
||||
<!-- Level 0: Root -->
|
||||
|
||||
<bool name="settings_root_general_visible">true</bool>
|
||||
<bool name="settings_root_notification_visible">true</bool>
|
||||
<bool name="settings_root_preferences_visible">true</bool>
|
||||
<bool name="settings_root_voice_video_visible">true</bool>
|
||||
<bool name="settings_root_ignored_users_visible">true</bool>
|
||||
<bool name="settings_root_security_privacy_visible">true</bool>
|
||||
<bool name="settings_root_labs_visible">true</bool>
|
||||
<bool name="settings_root_advanced_visible">true</bool>
|
||||
<bool name="settings_root_help_about_visible">true</bool>
|
||||
<bool name="settings_root_legals_visible">true</bool>
|
||||
|
||||
<!-- Level 1: General -->
|
||||
|
||||
<!-- Level 1: Notifications -->
|
||||
|
||||
<!-- Level 1: Preferences -->
|
||||
|
||||
<bool name="settings_interface_bubble_visible">true</bool>
|
||||
<bool name="settings_interface_bubble_default">false</bool>
|
||||
|
||||
<!-- Level 1: Voice and video -->
|
||||
|
||||
<!-- Level 1: Ignored Users -->
|
||||
|
||||
<!-- Level 1: Security and Privacy -->
|
||||
|
||||
<!-- Level 1: Labs -->
|
||||
|
||||
<!-- Level 1: Advcanced settings -->
|
||||
|
||||
<!-- Level 1: Help and about -->
|
||||
|
||||
<!-- Level 1: Legals -->
|
||||
|
||||
|
||||
</resources>
|
|
@ -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")
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -83,9 +83,10 @@
|
|||
<im.vector.app.core.preference.VectorPreferenceCategory android:title="@string/settings_category_timeline">
|
||||
|
||||
<im.vector.app.core.preference.VectorSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:defaultValue="@bool/settings_interface_bubble_default"
|
||||
android:key="SETTINGS_INTERFACE_BUBBLE_KEY"
|
||||
android:title="@string/message_bubbles" />
|
||||
android:title="@string/message_bubbles"
|
||||
app:isPreferenceVisible="@bool/settings_interface_bubble_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorSwitchPreference
|
||||
android:defaultValue="true"
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_general"
|
||||
android:title="@string/settings_general_title"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsGeneralFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsGeneralFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_general_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_flair"
|
||||
|
@ -16,46 +17,55 @@
|
|||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_notification"
|
||||
android:title="@string/settings_notifications"
|
||||
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment" />
|
||||
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_notification_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_preferences"
|
||||
android:title="@string/settings_preferences"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsPreferencesFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsPreferencesFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_preferences_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_call"
|
||||
android:title="@string/preference_voice_and_video"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsVoiceVideoFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsVoiceVideoFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_voice_video_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_ignored_users"
|
||||
android:title="@string/settings_ignored_users"
|
||||
app:fragment="im.vector.app.features.settings.ignored.VectorSettingsIgnoredUsersFragment" />
|
||||
app:fragment="im.vector.app.features.settings.ignored.VectorSettingsIgnoredUsersFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_ignored_users_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_security_privacy"
|
||||
android:title="@string/settings_security_and_privacy"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsSecurityPrivacyFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsSecurityPrivacyFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_security_privacy_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_labs"
|
||||
android:title="@string/room_settings_labs_pref_title"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsLabsFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsLabsFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_labs_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_advanced"
|
||||
android:title="@string/settings_advanced_settings"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsAdvancedSettingsFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsAdvancedSettingsFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_advanced_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_help_about"
|
||||
android:title="@string/preference_root_help_about"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsHelpAboutFragment" />
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsHelpAboutFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_help_about_visible" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:icon="@drawable/ic_settings_root_legals"
|
||||
android:title="@string/preference_root_legals"
|
||||
app:fragment="im.vector.app.features.settings.legals.LegalsFragment" />
|
||||
app:fragment="im.vector.app.features.settings.legals.LegalsFragment"
|
||||
app:isPreferenceVisible="@bool/settings_root_legals_visible" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue