Skip to content

Commit

Permalink
Merge pull request #372 from meshtastic/release
Browse files Browse the repository at this point in the history
1.2.57
  • Loading branch information
andrekir authored Feb 10, 2022
2 parents 9698490 + 7ff28ab commit 9cd1856
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 108 deletions.
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 30 // 30 can't work until an explicit location permissions dialog is added
versionCode 20256 // format is Mmmss (where M is 1+the numeric major number
versionName "1.2.56"
versionCode 20257 // format is Mmmss (where M is 1+the numeric major number
versionName "1.2.57"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// per https://developer.android.com/studio/write/vector-asset-studio
Expand Down Expand Up @@ -127,7 +127,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.fragment:fragment-ktx:1.4.0'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
Expand Down Expand Up @@ -177,7 +177,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-location:19.0.1'

// For Google Sign-In (owner name accesss)
implementation 'com.google.android.gms:play-services-auth:20.0.1'
implementation 'com.google.android.gms:play-services-auth:20.1.0'

// Add the Firebase SDK for Crashlytics.
implementation 'com.google.firebase:firebase-crashlytics:18.2.6'
Expand All @@ -191,6 +191,7 @@ dependencies {
// barcode support
// per https://github.com/journeyapps/zxing-android-embedded#older-sdk-versions for minSdkVersion 21
implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }
//noinspection GradleDependency
implementation 'com.google.zxing:core:3.3.0' // <-- don't update

def work_version = '2.7.1'
Expand Down
70 changes: 2 additions & 68 deletions app/src/main/java/com/geeksville/mesh/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothManager
import android.companion.AssociationRequest
import android.companion.BluetoothDeviceFilter
import android.companion.CompanionDeviceManager
import android.content.*
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
Expand All @@ -27,7 +23,6 @@ import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.Toolbar
Expand Down Expand Up @@ -70,8 +65,6 @@ import kotlinx.coroutines.cancel
import java.nio.charset.Charset
import java.text.DateFormat
import java.util.*
import java.util.regex.Pattern


/*
UI design
Expand Down Expand Up @@ -198,48 +191,6 @@ class MainActivity : AppCompatActivity(), Logging,
updateBluetoothEnabled()
}

fun startCompanionScan() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val deviceManager: CompanionDeviceManager by lazy {
getSystemService(Context.COMPANION_DEVICE_SERVICE) as CompanionDeviceManager
}

// To skip filtering based on name and supported feature flags (UUIDs),
// don't include calls to setNamePattern() and addServiceUuid(),
// respectively. This example uses Bluetooth.
// We only look for Mesh (rather than the full name) because NRF52 uses a very short name
val deviceFilter: BluetoothDeviceFilter = BluetoothDeviceFilter.Builder()
.setNamePattern(Pattern.compile("Mesh.*"))
// .addServiceUuid(ParcelUuid(RadioInterfaceService.BTM_SERVICE_UUID), null)
.build()

// The argument provided in setSingleDevice() determines whether a single
// device name or a list of device names is presented to the user as
// pairing options.
val pairingRequest: AssociationRequest = AssociationRequest.Builder()
.addDeviceFilter(deviceFilter)
.setSingleDevice(false)
.build()

// When the app tries to pair with the Bluetooth device, show the
// appropriate pairing request dialog to the user.
deviceManager.associate(pairingRequest,
object : CompanionDeviceManager.Callback() {
override fun onDeviceFound(chooserLauncher: IntentSender) {
startIntentSenderForResult(chooserLauncher,
SELECT_DEVICE_REQUEST_CODE, null, 0, 0, 0)
}

override fun onFailure(error: CharSequence?) {
warn("BLE selection service failed $error")
// changeDeviceSelection(mainActivity, null) // deselect any device
}
}, null
)
}
else warn("startCompanionScan should not run on SDK < 26")
}

/**
* Don't tell our app we have bluetooth until we have bluetooth _and_ location access
*/
Expand Down Expand Up @@ -502,8 +453,6 @@ class MainActivity : AppCompatActivity(), Logging,

/* not yet working
// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
val gso =
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
Expand Down Expand Up @@ -629,15 +578,13 @@ class MainActivity : AppCompatActivity(), Logging,
/**
* Dispatch incoming result to the correct fragment.
*/
@SuppressLint("InlinedApi", "MissingPermission")
override fun onActivityResult(
requestCode: Int,
resultCode: Int,
data: Intent?
) {
super.onActivityResult(requestCode, resultCode, data)

// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
when (requestCode) {
RC_SIGN_IN -> {
Expand All @@ -647,19 +594,6 @@ class MainActivity : AppCompatActivity(), Logging,
GoogleSignIn.getSignedInAccountFromIntent(data)
handleSignInResult(task)
}
(SELECT_DEVICE_REQUEST_CODE) -> when (resultCode) {
Activity.RESULT_OK -> {
val deviceToPair: BluetoothDevice =
data?.getParcelableExtra(CompanionDeviceManager.EXTRA_DEVICE)!!
if (deviceToPair.bondState != BluetoothDevice.BOND_BONDED) {
deviceToPair.createBond()
}
model.meshService?.let { service ->
MeshService.changeDeviceAddress(this@MainActivity, service, "x${deviceToPair.address}")
}
}
else -> warn("BLE device select intent failed")
}
CREATE_CSV_FILE -> {
if (resultCode == Activity.RESULT_OK) {
data?.data?.let { file_uri -> model.saveMessagesCSV(file_uri) }
Expand Down Expand Up @@ -1161,7 +1095,7 @@ class MainActivity : AppCompatActivity(), Logging,
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "application/csv"
putExtra(Intent.EXTRA_TITLE, "messages.csv")
putExtra(Intent.EXTRA_TITLE, "rangetest.csv")
}
startActivityForResult(intent, CREATE_CSV_FILE)
return true
Expand Down Expand Up @@ -1189,7 +1123,7 @@ class MainActivity : AppCompatActivity(), Logging,
private fun chooseThemeDialog() {

/// Prepare dialog and its items
val builder = AlertDialog.Builder(this)
val builder = MaterialAlertDialogBuilder(this)
builder.setTitle(getString(R.string.choose_theme_title))

val styles = arrayOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
@SuppressLint("NewApi", "MissingPermission")
override fun addressValid(context: Context, rest: String): Boolean {
val allPaired = if (hasCompanionDeviceApi(context)) {
val deviceManager = context.getSystemService(CompanionDeviceManager::class.java)
val deviceManager: CompanionDeviceManager by lazy {
context.getSystemService(Context.COMPANION_DEVICE_SERVICE) as CompanionDeviceManager
}
deviceManager.associations.map { it }.toSet()
} else {
getBluetoothAdapter(context)?.bondedDevices.orEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class RadioInterfaceService : Service(), Logging {
@SuppressLint("NewApi")
private fun setBondedDeviceAddress(address: String?): Boolean {
return if (getBondedDeviceAddress(this) == address && isStarted) {
warn("Ignoring setBondedDevice $address, because we are already using that device")
warn("Ignoring setBondedDevice ${address.anonymize}, because we are already using that device")
false
} else {
// Record that this use has configured a new radio
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
requireActivity().startActivity(shareIntent)
} catch (ex: ActivityNotFoundException) {
Snackbar.make(
binding.shareButton,
requireView(),
R.string.no_app_found,
Snackbar.LENGTH_SHORT
).show()
Expand All @@ -181,7 +181,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {

// Tell the user to try again
Snackbar.make(
binding.editableCheckbox,
requireView(),
R.string.radio_sleeping,
Snackbar.LENGTH_SHORT
).show()
Expand Down
Loading

0 comments on commit 9cd1856

Please sign in to comment.