Skip to content

Commit 83a1bc0

Browse files
rvandermeulenmergify[bot]
authored andcommitted
Use KTX extension for SharedPreferences.edit().
1 parent 816af96 commit 83a1bc0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

app/src/main/java/org/mozilla/reference/browser/NotificationManager.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.os.Build.VERSION.SDK_INT
1515
import androidx.annotation.RequiresApi
1616
import androidx.core.app.NotificationCompat
1717
import androidx.core.app.NotificationManagerCompat
18+
import androidx.core.content.edit
1819
import androidx.core.net.toUri
1920
import androidx.preference.PreferenceManager
2021
import mozilla.components.concept.sync.Device
@@ -151,10 +152,10 @@ object NotificationManager {
151152
NotificationManagerCompat.from(context)
152153
.notify(DATA_REPORTING_TAG, DATA_REPORTING_NOTIFICATION_ID, notificationBuilder.build())
153154

154-
preferences.edit()
155-
.putLong(PREFS_POLICY_NOTIFIED_TIME, System.currentTimeMillis())
156-
.putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION)
157-
.apply()
155+
preferences.edit {
156+
putLong(PREFS_POLICY_NOTIFIED_TIME, System.currentTimeMillis())
157+
putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION)
158+
}
158159
}
159160

160161
private fun getNotificationChannelId(

app/src/main/java/org/mozilla/reference/browser/settings/Settings.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package org.mozilla.reference.browser.settings
66

77
import android.content.Context
8+
import androidx.core.content.edit
89
import androidx.preference.PreferenceManager
910
import org.mozilla.reference.browser.R
1011

@@ -29,18 +30,16 @@ object Settings {
2930

3031
fun setOverrideAmoUser(context: Context, value: String) {
3132
val key = context.getString(R.string.pref_key_override_amo_user)
32-
PreferenceManager.getDefaultSharedPreferences(context)
33-
.edit()
34-
.putString(key, value)
35-
.apply()
33+
PreferenceManager.getDefaultSharedPreferences(context).edit {
34+
putString(key, value)
35+
}
3636
}
3737

3838
fun setOverrideAmoCollection(context: Context, value: String) {
3939
val key = context.getString(R.string.pref_key_override_amo_collection)
40-
PreferenceManager.getDefaultSharedPreferences(context)
41-
.edit()
42-
.putString(key, value)
43-
.apply()
40+
PreferenceManager.getDefaultSharedPreferences(context).edit {
41+
putString(key, value)
42+
}
4443
}
4544

4645
fun isAmoCollectionOverrideConfigured(context: Context): Boolean {

0 commit comments

Comments
 (0)