mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 19:05:56 +03:00
Remove DefaultSharedPreferences
since we now have @DefaultPreferences which provide a singleton.
This commit is contained in:
parent
c735ea5e3d
commit
2266723789
2 changed files with 15 additions and 12 deletions
|
@ -23,7 +23,7 @@ import android.content.IntentFilter
|
|||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import im.vector.app.core.debug.DebugReceiver
|
||||
import im.vector.app.core.di.DefaultSharedPreferences
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import im.vector.app.core.utils.lsFiles
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
@ -31,7 +31,10 @@ import javax.inject.Inject
|
|||
/**
|
||||
* Receiver to handle some command from ADB
|
||||
*/
|
||||
class VectorDebugReceiver @Inject constructor() : BroadcastReceiver(), DebugReceiver {
|
||||
class VectorDebugReceiver @Inject constructor(
|
||||
@DefaultPreferences
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) : BroadcastReceiver(), DebugReceiver {
|
||||
|
||||
override fun register(context: Context) {
|
||||
context.registerReceiver(this, getIntentFilter(context))
|
||||
|
@ -47,14 +50,14 @@ class VectorDebugReceiver @Inject constructor() : BroadcastReceiver(), DebugRece
|
|||
intent.action?.let {
|
||||
when {
|
||||
it.endsWith(DEBUG_ACTION_DUMP_FILESYSTEM) -> lsFiles(context)
|
||||
it.endsWith(DEBUG_ACTION_DUMP_PREFERENCES) -> dumpPreferences(context)
|
||||
it.endsWith(DEBUG_ACTION_ALTER_SCALAR_TOKEN) -> alterScalarToken(context)
|
||||
it.endsWith(DEBUG_ACTION_DUMP_PREFERENCES) -> dumpPreferences()
|
||||
it.endsWith(DEBUG_ACTION_ALTER_SCALAR_TOKEN) -> alterScalarToken()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dumpPreferences(context: Context) {
|
||||
logPrefs("DefaultSharedPreferences", DefaultSharedPreferences.getInstance(context))
|
||||
private fun dumpPreferences() {
|
||||
logPrefs("DefaultSharedPreferences", sharedPreferences)
|
||||
}
|
||||
|
||||
private fun logPrefs(name: String, sharedPreferences: SharedPreferences?) {
|
||||
|
@ -67,8 +70,8 @@ class VectorDebugReceiver @Inject constructor() : BroadcastReceiver(), DebugRece
|
|||
}
|
||||
}
|
||||
|
||||
private fun alterScalarToken(context: Context) {
|
||||
DefaultSharedPreferences.getInstance(context).edit {
|
||||
private fun alterScalarToken() {
|
||||
sharedPreferences.edit {
|
||||
// putString("SCALAR_TOKEN_PREFERENCE_KEY" + Matrix.getInstance(context).defaultSession.myUserId, "bad_token")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package im.vector.app.push.fcm
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.edit
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
|
@ -24,7 +25,7 @@ import com.google.android.gms.common.GoogleApiAvailability
|
|||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DefaultSharedPreferences
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import im.vector.app.core.pushers.FcmHelper
|
||||
import im.vector.app.core.pushers.PushersManager
|
||||
import timber.log.Timber
|
||||
|
@ -35,14 +36,13 @@ import javax.inject.Inject
|
|||
* It has an alter ego in the fdroid variant.
|
||||
*/
|
||||
class GoogleFcmHelper @Inject constructor(
|
||||
context: Context,
|
||||
@DefaultPreferences
|
||||
private val sharedPrefs: SharedPreferences,
|
||||
) : FcmHelper {
|
||||
companion object {
|
||||
private const val PREFS_KEY_FCM_TOKEN = "FCM_TOKEN"
|
||||
}
|
||||
|
||||
private val sharedPrefs = DefaultSharedPreferences.getInstance(context)
|
||||
|
||||
override fun isFirebaseAvailable(): Boolean = true
|
||||
|
||||
override fun getFcmToken(): String? {
|
||||
|
|
Loading…
Reference in a new issue