Skip to content

Commit

Permalink
Use KTX extension for SharedPreferences.edit().
Browse files Browse the repository at this point in the history
  • Loading branch information
rvandermeulen authored and mergify[bot] committed Jan 11, 2025
1 parent 816af96 commit 83a1bc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.os.Build.VERSION.SDK_INT
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.preference.PreferenceManager
import mozilla.components.concept.sync.Device
Expand Down Expand Up @@ -151,10 +152,10 @@ object NotificationManager {
NotificationManagerCompat.from(context)
.notify(DATA_REPORTING_TAG, DATA_REPORTING_NOTIFICATION_ID, notificationBuilder.build())

preferences.edit()
.putLong(PREFS_POLICY_NOTIFIED_TIME, System.currentTimeMillis())
.putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION)
.apply()
preferences.edit {
putLong(PREFS_POLICY_NOTIFIED_TIME, System.currentTimeMillis())
putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION)
}
}

private fun getNotificationChannelId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.mozilla.reference.browser.settings

import android.content.Context
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import org.mozilla.reference.browser.R

Expand All @@ -29,18 +30,16 @@ object Settings {

fun setOverrideAmoUser(context: Context, value: String) {
val key = context.getString(R.string.pref_key_override_amo_user)
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(key, value)
.apply()
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(key, value)
}
}

fun setOverrideAmoCollection(context: Context, value: String) {
val key = context.getString(R.string.pref_key_override_amo_collection)
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(key, value)
.apply()
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(key, value)
}
}

fun isAmoCollectionOverrideConfigured(context: Context): Boolean {
Expand Down

0 comments on commit 83a1bc0

Please sign in to comment.