Add a BuildConfig to allow external unifiedpush distrib
Change-Id: I5435c02dab05f84dd5dd99507afd1075f357e76d
This commit is contained in:
parent
c03c6867f7
commit
c4fd115209
|
@ -274,6 +274,7 @@ android {
|
|||
|
||||
resValue "bool", "isGplay", "true"
|
||||
buildConfigField "boolean", "ALLOW_FCM_USE", "true"
|
||||
buildConfigField "boolean", "ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB", "true"
|
||||
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
|
||||
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\""
|
||||
}
|
||||
|
@ -285,6 +286,7 @@ android {
|
|||
|
||||
resValue "bool", "isGplay", "false"
|
||||
buildConfigField "boolean", "ALLOW_FCM_USE", "false"
|
||||
buildConfigField "boolean", "ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB", "true"
|
||||
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
|
||||
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.Toast
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.edit
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.DefaultSharedPreferences
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
|
@ -86,6 +87,11 @@ object UPHelper {
|
|||
|
||||
fun registerUnifiedPush(context: Context, forceShowSelection: Boolean = false, onDoneRunnable: Runnable? = null) {
|
||||
val up = Registration()
|
||||
if (!BuildConfig.ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB) {
|
||||
up.saveDistributor(context, context.packageName)
|
||||
up.registerApp(context)
|
||||
return
|
||||
}
|
||||
if (forceShowSelection) {
|
||||
// Un-register first
|
||||
up.unregisterApp(context)
|
||||
|
|
|
@ -31,6 +31,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.lifecycle.map
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.SwitchPreference
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
|
@ -141,17 +142,21 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
|
|||
}
|
||||
|
||||
findPreference<VectorPreference>(SETTINGS_UNIFIED_PUSH_RE_REGISTER)?.let {
|
||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
lifecycleScope.launch {
|
||||
updateEnabledForDevice(false)
|
||||
UPHelper.registerUnifiedPush(requireContext(), forceShowSelection = true) {
|
||||
lifecycleScope.launch {
|
||||
updateEnabledForDevice(true)
|
||||
if (BuildConfig.ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB) {
|
||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
lifecycleScope.launch {
|
||||
updateEnabledForDevice(false)
|
||||
UPHelper.registerUnifiedPush(requireContext(), forceShowSelection = true) {
|
||||
lifecycleScope.launch {
|
||||
updateEnabledForDevice(true)
|
||||
}
|
||||
Handler(Looper.getMainLooper()).postDelayed({ refreshBackgroundSyncPrefs() }, 500)
|
||||
}
|
||||
Handler(Looper.getMainLooper()).postDelayed({ refreshBackgroundSyncPrefs() }, 500)
|
||||
}
|
||||
true
|
||||
}
|
||||
true
|
||||
} else {
|
||||
it.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue