mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 09:13:23 +00:00
refactor: adopt androidx.core KTX helpers (Bitmap/Uri/SharedPreferences)
This commit is contained in:
+2
-1
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.commons.blurhash
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.core.graphics.scale
|
||||
|
||||
actual class PlatformImage(
|
||||
val bitmap: Bitmap,
|
||||
@@ -43,7 +44,7 @@ actual class PlatformImage(
|
||||
actual fun scale(
|
||||
width: Int,
|
||||
height: Int,
|
||||
): PlatformImage = PlatformImage(Bitmap.createScaledBitmap(bitmap, width, height, false))
|
||||
): PlatformImage = PlatformImage(bitmap.scale(width, height, false))
|
||||
|
||||
actual companion object {
|
||||
actual fun create(
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.commons.keystorage
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.content.edit
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import androidx.security.crypto.MasterKey
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -86,7 +87,7 @@ actual class SecureKeyStorage private actual constructor() {
|
||||
) {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
encryptedPrefs.edit().putString(KEY_PREFIX + npub, privKeyHex).apply()
|
||||
encryptedPrefs.edit { putString(KEY_PREFIX + npub, privKeyHex) }
|
||||
} catch (e: Exception) {
|
||||
throw SecureStorageException("Failed to save private key", e)
|
||||
}
|
||||
@@ -108,7 +109,7 @@ actual class SecureKeyStorage private actual constructor() {
|
||||
val key = KEY_PREFIX + npub
|
||||
val existed = encryptedPrefs.contains(key)
|
||||
if (existed) {
|
||||
encryptedPrefs.edit().remove(key).apply()
|
||||
encryptedPrefs.edit { remove(key) }
|
||||
}
|
||||
existed
|
||||
} catch (e: Exception) {
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.commons.nip64Chess
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
|
||||
actual class ChessDismissedGamesStorage private actual constructor() {
|
||||
private var prefs: SharedPreferences? = null
|
||||
@@ -48,6 +49,6 @@ actual class ChessDismissedGamesStorage private actual constructor() {
|
||||
userPubkey: String,
|
||||
ids: Set<String>,
|
||||
) {
|
||||
prefs?.edit()?.putStringSet(prefsKey(userPubkey), ids)?.apply()
|
||||
prefs?.edit { putStringSet(prefsKey(userPubkey), ids) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user