Commit 5a7c6899 authored by Thomas Markiewicz's avatar Thomas Markiewicz
Browse files

Fixed importing multiple accounts from liberty-hub-android and going back to...

Fixed importing multiple accounts from liberty-hub-android and going back to onboarding screen when user logs out of all accounts
parent dfc8d0a7
Pipeline #51000 passed with stages
in 14 minutes and 8 seconds
......@@ -577,7 +577,7 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut
Intent intent;
if (newAccount == null) {
intent = LoginActivity.getIntent(MainActivity.this, false);
intent = OnboardingActivity.getIntent(MainActivity.this);
} else {
intent = new Intent(MainActivity.this, MainActivity.class);
}
......
......@@ -7,13 +7,10 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.webkit.WebView
import android.widget.Button
import androidx.appcompat.app.AlertDialog
import com.keylesspalace.tusky.di.Injectable
import kotlinx.coroutines.*
class OnboardingActivity : BaseActivity(), CoroutineScope by MainScope(), Injectable {
class OnboardingActivity : BaseActivity(), Injectable {
var numLibremOneAccounts = 0
var processedLibremOneAccounts = 0
......@@ -52,29 +49,17 @@ class OnboardingActivity : BaseActivity(), CoroutineScope by MainScope(), Inject
}
//else {
/* see: https://www.zoftino.com/how-to-get-auth-token-from-accountmanager-in-android
// start system-wide Librem One login activity
val intent = Intent(this, ZoftinoAccountActivity::class.java)
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, "com.zoftino")
intent.putExtra("addAccount", true)
startActivityForResult(intent, 22)
Toast.makeText(this, "You'll get notification once latest coupon data is downloaded", Toast.LENGTH_LONG).show()
return
/*
*/
NOTE:
/*
remove from the account manager by calling invalidateAuthToken() method.
NOTE:
After removing the token from account manager, you need to call getAuthToken method passing account, account type, and account manager callback to get new token.
remove from the account manager by calling invalidateAuthToken() method.
After removing the token from account manager, you need to call getAuthToken method passing account, account type, and account manager callback to get new token.
*/
*/
}
......@@ -118,7 +103,7 @@ class OnboardingActivity : BaseActivity(), CoroutineScope by MainScope(), Inject
// Otherwise the token is a named value in the bundle. The name of the value
// is stored in the constant AccountManager.KEY_AUTHTOKEN.
val token: String = bundle.getString(AccountManager.KEY_AUTHTOKEN)
val username: String = bundle.getString(AccountManager.KEY_ACCOUNT_NAME);
val username: String = bundle.getString(AccountManager.KEY_ACCOUNT_NAME).split('@')[0]
// accountManager in this case comes from app's BaseActivity()
accountManager.addAccount(token, "social.librem.one", username)
......
......@@ -64,7 +64,10 @@ class AccountManager(db: AppDatabase) {
val maxAccountId = accounts.maxBy { it.id }?.id ?: 0
val newAccountId = maxAccountId + 1
activeAccount = AccountEntity(id = newAccountId, username = username, domain = domain.toLowerCase(), accessToken = accessToken, isActive = true)
activeAccount?.let {
accountDao.insertOrReplace(it)
accounts.add(it)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment