kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
clean up user setting
rodzic
0befe48923
commit
9dcfb59ee0
6
TODO.md
6
TODO.md
|
@ -1,6 +1,11 @@
|
|||
# High priority
|
||||
MVP features required for first public alpha
|
||||
|
||||
* use google signin to get user name (later give other options)
|
||||
* always set a _unique_ owner id (if changed)
|
||||
* stop scan when we start the service
|
||||
* set the radio by using the service
|
||||
* startforegroundservice only if we have a valid radio
|
||||
* if no radio is selected, launch app on the radio select screen
|
||||
* when we select a new radio, restart the service
|
||||
* show bt scan progress centered and towards the bottom of the screen
|
||||
|
@ -47,6 +52,7 @@ Do this "Signal app compatible" release relatively soon after the alpha release
|
|||
# Medium priority
|
||||
Things for the betaish period.
|
||||
|
||||
* let user pick/specify a name through ways other than google signin (for the privacy concerned, or devices without Play API)
|
||||
* make my android app show mesh state
|
||||
* show qr code for each channel https://medium.com/@aanandshekharroy/generate-barcode-in-android-app-using-zxing-64c076a5d83a
|
||||
* register app link for our URLs https://developer.android.com/studio/write/app-link-indexing.html
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- for job intent service -->
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS " /> <!-- to get the owner's name so we can set it in the radio -->
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
|
||||
<!--
|
||||
This permission is required to allow the application to send
|
||||
events and properties to Mixpanel.
|
||||
|
|
|
@ -17,6 +17,7 @@ interface IMeshService {
|
|||
/**
|
||||
* Set the ID info for this node
|
||||
|
||||
If myId is null, then the existing unique node ID is preserved, only the human visible longName/shortName is changed
|
||||
*/
|
||||
void setOwner(String myId, String longName, String shortName);
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package com.geeksville.mesh
|
||||
|
||||
import android.Manifest
|
||||
import android.accounts.AccountManager
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.bluetooth.BluetoothManager
|
||||
import android.content.*
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.provider.ContactsContract
|
||||
import android.provider.ContactsContract.CommonDataKinds.Phone
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
|
@ -53,9 +50,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
Manifest.permission.BLUETOOTH,
|
||||
Manifest.permission.BLUETOOTH_ADMIN,
|
||||
Manifest.permission.WAKE_LOCK,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_CONTACTS,
|
||||
Manifest.permission.GET_ACCOUNTS
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
val missingPerms = perms.filter {
|
||||
|
@ -99,36 +94,10 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
|
||||
private fun setOwner() {
|
||||
try {
|
||||
if (false) {
|
||||
val SELF_PROJECTION =
|
||||
arrayOf(Phone._ID, Phone.DISPLAY_NAME, Phone.PHOTO_THUMBNAIL_URI)
|
||||
|
||||
val cursor = contentResolver.query(
|
||||
ContactsContract.Profile.CONTENT_URI,
|
||||
SELF_PROJECTION,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
if (cursor == null || !cursor.moveToFirst())
|
||||
error("Can't get owner contact")
|
||||
else {
|
||||
info("me: ${cursor.getString(1)}/${cursor.getString(2)}")
|
||||
}
|
||||
}
|
||||
val am = AccountManager.get(this) // "this" references the current Context
|
||||
|
||||
val accounts = am.getAccountsByType("com.google")
|
||||
accounts.forEach {
|
||||
info("acct ${it.name} ${it.type}")
|
||||
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
error("getting owner failed: $e")
|
||||
}
|
||||
|
||||
meshService!!.setOwner("+16508675309", "Kevin Xter", "kx")
|
||||
// Note: we are careful to not set a new unique ID
|
||||
meshService!!.setOwner(null, "Kevin Xter", "kx")
|
||||
}
|
||||
|
||||
private fun sendTestPackets() {
|
||||
|
@ -166,7 +135,8 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, "Error - this app requires bluetooth", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(this, "Error - this app requires bluetooth", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
|
||||
requestPermission()
|
||||
|
@ -253,7 +223,8 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
private var isBound = false
|
||||
|
||||
private var serviceConnection = object : ServiceConnection {
|
||||
override fun onServiceConnected(name: ComponentName, service: IBinder) = exceptionReporter {
|
||||
override fun onServiceConnected(name: ComponentName, service: IBinder) =
|
||||
exceptionReporter {
|
||||
val m = IMeshService.Stub.asInterface(service)
|
||||
meshService = m
|
||||
|
||||
|
@ -330,6 +301,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -314,8 +314,8 @@ class MeshService : Service(), Logging {
|
|||
updatefn(info)
|
||||
|
||||
// This might have been the first time we know an ID for this node, so also update the by ID map
|
||||
val userId = info.user?.id
|
||||
if (userId != null)
|
||||
val userId = info.user?.id.orEmpty()
|
||||
if (userId.isNotEmpty())
|
||||
nodeDBbyID[userId] = info
|
||||
|
||||
// parcelable is busted
|
||||
|
@ -535,11 +535,12 @@ class MeshService : Service(), Logging {
|
|||
clientPackages[receiverName] = packageName
|
||||
}
|
||||
|
||||
override fun setOwner(myId: String, longName: String, shortName: String) =
|
||||
override fun setOwner(myId: String?, longName: String, shortName: String) =
|
||||
toRemoteExceptions {
|
||||
debug("TetOwner $myId : $longName : $shortName")
|
||||
debug("SetOwner $myId : $longName : $shortName")
|
||||
|
||||
val user = MeshProtos.User.newBuilder().also {
|
||||
if (myId != null) // Only set the id if it was provided
|
||||
it.id = myId
|
||||
it.longName = longName
|
||||
it.shortName = shortName
|
||||
|
|
|
@ -105,7 +105,7 @@ A few nodenums are reserved and will never be requested:
|
|||
|
||||
*/
|
||||
message User {
|
||||
string id = 1; // a globally unique ID string for this user. In the case of Signal that would mean +16504442323
|
||||
string id = 1; // a globally unique ID string for this user. In the case of Signal that would mean +16504442323, for the default macaddr derived id it would be !<6 hexidecimal bytes>
|
||||
string long_name = 2; // A full name for this user, i.e. "Kevin Hester"
|
||||
string short_name = 3; // A VERY short name, ideally two characters. Suitable for a tiny OLED screen
|
||||
bytes macaddr = 4; // This is the addr of the radio. Not populated by the phone, but added by the esp32 when broadcasting
|
||||
|
|
Ładowanie…
Reference in New Issue