mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 18:36:21 +03:00
Revert "Avoid unifiedpush selection spam"
This reverts commit 509eabfe5c
.
This commit is contained in:
parent
001e22bbad
commit
f62381a972
1 changed files with 0 additions and 16 deletions
|
@ -35,7 +35,6 @@ import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||||
import org.unifiedpush.android.connector.UnifiedPush
|
import org.unifiedpush.android.connector.UnifiedPush
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class UnifiedPushHelper @Inject constructor(
|
class UnifiedPushHelper @Inject constructor(
|
||||||
|
@ -48,20 +47,12 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
private val fcmHelper: FcmHelper,
|
private val fcmHelper: FcmHelper,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val isRegistering = AtomicBoolean(false)
|
|
||||||
|
|
||||||
// Called when the home activity starts
|
// Called when the home activity starts
|
||||||
// or when notifications are enabled
|
// or when notifications are enabled
|
||||||
fun register(
|
fun register(
|
||||||
activity: FragmentActivity,
|
activity: FragmentActivity,
|
||||||
onDoneRunnable: Runnable? = null,
|
onDoneRunnable: Runnable? = null,
|
||||||
) {
|
) {
|
||||||
if (!isRegistering.compareAndSet(false, true)) {
|
|
||||||
// There's already a register() in progress, possibly because user hasn't reacted to the dialog yet
|
|
||||||
Timber.i("Skipping register() call with runnable $onDoneRunnable, still in register call")
|
|
||||||
onDoneRunnable?.run()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
registerInternal(
|
registerInternal(
|
||||||
activity,
|
activity,
|
||||||
onDoneRunnable = onDoneRunnable
|
onDoneRunnable = onDoneRunnable
|
||||||
|
@ -99,7 +90,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
UnifiedPush.saveDistributor(context, context.packageName)
|
UnifiedPush.saveDistributor(context, context.packageName)
|
||||||
UnifiedPush.registerApp(context)
|
UnifiedPush.registerApp(context)
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
|
@ -110,7 +100,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
if (!force && UnifiedPush.getDistributor(context).isNotEmpty()) {
|
if (!force && UnifiedPush.getDistributor(context).isNotEmpty()) {
|
||||||
UnifiedPush.registerApp(context)
|
UnifiedPush.registerApp(context)
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +109,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
UnifiedPush.saveDistributor(context, distributors.first())
|
UnifiedPush.saveDistributor(context, distributors.first())
|
||||||
UnifiedPush.registerApp(context)
|
UnifiedPush.registerApp(context)
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
} else {
|
} else {
|
||||||
openDistributorDialogInternal(
|
openDistributorDialogInternal(
|
||||||
activity = activity,
|
activity = activity,
|
||||||
|
@ -164,7 +152,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
Timber.i("Saving distributor: $distributor")
|
Timber.i("Saving distributor: $distributor")
|
||||||
UnifiedPush.registerApp(context)
|
UnifiedPush.registerApp(context)
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setOnCancelListener {
|
.setOnCancelListener {
|
||||||
|
@ -172,7 +159,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
UnifiedPush.saveDistributor(context, context.packageName)
|
UnifiedPush.saveDistributor(context, context.packageName)
|
||||||
UnifiedPush.registerApp(context)
|
UnifiedPush.registerApp(context)
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
}
|
}
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.show()
|
.show()
|
||||||
|
@ -214,7 +200,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
if (UnifiedPush.getDistributor(context) == context.packageName) {
|
if (UnifiedPush.getDistributor(context) == context.packageName) {
|
||||||
unifiedPushStore.storePushGateway(stringProvider.getString(R.string.pusher_http_url))
|
unifiedPushStore.storePushGateway(stringProvider.getString(R.string.pusher_http_url))
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// else, unifiedpush, and pushkey is an endpoint
|
// else, unifiedpush, and pushkey is an endpoint
|
||||||
|
@ -231,7 +216,6 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
Timber.d("Using custom gateway")
|
Timber.d("Using custom gateway")
|
||||||
unifiedPushStore.storePushGateway(custom)
|
unifiedPushStore.storePushGateway(custom)
|
||||||
onDoneRunnable?.run()
|
onDoneRunnable?.run()
|
||||||
isRegistering.set(false)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue