Partial Revert "Do not show account selection dialog, if there is only 1 account"
This reverts commit baa954eb20.
Reason for revert: If user has multiple accounts on microG but chooses to login
using one of them, they will not be prompted again for selecting accounts again as
Aurora Store can only see the permitted account from the first time.
This commit is contained in:
@@ -46,8 +46,6 @@
|
||||
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.USE_CREDENTIALS"
|
||||
android:maxSdkVersion="22" />
|
||||
|
||||
@@ -29,15 +29,14 @@ import android.os.Looper
|
||||
import android.util.Base64
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.aurora.extensions.hide
|
||||
import com.aurora.extensions.isMAndAbove
|
||||
import com.aurora.extensions.runOnUiThread
|
||||
import com.aurora.extensions.show
|
||||
import com.aurora.gplayapi.helpers.AuthHelper
|
||||
import com.aurora.store.R
|
||||
@@ -70,7 +69,7 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
|
||||
if (!accountName.isNullOrBlank()) {
|
||||
requestAuthTokenForGoogle(accountName)
|
||||
} else {
|
||||
runOnUiThread { resetActions() }
|
||||
resetActions()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,14 +202,6 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
|
||||
if (viewModel.authState.value != AuthState.Fetching) {
|
||||
binding.btnGoogle.updateProgress(true)
|
||||
if (isMAndAbove && PackageUtil.hasSupportedMicroG(requireContext())) {
|
||||
val accounts = fetchGoogleAccounts()
|
||||
|
||||
// Do not show selection dialog if there is only one account available
|
||||
if (accounts.isNotEmpty() && accounts.size == 1) {
|
||||
requestAuthTokenForGoogle(accounts.first().name)
|
||||
return@addOnClickListener
|
||||
}
|
||||
|
||||
Log.i(TAG, "Found supported microG, trying to request credentials")
|
||||
val accountIntent = AccountManager.newChooseAccountIntent(
|
||||
null,
|
||||
@@ -225,6 +216,7 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
|
||||
} else {
|
||||
findNavController().navigate(R.id.googleFragment)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,8 +234,7 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
|
||||
}
|
||||
|
||||
private fun navigateToDefaultTab() {
|
||||
val defaultDestination =
|
||||
Preferences.getInteger(requireContext(), PREFERENCE_DEFAULT_SELECTED_TAB)
|
||||
val defaultDestination = Preferences.getInteger(requireContext(), PREFERENCE_DEFAULT_SELECTED_TAB)
|
||||
val directions =
|
||||
when (requireArguments().getInt("destinationId", defaultDestination)) {
|
||||
R.id.updatesFragment -> {
|
||||
@@ -271,11 +262,6 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchGoogleAccounts(): Array<Account> {
|
||||
val accountManager = AccountManager.get(requireContext())
|
||||
return accountManager.getAccountsByType(GOOGLE_ACCOUNT_TYPE)
|
||||
}
|
||||
|
||||
private fun requestAuthTokenForGoogle(accountName: String) {
|
||||
try {
|
||||
AccountManager.get(requireContext())
|
||||
@@ -290,7 +276,7 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
|
||||
{
|
||||
viewModel.buildGoogleAuthData(
|
||||
accountName,
|
||||
it.result.getString(AccountManager.KEY_AUTHTOKEN) ?: "",
|
||||
it.result.getString(AccountManager.KEY_AUTHTOKEN)!!,
|
||||
AuthHelper.Token.AUTH
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user