forked from upstream-mirrors/quik
Perform partial sync if set as default SMS app
This commit is contained in:
@@ -48,6 +48,11 @@
|
||||
<activity android:name=".presentation.settings.SettingsActivity" />
|
||||
<activity android:name=".presentation.compose.ComposeActivity" />
|
||||
|
||||
<receiver android:name=".receiver.DefaultSmsChangedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".receiver.SmsReceiver"
|
||||
android:permission="android.permission.BROADCAST_SMS">
|
||||
|
||||
@@ -25,6 +25,7 @@ interface AppComponent {
|
||||
fun inject(adapter: ConversationsAdapter)
|
||||
fun inject(adapter: MessagesAdapter)
|
||||
|
||||
fun inject(receiver: DefaultSmsChangedReceiver)
|
||||
fun inject(receiver: SmsReceiver)
|
||||
fun inject(receiver: MessageDeliveredReceiver)
|
||||
fun inject(receiver: MessageSentReceiver)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.moez.QKSMS.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Telephony
|
||||
import android.support.annotation.RequiresApi
|
||||
import com.moez.QKSMS.common.di.AppComponentManager
|
||||
import com.moez.QKSMS.domain.interactor.PartialSync
|
||||
import javax.inject.Inject
|
||||
|
||||
class DefaultSmsChangedReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var partialSync: PartialSync
|
||||
|
||||
@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)
|
||||
if (isDefaultSmsApp) {
|
||||
val pendingResult = goAsync()
|
||||
partialSync.execute(Unit, { pendingResult.finish() })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user