From 4ad86a13a0ecb89d9286e131d1574880be42a29c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 27 Sep 2019 11:42:46 +0200 Subject: [PATCH] Upgrade the dependencies to the latest version --- gradle/wrapper/gradle-wrapper.properties | 4 +- matrix-sdk-android-rx/build.gradle | 6 +- matrix-sdk-android/build.gradle | 17 ++-- vector/build.gradle | 22 ++++-- .../fcm/VectorFirebaseMessagingService.kt | 27 +++---- ...sAdvancedNotificationPreferenceFragment.kt | 79 +++++++++---------- .../settings/VectorSettingsFlairFragment.kt | 2 +- .../settings/VectorSettingsGeneralFragment.kt | 35 ++++---- .../VectorSettingsHelpAboutFragment.kt | 19 ++--- .../VectorSettingsIgnoredUsersFragment.kt | 9 +-- .../VectorSettingsNotificationFragment.kt | 3 +- .../VectorSettingsPreferencesFragment.kt | 12 +-- .../VectorSettingsSecurityPrivacyFragment.kt | 35 ++++---- .../VectorSettingsVoiceVideoFragment.kt | 5 +- .../main/res/xml/vector_settings_general.xml | 2 +- 15 files changed, 140 insertions(+), 137 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 240d7e10ef..51b92600a0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Mar 19 09:53:05 CET 2019 +#Fri Sep 27 10:10:35 CEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle index 6e24d1d582..643eca82a3 100644 --- a/matrix-sdk-android-rx/build.gradle +++ b/matrix-sdk-android-rx/build.gradle @@ -29,12 +29,14 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - + kotlinOptions { + jvmTarget = "1.8" + } } dependencies { implementation project(":matrix-sdk-android") - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' // Paging diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index 8002625e12..a6ebe75e72 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -67,6 +67,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + kotlinOptions { + jvmTarget = "1.8" + } } static def gitRevision() { @@ -86,11 +90,10 @@ static def gitRevisionDate() { dependencies { - def arrow_version = "0.8.0" - def support_version = '1.1.0-beta01' + def arrow_version = "0.8.2" def moshi_version = '1.8.0' - def lifecycle_version = '2.0.0' - def coroutines_version = "1.0.1" + def lifecycle_version = '2.1.0' + def coroutines_version = "1.1.1" def markwon_version = '3.0.0' def daggerVersion = '2.23.1' @@ -98,8 +101,8 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - implementation "androidx.appcompat:appcompat:1.1.0-rc01" - implementation "androidx.recyclerview:recyclerview:1.1.0-beta01" + implementation "androidx.appcompat:appcompat:1.1.0" + implementation "androidx.recyclerview:recyclerview:1.1.0-beta04" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" @@ -120,7 +123,7 @@ dependencies { kapt 'dk.ilios:realmfieldnameshelper:1.1.1' // Work - implementation "androidx.work:work-runtime-ktx:2.1.0-rc01" + implementation "androidx.work:work-runtime-ktx:2.3.0-alpha01" // FP implementation "io.arrow-kt:arrow-core:$arrow_version" diff --git a/vector/build.gradle b/vector/build.gradle index c025219dae..586f007c54 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -208,6 +208,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + kotlinOptions { + jvmTarget = "1.8" + } } dependencies { @@ -229,10 +233,10 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' + implementation 'androidx.appcompat:appcompat:1.1.0' //Do not use beta2 at the moment, as it breaks things - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1' - implementation 'androidx.core:core-ktx:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' + implementation 'androidx.core:core-ktx:1.1.0' implementation "org.threeten:threetenbp:1.4.0:no-tzdb" implementation "com.gabrielittner.threetenbp:lazythreetenbp:0.7.0" @@ -251,7 +255,7 @@ dependencies { // rx implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' - implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' + implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0' // RXBinding implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0' @@ -264,7 +268,7 @@ dependencies { implementation 'com.airbnb.android:mvrx:1.0.1' // Work - implementation "androidx.work:work-runtime-ktx:2.1.0-rc01" + implementation "androidx.work:work-runtime-ktx:2.3.0-alpha01" // Paging implementation "androidx.paging:paging-runtime-ktx:2.1.0" @@ -273,11 +277,11 @@ dependencies { implementation "io.arrow-kt:arrow-core:$arrow_version" // Pref - implementation 'androidx.preference:preference:1.0.0' + implementation 'androidx.preference:preference:1.1.0' // UI implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' - implementation 'com.google.android.material:material:1.1.0-alpha08' + implementation 'com.google.android.material:material:1.1.0-alpha10' implementation 'me.gujun.android:span:1.7' implementation "ru.noties.markwon:core:$markwon_version" implementation "ru.noties.markwon:html:$markwon_version" @@ -324,7 +328,9 @@ dependencies { kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.4.0' // gplay flavor only - gplayImplementation('com.google.firebase:firebase-messaging:19.0.1') { + // Warning: due to the exclude, Android Studio does not propose to upgrade. Uncomment next line to be proposed to upgrade + // implementation 'com.google.firebase:firebase-messaging:20.0.0' + gplayImplementation('com.google.firebase:firebase-messaging:20.0.0') { exclude group: 'com.google.firebase', module: 'firebase-core' exclude group: 'com.google.firebase', module: 'firebase-analytics' exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' diff --git a/vector/src/gplay/java/im/vector/riotx/gplay/push/fcm/VectorFirebaseMessagingService.kt b/vector/src/gplay/java/im/vector/riotx/gplay/push/fcm/VectorFirebaseMessagingService.kt index cde848ea41..4856730489 100755 --- a/vector/src/gplay/java/im/vector/riotx/gplay/push/fcm/VectorFirebaseMessagingService.kt +++ b/vector/src/gplay/java/im/vector/riotx/gplay/push/fcm/VectorFirebaseMessagingService.kt @@ -73,16 +73,12 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { * * @param message the message */ - override fun onMessageReceived(message: RemoteMessage?) { + override fun onMessageReceived(message: RemoteMessage) { if (!vectorPreferences.areNotificationEnabledForDevice()) { Timber.i("Notification are disabled for this device") return } - if (message == null || message.data == null) { - Timber.e("## onMessageReceived() : received a null message or message with no data") - return - } if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { Timber.i("## onMessageReceived() %s", message.data.toString()) Timber.i("## onMessageReceived() from FCM with priority %s", message.priority) @@ -103,15 +99,11 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { * when the InstanceID token is initially generated, so this is where * you retrieve the token. */ - override fun onNewToken(refreshedToken: String?) { + override fun onNewToken(refreshedToken: String) { Timber.i("onNewToken: FCM Token has been updated") FcmHelper.storeFcmToken(this, refreshedToken) - if (refreshedToken == null) { - Timber.w("onNewToken:received null token") - } else { - if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) { - pusherManager.registerPusherWithFcmKey(refreshedToken) - } + if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) { + pusherManager.registerPusherWithFcmKey(refreshedToken) } } @@ -226,8 +218,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { } else { if (notifiableEvent is NotifiableMessageEvent) { if (TextUtils.isEmpty(notifiableEvent.senderName)) { - notifiableEvent.senderName = data["sender_display_name"] - ?: data["sender"] ?: "" + notifiableEvent.senderName = data["sender_display_name"] ?: data["sender"] ?: "" } if (TextUtils.isEmpty(notifiableEvent.roomName)) { notifiableEvent.roomName = findRoomNameBestEffort(data, session) ?: "" @@ -272,11 +263,11 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { try { return Event(eventId = data["event_id"], - senderId = data["sender"], - roomId = data["room_id"], - type = data.getValue("type"), + senderId = data["sender"], + roomId = data["room_id"], + type = data.getValue("type"), // TODO content = data.getValue("content"), - originServerTs = System.currentTimeMillis()) + originServerTs = System.currentTimeMillis()) } catch (e: Exception) { Timber.e(e, "buildEvent fails ") } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt index ec70a126cc..f01bb549f6 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt @@ -28,6 +28,7 @@ import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.extensions.withArgs import im.vector.riotx.core.preference.BingRule import im.vector.riotx.core.preference.BingRulePreference +import im.vector.riotx.core.preference.VectorPreference import im.vector.riotx.features.notifications.NotificationUtils import javax.inject.Inject @@ -54,7 +55,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF override fun bindPref() { - val callNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_CALL_NOTIFICATION_PREFERENCE_KEY) + val callNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_CALL_NOTIFICATION_PREFERENCE_KEY)!! if (NotificationUtils.supportNotificationChannels()) { callNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener { NotificationUtils.openSystemSettingsForCallCategory(this) @@ -64,7 +65,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF callNotificationsSystemOptions.isVisible = false } - val noisyNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_NOISY_NOTIFICATION_PREFERENCE_KEY) + val noisyNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_NOISY_NOTIFICATION_PREFERENCE_KEY)!! if (NotificationUtils.supportNotificationChannels()) { noisyNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener { NotificationUtils.openSystemSettingsForNoisyCategory(this) @@ -74,7 +75,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF noisyNotificationsSystemOptions.isVisible = false } - val silentNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_SILENT_NOTIFICATION_PREFERENCE_KEY) + val silentNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_SILENT_NOTIFICATION_PREFERENCE_KEY)!! if (NotificationUtils.supportNotificationChannels()) { silentNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener { NotificationUtils.openSystemSettingsForSilentCategory(this) @@ -86,7 +87,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF // Ringtone - val ringtonePreference = findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY) + val ringtonePreference = findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY)!! if (NotificationUtils.supportNotificationChannels()) { ringtonePreference.isVisible = false @@ -106,45 +107,43 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF } for (preferenceKey in mPrefKeyToBingRuleId.keys) { - val preference = findPreference(preferenceKey) - if (null != preference) { - if (preference is BingRulePreference) { - //preference.isEnabled = null != rules && isConnected && pushManager.areDeviceNotificationsAllowed() - val rule: BingRule? = null // TODO session.dataHandler.pushRules()?.findDefaultRule(mPrefKeyToBingRuleId[preferenceKey]) + val preference = findPreference(preferenceKey) + if (preference is BingRulePreference) { + //preference.isEnabled = null != rules && isConnected && pushManager.areDeviceNotificationsAllowed() + val rule: BingRule? = null // TODO session.dataHandler.pushRules()?.findDefaultRule(mPrefKeyToBingRuleId[preferenceKey]) - if (rule == null) { - // The rule is not defined, hide the preference - preference.isVisible = false - } else { - preference.isVisible = true - preference.setBingRule(rule) - preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> - val rule = preference.createRule(newValue as Int) - if (null != rule) { - /* - TODO - displayLoadingView() - session.dataHandler.bingRulesManager.updateRule(preference.rule, - rule, - object : BingRulesManager.onBingRuleUpdateListener { - private fun onDone() { - refreshDisplay() - hideLoadingView() - } + if (rule == null) { + // The rule is not defined, hide the preference + preference.isVisible = false + } else { + preference.isVisible = true + preference.setBingRule(rule) + preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> + val rule = preference.createRule(newValue as Int) + if (null != rule) { + /* + TODO + displayLoadingView() + session.dataHandler.bingRulesManager.updateRule(preference.rule, + rule, + object : BingRulesManager.onBingRuleUpdateListener { + private fun onDone() { + refreshDisplay() + hideLoadingView() + } - override fun onBingRuleUpdateSuccess() { - onDone() - } + override fun onBingRuleUpdateSuccess() { + onDone() + } - override fun onBingRuleUpdateFailure(errorMessage: String) { - activity?.toast(errorMessage) - onDone() - } - }) - */ - } - false + override fun onBingRuleUpdateFailure(errorMessage: String) { + activity?.toast(errorMessage) + onDone() + } + }) + */ } + false } } } @@ -166,7 +165,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF val notificationRingToneName = vectorPreferences.getNotificationRingToneName() if (null != notificationRingToneName) { vectorPreferences.setNotificationRingTone(vectorPreferences.getNotificationRingTone()) - findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY).summary = notificationRingToneName + findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY)!!.summary = notificationRingToneName } } } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsFlairFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsFlairFragment.kt index 817de1ad97..0ce468d292 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsFlairFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsFlairFragment.kt @@ -30,7 +30,7 @@ class VectorSettingsFlairFragment : VectorSettingsBaseFragment() { // Group Flairs private val mGroupsFlairCategory by lazy { - findPreference(VectorPreferences.SETTINGS_GROUPS_FLAIR_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_GROUPS_FLAIR_KEY)!! } override fun bindPref() { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt index e51feb2363..efaddb8db0 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt @@ -61,25 +61,25 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { private var mDisplayedPhoneNumber = ArrayList() private val mUserSettingsCategory by lazy { - findPreference(VectorPreferences.SETTINGS_USER_SETTINGS_PREFERENCE_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_USER_SETTINGS_PREFERENCE_KEY)!! } private val mUserAvatarPreference by lazy { - findPreference(VectorPreferences.SETTINGS_PROFILE_PICTURE_PREFERENCE_KEY) as UserAvatarPreference + findPreference(VectorPreferences.SETTINGS_PROFILE_PICTURE_PREFERENCE_KEY)!! } private val mDisplayNamePreference by lazy { - findPreference(VectorPreferences.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY) as EditTextPreference + findPreference(VectorPreferences.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY)!! } private val mPasswordPreference by lazy { - findPreference(VectorPreferences.SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY)!! } // Local contacts private val mContactSettingsCategory by lazy { - findPreference(VectorPreferences.SETTINGS_CONTACT_PREFERENCE_KEYS) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_CONTACT_PREFERENCE_KEYS)!! } private val mContactPhonebookCountryPreference by lazy { - findPreference(VectorPreferences.SETTINGS_CONTACTS_PHONEBOOK_COUNTRY_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_CONTACTS_PHONEBOOK_COUNTRY_PREFERENCE_KEY)!! } @@ -111,7 +111,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { } // Add Email - (findPreference(ADD_EMAIL_PREFERENCE_KEY) as EditTextPreference).let { + findPreference(ADD_EMAIL_PREFERENCE_KEY)!!.let { // It does not work on XML, do it here it.icon = activity?.let { ThemeUtils.tintDrawable(it, @@ -129,7 +129,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { } // Add phone number - findPreference(ADD_PHONE_NUMBER_PREFERENCE_KEY).let { + findPreference(ADD_PHONE_NUMBER_PREFERENCE_KEY)!!.let { // It does not work on XML, do it here it.icon = activity?.let { ThemeUtils.tintDrawable(it, @@ -147,15 +147,15 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // Advanced settings // user account - findPreference(VectorPreferences.SETTINGS_LOGGED_IN_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_LOGGED_IN_PREFERENCE_KEY)!! .summary = session.myUserId // home server - findPreference(VectorPreferences.SETTINGS_HOME_SERVER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_HOME_SERVER_PREFERENCE_KEY)!! .summary = session.sessionParams.homeServerConnectionConfig.homeServerUri.toString() // identity server - findPreference(VectorPreferences.SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY)!! .summary = session.sessionParams.homeServerConnectionConfig.identityServerUri.toString() @@ -165,7 +165,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { setContactsPreferences() // clear cache - findPreference(VectorPreferences.SETTINGS_CLEAR_CACHE_PREFERENCE_KEY).let { + findPreference(VectorPreferences.SETTINGS_CLEAR_CACHE_PREFERENCE_KEY)!!.let { /* TODO MXSession.getApplicationSizeCaches(activity, object : SimpleApiCallback() { @@ -185,7 +185,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { } // clear medias cache - findPreference(VectorPreferences.SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY).let { + findPreference(VectorPreferences.SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY)!!.let { val size = getSizeOfFiles(requireContext(), File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)) @@ -218,7 +218,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { } // Sign out - findPreference("SETTINGS_SIGN_OUT_KEY") + findPreference("SETTINGS_SIGN_OUT_KEY")!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.let { SignOutUiWorker(requireActivity()) @@ -232,7 +232,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // Deactivate account section // deactivate account - findPreference(VectorPreferences.SETTINGS_DEACTIVATE_ACCOUNT_KEY) + findPreference(VectorPreferences.SETTINGS_DEACTIVATE_ACCOUNT_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.let { notImplemented() @@ -478,7 +478,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { run { var index = 0 while (true) { - val preference = mUserSettingsCategory.findPreference(EMAIL_PREFERENCE_KEY_BASE + index) + val preference = mUserSettingsCategory.findPreference(EMAIL_PREFERENCE_KEY_BASE + index) if (null != preference) { mUserSettingsCategory.removePreference(preference) @@ -492,8 +492,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // add new emails list mDisplayedEmails = newEmailsList - val addEmailBtn = mUserSettingsCategory.findPreference(ADD_EMAIL_PREFERENCE_KEY) - ?: return + val addEmailBtn = mUserSettingsCategory.findPreference(ADD_EMAIL_PREFERENCE_KEY) ?: return var order = addEmailBtn.order diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsHelpAboutFragment.kt index 5408eb4e18..ee5725b92b 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsHelpAboutFragment.kt @@ -24,6 +24,7 @@ import com.google.android.gms.oss.licenses.OssLicensesMenuActivity import im.vector.matrix.android.api.Matrix import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.preference.VectorPreference import im.vector.riotx.core.utils.copyToClipboard import im.vector.riotx.core.utils.displayInWebView import im.vector.riotx.features.version.VersionProvider @@ -42,7 +43,7 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() { override fun bindPref() { // preference to start the App info screen, to facilitate App permissions access - findPreference(APP_INFO_LINK_PREFERENCE_KEY) + findPreference(APP_INFO_LINK_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.let { @@ -61,7 +62,7 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() { } // application version - (findPreference(VectorPreferences.SETTINGS_VERSION_PREFERENCE_KEY)).let { + findPreference(VectorPreferences.SETTINGS_VERSION_PREFERENCE_KEY)!!.let { it.summary = versionProvider.getVersion(longFormat = false, useBuildNumber = true) it.setOnPreferenceClickListener { pref -> @@ -71,7 +72,7 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() { } // SDK version - (findPreference(VectorPreferences.SETTINGS_SDK_VERSION_PREFERENCE_KEY)).let { + findPreference(VectorPreferences.SETTINGS_SDK_VERSION_PREFERENCE_KEY)!!.let { it.summary = Matrix.getSdkVersion() it.setOnPreferenceClickListener { pref -> @@ -81,38 +82,38 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() { } // olm version - findPreference(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY)!! .summary = session.getCryptoVersion(requireContext(), false) // copyright - findPreference(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.displayInWebView(VectorSettingsUrls.COPYRIGHT) false } // terms & conditions - findPreference(VectorPreferences.SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.displayInWebView(VectorSettingsUrls.TAC) false } // privacy policy - findPreference(VectorPreferences.SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.displayInWebView(VectorSettingsUrls.PRIVACY_POLICY) false } // third party notice - findPreference(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { activity?.displayInWebView(VectorSettingsUrls.THIRD_PARTY_LICENSES) false } - findPreference(VectorPreferences.SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { // See https://developers.google.com/android/guides/opensource startActivity(Intent(requireActivity(), OssLicensesMenuActivity::class.java)) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsIgnoredUsersFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsIgnoredUsersFragment.kt index 5ff01e5f3e..690859350e 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsIgnoredUsersFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsIgnoredUsersFragment.kt @@ -20,12 +20,9 @@ import androidx.appcompat.app.AlertDialog import androidx.preference.Preference import androidx.preference.PreferenceCategory import im.vector.riotx.R +import im.vector.riotx.core.preference.VectorPreference import java.util.ArrayList import kotlin.Comparator -import kotlin.String -import kotlin.getValue -import kotlin.lazy -import kotlin.let class VectorSettingsIgnoredUsersFragment : VectorSettingsBaseFragment() { @@ -34,10 +31,10 @@ class VectorSettingsIgnoredUsersFragment : VectorSettingsBaseFragment() { // displayed the ignored users list private val mIgnoredUserSettingsCategoryDivider by lazy { - findPreference(VectorPreferences.SETTINGS_IGNORE_USERS_DIVIDER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_IGNORE_USERS_DIVIDER_PREFERENCE_KEY)!! } private val mIgnoredUserSettingsCategory by lazy { - findPreference(VectorPreferences.SETTINGS_IGNORED_USERS_PREFERENCE_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_IGNORED_USERS_PREFERENCE_KEY)!! } override fun bindPref() { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationFragment.kt index 691618a151..ef5970806c 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationFragment.kt @@ -25,6 +25,7 @@ import im.vector.matrix.android.api.pushrules.RuleKind import im.vector.riotx.R import im.vector.riotx.core.di.ActiveSessionHolder import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.preference.VectorSwitchPreference import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.push.fcm.FcmHelper import javax.inject.Inject @@ -40,7 +41,7 @@ class VectorSettingsNotificationPreferenceFragment : VectorSettingsBaseFragment( @Inject lateinit var vectorPreferences: VectorPreferences override fun bindPref() { - findPreference(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY).let { pref -> + findPreference(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY)!!.let { pref -> val pushRuleService = session val mRuleMaster = pushRuleService.getPushRules() .find { it.ruleId == RuleIds.RULE_ID_DISABLE_ALL } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsPreferencesFragment.kt index 60b8f6a0b9..bac916626e 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsPreferencesFragment.kt @@ -27,6 +27,8 @@ import androidx.preference.Preference import androidx.preference.SwitchPreference import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.preference.VectorListPreference +import im.vector.riotx.core.preference.VectorPreference import im.vector.riotx.features.configuration.VectorConfiguration import im.vector.riotx.features.themes.ThemeUtils import javax.inject.Inject @@ -37,10 +39,10 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() { override val preferenceXmlRes = R.xml.vector_settings_preferences private val selectedLanguagePreference by lazy { - findPreference(VectorPreferences.SETTINGS_INTERFACE_LANGUAGE_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_INTERFACE_LANGUAGE_PREFERENCE_KEY)!! } private val textSizePreference by lazy { - findPreference(VectorPreferences.SETTINGS_INTERFACE_TEXT_SIZE_KEY) + findPreference(VectorPreferences.SETTINGS_INTERFACE_TEXT_SIZE_KEY)!! } @Inject lateinit var vectorConfiguration: VectorConfiguration @@ -56,7 +58,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() { setUserInterfacePreferences() // Themes - findPreference(ThemeUtils.APPLICATION_THEME_KEY) + findPreference(ThemeUtils.APPLICATION_THEME_KEY)!! .onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> if (newValue is String) { vectorConfiguration.updateApplicationTheme(newValue) @@ -73,7 +75,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() { } // Url preview - (findPreference(VectorPreferences.SETTINGS_SHOW_URL_PREVIEW_KEY) as SwitchPreference).let { + findPreference(VectorPreferences.SETTINGS_SHOW_URL_PREVIEW_KEY)!!.let { /* TODO it.isChecked = session.isURLPreviewEnabled @@ -113,7 +115,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() { } // update keep medias period - findPreference(VectorPreferences.SETTINGS_MEDIA_SAVING_PERIOD_KEY).let { + findPreference(VectorPreferences.SETTINGS_MEDIA_SAVING_PERIOD_KEY)!!.let { it.summary = vectorPreferences.getSelectedMediasSavingPeriodString() it.onPreferenceClickListener = Preference.OnPreferenceClickListener { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index 8fd24924d3..c7a3ec05a5 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -50,6 +50,7 @@ import im.vector.riotx.core.intent.getFilenameFromUri import im.vector.riotx.core.platform.SimpleTextWatcher import im.vector.riotx.core.preference.ProgressBarPreference import im.vector.riotx.core.preference.VectorPreference +import im.vector.riotx.core.preference.VectorPreferenceDivider import im.vector.riotx.core.utils.* import im.vector.riotx.features.crypto.keys.KeysExporter import im.vector.riotx.features.crypto.keys.KeysImporter @@ -76,57 +77,57 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() { // cryptography private val mCryptographyCategory by lazy { - findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY)!! } private val mCryptographyCategoryDivider by lazy { - findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY)!! } // cryptography manage private val mCryptographyManageCategory by lazy { - findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY)!! } private val mCryptographyManageCategoryDivider by lazy { - findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_DIVIDER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_DIVIDER_PREFERENCE_KEY)!! } // displayed pushers private val mPushersSettingsDivider by lazy { - findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGET_DIVIDER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGET_DIVIDER_PREFERENCE_KEY)!! } private val mPushersSettingsCategory by lazy { - findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGETS_PREFERENCE_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGETS_PREFERENCE_KEY)!! } private val mDevicesListSettingsCategory by lazy { - findPreference(VectorPreferences.SETTINGS_DEVICES_LIST_PREFERENCE_KEY) as PreferenceCategory + findPreference(VectorPreferences.SETTINGS_DEVICES_LIST_PREFERENCE_KEY)!! } private val mDevicesListSettingsCategoryDivider by lazy { - findPreference(VectorPreferences.SETTINGS_DEVICES_DIVIDER_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_DEVICES_DIVIDER_PREFERENCE_KEY)!! } private val cryptoInfoDeviceNamePreference by lazy { - findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY) as VectorPreference + findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY)!! } private val cryptoInfoDeviceIdPreference by lazy { - findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY)!! } private val manageBackupPref by lazy { - findPreference(VectorPreferences.SETTINGS_SECURE_MESSAGE_RECOVERY_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_SECURE_MESSAGE_RECOVERY_PREFERENCE_KEY)!! } private val exportPref by lazy { - findPreference(VectorPreferences.SETTINGS_ENCRYPTION_EXPORT_E2E_ROOM_KEYS_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_ENCRYPTION_EXPORT_E2E_ROOM_KEYS_PREFERENCE_KEY)!! } private val importPref by lazy { - findPreference(VectorPreferences.SETTINGS_ENCRYPTION_IMPORT_E2E_ROOM_KEYS_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_ENCRYPTION_IMPORT_E2E_ROOM_KEYS_PREFERENCE_KEY)!! } private val cryptoInfoTextPreference by lazy { - findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY)!! } // encrypt to unverified devices private val sendToUnverifiedDevicesPref by lazy { - findPreference(VectorPreferences.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY) as SwitchPreference + findPreference(VectorPreferences.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY)!! } @Inject lateinit var vectorPreferences: VectorPreferences @@ -148,7 +149,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() { // Analytics // Analytics tracking management - (findPreference(VectorPreferences.SETTINGS_USE_ANALYTICS_KEY) as SwitchPreference).let { + findPreference(VectorPreferences.SETTINGS_USE_ANALYTICS_KEY)!!.let { // On if the analytics tracking is activated it.isChecked = vectorPreferences.useAnalytics() @@ -159,7 +160,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() { } // Rageshake Management - (findPreference(VectorPreferences.SETTINGS_USE_RAGE_SHAKE_KEY) as SwitchPreference).let { + findPreference(VectorPreferences.SETTINGS_USE_RAGE_SHAKE_KEY)!!.let { it.isChecked = vectorPreferences.useRageshake() it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsVoiceVideoFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsVoiceVideoFragment.kt index 27a808555d..efae5a5d56 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsVoiceVideoFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsVoiceVideoFragment.kt @@ -23,6 +23,7 @@ import android.net.Uri import androidx.preference.Preference import androidx.preference.SwitchPreference import im.vector.riotx.R +import im.vector.riotx.core.preference.VectorPreference import im.vector.riotx.core.utils.getCallRingtoneName import im.vector.riotx.core.utils.getCallRingtoneUri import im.vector.riotx.core.utils.setCallRingtoneUri @@ -34,10 +35,10 @@ class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() { override val preferenceXmlRes = R.xml.vector_settings_voice_video private val mUseRiotCallRingtonePreference by lazy { - findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_USE_RIOT_PREFERENCE_KEY) as SwitchPreference + findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_USE_RIOT_PREFERENCE_KEY)!! } private val mCallRingtonePreference by lazy { - findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY) + findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY)!! } override fun bindPref() { diff --git a/vector/src/main/res/xml/vector_settings_general.xml b/vector/src/main/res/xml/vector_settings_general.xml index b289a9b2cc..d1ffe5bcf1 100644 --- a/vector/src/main/res/xml/vector_settings_general.xml +++ b/vector/src/main/res/xml/vector_settings_general.xml @@ -79,7 +79,7 @@ + tools:summary="https://identity.server.url" />