implementing the Manage People menu button at the conversation screen
This commit is contained in:
parent
f01bbb893e
commit
630c87c6d9
|
@ -84,7 +84,6 @@ class ThreadActivity : SimpleActivity() {
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_thread, menu)
|
menuInflater.inflate(R.menu.menu_thread, menu)
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.manage_people).isVisible = false
|
|
||||||
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
|
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +127,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
private fun setupButtons() {
|
private fun setupButtons() {
|
||||||
thread_type_message.setColors(config.textColor, config.primaryColor, config.backgroundColor)
|
thread_type_message.setColors(config.textColor, config.primaryColor, config.backgroundColor)
|
||||||
thread_send_message.applyColorFilter(config.textColor)
|
thread_send_message.applyColorFilter(config.textColor)
|
||||||
|
confirm_manage_contacts.applyColorFilter(config.textColor)
|
||||||
|
|
||||||
thread_send_message.setOnClickListener {
|
thread_send_message.setOnClickListener {
|
||||||
val msg = thread_type_message.value
|
val msg = thread_type_message.value
|
||||||
|
@ -151,6 +151,19 @@ class ThreadActivity : SimpleActivity() {
|
||||||
thread_send_message.isClickable = it.isNotEmpty()
|
thread_send_message.isClickable = it.isNotEmpty()
|
||||||
thread_send_message.alpha = if (it.isEmpty()) 0.4f else 0.9f
|
thread_send_message.alpha = if (it.isEmpty()) 0.4f else 0.9f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
confirm_manage_contacts.setOnClickListener {
|
||||||
|
hideKeyboard()
|
||||||
|
thread_add_contacts.beGone()
|
||||||
|
|
||||||
|
val numbers = selectedContacts.map { it.phoneNumber }.toSet()
|
||||||
|
val threadId = getThreadId(numbers).toInt()
|
||||||
|
Intent(this, ThreadActivity::class.java).apply {
|
||||||
|
putExtra(THREAD_ID, threadId)
|
||||||
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun blockNumber() {
|
private fun blockNumber() {
|
||||||
|
@ -259,8 +272,9 @@ class ThreadActivity : SimpleActivity() {
|
||||||
newLinearLayout.orientation = LinearLayout.HORIZONTAL
|
newLinearLayout.orientation = LinearLayout.HORIZONTAL
|
||||||
|
|
||||||
val sideMargin = (selected_contacts.layoutParams as RelativeLayout.LayoutParams).leftMargin
|
val sideMargin = (selected_contacts.layoutParams as RelativeLayout.LayoutParams).leftMargin
|
||||||
val parentWidth = realScreenSize.x - sideMargin * 2
|
|
||||||
val mediumMargin = resources.getDimension(R.dimen.medium_margin).toInt()
|
val mediumMargin = resources.getDimension(R.dimen.medium_margin).toInt()
|
||||||
|
val parentWidth = realScreenSize.x - sideMargin * 2
|
||||||
|
val firstRowWidth = parentWidth - resources.getDimension(R.dimen.normal_icon_size).toInt() + sideMargin / 2
|
||||||
var widthSoFar = 0
|
var widthSoFar = 0
|
||||||
var isFirstRow = true
|
var isFirstRow = true
|
||||||
for (i in views.indices) {
|
for (i in views.indices) {
|
||||||
|
@ -276,7 +290,8 @@ class ThreadActivity : SimpleActivity() {
|
||||||
LL.measure(0, 0)
|
LL.measure(0, 0)
|
||||||
widthSoFar += views[i].measuredWidth + mediumMargin
|
widthSoFar += views[i].measuredWidth + mediumMargin
|
||||||
|
|
||||||
if (widthSoFar >= parentWidth) {
|
val checkWidth = if (isFirstRow) firstRowWidth else parentWidth
|
||||||
|
if (widthSoFar >= checkWidth) {
|
||||||
isFirstRow = false
|
isFirstRow = false
|
||||||
selected_contacts.addView(newLinearLayout)
|
selected_contacts.addView(newLinearLayout)
|
||||||
newLinearLayout = LinearLayout(this)
|
newLinearLayout = LinearLayout(this)
|
||||||
|
|
|
@ -472,6 +472,15 @@ fun Context.getThreadId(address: String): Long {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
fun Context.getThreadId(addresses: Set<String>): Long {
|
||||||
|
return if (isMarshmallowPlus()) {
|
||||||
|
Telephony.Threads.getOrCreateThreadId(this, addresses)
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Context.isNumberBlocked(number: String): Boolean {
|
fun Context.isNumberBlocked(number: String): Boolean {
|
||||||
val blockedNumbers = getBlockedNumbers()
|
val blockedNumbers = getBlockedNumbers()
|
||||||
val numberToCompare = number.trimToComparableNumber()
|
val numberToCompare = number.trimToComparableNumber()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/thread_holder"
|
android:id="@+id/thread_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -10,7 +11,8 @@
|
||||||
android:id="@+id/thread_add_contacts"
|
android:id="@+id/thread_add_contacts"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone">
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/selected_contacts"
|
android:id="@+id/selected_contacts"
|
||||||
|
@ -19,6 +21,18 @@
|
||||||
android:layout_margin="@dimen/activity_margin"
|
android:layout_margin="@dimen/activity_margin"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/confirm_manage_contacts"
|
||||||
|
android:layout_width="@dimen/normal_icon_size"
|
||||||
|
android:layout_height="@dimen/normal_icon_size"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginStart="@dimen/medium_margin"
|
||||||
|
android:layout_marginTop="@dimen/normal_margin"
|
||||||
|
android:layout_marginEnd="@dimen/medium_margin"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/small_margin"
|
||||||
|
android:src="@drawable/ic_check_vector" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/message_divider_one"
|
android:id="@+id/message_divider_one"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue