Update dialog to reuse properties dialog from file manager

This commit is contained in:
Ensar Sarajčić 2023-07-11 11:02:55 +02:00
parent 6fef121599
commit 3adfdd401e
49 changed files with 63 additions and 23 deletions

View File

@ -63,7 +63,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:4c83ec8740'
implementation 'com.github.esensar:Simple-Commons:7b890eae3e'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
implementation 'com.github.tibbi:android-smsmms:33fcaf94d9'

View File

@ -3,48 +3,41 @@ package com.simplemobiletools.smsmessenger.dialogs
import android.annotation.SuppressLint
import android.telephony.SubscriptionInfo
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getTimeFormat
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.dialogs.BasePropertiesDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.extensions.config
import com.simplemobiletools.smsmessenger.extensions.subscriptionManagerCompat
import com.simplemobiletools.smsmessenger.models.Message
import kotlinx.android.synthetic.main.dialog_message_details.view.dialog_message_details_text_value
import org.joda.time.DateTime
class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Message) {
class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Message) : BasePropertiesDialog(activity) {
init {
@SuppressLint("MissingPermission")
val availableSIMs = activity.subscriptionManagerCompat().activeSubscriptionInfoList
@SuppressLint("SetTextI18n")
val view = activity.layoutInflater.inflate(R.layout.dialog_message_details, null).apply {
dialog_message_details_text_value.text = mutableListOf<String>().apply {
add("${message.getReceiverOrSenderLabel()}: ${message.getReceiverOrSenderPhoneNumbers()}")
if (availableSIMs.count() > 1) {
add("SIM: ${message.getSIM(availableSIMs)}")
}
add("${message.getSentOrReceivedAtLabel()}: ${message.getSentOrReceivedAt()}")
}.joinToString(separator = System.lineSeparator())
addProperty(message.getSenderOrReceiverLabel(), message.getSenderOrReceiverPhoneNumbers())
if (availableSIMs.count() > 1) {
addProperty(R.string.message_details_sim, message.getSIM(availableSIMs))
}
addProperty(message.getSentOrReceivedAtLabel(), message.getSentOrReceivedAt())
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> }
.apply {
activity.setupDialogStuff(view, this, R.string.message_details)
activity.setupDialogStuff(mDialogView, this, R.string.message_details)
}
}
private fun Message.getReceiverOrSenderLabel(): String {
private fun Message.getSenderOrReceiverLabel(): Int {
return if (isReceivedMessage()) {
activity.getString(R.string.message_details_sender)
R.string.message_details_sender
} else {
activity.getString(R.string.message_details_receiver)
R.string.message_details_receiver
}
}
private fun Message.getReceiverOrSenderPhoneNumbers(): String {
private fun Message.getSenderOrReceiverPhoneNumbers(): String {
return if (isReceivedMessage()) {
formatContactInfo(senderName, senderPhoneNumber)
} else {
@ -66,11 +59,11 @@ class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Messag
return availableSIMs.firstOrNull { it.subscriptionId == subscriptionId }?.displayName?.toString() ?: activity.getString(R.string.unknown)
}
private fun Message.getSentOrReceivedAtLabel(): String {
private fun Message.getSentOrReceivedAtLabel(): Int {
return if (isReceivedMessage()) {
activity.getString(R.string.message_details_received_at)
R.string.message_details_received_at
} else {
activity.getString(R.string.message_details_sent_at)
R.string.message_details_sent_at
}
}

View File

@ -54,6 +54,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -52,6 +52,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Pojedinosti poruke</string>
<string name="message_details_sender">Šalje</string>
<string name="message_details_receiver">Prima</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Poslano</string>
<string name="message_details_received_at">Primljeno</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -49,6 +49,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -52,6 +52,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -49,6 +49,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -52,6 +52,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -52,6 +52,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -52,6 +52,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -51,6 +51,7 @@
<string name="message_details">Детаљи о поруци</string>
<string name="message_details_sender">Шалје</string>
<string name="message_details_receiver">Прима</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Послано</string>
<string name="message_details_received_at">Примлјено</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -49,6 +49,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -52,6 +52,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -49,6 +49,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -49,6 +49,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->

View File

@ -50,6 +50,7 @@
<string name="message_details">Message details</string>
<string name="message_details_sender">Sender</string>
<string name="message_details_receiver">Receiver</string>
<string name="message_details_sim">SIM</string>
<string name="message_details_sent_at">Sent at</string>
<string name="message_details_received_at">Received at</string>
<!-- Notifications -->