mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-24 21:18:31 +00:00
When upgrading from previous version, do not show AssitantLanding page after WelcomeActivity and/or PermissionsFragment
This commit is contained in:
parent
23c3a63aed
commit
fbb59cbc2a
3 changed files with 55 additions and 10 deletions
|
|
@ -40,6 +40,8 @@ import org.linphone.ui.assistant.fragment.PermissionsFragmentDirections
|
||||||
class AssistantActivity : GenericActivity() {
|
class AssistantActivity : GenericActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "[Assistant Activity]"
|
private const val TAG = "[Assistant Activity]"
|
||||||
|
|
||||||
|
const val SKIP_LANDING_EXTRA = "SkipLandingIfAtLeastAnAccount"
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var binding: AssistantActivityBinding
|
private lateinit var binding: AssistantActivityBinding
|
||||||
|
|
@ -67,6 +69,18 @@ class AssistantActivity : GenericActivity() {
|
||||||
Log.w("$TAG Not all required permissions are granted, showing Permissions fragment")
|
Log.w("$TAG Not all required permissions are granted, showing Permissions fragment")
|
||||||
val action = PermissionsFragmentDirections.actionGlobalPermissionsFragment()
|
val action = PermissionsFragmentDirections.actionGlobalPermissionsFragment()
|
||||||
binding.assistantNavContainer.findNavController().navigate(action)
|
binding.assistantNavContainer.findNavController().navigate(action)
|
||||||
|
} else if (intent.getBooleanExtra(SKIP_LANDING_EXTRA, false)) {
|
||||||
|
Log.w(
|
||||||
|
"$TAG We were asked to leave assistant if at least an account is already configured"
|
||||||
|
)
|
||||||
|
coreContext.postOnCoreThread { core ->
|
||||||
|
if (core.accountList.isNotEmpty()) {
|
||||||
|
coreContext.postOnMainThread {
|
||||||
|
Log.w("$TAG At least one account was found, leaving assistant")
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,12 @@ import androidx.annotation.UiThread
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
|
import org.linphone.R
|
||||||
import org.linphone.compatibility.Compatibility
|
import org.linphone.compatibility.Compatibility
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.databinding.AssistantPermissionsFragmentBinding
|
import org.linphone.databinding.AssistantPermissionsFragmentBinding
|
||||||
|
import org.linphone.ui.assistant.AssistantActivity
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
class PermissionsFragment : Fragment() {
|
class PermissionsFragment : Fragment() {
|
||||||
|
|
@ -45,6 +48,7 @@ class PermissionsFragment : Fragment() {
|
||||||
private val requestPermissionLauncher = registerForActivityResult(
|
private val requestPermissionLauncher = registerForActivityResult(
|
||||||
ActivityResultContracts.RequestMultiplePermissions()
|
ActivityResultContracts.RequestMultiplePermissions()
|
||||||
) { permissions ->
|
) { permissions ->
|
||||||
|
var allGranted = true
|
||||||
permissions.entries.forEach {
|
permissions.entries.forEach {
|
||||||
val permissionName = it.key
|
val permissionName = it.key
|
||||||
val isGranted = it.value
|
val isGranted = it.value
|
||||||
|
|
@ -52,9 +56,16 @@ class PermissionsFragment : Fragment() {
|
||||||
Log.i("Permission [$permissionName] is now granted")
|
Log.i("Permission [$permissionName] is now granted")
|
||||||
} else {
|
} else {
|
||||||
Log.i("Permission [$permissionName] has been denied")
|
Log.i("Permission [$permissionName] has been denied")
|
||||||
|
allGranted = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goToLoginFragment()
|
|
||||||
|
if (!allGranted) { // If all permissions were granted, the onResume() will do the navigation
|
||||||
|
Log.w(
|
||||||
|
"$TAG Not all permissions were granted, leaving anyway, they will be asked again later..."
|
||||||
|
)
|
||||||
|
goToLoginFragment()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
|
@ -113,8 +124,25 @@ class PermissionsFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun goToLoginFragment() {
|
private fun goToLoginFragment() {
|
||||||
val action = PermissionsFragmentDirections.actionPermissionsFragmentToLandingFragment()
|
if (requireActivity().intent.getBooleanExtra(AssistantActivity.SKIP_LANDING_EXTRA, false)) {
|
||||||
findNavController().navigate(action)
|
Log.w(
|
||||||
|
"$TAG We were asked to leave assistant if at least an account is already configured"
|
||||||
|
)
|
||||||
|
coreContext.postOnCoreThread { core ->
|
||||||
|
if (core.accountList.isNotEmpty()) {
|
||||||
|
coreContext.postOnMainThread {
|
||||||
|
Log.w("$TAG At least one account was found, leaving assistant")
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (findNavController().currentDestination?.id == R.id.permissionsFragment) {
|
||||||
|
val action =
|
||||||
|
PermissionsFragmentDirections.actionPermissionsFragmentToLandingFragment()
|
||||||
|
findNavController().navigate(action)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun areAllPermissionsGranted(): Boolean {
|
private fun areAllPermissionsGranted(): Boolean {
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,7 @@ class WelcomeActivity : GenericActivity() {
|
||||||
|
|
||||||
binding.setSkipClickListener {
|
binding.setSkipClickListener {
|
||||||
Log.i("$TAG User clicked on 'skip' button, going to Assistant")
|
Log.i("$TAG User clicked on 'skip' button, going to Assistant")
|
||||||
finish()
|
goToAssistant()
|
||||||
val intent = Intent(this, AssistantActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.setNextClickListener {
|
binding.setNextClickListener {
|
||||||
|
|
@ -77,11 +75,9 @@ class WelcomeActivity : GenericActivity() {
|
||||||
Log.i(
|
Log.i(
|
||||||
"$TAG User clicked on 'start' button, leaving activity and going into Assistant"
|
"$TAG User clicked on 'start' button, leaving activity and going into Assistant"
|
||||||
)
|
)
|
||||||
finish()
|
goToAssistant()
|
||||||
val intent = Intent(this, AssistantActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
} else {
|
} else {
|
||||||
viewPager.currentItem = viewPager.currentItem + 1
|
viewPager.currentItem += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -96,6 +92,13 @@ class WelcomeActivity : GenericActivity() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun goToAssistant() {
|
||||||
|
finish()
|
||||||
|
val intent = Intent(this, AssistantActivity::class.java)
|
||||||
|
intent.putExtra(AssistantActivity.SKIP_LANDING_EXTRA, true)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
private inner class ScreenSlidePagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) {
|
private inner class ScreenSlidePagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) {
|
||||||
override fun getItemCount(): Int = PAGES
|
override fun getItemCount(): Int = PAGES
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue