Still more work on Android contacts
This commit is contained in:
@@ -106,7 +106,7 @@
|
|||||||
android:name=".AndroidContactActivity"
|
android:name=".AndroidContactActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:label="@string/contact"
|
android:label="@string/contact"
|
||||||
android:parentActivityName=".ContactsActivity" >
|
android:parentActivityName=".AndroidContactsActivity" >
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ConfigActivity"
|
android:name=".ConfigActivity"
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.core.content.ContextCompat.startActivity
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class AndroidContactListAdapter(private val ctx: Context,
|
class AndroidContactListAdapter(private val ctx: Context,
|
||||||
private val rows: ArrayList<AndroidContact>,
|
private val rows: ArrayList<AndroidContact>,
|
||||||
private val aor: String) :
|
private val aor: String) :
|
||||||
|
|||||||
@@ -1408,6 +1408,7 @@ class BaresipService: Service() {
|
|||||||
var callActionUri = ""
|
var callActionUri = ""
|
||||||
var isMainVisible = false
|
var isMainVisible = false
|
||||||
var isMicMuted = false
|
var isMicMuted = false
|
||||||
|
var preferAndroidContacts = false
|
||||||
|
|
||||||
val uas = ArrayList<UserAgent>()
|
val uas = ArrayList<UserAgent>()
|
||||||
val status = ArrayList<Int>()
|
val status = ArrayList<Int>()
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ object Config {
|
|||||||
config = "${config}jitter_buffer_wish 6\n"
|
config = "${config}jitter_buffer_wish 6\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaresipService.preferAndroidContacts = config.contains("prefer_android_contacts yes")
|
||||||
|
|
||||||
Utils.putFileContents(configPath, config.toByteArray())
|
Utils.putFileContents(configPath, config.toByteArray())
|
||||||
BaresipService.isConfigInitialized = true
|
BaresipService.isConfigInitialized = true
|
||||||
Log.i(TAG, "Initialized config to '$config'")
|
Log.i(TAG, "Initialized config to '$config'")
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
private lateinit var verifyServer: CheckBox
|
private lateinit var verifyServer: CheckBox
|
||||||
private lateinit var caFile: CheckBox
|
private lateinit var caFile: CheckBox
|
||||||
private lateinit var darkTheme: CheckBox
|
private lateinit var darkTheme: CheckBox
|
||||||
|
private lateinit var androidContacts: CheckBox
|
||||||
private lateinit var debug: CheckBox
|
private lateinit var debug: CheckBox
|
||||||
private lateinit var sipTrace: CheckBox
|
private lateinit var sipTrace: CheckBox
|
||||||
private lateinit var reset: CheckBox
|
private lateinit var reset: CheckBox
|
||||||
@@ -55,6 +56,7 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
private var oldCAFile = false
|
private var oldCAFile = false
|
||||||
private var oldLogLevel = ""
|
private var oldLogLevel = ""
|
||||||
private var oldDisplayTheme = -1
|
private var oldDisplayTheme = -1
|
||||||
|
private var oldAndroidContacts = ""
|
||||||
private var save = false
|
private var save = false
|
||||||
private var restart = false
|
private var restart = false
|
||||||
private var menu: Menu? = null
|
private var menu: Menu? = null
|
||||||
@@ -291,6 +293,11 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
oldDisplayTheme = Preferences(applicationContext).displayTheme
|
oldDisplayTheme = Preferences(applicationContext).displayTheme
|
||||||
darkTheme.isChecked = oldDisplayTheme == AppCompatDelegate.MODE_NIGHT_YES
|
darkTheme.isChecked = oldDisplayTheme == AppCompatDelegate.MODE_NIGHT_YES
|
||||||
|
|
||||||
|
androidContacts = binding.AndroidContacts
|
||||||
|
val acCv = Config.variable("prefer_android_contacts")
|
||||||
|
oldAndroidContacts = if (acCv.size == 0) "no" else acCv[0]
|
||||||
|
androidContacts.isChecked = oldAndroidContacts == "yes"
|
||||||
|
|
||||||
debug = binding.Debug
|
debug = binding.Debug
|
||||||
val dbCv = Config.variable("log_level")
|
val dbCv = Config.variable("log_level")
|
||||||
oldLogLevel = if (dbCv.size == 0)
|
oldLogLevel = if (dbCv.size == 0)
|
||||||
@@ -428,6 +435,16 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
if (oldDisplayTheme != newDisplayTheme)
|
if (oldDisplayTheme != newDisplayTheme)
|
||||||
Preferences(applicationContext).displayTheme = newDisplayTheme
|
Preferences(applicationContext).displayTheme = newDisplayTheme
|
||||||
|
|
||||||
|
val androidContactsString = if (androidContacts.isChecked)
|
||||||
|
"yes"
|
||||||
|
else
|
||||||
|
"no"
|
||||||
|
if (oldAndroidContacts != androidContactsString) {
|
||||||
|
Config.replaceVariable("prefer_android_contacts", androidContactsString)
|
||||||
|
BaresipService.preferAndroidContacts = androidContacts.isChecked
|
||||||
|
save = true
|
||||||
|
}
|
||||||
|
|
||||||
var logLevelString = "2"
|
var logLevelString = "2"
|
||||||
if (debug.isChecked) logLevelString = "0"
|
if (debug.isChecked) logLevelString = "0"
|
||||||
if (oldLogLevel != logLevelString) {
|
if (oldLogLevel != logLevelString) {
|
||||||
@@ -522,6 +539,10 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
Utils.alertView(this, getString(R.string.dark_theme),
|
Utils.alertView(this, getString(R.string.dark_theme),
|
||||||
getString(R.string.dark_theme_help))
|
getString(R.string.dark_theme_help))
|
||||||
}
|
}
|
||||||
|
binding.AndroidContactsTitle.setOnClickListener {
|
||||||
|
Utils.alertView(this, getString(R.string.show_android_contacts),
|
||||||
|
getString(R.string.show_android_contacts_help))
|
||||||
|
}
|
||||||
binding.DebugTitle.setOnClickListener {
|
binding.DebugTitle.setOnClickListener {
|
||||||
Utils.alertView(this, getString(R.string.debug), getString(R.string.debug_help))
|
Utils.alertView(this, getString(R.string.debug), getString(R.string.debug_help))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -460,6 +460,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contactsButton.setOnClickListener {
|
contactsButton.setOnClickListener {
|
||||||
|
if (BaresipService.preferAndroidContacts) {
|
||||||
|
val i = Intent(this@MainActivity, AndroidContactsActivity::class.java)
|
||||||
|
if (aorSpinner.selectedItemPosition >= 0)
|
||||||
|
i.putExtra("aor", aorSpinner.tag.toString())
|
||||||
|
else
|
||||||
|
i.putExtra("aor", "")
|
||||||
|
startActivity(i)
|
||||||
|
} else {
|
||||||
val i = Intent(this@MainActivity, ContactsActivity::class.java)
|
val i = Intent(this@MainActivity, ContactsActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
if (aorSpinner.selectedItemPosition >= 0)
|
if (aorSpinner.selectedItemPosition >= 0)
|
||||||
@@ -469,6 +477,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
contactsRequest.launch(i)
|
contactsRequest.launch(i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
chatRequests = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
chatRequests = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
spinToAor(activityAor)
|
spinToAor(activityAor)
|
||||||
|
|||||||
@@ -231,6 +231,32 @@
|
|||||||
android:textSize="18sp">
|
android:textSize="18sp">
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/AndroidContactsTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toStartOf="@id/AndroidContacts"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:text="@string/show_android_contacts" >
|
||||||
|
</TextView>
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/AndroidContacts"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:checked="false" >
|
||||||
|
</CheckBox>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -367,6 +367,9 @@
|
|||||||
<string name="video_size_help">Lähetettävän videon kehyskoko (leveys x korkeus).
|
<string name="video_size_help">Lähetettävän videon kehyskoko (leveys x korkeus).
|
||||||
Tehdasasetus on 800x600.</string>
|
Tehdasasetus on 800x600.</string>
|
||||||
<string name="android_settings">Android-asetukset</string>
|
<string name="android_settings">Android-asetukset</string>
|
||||||
|
<string name="show_android_contacts">Näytä Androidin yhteystiedot</string>
|
||||||
|
<string name="show_android_contacts_help">Jos valittu, niin Yhteystiedot-ikoni näyttää
|
||||||
|
Androidin yhteystiedot.</string>
|
||||||
<string name="debug">Lokiviestit</string>
|
<string name="debug">Lokiviestit</string>
|
||||||
<string name="debug_help">Jos merkitty, baresip tuottaa debug- ja info-tason Logcat-viestejä.</string>
|
<string name="debug_help">Jos merkitty, baresip tuottaa debug- ja info-tason Logcat-viestejä.</string>
|
||||||
<string name="sip_trace">SIP-sanomien jäljitys</string>
|
<string name="sip_trace">SIP-sanomien jäljitys</string>
|
||||||
|
|||||||
@@ -329,6 +329,9 @@
|
|||||||
<string name="video_size_help">Size of transmitted video frames (width x height).
|
<string name="video_size_help">Size of transmitted video frames (width x height).
|
||||||
Factory default is 800x600.</string>
|
Factory default is 800x600.</string>
|
||||||
<string name="android_settings">Android Settings</string>
|
<string name="android_settings">Android Settings</string>
|
||||||
|
<string name="show_android_contacts">Show Android Contacts</string>
|
||||||
|
<string name="show_android_contacts_help">If checked, Android contacts are shown when Contacts
|
||||||
|
button is touched.</string>
|
||||||
<string name="debug">Debug</string>
|
<string name="debug">Debug</string>
|
||||||
<string name="debug_help">If checked, provides debug and info level log messages to Logcat.</string>
|
<string name="debug_help">If checked, provides debug and info level log messages to Logcat.</string>
|
||||||
<string name="sip_trace">SIP Trace</string>
|
<string name="sip_trace">SIP Trace</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user