use check icon for saving in all activities
This commit is contained in:
@ -29,8 +29,7 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_account)
|
setContentView(R.layout.activity_account)
|
||||||
|
|
||||||
val b = intent.extras
|
acc = Account.find(MainActivity.uas, intent.extras.getString("accp"))!!
|
||||||
acc = Account.find(MainActivity.uas, b.getString("accp"))!!
|
|
||||||
aor = acc.aor
|
aor = acc.aor
|
||||||
setTitle(aor.replace("sip:", ""))
|
setTitle(aor.replace("sip:", ""))
|
||||||
|
|
||||||
@ -122,6 +121,8 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
|
||||||
|
val i = Intent(this, MainActivity::class.java)
|
||||||
|
|
||||||
if (item.itemId == R.id.checkIcon) {
|
if (item.itemId == R.id.checkIcon) {
|
||||||
|
|
||||||
val dn = displayName.text.toString().trim()
|
val dn = displayName.text.toString().trim()
|
||||||
@ -257,19 +258,19 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
UserAgent.ua_register(Account.findUA(acc.aor)!!.uap)
|
UserAgent.ua_register(Account.findUA(acc.aor)!!.uap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setResult(RESULT_OK, intent)
|
setResult(RESULT_OK, i)
|
||||||
finish()
|
finish()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
} else if (item.itemId == android.R.id.home) {
|
} else if (item.itemId == android.R.id.home) {
|
||||||
|
|
||||||
Log.d("Baresip", "Back array was pressed at Account")
|
Log.d("Baresip", "Back array was pressed at Account")
|
||||||
intent.putExtra("action", "cancel")
|
i.putExtra("action", "cancel")
|
||||||
if (acc.regint > 0) {
|
if (acc.regint > 0) {
|
||||||
Log.d("Baresip", "Registering ${acc.aor}")
|
Log.d("Baresip", "Registering ${acc.aor}")
|
||||||
UserAgent.ua_register(Account.findUA(acc.aor)!!.uap)
|
UserAgent.ua_register(Account.findUA(acc.aor)!!.uap)
|
||||||
}
|
}
|
||||||
setResult(RESULT_OK, intent)
|
setResult(RESULT_OK, i)
|
||||||
finish()
|
finish()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
@ -63,41 +64,44 @@ class EditConfigActivity : AppCompatActivity() {
|
|||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
super.onCreateOptionsMenu(menu)
|
super.onCreateOptionsMenu(menu)
|
||||||
val inflater = menuInflater
|
val inflater = menuInflater
|
||||||
inflater.inflate(R.menu.edit_menu, menu)
|
inflater.inflate(R.menu.check_icon, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val i = Intent(this, MainActivity::class.java)
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.save -> {
|
|
||||||
try {
|
|
||||||
val fOut = FileOutputStream(file!!.absoluteFile, false)
|
|
||||||
val fWriter = OutputStreamWriter(fOut)
|
|
||||||
val res = editText!!.text.toString()
|
|
||||||
try {
|
|
||||||
fWriter.write(res)
|
|
||||||
fWriter.close()
|
|
||||||
fOut.close()
|
|
||||||
} catch (e: java.io.IOException) {
|
|
||||||
Log.e("Baresip", "Failed to write config file: " + e.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e: java.io.FileNotFoundException) {
|
val i = Intent(this, MainActivity::class.java)
|
||||||
Log.e("Baresip", "Failed to find config file: " + e.toString())
|
|
||||||
|
if (item.itemId == R.id.checkIcon) {
|
||||||
|
try {
|
||||||
|
val fOut = FileOutputStream(file!!.absoluteFile, false)
|
||||||
|
val fWriter = OutputStreamWriter(fOut)
|
||||||
|
val res = editText!!.text.toString()
|
||||||
|
try {
|
||||||
|
fWriter.write(res)
|
||||||
|
fWriter.close()
|
||||||
|
fOut.close()
|
||||||
|
} catch (e: java.io.IOException) {
|
||||||
|
Log.e("Baresip", "Failed to write config file: " + e.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("Baresip", "Updated config file")
|
} catch (e: java.io.FileNotFoundException) {
|
||||||
setResult(RESULT_OK, i)
|
Log.e("Baresip", "Failed to find config file: " + e.toString())
|
||||||
finish()
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
R.id.cancel, android.R.id.home -> {
|
|
||||||
setResult(RESULT_CANCELED, i)
|
Log.d("Baresip", "Updated config file")
|
||||||
finish()
|
setResult(RESULT_OK, i)
|
||||||
return true
|
finish()
|
||||||
}
|
return true
|
||||||
else -> return super.onOptionsItemSelected(item)
|
|
||||||
}
|
} else if (item.itemId == android.R.id.home) {
|
||||||
|
|
||||||
|
Log.d("Baresip", "Back array was pressed at Edit Config")
|
||||||
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
|
finish()
|
||||||
|
return true
|
||||||
|
|
||||||
|
} else return super.onOptionsItemSelected(item)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
@ -34,33 +35,33 @@ class EditContactsActivity : AppCompatActivity() {
|
|||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
super.onCreateOptionsMenu(menu)
|
super.onCreateOptionsMenu(menu)
|
||||||
val inflater = menuInflater
|
val inflater = menuInflater
|
||||||
inflater.inflate(R.menu.edit_menu, menu)
|
inflater.inflate(R.menu.check_icon, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
|
||||||
val i = Intent(this, MainActivity::class.java)
|
val i = Intent(this, MainActivity::class.java)
|
||||||
when (item.itemId) {
|
|
||||||
R.id.save -> {
|
if (item.itemId == R.id.checkIcon) {
|
||||||
val path = applicationContext.filesDir.absolutePath + "/contacts"
|
val path = applicationContext.filesDir.absolutePath + "/contacts"
|
||||||
val file = File(path)
|
val file = File(path)
|
||||||
Utils.putFileContents(file, editText!!.text.toString())
|
Utils.putFileContents(file, editText!!.text.toString())
|
||||||
Log.d("Baresip", "Updated contacts file")
|
Log.d("Baresip", "Updated contacts file")
|
||||||
MainActivity.contacts_remove()
|
MainActivity.contacts_remove()
|
||||||
updateContactsAndNames(path)
|
updateContactsAndNames(path)
|
||||||
// MainActivity.calleeAdapter.notifyDataSetChanged(); does not work
|
setResult(RESULT_OK, i)
|
||||||
setResult(RESULT_OK, i)
|
finish()
|
||||||
finish()
|
return true
|
||||||
return true
|
|
||||||
}
|
} else if (item.itemId == android.R.id.home) {
|
||||||
R.id.cancel, android.R.id.home -> {
|
Log.d("Baresip", "Back array was pressed at Contacts")
|
||||||
i.putExtra("action", "cancel")
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
setResult(RESULT_OK, i)
|
finish()
|
||||||
finish()
|
return true
|
||||||
return true
|
|
||||||
}
|
} else return super.onOptionsItemSelected(item)
|
||||||
else -> return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class HistoryActivity : AppCompatActivity() {
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
Log.d("Baresip", "Back array was pressed")
|
Log.d("Baresip", "Back array was pressed at History")
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
setResult(Activity.RESULT_CANCELED, i)
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
finish()
|
finish()
|
||||||
|
|||||||
@ -487,7 +487,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EDIT_CONTACTS_CODE, ABOUT_CODE -> {
|
EDIT_CONTACTS_CODE, ABOUT_CODE -> {
|
||||||
Log.d("Baresip", "Back arrow or Cancel pressed at request: $requestCode")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user