mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
WIP. Fix failing login etc
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
40bcf7444a
commit
10a57d8217
@ -22,7 +22,6 @@ import androidx.work.WorkInfo
|
|||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
import com.bluelinelabs.logansquare.LoganSquare
|
import com.bluelinelabs.logansquare.LoganSquare
|
||||||
import com.google.android.material.snackbar.Snackbar
|
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.activities.BaseActivity
|
import com.nextcloud.talk.activities.BaseActivity
|
||||||
import com.nextcloud.talk.api.NcApi
|
import com.nextcloud.talk.api.NcApi
|
||||||
@ -240,7 +239,7 @@ class AccountVerificationActivity : BaseActivity() {
|
|||||||
UserManager.UserAttributes(
|
UserManager.UserAttributes(
|
||||||
id = null,
|
id = null,
|
||||||
serverUrl = baseUrl,
|
serverUrl = baseUrl,
|
||||||
currentUser = true,
|
currentUser = false,
|
||||||
userId = userId,
|
userId = userId,
|
||||||
token = token,
|
token = token,
|
||||||
displayName = displayName,
|
displayName = displayName,
|
||||||
@ -259,6 +258,7 @@ class AccountVerificationActivity : BaseActivity() {
|
|||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onSuccess(user: User) {
|
override fun onSuccess(user: User) {
|
||||||
|
if (userManager.setUserAsActive(user).blockingGet()) {
|
||||||
internalAccountId = user.id!!
|
internalAccountId = user.id!!
|
||||||
if (ClosedInterfaceImpl().isGooglePlayServicesAvailable) {
|
if (ClosedInterfaceImpl().isGooglePlayServicesAvailable) {
|
||||||
ClosedInterfaceImpl().setUpPushTokenRegistration()
|
ClosedInterfaceImpl().setUpPushTokenRegistration()
|
||||||
@ -272,12 +272,18 @@ class AccountVerificationActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
fetchAndStoreCapabilities()
|
fetchAndStoreCapabilities()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Failed to set user active")
|
||||||
|
binding.progressText.text = """ ${binding.progressText.text}""".trimIndent() +
|
||||||
|
resources!!.getString(R.string.nc_common_error_sorry)
|
||||||
|
abortVerification()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
binding.progressText.text = """ ${binding.progressText.text}""".trimIndent() +
|
binding.progressText.text = """ ${binding.progressText.text}""".trimIndent() +
|
||||||
resources!!.getString(R.string.nc_display_name_not_stored)
|
resources!!.getString(R.string.nc_common_error_sorry)
|
||||||
abortVerification()
|
abortVerification()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +377,10 @@ class AccountVerificationActivity : BaseActivity() {
|
|||||||
fetchAndStoreExternalSignalingSettings()
|
fetchAndStoreExternalSignalingSettings()
|
||||||
}
|
}
|
||||||
} else if (eventStatus.eventType == EventStatus.EventType.SIGNALING_SETTINGS) {
|
} else if (eventStatus.eventType == EventStatus.EventType.SIGNALING_SETTINGS) {
|
||||||
if (internalAccountId == eventStatus.userId && !eventStatus.isAllGood) {
|
if (internalAccountId == eventStatus.userId) {
|
||||||
|
if (eventStatus.isAllGood) {
|
||||||
|
proceedWithLogin()
|
||||||
|
} else {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
binding.progressText.text =
|
binding.progressText.text =
|
||||||
"""
|
"""
|
||||||
@ -380,7 +389,13 @@ class AccountVerificationActivity : BaseActivity() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proceedWithLogin()
|
} else {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
"got SIGNALING_SETTINGS, internalAccountId=$internalAccountId , eventStatus.userId=" +
|
||||||
|
eventStatus.userId
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,33 +429,27 @@ class AccountVerificationActivity : BaseActivity() {
|
|||||||
|
|
||||||
private fun proceedWithLogin() {
|
private fun proceedWithLogin() {
|
||||||
cookieManager.cookieStore.removeAll()
|
cookieManager.cookieStore.removeAll()
|
||||||
|
// make sure currentUser is already set! otherwise: continuing proceedWithLogin was skipped for this user
|
||||||
|
|
||||||
if (userManager.users.blockingGet().size == 1 ||
|
// val usersAmount = userManager.users.blockingGet().size
|
||||||
currentUserProvider.currentUser.blockingGet().id != internalAccountId
|
// val currentUserId = currentUserProvider.currentUser.blockingGet().id
|
||||||
) {
|
|
||||||
val userToSetAsActive = userManager.getUserWithId(internalAccountId).blockingGet()
|
// Log.d(TAG, "usersAmount in proceedWithLogin: $usersAmount")
|
||||||
Log.d(TAG, "userToSetAsActive: " + userToSetAsActive.username)
|
// Log.d(TAG, "currentUserId in proceedWithLogin: $currentUserId")
|
||||||
|
Log.d(TAG, "internalAccountId in proceedWithLogin: $internalAccountId")
|
||||||
|
|
||||||
if (userManager.setUserAsActive(userToSetAsActive).blockingGet()) {
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (userManager.users.blockingGet().size == 1) {
|
// if (usersAmount == 1) {
|
||||||
val intent = Intent(context, ConversationsListActivity::class.java)
|
// val intent = Intent(context, ConversationsListActivity::class.java)
|
||||||
startActivity(intent)
|
// startActivity(intent)
|
||||||
} else {
|
// } else {
|
||||||
if (isAccountImport) {
|
if (isAccountImport) {
|
||||||
ApplicationWideMessageHolder.getInstance().messageType =
|
ApplicationWideMessageHolder.getInstance().messageType =
|
||||||
ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED
|
ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED
|
||||||
}
|
}
|
||||||
val intent = Intent(context, ConversationsListActivity::class.java)
|
val intent = Intent(context, ConversationsListActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "failed to set active user")
|
|
||||||
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "continuing proceedWithLogin was skipped for this user")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1780,6 +1780,7 @@ class ConversationsListActivity :
|
|||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
private fun deleteUserAndRestartApp() {
|
private fun deleteUserAndRestartApp() {
|
||||||
|
val userToDeleteDisplayName = currentUser!!.displayName
|
||||||
userManager.scheduleUserForDeletionWithId(currentUser!!.id!!).blockingGet()
|
userManager.scheduleUserForDeletionWithId(currentUser!!.id!!).blockingGet()
|
||||||
val accountRemovalWork = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java).build()
|
val accountRemovalWork = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java).build()
|
||||||
WorkManager.getInstance(applicationContext).enqueue(accountRemovalWork)
|
WorkManager.getInstance(applicationContext).enqueue(accountRemovalWork)
|
||||||
@ -1791,7 +1792,7 @@ class ConversationsListActivity :
|
|||||||
WorkInfo.State.SUCCEEDED -> {
|
WorkInfo.State.SUCCEEDED -> {
|
||||||
val text = String.format(
|
val text = String.format(
|
||||||
context.resources.getString(R.string.nc_deleted_user),
|
context.resources.getString(R.string.nc_deleted_user),
|
||||||
currentUser!!.displayName
|
userToDeleteDisplayName
|
||||||
)
|
)
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
context,
|
context,
|
||||||
@ -1807,7 +1808,7 @@ class ConversationsListActivity :
|
|||||||
context.resources.getString(R.string.nc_common_error_sorry),
|
context.resources.getString(R.string.nc_common_error_sorry),
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
Log.e(TAG, "something went wrong when deleting user with id " + currentUser!!.userId)
|
Log.e(TAG, "something went wrong when deleting user")
|
||||||
restartApp()
|
restartApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ abstract class TalkDatabase : RoomDatabase() {
|
|||||||
return Room
|
return Room
|
||||||
.databaseBuilder(context.applicationContext, TalkDatabase::class.java, dbName)
|
.databaseBuilder(context.applicationContext, TalkDatabase::class.java, dbName)
|
||||||
// comment out openHelperFactory to view the database entries in Android Studio for debugging
|
// comment out openHelperFactory to view the database entries in Android Studio for debugging
|
||||||
.openHelperFactory(factory)
|
// .openHelperFactory(factory)
|
||||||
.addMigrations(
|
.addMigrations(
|
||||||
Migrations.MIGRATION_6_8,
|
Migrations.MIGRATION_6_8,
|
||||||
Migrations.MIGRATION_7_8,
|
Migrations.MIGRATION_7_8,
|
||||||
|
Loading…
Reference in New Issue
Block a user