Remaining alert dialog cleanups.
This commit is contained in:
@@ -91,7 +91,6 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun askPassword(ua: UserAgent) {
|
private fun askPassword(ua: UserAgent) {
|
||||||
val builder = AlertDialog.Builder(this)
|
|
||||||
val layout = LayoutInflater.from(this)
|
val layout = LayoutInflater.from(this)
|
||||||
.inflate(R.layout.password_dialog, findViewById(android.R.id.content) as ViewGroup,
|
.inflate(R.layout.password_dialog, findViewById(android.R.id.content) as ViewGroup,
|
||||||
false)
|
false)
|
||||||
@@ -108,7 +107,7 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
else
|
else
|
||||||
input.transformationMethod = PasswordTransformationMethod()
|
input.transformationMethod = PasswordTransformationMethod()
|
||||||
}
|
}
|
||||||
with (builder) {
|
with (AlertDialog.Builder(this)) {
|
||||||
setView(layout)
|
setView(layout)
|
||||||
setPositiveButton(android.R.string.ok) { dialog, _ ->
|
setPositiveButton(android.R.string.ok) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import android.text.format.DateUtils.isToday
|
import android.text.format.DateUtils.isToday
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.ListView
|
import android.widget.ListView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
@@ -74,13 +75,14 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||||
lastClick = SystemClock.elapsedRealtime()
|
lastClick = SystemClock.elapsedRealtime()
|
||||||
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
with (AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)) {
|
||||||
builder.setMessage(String.format(getString(R.string.calls_call_message_question),
|
setMessage(String.format(getString(R.string.calls_call_message_question),
|
||||||
peerName))
|
peerName))
|
||||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
.setNegativeButton(getString(R.string.call), dialogClickListener)
|
setNegativeButton(getString(R.string.call), dialogClickListener)
|
||||||
.setPositiveButton(getString(R.string.send_message), dialogClickListener)
|
setPositiveButton(getString(R.string.send_message), dialogClickListener)
|
||||||
.show()
|
show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,20 +115,22 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
callText = getString(R.string.calls_call)
|
callText = getString(R.string.calls_call)
|
||||||
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
||||||
if (peerName.startsWith("sip:"))
|
if (peerName.startsWith("sip:"))
|
||||||
builder.setMessage(String.format(getString(R.string.calls_add_delete_question),
|
with (builder) {
|
||||||
|
setMessage(String.format(getString(R.string.calls_add_delete_question),
|
||||||
Utils.friendlyUri(peerName, Utils.aorDomain(aor)), callText))
|
Utils.friendlyUri(peerName, Utils.aorDomain(aor)), callText))
|
||||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
.setNegativeButton(getString(R.string.add_contact), dialogClickListener)
|
setNegativeButton(getString(R.string.add_contact), dialogClickListener)
|
||||||
.setPositiveButton(String.format(getString(R.string.delete), callText),
|
setPositiveButton(String.format(getString(R.string.delete), callText), dialogClickListener)
|
||||||
dialogClickListener)
|
show()
|
||||||
.show()
|
}
|
||||||
else
|
else
|
||||||
builder.setMessage(String.format(getString(R.string.calls_delete_question),
|
with (builder) {
|
||||||
|
setMessage(String.format(getString(R.string.calls_delete_question),
|
||||||
Utils.friendlyUri(peerName, Utils.aorDomain(aor)), callText))
|
Utils.friendlyUri(peerName, Utils.aorDomain(aor)), callText))
|
||||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
.setPositiveButton(String.format(getString(R.string.delete), callText),
|
setPositiveButton(String.format(getString(R.string.delete), callText), dialogClickListener)
|
||||||
dialogClickListener)
|
show()
|
||||||
.show()
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,20 +146,24 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
|
|
||||||
R.id.delete_history -> {
|
R.id.delete_history -> {
|
||||||
val deleteDialog = AlertDialog.Builder(this@CallsActivity)
|
val titleView = View.inflate(this, R.layout.alert_title, null) as TextView
|
||||||
deleteDialog.setMessage(String.format(getString(R.string.delete_history_alert),
|
titleView.text = getString(R.string.confirmation)
|
||||||
|
with (AlertDialog.Builder(this@CallsActivity)) {
|
||||||
|
setCustomTitle(titleView)
|
||||||
|
setMessage(String.format(getString(R.string.delete_history_alert),
|
||||||
aor.substringAfter(":")))
|
aor.substringAfter(":")))
|
||||||
deleteDialog.setPositiveButton(getText(R.string.delete)) { dialog, _ ->
|
setPositiveButton(getText(R.string.delete)) { dialog, _ ->
|
||||||
CallHistory.clear(aor)
|
CallHistory.clear(aor)
|
||||||
CallHistory.save()
|
CallHistory.save()
|
||||||
aorGenerateHistory(aor)
|
aorGenerateHistory(aor)
|
||||||
clAdapter.notifyDataSetChanged()
|
clAdapter.notifyDataSetChanged()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
deleteDialog.setNegativeButton(getText(R.string.cancel)) { dialog, _ ->
|
setNegativeButton(getText(R.string.cancel)) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
deleteDialog.create().show()
|
show()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,17 +106,21 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
val builder = AlertDialog.Builder(this@ChatActivity, R.style.Theme_AppCompat)
|
val builder = AlertDialog.Builder(this@ChatActivity, R.style.Theme_AppCompat)
|
||||||
if (ContactsActivity.contactName(peerUri) == peerUri)
|
if (ContactsActivity.contactName(peerUri) == peerUri)
|
||||||
builder.setMessage(String.format(getString(R.string.long_message_question),
|
with (builder) {
|
||||||
|
setMessage(String.format(getString(R.string.long_message_question),
|
||||||
chatPeer))
|
chatPeer))
|
||||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
.setNegativeButton(getString(R.string.delete), dialogClickListener)
|
setNegativeButton(getString(R.string.delete), dialogClickListener)
|
||||||
.setPositiveButton(getString(R.string.add_contact), dialogClickListener)
|
setPositiveButton(getString(R.string.add_contact), dialogClickListener)
|
||||||
.show()
|
show()
|
||||||
|
}
|
||||||
else
|
else
|
||||||
builder.setMessage(getText(R.string.short_message_question))
|
with (builder) {
|
||||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setMessage(getText(R.string.short_message_question))
|
||||||
.setNegativeButton(getString(R.string.delete), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
.show()
|
setNegativeButton(getString(R.string.delete), dialogClickListener)
|
||||||
|
show()
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -81,17 +82,21 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
val builder = AlertDialog.Builder(this@ChatsActivity, R.style.Theme_AppCompat)
|
val builder = AlertDialog.Builder(this@ChatsActivity, R.style.Theme_AppCompat)
|
||||||
val peer = ContactsActivity.contactName(uaMessages[pos].peerUri)
|
val peer = ContactsActivity.contactName(uaMessages[pos].peerUri)
|
||||||
if (peer.startsWith("sip:"))
|
if (peer.startsWith("sip:"))
|
||||||
builder.setMessage(String.format(getString(R.string.long_chat_question),
|
with (builder) {
|
||||||
|
setMessage(String.format(getString(R.string.long_chat_question),
|
||||||
Utils.friendlyUri(peer, Utils.aorDomain(aor))))
|
Utils.friendlyUri(peer, Utils.aorDomain(aor))))
|
||||||
.setNeutralButton(getText(R.string.cancel), dialogClickListener)
|
setNeutralButton(getText(R.string.cancel), dialogClickListener)
|
||||||
.setNegativeButton(getText(R.string.delete), dialogClickListener)
|
setNegativeButton(getText(R.string.delete), dialogClickListener)
|
||||||
.setPositiveButton(getText(R.string.add_contact), dialogClickListener)
|
setPositiveButton(getText(R.string.add_contact), dialogClickListener)
|
||||||
.show()
|
show()
|
||||||
|
}
|
||||||
else
|
else
|
||||||
builder.setMessage(String.format(getString(R.string.short_chat_question), peer))
|
with (builder) {
|
||||||
.setNeutralButton(getText(R.string.cancel), dialogClickListener)
|
setMessage(String.format(getString(R.string.short_chat_question), peer))
|
||||||
.setNegativeButton(getText(R.string.delete), dialogClickListener)
|
setNeutralButton(getText(R.string.cancel), dialogClickListener)
|
||||||
.show()
|
setNegativeButton(getText(R.string.delete), dialogClickListener)
|
||||||
|
show()
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,10 +152,13 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
|
|
||||||
R.id.delete_chats -> {
|
R.id.delete_chats -> {
|
||||||
val deleteDialog = AlertDialog.Builder(this@ChatsActivity)
|
val titleView = View.inflate(this, R.layout.alert_title, null) as TextView
|
||||||
deleteDialog.setMessage(String.format(getString(R.string.delete_chats_alert),
|
titleView.text = getString(R.string.confirmation)
|
||||||
|
with (AlertDialog.Builder(this@ChatsActivity)) {
|
||||||
|
setCustomTitle(titleView)
|
||||||
|
setMessage(String.format(getString(R.string.delete_chats_alert),
|
||||||
aor.substringAfter(":")))
|
aor.substringAfter(":")))
|
||||||
deleteDialog.setPositiveButton(getText(R.string.delete)) { dialog, _ ->
|
setPositiveButton(getText(R.string.delete)) { dialog, _ ->
|
||||||
Message.clear(aor)
|
Message.clear(aor)
|
||||||
Message.save()
|
Message.save()
|
||||||
uaMessages.clear()
|
uaMessages.clear()
|
||||||
@@ -158,10 +166,11 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
UserAgent.ofAor(aor)!!.account.unreadMessages = false
|
UserAgent.ofAor(aor)!!.account.unreadMessages = false
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
deleteDialog.setNegativeButton(getText(R.string.cancel)) { dialog, _ ->
|
setNegativeButton(getText(R.string.cancel)) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
deleteDialog.create().show()
|
show()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import java.io.File
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<Contact>,
|
class ContactListAdapter(private val ctx: Context, private val rows: ArrayList<Contact>,
|
||||||
private val aor: String) :
|
private val aor: String) :
|
||||||
ArrayAdapter<Contact>(cxt, R.layout.contact_row, rows) {
|
ArrayAdapter<Contact>(ctx, R.layout.contact_row, rows) {
|
||||||
|
|
||||||
private var lastClick: Long = 0
|
private var lastClick: Long = 0
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
|||||||
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
||||||
when (which) {
|
when (which) {
|
||||||
DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> {
|
DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> {
|
||||||
val i = Intent(cxt, MainActivity::class.java)
|
val i = Intent(ctx, MainActivity::class.java)
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
if (which == DialogInterface.BUTTON_NEGATIVE)
|
if (which == DialogInterface.BUTTON_NEGATIVE)
|
||||||
@@ -73,7 +73,7 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
|||||||
BaresipService.activities.clear()
|
BaresipService.activities.clear()
|
||||||
i.putExtra("uap", ua.uap)
|
i.putExtra("uap", ua.uap)
|
||||||
i.putExtra("peer", Contact.contacts()[position].uri)
|
i.putExtra("peer", Contact.contacts()[position].uri)
|
||||||
(cxt as Activity).startActivity(i)
|
(ctx as Activity).startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DialogInterface.BUTTON_NEUTRAL -> {
|
DialogInterface.BUTTON_NEUTRAL -> {
|
||||||
@@ -82,13 +82,14 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
|||||||
}
|
}
|
||||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||||
lastClick = SystemClock.elapsedRealtime()
|
lastClick = SystemClock.elapsedRealtime()
|
||||||
val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat)
|
with (AlertDialog.Builder(ctx, R.style.Theme_AppCompat)) {
|
||||||
builder.setMessage(String.format(cxt.getString(R.string.contact_action_question),
|
setMessage(String.format(ctx.getString(R.string.contact_action_question),
|
||||||
Contact.contacts()[position].name))
|
Contact.contacts()[position].name))
|
||||||
.setNeutralButton(cxt.getText(R.string.cancel), dialogClickListener)
|
setNeutralButton(ctx.getText(R.string.cancel), dialogClickListener)
|
||||||
.setNegativeButton(cxt.getText(R.string.call), dialogClickListener)
|
setNegativeButton(ctx.getText(R.string.call), dialogClickListener)
|
||||||
.setPositiveButton(cxt.getText(R.string.send_message), dialogClickListener)
|
setPositiveButton(ctx.getText(R.string.send_message), dialogClickListener)
|
||||||
.show()
|
show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,24 +114,28 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat)
|
val titleView = View.inflate(ctx, R.layout.alert_title, null) as TextView
|
||||||
builder.setMessage(String.format(cxt.getString(R.string.contact_delete_question),
|
titleView.text = ctx.getString(R.string.confirmation)
|
||||||
|
with (AlertDialog.Builder(ctx)) {
|
||||||
|
setCustomTitle(titleView)
|
||||||
|
setMessage(String.format(ctx.getString(R.string.contact_delete_question),
|
||||||
Contact.contacts()[position].name))
|
Contact.contacts()[position].name))
|
||||||
.setNegativeButton(cxt.getText(R.string.cancel), dialogClickListener)
|
setNegativeButton(ctx.getText(R.string.cancel), dialogClickListener)
|
||||||
.setPositiveButton(cxt.getText(R.string.delete), dialogClickListener)
|
setPositiveButton(ctx.getText(R.string.delete), dialogClickListener)
|
||||||
.show()
|
show()
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
val actionView = rowView.findViewById(R.id.edit) as ImageButton
|
val actionView = rowView.findViewById(R.id.edit) as ImageButton
|
||||||
actionView.setOnClickListener { _ ->
|
actionView.setOnClickListener { _ ->
|
||||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||||
lastClick = SystemClock.elapsedRealtime()
|
lastClick = SystemClock.elapsedRealtime()
|
||||||
val i = Intent(cxt, ContactActivity::class.java)
|
val i = Intent(ctx, ContactActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putBoolean("new", false)
|
b.putBoolean("new", false)
|
||||||
b.putInt("index", position)
|
b.putInt("index", position)
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
(cxt as Activity).startActivityForResult(i, MainActivity.CONTACT_CODE)
|
(ctx as Activity).startActivityForResult(i, MainActivity.CONTACT_CODE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rowView
|
return rowView
|
||||||
|
|||||||
Reference in New Issue
Block a user