From 32f61016f2bfc6a990cfba5e3140084246576de6 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sat, 20 Mar 2021 16:20:39 +0200 Subject: [PATCH] Cleaned up some code and resources --- .../com/tutpro/baresip/AboutActivity.kt | 2 +- .../com/tutpro/baresip/AccountActivity.kt | 10 +-- .../com/tutpro/baresip/BaresipService.kt | 41 ++++++----- .../tutpro/baresip/BootCompletedReceiver.kt | 1 - .../main/kotlin/com/tutpro/baresip/Call.kt | 8 --- .../kotlin/com/tutpro/baresip/ChatActivity.kt | 10 +-- .../com/tutpro/baresip/ChatListAdapter.kt | 2 +- .../com/tutpro/baresip/CodecsActivity.kt | 4 +- .../com/tutpro/baresip/ConfigActivity.kt | 2 +- .../com/tutpro/baresip/ContactActivity.kt | 10 +-- .../com/tutpro/baresip/ContactListAdapter.kt | 10 +-- .../kotlin/com/tutpro/baresip/MainActivity.kt | 20 +++--- .../com/tutpro/baresip/UaSpinnerAdapter.kt | 1 - .../main/kotlin/com/tutpro/baresip/Utils.kt | 8 +-- app/src/main/res/drawable/action_add.png | Bin 1028 -> 0 bytes app/src/main/res/layout/call_notification.xml | 66 ------------------ app/src/main/res/values/dimens.xml | 3 - app/src/main/res/values/strings.xml | 3 - 18 files changed, 59 insertions(+), 142 deletions(-) delete mode 100644 app/src/main/res/drawable/action_add.png delete mode 100644 app/src/main/res/layout/call_notification.xml diff --git a/app/src/main/kotlin/com/tutpro/baresip/AboutActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AboutActivity.kt index 9afb815b..cb84663e 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AboutActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AboutActivity.kt @@ -24,7 +24,7 @@ class AboutActivity : AppCompatActivity() { val text = String.format(getString(R.string.about_text), BuildConfig.VERSION_NAME) binding.aboutText.text = HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY) - binding.aboutText.setMovementMethod(LinkMovementMethod.getInstance()) + binding.aboutText.movementMethod = LinkMovementMethod.getInstance() } diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt index 06df76c2..a8098a71 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt @@ -253,7 +253,7 @@ class AccountActivity : AppCompatActivity() { if (dn != acc.displayName) { if (Account.checkDisplayName(dn)) { if (Api.account_set_display_name(acc.accp, dn) == 0) { - acc.displayName = Api.account_display_name(acc.accp); + acc.displayName = Api.account_display_name(acc.accp) Log.d(TAG, "New display name is ${acc.displayName}") save = true } else { @@ -272,7 +272,7 @@ class AccountActivity : AppCompatActivity() { if (au != acc.authUser) { if (Account.checkAuthUser(au)) { if (Api.account_set_auth_user(acc.accp, au) == 0) { - acc.authUser = Api.account_auth_user(acc.accp); + acc.authUser = Api.account_auth_user(acc.accp) Log.d(TAG, "New auth user is ${acc.authUser}") save = true } else { @@ -344,7 +344,7 @@ class AccountActivity : AppCompatActivity() { return false } } - Log.d(TAG, "New outbound proxies are ${outbound}") + Log.d(TAG, "New outbound proxies are $outbound") acc.outbound = outbound if (outbound.isEmpty()) Api.account_set_sipnat(acc.accp, "") @@ -411,7 +411,7 @@ class AccountActivity : AppCompatActivity() { if (acc.stunUser != newStunUser) { if (Account.checkAuthUser(newStunUser)) { if (Api.account_set_stun_user(acc.accp, newStunUser) == 0) { - acc.stunUser = Api.account_stun_user(acc.accp); + acc.stunUser = Api.account_stun_user(acc.accp) Log.d(TAG, "New STUN/TURN user is ${acc.stunUser}") save = true } else { @@ -428,7 +428,7 @@ class AccountActivity : AppCompatActivity() { if (acc.stunPass != newStunPass) { if (newStunPass.isEmpty() || Account.checkAuthPass(newStunPass)) { if (Api.account_set_stun_pass(acc.accp, newStunPass) == 0) { - acc.stunPass = Api.account_stun_pass(acc.accp); + acc.stunPass = Api.account_stun_pass(acc.accp) save = true } else { Log.e(TAG, "Setting of stun pass failed") diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 28aed3bd..5f2ef42f 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -261,7 +261,7 @@ class BaresipService: Service() { val dnsServers = Utils.findDnsServers(BaresipService.dnsServers) if ((ipV4Addr == "") && (ipV6Addr == "")) Log.w(LOG_TAG, "Starting baresip without IP addresses") - Thread(Runnable { + Thread({ baresipStart(filesPath, ipV4Addr, ipV6Addr, "", dnsServers, Api.AF_UNSPEC, logLevel) }).start() @@ -466,7 +466,7 @@ class BaresipService: Service() { newEvent = "registering failed,DNS lookup failed" Api.net_dns_debug() if (dynDns) - if (Build.VERSION.SDK_INT >= 23) { + if (VERSION.SDK_INT >= 23) { val activeNetwork = cm.activeNetwork if (activeNetwork != null) { val props = cm.getLinkProperties(activeNetwork) @@ -531,7 +531,7 @@ class BaresipService: Service() { Call(callp, ua, peerUri, "in", "incoming", Utils.dtmfWatcher(callp)).add() if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) { - if (Build.VERSION.SDK_INT >= 23) { + if (VERSION.SDK_INT >= 23) { Log.d(LOG_TAG, "CurrentInterruptionFilter ${nm.currentInterruptionFilter}") if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL) startRinging() @@ -568,7 +568,7 @@ class BaresipService: Service() { .setContentText(caller) .setShowWhen(true) .setFullScreenIntent(pi, true) - if (Build.VERSION.SDK_INT < 26) { + if (VERSION.SDK_INT < 26) { nb.setVibrate(LongArray(0)) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .priority = Notification.PRIORITY_HIGH @@ -659,10 +659,9 @@ class BaresipService: Service() { .setAutoCancel(true) .setContentTitle(getString(R.string.transfer_request_to)) .setContentText(target) - if (Build.VERSION.SDK_INT < 26) { + if (VERSION.SDK_INT < 26) { nb.setVibrate(LongArray(0)) - .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) - .setPriority(Notification.PRIORITY_HIGH) + .setVisibility(NotificationCompat.VISIBILITY_PRIVATE).priority = Notification.PRIORITY_HIGH } val acceptIntent = Intent(this, BaresipService::class.java) acceptIntent.action = "Transfer Accept" @@ -729,7 +728,7 @@ class BaresipService: Service() { .setAutoCancel(true) .setContentTitle(getString(R.string.missed_call_from)) .setContentText(caller) - if (Build.VERSION.SDK_INT < 26) { + if (VERSION.SDK_INT < 26) { nb.setVibrate(LongArray(0)) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .priority = Notification.PRIORITY_HIGH @@ -796,7 +795,7 @@ class BaresipService: Service() { .setAutoCancel(true) .setContentTitle(getString(R.string.message_from) + " " + sender) .setContentText(text) - if (Build.VERSION.SDK_INT < 26) { + if (VERSION.SDK_INT < 26) { nb.setVibrate(LongArray(0)) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .priority = Notification.PRIORITY_HIGH @@ -877,7 +876,7 @@ class BaresipService: Service() { } private fun createNotificationChannels() { - if (Build.VERSION.SDK_INT >= 26) { + if (VERSION.SDK_INT >= 26) { val defaultChannel = NotificationChannel(DEFAULT_CHANNEL_ID, "Default", NotificationManager.IMPORTANCE_LOW) defaultChannel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC @@ -904,7 +903,7 @@ class BaresipService: Service() { } private fun updateStatusNotification() { - val contentView = RemoteViews(getPackageName(), R.layout.status_notification) + val contentView = RemoteViews(packageName, R.layout.status_notification) for (i: Int in 0..5) { val resID = resources.getIdentifier("status$i", "id", packageName) if (i < status.size) { @@ -922,7 +921,7 @@ class BaresipService: Service() { nm.notify(STATUS_NOTIFICATION_ID, snb.build()) } - private fun getActionText(@StringRes stringRes: Int, @ColorRes colorRes: Int): Spannable? { + private fun getActionText(@StringRes stringRes: Int, @ColorRes colorRes: Int): Spannable { val spannable: Spannable = SpannableString(applicationContext.getText(stringRes)) if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) { spannable.setSpan( @@ -939,7 +938,7 @@ class BaresipService: Service() { else abandonAudioFocus() } - if ((Build.VERSION.SDK_INT >= 26) && (audioFocusRequest == null)) { + if ((VERSION.SDK_INT >= 26) && (audioFocusRequest == null)) { @TargetApi(26) audioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE) .run { @@ -987,7 +986,7 @@ class BaresipService: Service() { } private fun abandonAudioFocus() { - if (Build.VERSION.SDK_INT >= 26) { + if (VERSION.SDK_INT >= 26) { if (audioFocusRequest != null) { if (am.abandonAudioFocusRequest(audioFocusRequest!!) == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { @@ -1013,7 +1012,7 @@ class BaresipService: Service() { private fun startRinging() { am.mode = AudioManager.MODE_RINGTONE requestAudioFocus(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) - if (Build.VERSION.SDK_INT >= 28) { + if (VERSION.SDK_INT >= 28) { rt.isLooping = true rt.play() } else { @@ -1021,7 +1020,7 @@ class BaresipService: Service() { rtTimer = Timer() rtTimer!!.scheduleAtFixedRate(object : TimerTask() { override fun run() { - if (!rt.isPlaying()) { + if (!rt.isPlaying) { rt.play() } } @@ -1031,7 +1030,7 @@ class BaresipService: Service() { private fun stopRinging() { if (am.mode == AudioManager.MODE_RINGTONE) { - if ((Build.VERSION.SDK_INT < 28) && (rtTimer != null)) { + if ((VERSION.SDK_INT < 28) && (rtTimer != null)) { rtTimer!!.cancel() rtTimer = null } @@ -1065,14 +1064,14 @@ class BaresipService: Service() { private fun proximitySensing(enable: Boolean) { if (enable) { - if (!proximityWakeLock.isHeld()) { + if (!proximityWakeLock.isHeld) { Log.d(LOG_TAG, "Acquiring proximity wake lock") proximityWakeLock.acquire() } else { Log.d(LOG_TAG, "Proximity wake lock already acquired") } } else { - if (proximityWakeLock.isHeld()) { + if (proximityWakeLock.isHeld) { proximityWakeLock.release() Log.d(LOG_TAG, "Released proximity wake lock") } else { @@ -1138,7 +1137,7 @@ class BaresipService: Service() { } private fun isNetworkActive(network: Network): Boolean { - if (Build.VERSION.SDK_INT >= 23) + if (VERSION.SDK_INT >= 23) return network == cm.activeNetwork if ((cm.activeNetworkInfo != null) && (cm.getNetworkInfo(network) != null)) return cm.activeNetworkInfo!!.toString() == cm.getNetworkInfo(network)!!.toString() @@ -1207,7 +1206,7 @@ class BaresipService: Service() { var callHistory = ArrayList() var messages = ArrayList() val contacts = ArrayList() - val chatTexts: MutableMap = mutableMapOf() + val chatTexts: MutableMap = mutableMapOf() val activities = mutableListOf() var linkAddresses = listOf() var dnsServers = listOf() diff --git a/app/src/main/kotlin/com/tutpro/baresip/BootCompletedReceiver.kt b/app/src/main/kotlin/com/tutpro/baresip/BootCompletedReceiver.kt index 9aa54328..856dd24a 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BootCompletedReceiver.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BootCompletedReceiver.kt @@ -9,7 +9,6 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle -import android.provider.Settings.Global.getString import androidx.core.app.NotificationCompat import java.nio.charset.StandardCharsets diff --git a/app/src/main/kotlin/com/tutpro/baresip/Call.kt b/app/src/main/kotlin/com/tutpro/baresip/Call.kt index 217c5862..78c810c6 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Call.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Call.kt @@ -28,10 +28,6 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S call_start_audio(callp) } - fun stopAudio() { - call_stop_audio(callp) - } - fun hold(): Int { return call_hold(callp) } @@ -53,10 +49,6 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S call_notify_sipfrag(callp, code, reason) } - fun hasVideo(): Boolean { - return call_has_video(callp) - } - fun status(): String { return call_status(callp) } diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt index a11a499e..fa8086fb 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt @@ -128,11 +128,11 @@ class ChatActivity : AppCompatActivity() { } newMessage = binding.text - newMessage.setOnFocusChangeListener(View.OnFocusChangeListener { _, hasFocus -> + newMessage.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus -> if (hasFocus) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) } - }) + } if (focus) newMessage.requestFocus() @@ -147,7 +147,7 @@ class ChatActivity : AppCompatActivity() { msg.add() chatMessages.add(msg) if (Api.message_send(ua.uap, peerUri, msgText, time.toString()) != 0) { - Toast.makeText(getApplicationContext(), "${getString(R.string.message_failed)}!", + Toast.makeText(applicationContext, "${getString(R.string.message_failed)}!", Toast.LENGTH_SHORT).show() msg.direction = R.drawable.arrow_up_red msg.responseReason = getString(R.string.message_failed) @@ -216,8 +216,8 @@ class ChatActivity : AppCompatActivity() { 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.flags = 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) diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt index 531ce0cf..d5c7fae6 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt @@ -73,7 +73,7 @@ class ChatListAdapter(private val ctx: Context, private var rows: ArrayList ArrayList()}) + val spinnerList = Array(codecs.size) { ArrayList() } for (i in codecs.indices) { val spinner = Spinner(applicationContext) spinner.id = i + 100 @@ -72,7 +72,7 @@ class CodecsActivity : AppCompatActivity() { spinnerList[i].addAll(codecs) spinnerList[i].add(0, "-") } - val codecSpinner = findViewById(spinner.id) as Spinner + val codecSpinner = findViewById(spinner.id) val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, spinnerList[i]) adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) diff --git a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt index ef64fee9..f2d70610 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt @@ -96,7 +96,7 @@ class ConfigActivity : AppCompatActivity() { volVals.removeAt(curVal) volKeys.add(0, curKey) volVals.add(0, curVal) - val callVolAdapter = ArrayAdapter(this,android.R.layout.simple_spinner_item, + val callVolAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, volKeys) callVolAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) callVolSpinner.adapter = callVolAdapter diff --git a/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt index 90f0ed79..a5d6c254 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt @@ -102,7 +102,7 @@ class ContactActivity : AppCompatActivity() { oldAndroid = androidCheck.isChecked - textAvatarView.setOnClickListener { _ -> + textAvatarView.setOnClickListener { val intent = Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) @@ -112,7 +112,7 @@ class ContactActivity : AppCompatActivity() { } - textAvatarView.setOnLongClickListener { _ -> + textAvatarView.setOnLongClickListener { color = Utils.randomColor() showTextAvatar(textAvatarView.text.toString(), color) @@ -121,7 +121,7 @@ class ContactActivity : AppCompatActivity() { } - cardAvatarView.setOnClickListener { _ -> + cardAvatarView.setOnClickListener { val intent = Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) @@ -131,7 +131,7 @@ class ContactActivity : AppCompatActivity() { } - cardAvatarView.setOnLongClickListener { _ -> + cardAvatarView.setOnLongClickListener { color = Utils.randomColor() showTextAvatar(nameView.text.toString(), color) @@ -533,7 +533,7 @@ class ContactActivity : AppCompatActivity() { val cur: Cursor? = ctx.contentResolver.query(ContactsContract.Data.CONTENT_URI, projection, selection, null, null) while (cur != null && cur.moveToNext()) { - val id = cur.getLong(0); + val id = cur.getLong(0) val name = cur.getString(1) // display name val mime = cur.getString(2) // type of data val data = cur.getString(3) // info diff --git a/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt index 852e368a..0b1a2f46 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt @@ -75,13 +75,13 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList + viewHolder.nameView.setOnClickListener { val dialogClickListener = DialogInterface.OnClickListener { _, which -> when (which) { DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> { val i = Intent(ctx, MainActivity::class.java) - i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or - Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) + i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or + Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP if (which == DialogInterface.BUTTON_NEGATIVE) i.putExtra("action", "call") else @@ -114,7 +114,7 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList + viewHolder.nameView.setOnLongClickListener { val dialogClickListener = DialogInterface.OnClickListener { _, which -> when (which) { DialogInterface.BUTTON_POSITIVE -> { @@ -151,7 +151,7 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList + viewHolder.actionView.setOnClickListener { if (SystemClock.elapsedRealtime() - lastClick > 1000) { lastClick = SystemClock.elapsedRealtime() val i = Intent(ctx, ContactActivity::class.java) diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index 17581659..892b9672 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -136,13 +136,13 @@ class MainActivity : AppCompatActivity() { override fun onFinish() { when (stopState) { "initial" -> { - baresipService.setAction("Stop Force"); + baresipService.action = "Stop Force" startService(baresipService) stopState = "force" quitTimer.start() } "force" -> { - baresipService.setAction("Kill"); + baresipService.action = "Kill" startService(baresipService) finishAndRemoveTask() System.exit(0) @@ -386,8 +386,8 @@ class MainActivity : AppCompatActivity() { when (which) { DialogInterface.BUTTON_POSITIVE -> { val callIntent = Intent(this, MainActivity::class.java) - callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or - Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) + callIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or + Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP callIntent.putExtra("action", "call") callIntent.putExtra("uap", ua.uap) callIntent.putExtra("peer", acc.vmUri) @@ -729,7 +729,7 @@ class MainActivity : AppCompatActivity() { override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { when (keyCode) { KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_UP -> { - Log.d(TAG, "Adjusting volume $keyCode of stream ${volumeControlStream}") + Log.d(TAG, "Adjusting volume $keyCode of stream $volumeControlStream") am.adjustStreamVolume(volumeControlStream, if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) AudioManager.ADJUST_LOWER else @@ -989,7 +989,7 @@ class MainActivity : AppCompatActivity() { "message", "message show", "message reply" -> { val peer = params[1] val i = Intent(applicationContext, ChatActivity::class.java) - i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + i.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP val b = Bundle() b.putString("aor", aor) b.putString("peer", peer) @@ -1024,7 +1024,7 @@ class MainActivity : AppCompatActivity() { private fun reStart() { Log.d(TAG, "Trigger restart") val pm = applicationContext.packageManager - val intent = pm.getLaunchIntentForPackage(this.getPackageName()) + val intent = pm.getLaunchIntentForPackage(this.packageName) this.finishAffinity() this.startActivity(intent) System.exit(0) @@ -1116,7 +1116,7 @@ class MainActivity : AppCompatActivity() { if (aorSpinner.tag != "") updateIcons(Account.ofAor(aorSpinner.tag.toString())!!) if (BaresipService.isServiceRunning) { - baresipService.setAction("UpdateNotification") + baresipService.action = "UpdateNotification" startService(baresipService) } } @@ -1205,7 +1205,7 @@ class MainActivity : AppCompatActivity() { Log.d(TAG, "quitRestart Restart = $reStart") if (BaresipService.isServiceRunning) { restart = reStart - baresipService.setAction("Stop"); + baresipService.action = "Stop" startService(baresipService) quitTimer.start() } else { @@ -1379,7 +1379,7 @@ class MainActivity : AppCompatActivity() { } private fun startBaresip() { - baresipService.setAction("Start") + baresipService.action = "Start" startService(baresipService) if (atStartup) moveTaskToBack(true) diff --git a/app/src/main/kotlin/com/tutpro/baresip/UaSpinnerAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/UaSpinnerAdapter.kt index ce4c2cc2..26a19410 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/UaSpinnerAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/UaSpinnerAdapter.kt @@ -5,7 +5,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter -import android.widget.ImageButton import android.widget.ImageView import android.widget.TextView diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt index de946cb5..263da454 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt @@ -270,7 +270,7 @@ object Utils { var servers = "" for (dnsServer in list) { var address = dnsServer.hostAddress.removePrefix("/") - if (Utils.checkIpV4(address)) + if (checkIpV4(address)) address = "${address}:53" else address = "[${address}]:53" @@ -518,7 +518,7 @@ object Utils { fun decryptFromFile(filePath: String, password: String): ByteArray? { var plainData: ByteArray? = null try { - ObjectInputStream(FileInputStream(File(filePath))).use { it -> + ObjectInputStream(FileInputStream(File(filePath))).use { val obj = it.readObject() as Crypto plainData = decrypt(obj, password.toCharArray()) } @@ -577,7 +577,7 @@ object Utils { return false } (allFiles - zipFiles).iterator().forEach { - deleteFile(File(BaresipService.filesPath, "$it")) + deleteFile(File(BaresipService.filesPath, it)) } return true } @@ -589,7 +589,7 @@ object Utils { Log.d("Baresip", "Dumping intent start") while (it.hasNext()) { val key = it.next() - Log.d("Baresip","[" + key + "=" + bundle.get(key)+"]"); + Log.d("Baresip", "[" + key + "=" + bundle.get(key) + "]") } Log.d("Baresip", "Dumping intent finish") } diff --git a/app/src/main/res/drawable/action_add.png b/app/src/main/res/drawable/action_add.png deleted file mode 100644 index 326d0502881034dc45c11e2c3c2fedd9e6570a04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1028 zcmV+f1pE7mP)*&6Z@?vTkXmvsSCp(P^R3t|AlBQYTKP_=2uw*n-6miZBOi zEt^zC9Ozc(HZ~`dY473(^@BQ*x=KaV%{#lv94%&RSDW{9d~$CM=%>P+C!FNu<~h&r z|NPH$LinEtEhVUPt}uJs z1|v#I;tDLpD|=rsF6>S?2dvoQ6QS0i`FQIyQE3^(?@D3!J1-gMhp%jMZqb9+iIsOO zHy>_!x@b`WGP3VAV`^yDc?D~Fmka+*Uh{!lAGH9S+_LDc_ueqhy*#%xK=a$N2Deu< z`F-UOq(LM5hg>F$>ECB`3MF5?xACEhf^uc)mw5NY-pO!y^|06DRhnB^w&fM?QF+WR z%prL-`{j>M{dSf@17+k1xlZ+U4m5joK}1Svtdl>jHL>gS`OB2$#^=-|VVhJY0?=4a zo{4$M$)%#4lq$>XMEVMi9^dy-VpnQ2Mf#WNrD5NAcU#YTO_Rja0%#-|z`Hmlc+K{( zK54fpTa>pHODic)Wb=}Estm8wIZ0#3;_;c`WCun2%k;|X(D=6YZ46Mvi5DwifL2JF z$4q95P|(T%wRjIIM1)P$iF0xV4EU!4_UURiN&62Th))ltIw;)d)t6P%_=cw7jUKmx z%LNFXE70w8VC8U$D17dffYqXQn=YhHNSUyLq-7D1%>n6*LW<{SpCsZJhGYj-+)ui{ zQGL6%7L6VkhyhA)a!unR_yBk>%7cEY3EXB|wAe*wE`E*7LfVS4>Xe{d4$6Y0L6cu$ z?2p&cMJ4T^^hI>LD$&BhRBSC>)>y8J7fs^m$%%76AI_XWG0Yyyo+>wu zcsVk!Eix#oxFOD8IzUV#U z91wZLBd+h%%{$iyqa`Kwv-x@8$k?>;%X2B`7Wp@kC~sF2>uOQ&_1G08Q^4s@aVRl@ yEsg<&p@*?vYN#$g;6rwKFp>EcQ`ZFGWc&@z@#H93SJX`a0000 - - - - - - - - - - - - -