forked from GitHub-Mirror/riotX-android
Cleans notification pref screen
+ fix troubleshoots
This commit is contained in:
@ -21,6 +21,7 @@ import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.utils.startAddGoogleAccountIntent
|
||||
import im.vector.riotredesign.features.settings.troubleshoot.NotificationTroubleshootTestManager
|
||||
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
||||
import im.vector.riotredesign.push.fcm.FcmHelper
|
||||
import timber.log.Timber
|
||||
|
||||
/*
|
||||
@ -58,6 +59,7 @@ class TestFirebaseToken(val fragment: Fragment) : TroubleshootTest(R.string.sett
|
||||
val tok = it.substring(0, Math.min(8, it.length)) + "********************"
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_fcm_success, tok)
|
||||
Timber.e("Retrieved FCM token success [$it].")
|
||||
FcmHelper.storeFcmToken(fragment.requireContext(),tok)
|
||||
}
|
||||
status = TestStatus.SUCCESS
|
||||
}
|
||||
|
@ -16,8 +16,16 @@
|
||||
package im.vector.riotredesign.gplay.features.settings.troubleshoot
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.matrix.android.api.session.pushers.PusherState
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.pushers.PushersManager
|
||||
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
||||
import im.vector.riotredesign.push.fcm.FcmHelper
|
||||
import org.koin.android.ext.android.get
|
||||
|
||||
/**
|
||||
* Force registration of the token to HomeServer
|
||||
@ -25,32 +33,45 @@ import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
||||
class TestTokenRegistration(val fragment: Fragment) : TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) {
|
||||
|
||||
override fun perform() {
|
||||
/*
|
||||
TODO
|
||||
Matrix.getInstance(VectorApp.getInstance().baseContext).pushManager.forceSessionsRegistration(object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(info: Void?) {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_token_registration_success)
|
||||
status = TestStatus.SUCCESS
|
||||
//Check if we have a registered pusher for this token
|
||||
val fcmToken = FcmHelper.getFcmToken(fragment.requireContext()) ?: run {
|
||||
status = TestStatus.FAILED
|
||||
return
|
||||
}
|
||||
|
||||
val session = Matrix.getInstance().currentSession ?: run {
|
||||
status = TestStatus.FAILED
|
||||
return
|
||||
}
|
||||
|
||||
val pusher = session.pushers().filter {
|
||||
it.pushKey == fcmToken && it.state == PusherState.REGISTERED
|
||||
}
|
||||
|
||||
if (pusher == null) {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_token_registration_failed, null)
|
||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_token_registration_quick_fix) {
|
||||
override fun doFix() {
|
||||
val workId = fragment.get<PushersManager>().registerPusherWithFcmKey(fcmToken)
|
||||
WorkManager.getInstance().getWorkInfoByIdLiveData(workId).observe(fragment, Observer { workInfo ->
|
||||
if (workInfo != null) {
|
||||
if (workInfo.state == WorkInfo.State.SUCCEEDED) {
|
||||
manager?.retry()
|
||||
} else if (workInfo.state == WorkInfo.State.FAILED) {
|
||||
manager?.retry()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onNetworkError(e: Exception?) {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_token_registration_failed, e?.localizedMessage)
|
||||
status = TestStatus.FAILED
|
||||
}
|
||||
status = TestStatus.FAILED
|
||||
|
||||
override fun onMatrixError(e: MatrixError?) {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_token_registration_failed, e?.localizedMessage)
|
||||
status = TestStatus.FAILED
|
||||
}
|
||||
|
||||
override fun onUnexpectedError(e: Exception?) {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_token_registration_failed, e?.localizedMessage)
|
||||
status = TestStatus.FAILED
|
||||
}
|
||||
})
|
||||
*/
|
||||
|
||||
status = TestStatus.FAILED
|
||||
} else {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_token_registration_success)
|
||||
status = TestStatus.SUCCESS
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user