Use drawable as security button tag
This commit is contained in:
@@ -11,7 +11,7 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
|
|||||||
var onHoldCall: Call? = null
|
var onHoldCall: Call? = null
|
||||||
var newCall: Call? = null
|
var newCall: Call? = null
|
||||||
var rejected = false
|
var rejected = false
|
||||||
var security = 0
|
var security = R.drawable.unlocked
|
||||||
var zid = ""
|
var zid = ""
|
||||||
var startTime: GregorianCalendar? = null // Set when call is established
|
var startTime: GregorianCalendar? = null // Set when call is established
|
||||||
var referTo = ""
|
var referTo = ""
|
||||||
|
|||||||
@@ -284,15 +284,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
securityButton.setOnClickListener {
|
securityButton.setOnClickListener {
|
||||||
when (securityButton.tag) {
|
when (securityButton.tag) {
|
||||||
"red" -> {
|
R.drawable.unlocked -> {
|
||||||
Utils.alertView(this, getString(R.string.alert),
|
Utils.alertView(this, getString(R.string.alert),
|
||||||
getString(R.string.call_not_secure))
|
getString(R.string.call_not_secure))
|
||||||
}
|
}
|
||||||
"yellow" -> {
|
R.drawable.locked_yellow -> {
|
||||||
Utils.alertView(this, getString(R.string.alert),
|
Utils.alertView(this, getString(R.string.alert),
|
||||||
getString(R.string.peer_not_verified))
|
getString(R.string.peer_not_verified))
|
||||||
}
|
}
|
||||||
"green" -> {
|
R.drawable.locked_green -> {
|
||||||
with(MaterialAlertDialogBuilder(this, R.style.AlertDialogTheme)) {
|
with(MaterialAlertDialogBuilder(this, R.style.AlertDialogTheme)) {
|
||||||
setTitle(R.string.info)
|
setTitle(R.string.info)
|
||||||
setMessage(getString(R.string.call_is_secure))
|
setMessage(getString(R.string.call_is_secure))
|
||||||
@@ -304,12 +304,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Log.e(TAG, "Command 'zrtp_unverify ${call.zid}' failed")
|
Log.e(TAG, "Command 'zrtp_unverify ${call.zid}' failed")
|
||||||
} else {
|
} else {
|
||||||
securityButton.setImageResource(R.drawable.locked_yellow)
|
securityButton.setImageResource(R.drawable.locked_yellow)
|
||||||
securityButton.tag = "yellow"
|
securityButton.tag = R.drawable.locked_yellow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
setNeutralButton(getString(R.string.no)) { dialog, _ ->
|
setNeutralButton(getString(R.string.cancel)) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
show()
|
show()
|
||||||
@@ -1037,21 +1037,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
setMessage(String.format(getString(R.string.verify_sas),
|
setMessage(String.format(getString(R.string.verify_sas),
|
||||||
ev[1], ev[2]))
|
ev[1], ev[2]))
|
||||||
setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
||||||
val security: Int = if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) {
|
call.security = if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) {
|
||||||
Log.e(TAG, "Command 'zrtp_verify ${ev[3]}' failed")
|
Log.e(TAG, "Command 'zrtp_verify ${ev[3]}' failed")
|
||||||
R.drawable.locked_yellow
|
R.drawable.locked_yellow
|
||||||
} else {
|
} else {
|
||||||
R.drawable.locked_green
|
R.drawable.locked_green
|
||||||
}
|
}
|
||||||
call.security = security
|
|
||||||
call.zid = ev[3]
|
call.zid = ev[3]
|
||||||
if (aor == aorSpinner.tag) {
|
if (aor == aorSpinner.tag) {
|
||||||
securityButton.setImageResource(security)
|
securityButton.tag = call.security
|
||||||
setSecurityButtonTag(securityButton, security)
|
securityButton.setImageResource(call.security)
|
||||||
securityButton.visibility = if (Call.ofCallp(callp) == null)
|
|
||||||
View.INVISIBLE
|
|
||||||
else
|
|
||||||
View.VISIBLE
|
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
@@ -1059,12 +1054,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
call.security = R.drawable.locked_yellow
|
call.security = R.drawable.locked_yellow
|
||||||
call.zid = ev[3]
|
call.zid = ev[3]
|
||||||
if (aor == aorSpinner.tag) {
|
if (aor == aorSpinner.tag) {
|
||||||
|
securityButton.tag = R.drawable.locked_yellow
|
||||||
securityButton.setImageResource(R.drawable.locked_yellow)
|
securityButton.setImageResource(R.drawable.locked_yellow)
|
||||||
securityButton.tag = "yellow"
|
|
||||||
securityButton.visibility = if (Call.ofCallp(callp) == null)
|
|
||||||
View.INVISIBLE
|
|
||||||
else
|
|
||||||
View.VISIBLE
|
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
@@ -1078,13 +1069,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
handleNextEvent("Call $callp that is verified is not found")
|
handleNextEvent("Call $callp that is verified is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val tag: String = if (call.security == R.drawable.locked_yellow)
|
|
||||||
"yellow"
|
|
||||||
else
|
|
||||||
"green"
|
|
||||||
if (aor == aorSpinner.tag) {
|
if (aor == aorSpinner.tag) {
|
||||||
securityButton.setImageResource(call.security)
|
securityButton.setImageResource(call.security)
|
||||||
securityButton.tag = tag
|
securityButton.tag = call.security
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"call transfer", "transfer show" -> {
|
"call transfer", "transfer show" -> {
|
||||||
@@ -1716,20 +1703,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSecurityButtonTag(button: ImageButton, security: Int) {
|
|
||||||
when (security) {
|
|
||||||
R.drawable.unlocked -> {
|
|
||||||
button.tag = "red"
|
|
||||||
}
|
|
||||||
R.drawable.locked_yellow -> {
|
|
||||||
button.tag = "yellow"
|
|
||||||
}
|
|
||||||
R.drawable.locked_green -> {
|
|
||||||
button.tag = "green"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun makeCall() {
|
private fun makeCall() {
|
||||||
callUri.setAdapter(null)
|
callUri.setAdapter(null)
|
||||||
val ua = BaresipService.uas[aorSpinner.selectedItemPosition]
|
val ua = BaresipService.uas[aorSpinner.selectedItemPosition]
|
||||||
@@ -1897,8 +1870,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (ua.account.mediaEnc == "") {
|
if (ua.account.mediaEnc == "") {
|
||||||
securityButton.visibility = View.INVISIBLE
|
securityButton.visibility = View.INVISIBLE
|
||||||
} else {
|
} else {
|
||||||
|
securityButton.tag = call.security
|
||||||
securityButton.setImageResource(call.security)
|
securityButton.setImageResource(call.security)
|
||||||
setSecurityButtonTag(securityButton, call.security)
|
|
||||||
securityButton.visibility = View.VISIBLE
|
securityButton.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
callButton.visibility = View.INVISIBLE
|
callButton.visibility = View.INVISIBLE
|
||||||
|
|||||||
Reference in New Issue
Block a user