Started work on Android contacts
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.tutpro.baresip">
|
||||
package="com.tutpro.baresip" >
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
@ -13,8 +13,10 @@
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" android:maxSdkVersion="28" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="28"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
||||
@ -27,36 +29,38 @@
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
android:required="false" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:installLocation="internalOnly"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:installLocation="internalOnly"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:remove="android:appComponentFactory">
|
||||
tools:remove="android:appComponentFactory" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme.Main"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask">
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/AppTheme.Main"
|
||||
android:windowSoftInputMode="adjustResize" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.DIAL" />
|
||||
<action android:name="android.intent.action.CALL" />
|
||||
<action android:name="android.intent.action.CALL_PRIVILEGED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="tel" />
|
||||
<data android:scheme="sip" />
|
||||
</intent-filter>
|
||||
@ -81,9 +85,9 @@
|
||||
<activity
|
||||
android:name=".ContactsActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/contacts"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:parentActivityName=".MainActivity" >
|
||||
android:label="@string/baresip_contacts"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:windowSoftInputMode="adjustPan" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ContactActivity"
|
||||
@ -91,6 +95,19 @@
|
||||
android:label="@string/contact"
|
||||
android:parentActivityName=".ContactsActivity" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AndroidContactsActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/android_contacts"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:windowSoftInputMode="adjustPan" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AndroidContactActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/contact"
|
||||
android:parentActivityName=".ContactsActivity" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ConfigActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
@ -130,15 +147,15 @@
|
||||
android:name=".AboutActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/about_title"
|
||||
android:parentActivityName=".MainActivity">
|
||||
android:parentActivityName=".MainActivity" >
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".BaresipService"
|
||||
android:permission="android.permission.FOREGROUND_SERVICE"
|
||||
android:enabled="true"
|
||||
android:foregroundServiceType="microphone|phoneCall"
|
||||
android:stopWithTask="false"
|
||||
android:enabled="true" >
|
||||
android:permission="android.permission.FOREGROUND_SERVICE"
|
||||
android:stopWithTask="false" >
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
@ -151,7 +168,6 @@
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@ -567,49 +567,6 @@ class ContactActivity : AppCompatActivity() {
|
||||
null)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED")
|
||||
fun logAndroidContacts(ctx: Context, type: String): HashMap<Long, MutableList<String>> {
|
||||
val mimeType = if (type == "sip")
|
||||
CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE
|
||||
else
|
||||
CommonDataKinds.Phone.CONTENT_ITEM_TYPE
|
||||
val contacts = HashMap<Long, MutableList<String>>()
|
||||
val projection = arrayOf(ContactsContract.Data.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME,
|
||||
ContactsContract.Data.MIMETYPE, ContactsContract.Data.DATA1,
|
||||
ContactsContract.Data.PHOTO_THUMBNAIL_URI)
|
||||
val selection = ContactsContract.Data.MIMETYPE + "='" + mimeType + "'"
|
||||
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 name = cur.getString(1) // display name
|
||||
val mime = cur.getString(2) // type of data
|
||||
val data = cur.getString(3) // info
|
||||
val thumb = cur.getString(4) // thumbnail
|
||||
var kind = "unknown"
|
||||
when (mime) {
|
||||
CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE -> kind = "sip"
|
||||
CommonDataKinds.Photo.CONTENT_ITEM_TYPE -> kind = "thumb"
|
||||
CommonDataKinds.Phone.CONTENT_ITEM_TYPE -> kind = "tel"
|
||||
}
|
||||
Log.d(TAG, "got $id, $name, $kind - $data")
|
||||
var info: MutableList<String>
|
||||
if (contacts.containsKey(id)) {
|
||||
info = contacts[id]!!
|
||||
} else {
|
||||
info = mutableListOf()
|
||||
info.add("name = $name")
|
||||
info.add("thumb = $thumb")
|
||||
contacts[id] = info
|
||||
}
|
||||
info.add("$kind = $data")
|
||||
}
|
||||
cur?.close()
|
||||
return contacts
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.*
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.view.Menu
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@ -57,6 +58,11 @@ class ContactsActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.swap_contacts_icon, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
||||
super.onResume()
|
||||
@ -68,6 +74,17 @@ class ContactsActivity : AppCompatActivity() {
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.swapContactsIcon -> {
|
||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||
lastClick = SystemClock.elapsedRealtime()
|
||||
val intent = Intent(this, AndroidContactsActivity::class.java)
|
||||
intent.putExtra("aor", aor)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
BaresipService.activities.remove("contacts,$aor")
|
||||
setResult(Activity.RESULT_OK, Intent())
|
||||
|
||||
@ -358,10 +358,13 @@
|
||||
<string name="avatar_image">Profile image</string>
|
||||
<!-- Contacts Activity -->
|
||||
<string name="contacts">Contacts</string>
|
||||
<string name="baresip_contacts">baresip Contacts</string>
|
||||
<string name="contact_action_question">Do you want to call or send message to \'%1$s\'?</string>
|
||||
<string name="send_message">Send Message</string>
|
||||
<string name="contact_delete_question">Do you want to delete contact \'%1$s\'?</string>
|
||||
<string name="contacts_exceeded">Your maximum number of contacts %1$d has been exceeded.</string>
|
||||
<!-- Android Contacts Activity -->
|
||||
<string name="android_contacts">Android Contacts</string>
|
||||
<!-- Generic -->
|
||||
<string name="alert">Alert</string>
|
||||
<string name="info">Info</string>
|
||||
|
||||
Reference in New Issue
Block a user