Create utility class to make preference usage easier and more reliable

This commit is contained in:
Moez Bhatti
2017-12-04 00:58:00 -05:00
parent 64504a2433
commit 61a9d87afd
4 changed files with 33 additions and 10 deletions
@@ -6,22 +6,22 @@ import android.content.Intent
import android.os.Build
import android.provider.Telephony
import android.support.annotation.RequiresApi
import com.f2prateek.rx.preferences2.RxSharedPreferences
import com.moez.QKSMS.common.di.AppComponentManager
import com.moez.QKSMS.common.util.Preferences
import com.moez.QKSMS.domain.interactor.PartialSync
import javax.inject.Inject
class DefaultSmsChangedReceiver : BroadcastReceiver() {
@Inject lateinit var partialSync: PartialSync
@Inject lateinit var prefs: RxSharedPreferences
@Inject lateinit var prefs: Preferences
@RequiresApi(Build.VERSION_CODES.N)
override fun onReceive(context: Context, intent: Intent) {
AppComponentManager.appComponent.inject(this)
val isDefaultSmsApp = intent.getBooleanExtra(Telephony.Sms.Intents.EXTRA_IS_DEFAULT_SMS_APP, false)
prefs.getBoolean("defaultSms").set(isDefaultSmsApp)
prefs.defaultSms.set(isDefaultSmsApp)
if (isDefaultSmsApp) {
val pendingResult = goAsync()