Commit bb32dd3a authored by Adrien Béraud's avatar Adrien Béraud
Browse files

home activity: fix opening conversation from notification

Change-Id: I492e5c9b77267333db05175db97d3b8618c82515
parent b57104ac
......@@ -174,23 +174,27 @@ class HomeActivity : AppCompatActivity(), NavigationBarView.OnItemSelectedListen
Log.d(TAG, "handleIntent: $intent")
val extra = intent.extras
val action = intent.action
if (ACTION_PRESENT_TRUST_REQUEST_FRAGMENT == action) {
//mAccountWithPendingrequests = extra.getString(ContactRequestsFragment.ACCOUNT_ID);
presentTrustRequestFragment(extra?.getString(AccountEditionFragment.ACCOUNT_ID_KEY) ?: return)
} else if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
val path = ConversationPath.fromBundle(extra)
if (path != null) {
startConversation(path)
} else {
intent.setClass(applicationContext, ShareActivity::class.java)
startActivity(intent)
when (action) {
ACTION_PRESENT_TRUST_REQUEST_FRAGMENT -> {
presentTrustRequestFragment(extra?.getString(AccountEditionFragment.ACCOUNT_ID_KEY) ?: return)
}
Intent.ACTION_SEND,
Intent.ACTION_SEND_MULTIPLE -> {
val path = ConversationPath.fromBundle(extra)
if (path != null) {
startConversation(path)
} else {
intent.setClass(applicationContext, ShareActivity::class.java)
startActivity(intent)
}
}
} else if (DRingService.ACTION_CONV_ACCEPT == action || Intent.ACTION_VIEW == action) {
val path = ConversationPath.fromBundle(extra)
if (path != null) {
startConversation(path)
Intent.ACTION_VIEW,
DRingService.ACTION_CONV_ACCEPT -> {
val path = ConversationPath.fromIntent(intent)
if (path != null)
startConversation(path)
}
} //else {
}
val fragmentManager = supportFragmentManager
fContent = fragmentManager.findFragmentById(R.id.main_frame)
if (fContent == null || Intent.ACTION_SEARCH == action) {
......
......@@ -165,8 +165,9 @@ class ConversationPath {
if (accountId != null && contactId != null) {
return ConversationPath(accountId, contactId)
} else {
val shortcutId = bundle.getString(ShortcutManagerCompat.EXTRA_SHORTCUT_ID)
if (shortcutId != null) return fromKey(shortcutId)
bundle.getString(ShortcutManagerCompat.EXTRA_SHORTCUT_ID)?.let { shortcutId ->
return fromKey(shortcutId)
}
}
}
return null
......@@ -174,9 +175,7 @@ class ConversationPath {
fun fromIntent(intent: Intent?): ConversationPath? {
if (intent != null) {
val uri = intent.data
val conversationPath = fromUri(uri)
return conversationPath ?: fromBundle(intent.extras)
return fromUri(intent.data) ?: fromBundle(intent.extras)
}
return null
}
......
Supports Markdown
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