show the other persons name at the Thread title

This commit is contained in:
tibbi 2020-04-03 19:54:13 +02:00
parent f938c14cba
commit d20623c44a
4 changed files with 9 additions and 1 deletions

View File

@ -31,7 +31,9 @@
<activity android:name=".activities.MainActivity" />
<activity android:name=".activities.ThreadActivity" />
<activity
android:name=".activities.ThreadActivity"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name=".activities.SettingsActivity"

View File

@ -15,6 +15,7 @@ import com.simplemobiletools.smsmessenger.adapters.MessagesAdapter
import com.simplemobiletools.smsmessenger.extensions.config
import com.simplemobiletools.smsmessenger.extensions.getMessages
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
import com.simplemobiletools.smsmessenger.helpers.THREAD_NAME
import com.simplemobiletools.smsmessenger.models.Message
import kotlinx.android.synthetic.main.activity_main.*
@ -78,6 +79,7 @@ class MainActivity : SimpleActivity() {
MessagesAdapter(this, messages, messages_list, messages_fastscroller) {
Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, (it as Message).thread)
putExtra(THREAD_NAME, it.address)
startActivity(this)
}
}.apply {

View File

@ -5,6 +5,7 @@ import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.adapters.ThreadAdapter
import com.simplemobiletools.smsmessenger.extensions.getMessages
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
import com.simplemobiletools.smsmessenger.helpers.THREAD_NAME
import kotlinx.android.synthetic.main.activity_thread.*
class ThreadActivity : SimpleActivity() {
@ -12,6 +13,8 @@ class ThreadActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_thread)
title = intent.getStringExtra(THREAD_NAME) ?: getString(R.string.app_launcher_name)
val threadID = intent.getIntExtra(THREAD_ID, 0)
val messages = getMessages(threadID)
messages.sortBy { it.id }

View File

@ -1,3 +1,4 @@
package com.simplemobiletools.smsmessenger.helpers
const val THREAD_ID = "thread_id"
const val THREAD_NAME = "thread_name"