We need an Activity to display the dialog
This commit is contained in:
parent
ddf6a69a69
commit
ad8cb22863
@ -19,6 +19,7 @@ package im.vector.app.core.pushers
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
@ -91,18 +92,24 @@ class UnifiedPushHelper @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun register(onDoneRunnable: Runnable? = null) {
|
fun register(
|
||||||
|
activity: FragmentActivity,
|
||||||
|
onDoneRunnable: Runnable? = null,
|
||||||
|
) {
|
||||||
gRegister(
|
gRegister(
|
||||||
|
activity,
|
||||||
onDoneRunnable = onDoneRunnable
|
onDoneRunnable = onDoneRunnable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reRegister(
|
fun reRegister(
|
||||||
|
activity: FragmentActivity,
|
||||||
pushersManager: PushersManager,
|
pushersManager: PushersManager,
|
||||||
vectorPreferences: VectorPreferences,
|
vectorPreferences: VectorPreferences,
|
||||||
onDoneRunnable: Runnable? = null
|
onDoneRunnable: Runnable? = null
|
||||||
) {
|
) {
|
||||||
gRegister(
|
gRegister(
|
||||||
|
activity,
|
||||||
force = true,
|
force = true,
|
||||||
pushersManager = pushersManager,
|
pushersManager = pushersManager,
|
||||||
vectorPreferences = vectorPreferences,
|
vectorPreferences = vectorPreferences,
|
||||||
@ -111,6 +118,7 @@ class UnifiedPushHelper @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun gRegister(
|
private fun gRegister(
|
||||||
|
activity: FragmentActivity,
|
||||||
force: Boolean = false,
|
force: Boolean = false,
|
||||||
pushersManager: PushersManager? = null,
|
pushersManager: PushersManager? = null,
|
||||||
vectorPreferences: VectorPreferences? = null,
|
vectorPreferences: VectorPreferences? = null,
|
||||||
@ -163,7 +171,7 @@ class UnifiedPushHelper @Inject constructor(
|
|||||||
}
|
}
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
|
|
||||||
MaterialAlertDialogBuilder(context)
|
MaterialAlertDialogBuilder(activity)
|
||||||
.setTitle(stringProvider.getString(R.string.unifiedpush_getdistributors_dialog_title))
|
.setTitle(stringProvider.getString(R.string.unifiedpush_getdistributors_dialog_title))
|
||||||
.setItems(distributorsNameArray) { _, which ->
|
.setItems(distributorsNameArray) { _, which ->
|
||||||
val distributor = distributorsArray[which]
|
val distributor = distributorsArray[which]
|
||||||
|
@ -189,7 +189,7 @@ class HomeActivity :
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
analyticsScreenName = MobileScreen.ScreenName.Home
|
analyticsScreenName = MobileScreen.ScreenName.Home
|
||||||
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)
|
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)
|
||||||
unifiedPushHelper.register {
|
unifiedPushHelper.register(this) {
|
||||||
if (unifiedPushHelper.isEmbeddedDistributor()) {
|
if (unifiedPushHelper.isEmbeddedDistributor()) {
|
||||||
FcmHelper.ensureFcmTokenIsRetrieved(
|
FcmHelper.ensureFcmTokenIsRetrieved(
|
||||||
this,
|
this,
|
||||||
|
@ -100,7 +100,7 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
|
|||||||
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)?.let {
|
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)?.let {
|
||||||
it.setTransactionalSwitchChangeListener(lifecycleScope) { isChecked ->
|
it.setTransactionalSwitchChangeListener(lifecycleScope) { isChecked ->
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
unifiedPushHelper.register()
|
unifiedPushHelper.register(requireActivity())
|
||||||
} else {
|
} else {
|
||||||
unifiedPushHelper.unregister(
|
unifiedPushHelper.unregister(
|
||||||
pushersManager,
|
pushersManager,
|
||||||
@ -153,6 +153,7 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
|
|||||||
if (BuildConfig.ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB) {
|
if (BuildConfig.ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB) {
|
||||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
unifiedPushHelper.reRegister(
|
unifiedPushHelper.reRegister(
|
||||||
|
requireActivity(),
|
||||||
pushersManager,
|
pushersManager,
|
||||||
vectorPreferences
|
vectorPreferences
|
||||||
) {
|
) {
|
||||||
|
@ -61,6 +61,7 @@ class TestEndpointAsTokenRegistration @Inject constructor(
|
|||||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_endpoint_registration_quick_fix) {
|
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_endpoint_registration_quick_fix) {
|
||||||
override fun doFix() {
|
override fun doFix() {
|
||||||
unifiedPushHelper.reRegister(
|
unifiedPushHelper.reRegister(
|
||||||
|
context,
|
||||||
pushersManager,
|
pushersManager,
|
||||||
vectorPreferences
|
vectorPreferences
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user