- Prevent crashes resulting from double clicking of various icons and
list items.
This commit is contained in:
@ -35,13 +35,14 @@ class AccountActivity : AppCompatActivity() {
|
||||
private var newCodecs = ArrayList<String>()
|
||||
private var save = false
|
||||
private var uaIndex= -1
|
||||
private var accp = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_account)
|
||||
|
||||
val accp = intent.getStringExtra("accp")
|
||||
accp = intent.getStringExtra("accp")
|
||||
Utils.addActivity("account,$accp")
|
||||
|
||||
acc = Account.find(accp)!!
|
||||
@ -204,6 +205,8 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
if (BaresipService.activities.indexOf("account,$accp") == -1) return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.checkIcon -> {
|
||||
@ -456,7 +459,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
if (regCheck.isChecked) Api.ua_register(ua.uap)
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("account,$accp")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
@ -465,7 +468,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
android.R.id.home -> {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("account,$accp")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
@ -480,7 +483,10 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("account,$accp")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
@ -68,6 +68,8 @@ class AccountsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
if (BaresipService.activities.indexOf("accounts") == -1) return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.help -> {
|
||||
@ -76,8 +78,7 @@ class AccountsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
Log.d("Baresip", "Back array was pressed at Accounts")
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("accounts")
|
||||
val i = Intent()
|
||||
setResult(RESULT_OK, i)
|
||||
finish()
|
||||
@ -96,7 +97,7 @@ class AccountsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("accounts")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
|
||||
@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.text.format.DateUtils.isToday
|
||||
@ -23,6 +24,7 @@ class CallsActivity : AppCompatActivity() {
|
||||
|
||||
internal var uaHistory = ArrayList<CallRow>()
|
||||
internal var aor = ""
|
||||
private var lastClick: Long = 0
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -67,13 +69,16 @@ class CallsActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
||||
builder.setMessage(String.format(getString(R.string.calls_call_message_question),
|
||||
peerName))
|
||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.call), dialogClickListener)
|
||||
.setPositiveButton(getString(R.string.send_message), dialogClickListener)
|
||||
.show()
|
||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||
lastClick = SystemClock.elapsedRealtime()
|
||||
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
||||
builder.setMessage(String.format(getString(R.string.calls_call_message_question),
|
||||
peerName))
|
||||
.setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.call), dialogClickListener)
|
||||
.setPositiveButton(getString(R.string.send_message), dialogClickListener)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, _, pos, _ ->
|
||||
@ -134,6 +139,8 @@ class CallsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
if (BaresipService.activities.indexOf("calls,$aor") == -1) return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.delete_history -> {
|
||||
@ -160,7 +167,7 @@ class CallsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("calls,$aor")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
@ -172,7 +179,10 @@ class CallsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("calls,$aor")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.tutpro.baresip
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
@ -26,6 +27,9 @@ class ChatActivity : AppCompatActivity() {
|
||||
internal lateinit var ua: UserAgent
|
||||
internal lateinit var messageResponseReceiver: BroadcastReceiver
|
||||
|
||||
private var focus = false
|
||||
private var lastCall: Long = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -34,7 +38,15 @@ class ChatActivity : AppCompatActivity() {
|
||||
|
||||
aor = intent.getStringExtra("aor")!!
|
||||
peerUri = intent.getStringExtra("peer")!!
|
||||
val focus = intent.getBooleanExtra("focus", false)
|
||||
focus = intent.getBooleanExtra("focus", false)
|
||||
|
||||
if (BaresipService.activities.first().startsWith("chat,$aor,$peerUri")) {
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
} else {
|
||||
Utils.addActivity("chat,$aor,$peerUri,$focus")
|
||||
}
|
||||
|
||||
val userAgent = Account.findUa(aor)
|
||||
if (userAgent == null) {
|
||||
@ -47,9 +59,6 @@ class ChatActivity : AppCompatActivity() {
|
||||
ua = userAgent
|
||||
}
|
||||
|
||||
if (!BaresipService.activities.first().startsWith("chat,$aor,$peerUri"))
|
||||
Utils.addActivity("chat,$aor,$peerUri,$focus")
|
||||
|
||||
imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
this@ChatActivity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
||||
|
||||
@ -175,11 +184,6 @@ class ChatActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
/*override fun onStop() {
|
||||
super.onStop()
|
||||
Log.d("Baresip", "Chat Stopped")
|
||||
}*/
|
||||
|
||||
override fun onResume() {
|
||||
|
||||
super.onResume()
|
||||
@ -207,6 +211,10 @@ class ChatActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
if ((BaresipService.activities.indexOf("chat,$aor,$peerUri,false") == -1) &&
|
||||
(BaresipService.activities.indexOf("chat,$aor,$peerUri,true") == -1))
|
||||
return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
android.R.id.home -> {
|
||||
@ -219,31 +227,37 @@ class ChatActivity : AppCompatActivity() {
|
||||
}
|
||||
if (save) Message.save()
|
||||
imm.hideSoftInputFromWindow(newMessage.windowToken, 0)
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("chat,$aor,$peerUri,false")
|
||||
BaresipService.activities.remove("chat,$aor,$peerUri,true")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
}
|
||||
|
||||
R.id.callIcon -> {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
intent.putExtra("action", "call")
|
||||
intent.putExtra("uap", ua.uap)
|
||||
intent.putExtra("peer", peerUri)
|
||||
startActivity(intent)
|
||||
if (SystemClock.elapsedRealtime() - lastCall > 1000) {
|
||||
lastCall = SystemClock.elapsedRealtime()
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
intent.putExtra("action", "call")
|
||||
intent.putExtra("uap", ua.uap)
|
||||
intent.putExtra("peer", peerUri)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
finish()
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("chat,$aor,$peerUri,false")
|
||||
BaresipService.activities.remove("chat,$aor,$peerUri,true")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
|
||||
@ -19,7 +19,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
internal lateinit var peerUri: AutoCompleteTextView
|
||||
internal lateinit var plusButton: ImageButton
|
||||
|
||||
internal var aor = ""
|
||||
private var aor = ""
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -171,7 +171,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("chats,$aor")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
@ -197,10 +197,11 @@ class ChatsActivity: AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("chats,$aor")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -186,7 +186,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
if (BaresipService.activities.indexOf("config") == -1) return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
@ -386,8 +386,9 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
if (save) Config.save()
|
||||
|
||||
BaresipService.activities.remove("config")
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
if (restart) intent.putExtra("restart", true)
|
||||
|
||||
setResult(RESULT_OK, intent)
|
||||
finish()
|
||||
|
||||
@ -395,13 +396,14 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
android.R.id.home -> {
|
||||
|
||||
BaresipService.activities.remove("config")
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
setResult(Activity.RESULT_CANCELED, intent)
|
||||
finish()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
return true
|
||||
|
||||
}
|
||||
@ -430,7 +432,10 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("config")
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
setResult(Activity.RESULT_CANCELED, intent)
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
internal var newContact = false
|
||||
internal var newAvatar = ""
|
||||
internal var uOrI = ""
|
||||
|
||||
private var index = 0
|
||||
private var color = 0
|
||||
@ -45,7 +46,6 @@ class ContactActivity : AppCompatActivity() {
|
||||
uriView = findViewById(R.id.Uri) as EditText
|
||||
|
||||
newContact = intent.getBooleanExtra("new", false)
|
||||
val uOrI: String
|
||||
|
||||
if (newContact) {
|
||||
title = getString(R.string.new_contact)
|
||||
@ -118,7 +118,7 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
BaresipService.activities.add(0, "contact,$newContact,$uOrI")
|
||||
Utils.addActivity("contact,$newContact,$uOrI")
|
||||
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
val i = Intent(this, MainActivity::class.java)
|
||||
if (BaresipService.activities.indexOf("contact,$newContact,$uOrI") == -1) return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
@ -231,6 +231,8 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
Contact.save()
|
||||
|
||||
BaresipService.activities.remove("contact,$newContact,$uOrI")
|
||||
val i = Intent(this, MainActivity::class.java)
|
||||
i.putExtra("name", newName)
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
@ -238,20 +240,24 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
android.R.id.home -> {
|
||||
|
||||
BaresipService.activities.remove("contact,$newContact,$uOrI")
|
||||
val i = Intent(this, MainActivity::class.java)
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("contact,$newContact,$uOrI")
|
||||
val i = Intent(this, MainActivity::class.java)
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.support.v7.widget.CardView
|
||||
import android.view.LayoutInflater
|
||||
@ -24,6 +25,8 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
||||
private val aor: String) :
|
||||
ArrayAdapter<Contact>(cxt, R.layout.contact_row, rows) {
|
||||
|
||||
private var lastClick: Long = 0
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
val contact = rows[position]
|
||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
@ -77,13 +80,16 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
||||
}
|
||||
}
|
||||
}
|
||||
val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat)
|
||||
builder.setMessage(String.format(cxt.getString(R.string.contact_action_question),
|
||||
Contact.contacts()[position].name))
|
||||
.setNeutralButton(cxt.getText(R.string.cancel), dialogClickListener)
|
||||
.setNegativeButton(cxt.getText(R.string.call), dialogClickListener)
|
||||
.setPositiveButton(cxt.getText(R.string.send_message), dialogClickListener)
|
||||
.show()
|
||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||
lastClick = SystemClock.elapsedRealtime()
|
||||
val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat)
|
||||
builder.setMessage(String.format(cxt.getString(R.string.contact_action_question),
|
||||
Contact.contacts()[position].name))
|
||||
.setNeutralButton(cxt.getText(R.string.cancel), dialogClickListener)
|
||||
.setNegativeButton(cxt.getText(R.string.call), dialogClickListener)
|
||||
.setPositiveButton(cxt.getText(R.string.send_message), dialogClickListener)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
nameView.setOnLongClickListener { _ ->
|
||||
@ -117,12 +123,15 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
||||
}
|
||||
val actionView = rowView.findViewById(R.id.edit) as ImageButton
|
||||
actionView.setOnClickListener { _ ->
|
||||
val i = Intent(cxt, ContactActivity::class.java)
|
||||
val b = Bundle()
|
||||
b.putBoolean("new", false)
|
||||
b.putInt("index", position)
|
||||
i.putExtras(b)
|
||||
(cxt as Activity).startActivityForResult(i, MainActivity.CONTACT_CODE)
|
||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||
lastClick = SystemClock.elapsedRealtime()
|
||||
val i = Intent(cxt, ContactActivity::class.java)
|
||||
val b = Bundle()
|
||||
b.putBoolean("new", false)
|
||||
b.putInt("index", position)
|
||||
i.putExtras(b)
|
||||
(cxt as Activity).startActivityForResult(i, MainActivity.CONTACT_CODE)
|
||||
}
|
||||
}
|
||||
return rowView
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.tutpro.baresip
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
import android.widget.ImageButton
|
||||
@ -12,6 +13,7 @@ class ContactsActivity : AppCompatActivity() {
|
||||
|
||||
internal lateinit var clAdapter: ContactListAdapter
|
||||
internal lateinit var aor: String
|
||||
private var lastClick: Long = 0
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -33,12 +35,15 @@ class ContactsActivity : AppCompatActivity() {
|
||||
String.format(getString(R.string.contacts_exceeded),
|
||||
Contact.CONTACTS_SIZE))
|
||||
} else {
|
||||
val i = Intent(this, ContactActivity::class.java)
|
||||
val b = Bundle()
|
||||
b.putBoolean("new", true)
|
||||
b.putString("uri", "")
|
||||
i.putExtras(b)
|
||||
startActivityForResult(i, MainActivity.CONTACT_CODE)
|
||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||
lastClick = SystemClock.elapsedRealtime()
|
||||
val i = Intent(this, ContactActivity::class.java)
|
||||
val b = Bundle()
|
||||
b.putBoolean("new", true)
|
||||
b.putString("uri", "")
|
||||
i.putExtras(b)
|
||||
startActivityForResult(i, MainActivity.CONTACT_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +60,7 @@ class ContactsActivity : AppCompatActivity() {
|
||||
when (item.itemId) {
|
||||
|
||||
android.R.id.home -> {
|
||||
Log.d("Baresip", "Back array was pressed at Contacts")
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("contacts,$aor")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
@ -69,7 +73,7 @@ class ContactsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
BaresipService.activities.removeAt(0)
|
||||
BaresipService.activities.remove("contacts,$aor")
|
||||
val i = Intent()
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
finish()
|
||||
|
||||
Reference in New Issue
Block a user