mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 22:04:24 +01:00
fix to handleActionFromContact
handleActionFromContact was not executed in onCreate of the MainActivity which is now fixed by this commit. + refactoring some intent handling Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
007c4a97dc
commit
4c9913a760
@ -62,7 +62,6 @@ import com.nextcloud.talk.utils.ApiUtils
|
|||||||
import com.nextcloud.talk.utils.SecurityUtils
|
import com.nextcloud.talk.utils.SecurityUtils
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ACCOUNT
|
import com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ACCOUNT
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID
|
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
import io.reactivex.SingleObserver
|
import io.reactivex.SingleObserver
|
||||||
@ -114,37 +113,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
|
|
||||||
router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
|
router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
|
||||||
|
|
||||||
if (intent.hasExtra(ADD_ACCOUNT) && intent.getBooleanExtra(ADD_ACCOUNT, false)) {
|
handleIntent(intent)
|
||||||
addAccount()
|
|
||||||
} else if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
|
|
||||||
onNewIntent(intent)
|
|
||||||
} else if (!router!!.hasRootController()) {
|
|
||||||
if (!appPreferences.isDbRoomMigrated) {
|
|
||||||
appPreferences.isDbRoomMigrated = true
|
|
||||||
}
|
|
||||||
|
|
||||||
userManager.users.subscribe(object : SingleObserver<List<User>> {
|
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSuccess(users: List<User>) {
|
|
||||||
if (users.isNotEmpty()) {
|
|
||||||
runOnUiThread {
|
|
||||||
openConversationList()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
runOnUiThread {
|
|
||||||
launchLoginScreen()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, "Error loading existing users", e)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
}
|
}
|
||||||
@ -281,7 +250,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
override fun onNext(roomOverall: RoomOverall) {
|
override fun onNext(roomOverall: RoomOverall) {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
|
bundle.putString(KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
|
||||||
bundle.putString(KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId)
|
|
||||||
|
|
||||||
val chatIntent = Intent(context, ChatActivity::class.java)
|
val chatIntent = Intent(context, ChatActivity::class.java)
|
||||||
chatIntent.putExtras(bundle)
|
chatIntent.putExtras(bundle)
|
||||||
@ -301,35 +269,67 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
Log.d(TAG, "onNewIntent Activity: " + System.identityHashCode(this).toString())
|
Log.d(TAG, "onNewIntent Activity: " + System.identityHashCode(this).toString())
|
||||||
|
handleIntent(intent)
|
||||||
val internalUserId = intent.extras?.getLong(BundleKeys.KEY_INTERNAL_USER_ID)
|
|
||||||
val user = userManager.getUserWithId(internalUserId!!).blockingGet()
|
|
||||||
|
|
||||||
if (user != null && userManager.setUserAsActive(user).blockingGet()) {
|
|
||||||
handleIntent(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleIntent(intent: Intent) {
|
private fun handleIntent(intent: Intent) {
|
||||||
handleActionFromContact(intent)
|
handleActionFromContact(intent)
|
||||||
|
|
||||||
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
|
val internalUserId = intent.extras?.getLong(BundleKeys.KEY_INTERNAL_USER_ID)
|
||||||
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
|
|
||||||
if (!router!!.hasRootController()) {
|
var user: User? = null
|
||||||
openConversationList()
|
if (internalUserId != null) {
|
||||||
|
user = userManager.getUserWithId(internalUserId).blockingGet()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user != null && userManager.setUserAsActive(user).blockingGet()) {
|
||||||
|
// this should be avoided (it's still from conductor architecture). activities should be opened directly.
|
||||||
|
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
|
||||||
|
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
|
||||||
|
if (!router!!.hasRootController()) {
|
||||||
|
openConversationList()
|
||||||
|
}
|
||||||
|
val callNotificationIntent = Intent(this, CallNotificationActivity::class.java)
|
||||||
|
intent.extras?.let { callNotificationIntent.putExtras(it) }
|
||||||
|
startActivity(callNotificationIntent)
|
||||||
|
} else {
|
||||||
|
logRouterBackStack(router!!)
|
||||||
|
|
||||||
|
val chatIntent = Intent(context, ChatActivity::class.java)
|
||||||
|
chatIntent.putExtras(intent.extras!!)
|
||||||
|
startActivity(chatIntent)
|
||||||
|
|
||||||
|
logRouterBackStack(router!!)
|
||||||
}
|
}
|
||||||
val callNotificationIntent = Intent(this, CallNotificationActivity::class.java)
|
|
||||||
intent.extras?.let { callNotificationIntent.putExtras(it) }
|
|
||||||
startActivity(callNotificationIntent)
|
|
||||||
} else {
|
|
||||||
logRouterBackStack(router!!)
|
|
||||||
|
|
||||||
val chatIntent = Intent(context, ChatActivity::class.java)
|
|
||||||
chatIntent.putExtras(intent.extras!!)
|
|
||||||
startActivity(chatIntent)
|
|
||||||
|
|
||||||
logRouterBackStack(router!!)
|
|
||||||
}
|
}
|
||||||
|
} else if (intent.hasExtra(ADD_ACCOUNT) && intent.getBooleanExtra(ADD_ACCOUNT, false)) {
|
||||||
|
addAccount()
|
||||||
|
} else if (!router!!.hasRootController()) {
|
||||||
|
if (!appPreferences.isDbRoomMigrated) {
|
||||||
|
appPreferences.isDbRoomMigrated = true
|
||||||
|
}
|
||||||
|
|
||||||
|
userManager.users.subscribe(object : SingleObserver<List<User>> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess(users: List<User>) {
|
||||||
|
if (users.isNotEmpty()) {
|
||||||
|
runOnUiThread {
|
||||||
|
openConversationList()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
runOnUiThread {
|
||||||
|
launchLoginScreen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Log.e(TAG, "Error loading existing users", e)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user