From ce3242c748678ea94b84d5037c1614e01162810e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 25 Jun 2019 15:03:32 +0200 Subject: [PATCH] Code quality: preference --- tools/check/forbidden_strings_in_resources.txt | 6 +++--- .../core/preference/UserAvatarPreference.kt | 3 ++- .../preference/VectorEditTextPreference.kt | 3 ++- .../core/preference/VectorListPreference.kt | 3 ++- .../core/preference/VectorPreference.kt | 7 ++----- .../preference/VectorPreferenceCategory.kt | 7 +++++-- .../core/preference/VectorSwitchPreference.kt | 3 ++- .../services/AlarmSyncBroadcastReceiver.kt | 7 +++---- .../core/services/VectorSyncService.kt | 4 +--- ...tings_notification_advanced_preferences.xml | 4 ++-- .../res/xml/vector_settings_notifications.xml | 18 +++++++++--------- .../xml/vector_settings_preferences_root.xml | 18 +++++++++--------- 12 files changed, 42 insertions(+), 41 deletions(-) diff --git a/tools/check/forbidden_strings_in_resources.txt b/tools/check/forbidden_strings_in_resources.txt index 26d7725591..120438efde 100644 --- a/tools/check/forbidden_strings_in_resources.txt +++ b/tools/check/forbidden_strings_in_resources.txt @@ -70,13 +70,13 @@ DO NOT COMMIT layout_constraintRight_ layout_constraintLeft_ -### Use Preference from v7 library (android.support.v7.preference.PreferenceScreen) +### Use Preference from androidx library (androidx.preference.PreferenceScreen) = Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { ContextCompat.startForegroundService(context, intent) } else { context.startService(intent) @@ -41,7 +40,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { } } - scheduleAlarm(context,30_000L) + scheduleAlarm(context, 30_000L) Timber.i("Alarm scheduled to restart service") } @@ -56,7 +55,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { intent, PendingIntent.FLAG_UPDATE_CURRENT) val firstMillis = System.currentTimeMillis() + delay val alarmMgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager - if (SDK_INT >= Build.VERSION_CODES.M) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarmMgr.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, firstMillis, pIntent) } else { alarmMgr.set(AlarmManager.RTC_WAKEUP, firstMillis, pIntent) diff --git a/vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt b/vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt index e56399b917..6f105c94fd 100644 --- a/vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt +++ b/vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt @@ -19,13 +19,11 @@ import android.app.NotificationManager import android.content.Context import android.content.Intent import android.os.Build -import android.os.Build.VERSION.SDK_INT import android.os.IBinder import im.vector.matrix.android.internal.session.sync.job.SyncService import im.vector.riotredesign.R import im.vector.riotredesign.features.notifications.NotificationUtils import timber.log.Timber -import java.util.* class VectorSyncService : SyncService() { @@ -51,7 +49,7 @@ class VectorSyncService : SyncService() { */ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { Timber.v("VectorSyncService - onStartCommand ") - if (SDK_INT >= Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notification = NotificationUtils.buildForegroundServiceNotification(applicationContext, R.string.notification_listening_for_events, false) startForeground(NotificationUtils.NOTIFICATION_ID_FOREGROUND_SERVICE, notification) } diff --git a/vector/src/main/res/xml/vector_settings_notification_advanced_preferences.xml b/vector/src/main/res/xml/vector_settings_notification_advanced_preferences.xml index 5ff42694ee..bb5de919c5 100644 --- a/vector/src/main/res/xml/vector_settings_notification_advanced_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_notification_advanced_preferences.xml @@ -1,7 +1,7 @@ - @@ -34,7 +34,7 @@ android:key="SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY_2" android:title="@string/settings_messages_sent_by_bot" /> - + diff --git a/vector/src/main/res/xml/vector_settings_notifications.xml b/vector/src/main/res/xml/vector_settings_notifications.xml index ed20daf6ac..325c5fe11e 100644 --- a/vector/src/main/res/xml/vector_settings_notifications.xml +++ b/vector/src/main/res/xml/vector_settings_notifications.xml @@ -1,12 +1,12 @@ - - + - @@ -17,12 +17,12 @@ - + - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/vector/src/main/res/xml/vector_settings_preferences_root.xml b/vector/src/main/res/xml/vector_settings_preferences_root.xml index cb3b5840b0..077293706d 100644 --- a/vector/src/main/res/xml/vector_settings_preferences_root.xml +++ b/vector/src/main/res/xml/vector_settings_preferences_root.xml @@ -1,21 +1,21 @@ - - - - - - - - - \ No newline at end of file + \ No newline at end of file