Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes proprietary dependencies from Meshtastic for Android. Compile tested.
From c4489d4c368add64da475eb044471fd083a06a8c Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Wed, 2 Jun 2021 13:05:45 -0400
Subject: [PATCH] Liberate
---
.idea/compiler.xml | 6 +
.idea/gradle.xml | 1 +
.idea/misc.xml | 2 +-
.idea/runConfigurations.xml | 1 +
build.gradle | 6 -
gradle/wrapper/gradle-wrapper.properties | 6 +-
gradlew | 53 +++--
gradlew.bat | 43 ++--
.../geeksville/analytics/AnalyticsClient.kt | 49 -----
.../geeksville/analytics/FirebaseAnalytics.kt | 78 --------
.../geeksville/analytics/MixpanelAnalytics.kt | 79 --------
.../geeksville/analytics/SplunkAnalytics.kt | 68 -------
.../com/geeksville/analytics/TeeAnalytics.kt | 45 -----
.../android/GeeksvilleApplication.kt | 37 ----
.../com/geeksville/android/PlayClient.kt | 185 ------------------
15 files changed, 69 insertions(+), 590 deletions(-)
create mode 100644 .idea/compiler.xml
delete mode 100644 src/main/kotlin/com/geeksville/analytics/AnalyticsClient.kt
delete mode 100644 src/main/kotlin/com/geeksville/analytics/FirebaseAnalytics.kt
delete mode 100644 src/main/kotlin/com/geeksville/analytics/MixpanelAnalytics.kt
delete mode 100644 src/main/kotlin/com/geeksville/analytics/SplunkAnalytics.kt
delete mode 100644 src/main/kotlin/com/geeksville/analytics/TeeAnalytics.kt
delete mode 100644 src/main/kotlin/com/geeksville/android/PlayClient.kt
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="CompilerConfiguration">
+ <bytecodeTargetLevel target="11" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 785852f..019835f 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
+ <component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 37a7509..4700283 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
index 7f68460..e497da9 100644
--- a/.idea/runConfigurations.xml
+++ b/.idea/runConfigurations.xml
@@ -3,6 +3,7 @@
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
+ <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
diff --git a/build.gradle b/build.gradle
index 8089601..1298ada 100644
--- a/build.gradle
+++ b/build.gradle
@@ -58,11 +58,6 @@ dependencies {
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
-
- // NOTE: 8.4 depends on targeting 23, so I'm staying on 8.3
- // See list here: https://developers.google.com/android/guides/setup
- implementation 'com.google.android.gms:play-services-base:17.6.0'
- implementation 'com.google.firebase:firebase-analytics:18.0.3'
}
buildscript {
@@ -75,7 +70,6 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:4.2.0'
- // classpath 'com.google.gms:google-services:4.3.5'
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 9927571..aa7f73d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Jan 21 20:01:23 PST 2020
+#Wed Jun 02 12:01:10 GMT-05:00 2021
distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-rc-1-all.zip
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
index cccdd3d..4f906e0 100755
--- a/gradlew
+++ b/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index e95643d..ac1b06f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/src/main/kotlin/com/geeksville/analytics/AnalyticsClient.kt b/src/main/kotlin/com/geeksville/analytics/AnalyticsClient.kt
deleted file mode 100644
index ed934a5..0000000
--- a/src/main/kotlin/com/geeksville/analytics/AnalyticsClient.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.geeksville.analytics
-
-import com.google.firebase.analytics.FirebaseAnalytics
-
-/**
- * Created by kevinh on 12/24/14.
- */
-class DataPair(val name: String, valueIn: Any?) {
- val value = valueIn ?: "null"
-
- /// An accumulating firebase event - only one allowed per event
- constructor(d: Double) : this(FirebaseAnalytics.Param.VALUE, d)
- constructor(d: Int) : this(FirebaseAnalytics.Param.VALUE, d)
-}
-
-public interface AnalyticsProvider {
-
- // Turn analytics logging on/off
- fun setEnabled(on: Boolean)
-
- /**
- * Store an event
- */
- fun track(event: String, vararg properties: DataPair): Unit
-
- /**
- * Only track this event if using a cheap provider (like google)
- */
- fun trackLowValue(event: String, vararg properties: DataPair): Unit
-
- fun endSession(): Unit
- fun startSession(): Unit
-
- /**
- * Set persistent ID info about this user, as a key value pair
- */
- fun setUserInfo(vararg p: DataPair)
-
- /**
- * Increment some sort of anyalytics counter
- */
- fun increment(name: String, amount: Double = 1.0)
-
- fun sendScreenView(name: String)
- fun endScreenView()
-
-}
-
-
diff --git a/src/main/kotlin/com/geeksville/analytics/FirebaseAnalytics.kt b/src/main/kotlin/com/geeksville/analytics/FirebaseAnalytics.kt
deleted file mode 100644
index b775aae..0000000
--- a/src/main/kotlin/com/geeksville/analytics/FirebaseAnalytics.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.geeksville.analytics
-
-import android.content.Context
-import android.os.Bundle
-import com.geeksville.android.AppPrefs
-import com.geeksville.android.GeeksvilleApplication
-import com.geeksville.android.Logging
-
-/**
- * Implement our analytics API using firebase analtics
- */
-class GoogleAnalytics(context: Context) : AnalyticsProvider, Logging {
-
- val t = com.google.firebase.analytics.FirebaseAnalytics.getInstance(context)
-
- init {
- val pref = AppPrefs(context)
- t.setUserId(pref.getInstallId())
- }
-
- override fun setEnabled(on: Boolean) {
- t.setAnalyticsCollectionEnabled(on)
- }
-
- override fun endSession() {
- track("End Session")
- // Mint.flush() // Send results now
- }
-
- override fun trackLowValue(event: String, vararg properties: DataPair) {
- track(event, *properties)
- }
-
- override fun track(event: String, vararg properties: DataPair) {
- debug("Analytics: track $event")
-
- val bundle = Bundle()
- properties.forEach {
- when (it.value) {
- is Double -> bundle.putDouble(it.name, it.value)
- is Int -> bundle.putLong(it.name, it.value.toLong())
- is Long -> bundle.putLong(it.name, it.value)
- is Float -> bundle.putDouble(it.name, it.value.toDouble())
- else -> bundle.putString(it.name, it.value.toString())
- }
- }
- t.logEvent(event, bundle)
- }
-
- override fun startSession() {
- debug("Analytics: start session")
- // automatic with firebase
- }
-
- override fun setUserInfo(vararg p: DataPair) {
- p.forEach { t.setUserProperty(it.name, it.value.toString()) }
- }
-
- override fun increment(name: String, amount: Double) {
- //Mint.logEvent("$name increment")
- }
-
- /**
- * Send a google analyics screen view event
- */
- override fun sendScreenView(name: String) {
- debug("Analytics: start screen $name")
- GeeksvilleApplication.currentActivity?.let {
- t.setCurrentScreen(
- it, name, null
- )
- }
- }
-
- override fun endScreenView() {
- // debug("Analytics: end screen")
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/com/geeksville/analytics/MixpanelAnalytics.kt b/src/main/kotlin/com/geeksville/analytics/MixpanelAnalytics.kt
deleted file mode 100644
index efd1d7c..0000000
--- a/src/main/kotlin/com/geeksville/analytics/MixpanelAnalytics.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.geeksville.analytics
-
-
-import android.content.Context
-import com.geeksville.android.AppPrefs
-import com.geeksville.android.Logging
-import com.mixpanel.android.mpmetrics.MixpanelAPI
-import org.json.JSONObject
-
-
-class MixpanelAnalytics(context: Context, apiToken: String, pushToken: String? = null) :
- AnalyticsProvider, Logging {
- // Initialize the library with your
- // Mixpanel project token, MIXPANEL_TOKEN, and a reference
- // to your application context.
- // See mixpanel docs at https://mixpanel.com/help/reference/android
- val mixpanel: MixpanelAPI = MixpanelAPI.getInstance(context, apiToken)
- val people = mixpanel.getPeople()!!
-
- init {
- // fixupMixpanel()
-
- // Assign a unique ID
- val pref = AppPrefs(context)
- val id = pref.getInstallId()
- debug("Connecting to mixpanel $id")
- mixpanel.identify(id)
- people.identify(id)
- }
-
- private fun makeJSON(properties: Array<out DataPair>) =
- if (properties.isEmpty())
- null
- else {
- val r = JSONObject()
- properties.forEach { r.put(it.name, it.value) }
- r
- }
-
- override fun trackLowValue(event: String, vararg properties: DataPair) {
- }
-
- override fun setEnabled(on: Boolean) {
- if (on) mixpanel.optInTracking() else mixpanel.optOutTracking()
- }
-
- override fun track(event: String, vararg properties: DataPair) {
-
- debug("Tracking $event")
- val obj = makeJSON(properties)
-
- mixpanel.track(event, obj)
- }
-
- override fun endSession() {
- // track("End Session")
- mixpanel.flush()
- }
-
- override fun startSession() {
- track("Start Session")
- }
-
- override fun setUserInfo(vararg p: DataPair) {
- mixpanel.registerSuperProperties(makeJSON(p))
- }
-
- override fun increment(name: String, amount: Double) {
- mixpanel.people.increment(name, amount)
- }
-
- override fun sendScreenView(name: String) {
- // too verbose for mixpanel
- track(name)
- }
-
- override fun endScreenView() {}
-}
-
diff --git a/src/main/kotlin/com/geeksville/analytics/SplunkAnalytics.kt b/src/main/kotlin/com/geeksville/analytics/SplunkAnalytics.kt
deleted file mode 100644
index bf95ef4..0000000
--- a/src/main/kotlin/com/geeksville/analytics/SplunkAnalytics.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.geeksville.analytics
-
-import android.content.Context
-import com.geeksville.android.Logging
-
-
-/**
- * Created by kevinh on 12/24/14.
- */
-
-// Mint.initAndStartSession(MyActivity.this, "01a9c628");
-
-/* disable for now because something in gradle doesn't like their lib repo
-import com.splunk.mint.Mint
-
-class SplunkAnalytics(val context: Context, apiToken: String) : AnalyticsProvider, Logging {
-
- private var inited = false
-
- init {
- try {
- Mint.initAndStartSession(context, apiToken)
- inited = true
- } catch(ex: Exception) {
- error("exception logging failed to init")
- }
- }
-
- override fun endSession() {
- track("End Session")
- if (inited)
- Mint.closeSession(context)
- // Mint.flush() // Send results now
- }
-
- override fun trackLowValue(event: String, vararg properties: DataPair) {
- }
-
- override fun track(event: String, vararg properties: DataPair) {
- if (inited)
- Mint.logEvent(event)
- }
-
- override fun startSession() {
- if (inited) {
- Mint.startSession(context)
- track("Start Session")
- }
- }
-
- override fun setUserInfo(vararg p: DataPair) {
- if (inited)
- p.forEach { Mint.addExtraData(it.name, it.value.toString()) }
- }
-
- override fun increment(name: String, amount: Double) {
- if (inited)
- Mint.logEvent("$name increment")
- }
-
- override fun sendScreenView(name: String) {
- }
-
- override fun endScreenView() {
- }
-}
-
- */
\ No newline at end of file
diff --git a/src/main/kotlin/com/geeksville/analytics/TeeAnalytics.kt b/src/main/kotlin/com/geeksville/analytics/TeeAnalytics.kt
deleted file mode 100644
index 411b12f..0000000
--- a/src/main/kotlin/com/geeksville/analytics/TeeAnalytics.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.geeksville.analytics
-
-/**
- * Created by kevinh on 1/12/16.
- */
-class TeeAnalytics(vararg providersIn: AnalyticsProvider) : AnalyticsProvider {
-
- val providers = providersIn
-
- override fun track(event: String, vararg properties: DataPair) {
- providers.forEach { it.track(event, *properties) }
- }
-
- override fun trackLowValue(event: String, vararg properties: DataPair) {
- providers.forEach { it.trackLowValue(event, *properties) }
- }
-
- override fun endSession() {
- providers.forEach { it.endSession() }
- }
-
- override fun increment(name: String, amount: Double) {
- providers.forEach { it.increment(name, amount) }
- }
-
- override fun setUserInfo(vararg p: DataPair) {
- providers.forEach { it.setUserInfo(*p) }
- }
-
- override fun startSession() {
- providers.forEach { it.startSession() }
- }
-
- override fun sendScreenView(name: String) {
- providers.forEach { it.sendScreenView(name) }
- }
-
- override fun endScreenView() {
- providers.forEach { it.endScreenView() }
- }
-
- override fun setEnabled(on: Boolean) {
- providers.forEach { it.setEnabled(on) }
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/com/geeksville/android/GeeksvilleApplication.kt b/src/main/kotlin/com/geeksville/android/GeeksvilleApplication.kt
index e49e5b7..0b7fcd9 100644
--- a/src/main/kotlin/com/geeksville/android/GeeksvilleApplication.kt
+++ b/src/main/kotlin/com/geeksville/android/GeeksvilleApplication.kt
@@ -8,19 +8,8 @@ import android.net.ConnectivityManager
import android.os.Bundle
import android.provider.Settings
import androidx.core.content.edit
-import com.geeksville.analytics.AnalyticsProvider
-import com.geeksville.analytics.MixpanelAnalytics
-import com.geeksville.analytics.TeeAnalytics
-import com.google.android.gms.common.ConnectionResult
-import com.google.android.gms.common.GoogleApiAvailability
-fun isGooglePlayAvailable(context: Context): Boolean {
- val a = GoogleApiAvailability.getInstance()
- val r = a.isGooglePlayServicesAvailable(context)
- return r != ConnectionResult.SERVICE_MISSING && r != ConnectionResult.SERVICE_INVALID
-}
-
/**
* Created by kevinh on 1/4/15.
*/
@@ -32,13 +21,9 @@ open class GeeksvilleApplication(
) : Application(), Logging {
companion object {
- lateinit var analytics: AnalyticsProvider
var currentActivity: Activity? = null
}
- var splunk: AnalyticsProvider? = null
- var mixAnalytics: MixpanelAnalytics? = null
-
private val lifecycleCallbacks = object : ActivityLifecycleCallbacks {
override fun onActivityPaused(activity: Activity) {
}
@@ -87,31 +72,11 @@ open class GeeksvilleApplication(
analyticsPrefs.edit(commit = true) {
putBoolean("allowed", value)
}
-
- // Change the flag with the providers
- analytics.setEnabled(value && !isInTestLab) // Never do analytics in the test lab
}
override fun onCreate() {
super<Application>.onCreate()
- /*
- if(splunkKey != null)
- splunk = SplunkAnalytics(this, splunkKey) // Only used for crash reports
- */
-
- val googleAnalytics = com.geeksville.analytics.GoogleAnalytics(this)
- if (mixpanelKey != null) {
- val mix = com.geeksville.analytics.MixpanelAnalytics(this, mixpanelKey, pushKey)
- mixAnalytics = mix
-
- analytics = TeeAnalytics(googleAnalytics, mix)
- } else
- analytics = googleAnalytics
-
- // Set analytics per prefs
- isAnalyticsAllowed = isAnalyticsAllowed
-
registerActivityLifecycleCallbacks(lifecycleCallbacks)
}
@@ -133,6 +98,4 @@ fun geeksvilleApp(context: Context) = context.applicationContext as GeeksvilleAp
interface GeeksvilleApplicationClient {
- fun getAnalytics() = GeeksvilleApplication.analytics
-
}
\ No newline at end of file
diff --git a/src/main/kotlin/com/geeksville/android/PlayClient.kt b/src/main/kotlin/com/geeksville/android/PlayClient.kt
deleted file mode 100644
index 349259b..0000000
--- a/src/main/kotlin/com/geeksville/android/PlayClient.kt
+++ /dev/null
@@ -1,185 +0,0 @@
-package com.geeksville.android
-
-import android.app.Activity
-import android.os.Bundle
-import com.google.android.gms.common.api.Api
-import com.google.android.gms.common.api.Api.ApiOptions.NotRequiredOptions
-import com.google.android.gms.common.api.Scope
-import com.google.android.gms.common.api.GoogleApiClient
-import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks
-import com.google.android.gms.common.ConnectionResult
-import com.google.android.gms.common.GooglePlayServicesUtil
-import android.content.IntentSender
-import android.content.Intent
-import android.util.Log
-
-
-interface PlayClientCallbacks /* : Activity */ {
- /**
- * Called to tell activity we've lost connection to play
- */
- fun onPlayConnectionSuspended() :Unit
-
- /**
- * Called to tell activity we are now connected to play
- * Do remaining init here
- */
- fun onPlayConnected() : Unit
-
- /**
- * Called when this machine does not have a valid form of play.
- */
- fun onPlayUnavailable() : Unit
-
-}
-
-/**
- * Created by kevinh on 1/5/15.
- */
-
-public class PlayClient(val context: Activity, val playCallbacks: PlayClientCallbacks) : Logging {
-
- var apiClient: GoogleApiClient? = null
- var authInProgress: Boolean = false
-
- companion object {
- val PLAY_OAUTH_REQUEST_CODE = 901
- val AUTH_PENDING = "authPend"
- }
-
-
- /**
- * Must be called from onCreate
- */
- fun playOnCreate(savedInstanceState: Bundle?, apis: Array<Api<out NotRequiredOptions>>, scopes: Array<Scope> = arrayOf()) {
-
- if(savedInstanceState != null)
- authInProgress = savedInstanceState.getBoolean(AUTH_PENDING)
-
- if(hasPlayServices()) {
- var builder = GoogleApiClient.Builder(context)
- .addConnectionCallbacks(object : GoogleApiClient.ConnectionCallbacks {
-
- override fun onConnected(p0: Bundle?) {
- // Connected to Google Play services!
- // The good stuff goes here.
-
- playCallbacks.onPlayConnected()
- }
-
- override fun onConnectionSuspended(i: Int) {
- // If your connection to the sensor gets lost at some point,
- // you'll be able to determine the reason and react to it here.
- if (i == ConnectionCallbacks.CAUSE_NETWORK_LOST) {
- info("Connection lost. Cause: Network Lost.");
- } else if (i == ConnectionCallbacks.CAUSE_SERVICE_DISCONNECTED) {
- info("Connection lost. Reason: Service Disconnected");
- } else
- errormsg("Unknown play kode $i")
-
- playCallbacks.onPlayConnectionSuspended()
- }
- })
- .addOnConnectionFailedListener(object : GoogleApiClient.OnConnectionFailedListener {
- override fun onConnectionFailed(result: ConnectionResult) {
- info("Play connection failed $result")
- if (!result.hasResolution()) {
- showErrorDialog(result.errorCode)
- } else {
- // The failure has a resolution. Resolve it.
- // Called typically when the app is not yet authorized, and an
- // authorization dialog is displayed to the user.
- if (!authInProgress) {
- try {
- info("Attempting to resolve failed connection");
- authInProgress = true;
- result.startResolutionForResult(context,
- PLAY_OAUTH_REQUEST_CODE);
- } catch (e: IntentSender.SendIntentException) {
- errormsg("Exception while starting resolution activity")
- playCallbacks.onPlayUnavailable()
- }
- }
- }
- }
- })
-
- apis.forEach { api ->
- builder = builder.addApi(api)
- }
-
- scopes.forEach { s ->
- builder = builder.addScope(s)
- }
-
- apiClient = builder.build()
- }
- }
-
- private fun showErrorDialog(code: Int) {
- // Show the localized error dialog
- GooglePlayServicesUtil.getErrorDialog(code,
- context, 0).show();
- playCallbacks.onPlayUnavailable()
- }
-
- fun hasPlayServices(): Boolean {
- // Check that Google Play services is available
- val resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context)
- // For testing
- //val resultCode = ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED
-
- if (ConnectionResult.SUCCESS == resultCode) {
- // In debug mode, log the status
- Log.d("Geofence Detection",
- "Google Play services is available.");
-
- // getAnalytics().track("Has Play")
-
- // Continue
- return true
- // Google Play services was not available for some reason
- } else {
- showErrorDialog(resultCode)
-
- return false
- }
- }
-
- /**
- * Must be called from onActivityResult
- * @return true if we handled this
- */
- fun playOnActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean =
- if (requestCode == PLAY_OAUTH_REQUEST_CODE) {
- authInProgress = false;
- if (resultCode == Activity.RESULT_OK) {
- // Make sure the app is not already connected or attempting to connect
- if (!apiClient!!.isConnecting && !apiClient!!.isConnected) {
- apiClient!!.connect();
- }
- }
- else {
- // User opted to not install play
- errormsg("User declined play")
- context.finish()
- }
- true
- }
- else
- false
-
- fun playOnStart() {
- if(apiClient != null)
- apiClient!!.connect()
- }
-
- fun playOnStop() {
- if(apiClient != null && apiClient!!.isConnected)
- apiClient!!.disconnect()
- }
-
- fun playSaveInstanceState(outState: Bundle) {
- outState.putBoolean(AUTH_PENDING, authInProgress)
- }
-}
--
2.31.1
From 407d2dd0379a98a85322b47bd2732ae7ac92c23f Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Wed, 2 Jun 2021 13:39:56 -0400
Subject: [PATCH] Liberate
---
.idea/gradle.xml | 3 +-
.idea/misc.xml | 2 +-
app/build.gradle | 44 +---
.../java/com/geeksville/mesh/MainActivity.kt | 56 -----
.../geeksville/mesh/MeshUtilApplication.kt | 26 --
.../geeksville/mesh/service/MeshService.kt | 187 --------------
.../service/MeshServiceLocationCallback.kt | 72 ------
.../mesh/service/RadioInterfaceService.kt | 5 -
.../geeksville/mesh/service/SafeBluetooth.kt | 1 -
.../com/geeksville/mesh/ui/ChannelFragment.kt | 6 -
.../com/geeksville/mesh/ui/MapFragment.kt | 237 ------------------
.../com/geeksville/mesh/ui/ScreenFragment.kt | 2 -
.../geeksville/mesh/ui/SettingsFragment.kt | 69 +----
app/src/main/res/layout/map_not_allowed.xml | 19 --
app/src/main/res/layout/map_view.xml | 17 --
.../main/res/values/curfirmwareversion.xml | 1 -
build.gradle | 23 --
geeksville-androidlib | 2 +-
18 files changed, 5 insertions(+), 767 deletions(-)
delete mode 100644 app/src/main/java/com/geeksville/mesh/service/MeshServiceLocationCallback.kt
delete mode 100644 app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt
delete mode 100644 app/src/main/res/layout/map_not_allowed.xml
delete mode 100644 app/src/main/res/layout/map_view.xml
delete mode 120000 app/src/main/res/values/curfirmwareversion.xml
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index dba811c..46fb20b 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -4,10 +4,10 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
- <option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
+ <option name="gradleJvm" value="#JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
@@ -16,7 +16,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
- <option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 860da66..6199cc2 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
diff --git a/app/build.gradle b/app/build.gradle
index 971e266..e6e73da 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,13 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlinx-serialization'
-apply plugin: 'com.google.gms.google-services'
-apply plugin: 'com.github.triplet.play'
apply plugin: 'de.mobilej.unmock'
-// apply plugin: "app.brant.amazonappstorepublisher"
-
-// Apply the Crashlytics Gradle plugin
-apply plugin: 'com.google.firebase.crashlytics'
// protobuf
apply plugin: 'com.google.protobuf'
@@ -21,20 +15,11 @@ unMock {
}
android {
- /*
- signingConfigs {
- release {
- storeFile "$meshtasticKeystoreFile"
- keyAlias 'upload'
- storePassword "$meshtasticKeystorePassword"
- keyPassword "$meshtasticKeyPassword"
- }
- } */
compileSdkVersion 30
// leave undefined to use version plugin wants
// buildToolsVersion "30.0.2" // Note: 30.0.2 doesn't yet work on Github actions CI
defaultConfig {
- applicationId "com.geeksville.mesh"
+ applicationId "com.geeksville.mesh.libre"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 29 // 30 can't work until an explicit location permissions dialog is added
versionCode 20231 // format is Mmmss (where M is 1+the numeric major number
@@ -59,11 +44,6 @@ android {
// We have to list all translated languages here, because some of our libs have bogus languages that google play
// doesn't like and we need to strip them (gr)
resConfigs "cs", "de", "el", "en", "es", "fi", "fr", "ga", "ht", "it", "ja", "ko", "nl", "no", "pt", "ro", "ru", "sk", "sl", "sq", "sv", "tr", "zh"
-
- // Needed to make mapbox work inside the firebase testlab - FIXME, alas, still doesn't work
- ndk {
- // abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
- }
}
buildFeatures {
@@ -86,13 +66,6 @@ android {
}
}
-play {
- // configure per https://github.com/Triple-T/gradle-play-publisher#authenticating-gradle-play-publisher
- track = 'internal'
- defaultToAppBundles = true
- serviceAccountCredentials = file("../../play-credentials.json")
-}
-
// per protobuf-gradle-plugin docs, this is recommended for android
protobuf {
protoc {
@@ -143,9 +116,6 @@ dependencies {
// kotlin serialization
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc"
- // rate this app
- implementation "com.vorlonsoft:androidrate:1.2.1"
-
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
@@ -157,21 +127,9 @@ dependencies {
// implementation 'com.google.android.things:androidthings:1.0'
implementation 'com.github.mik3y:usb-serial-for-android:v3.0.0'
- // mapbox
- implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0'
-
// mapbox specifies a really old version of okhttp3 which causes lots of API warnings. trying a newer version
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
- // location services
- implementation 'com.google.android.gms:play-services-location:18.0.0'
-
- // For Google Sign-In (owner name accesss)
- implementation 'com.google.android.gms:play-services-auth:19.0.0'
-
- // Add the Firebase SDK for Crashlytics.
- implementation 'com.google.firebase:firebase-crashlytics:17.4.1'
-
// alas implementation bug deep in the bowels when I tried it for my SyncBluetoothDevice class
// implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"
diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt
index a083bfd..f3e111c 100644
--- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt
+++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt
@@ -50,16 +50,9 @@ import com.geeksville.mesh.service.*
import com.geeksville.mesh.ui.*
import com.geeksville.util.Exceptions
import com.geeksville.util.exceptionReporter
-import com.google.android.gms.auth.api.signin.GoogleSignIn
-import com.google.android.gms.auth.api.signin.GoogleSignInAccount
-import com.google.android.gms.common.ConnectionResult
-import com.google.android.gms.common.GoogleApiAvailability
-import com.google.android.gms.tasks.Task
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.tabs.TabLayoutMediator
import com.google.protobuf.InvalidProtocolBufferException
-import com.vorlonsoft.android.rate.AppRate
-import com.vorlonsoft.android.rate.StoreType
import kotlinx.coroutines.*
import java.io.FileOutputStream
import java.lang.Runnable
@@ -159,11 +152,6 @@ class MainActivity : AppCompatActivity(), Logging,
R.drawable.ic_twotone_people_24,
UsersFragment()
),
- TabInfo(
- "Map",
- R.drawable.ic_twotone_map_24,
- MapFragment()
- ),
TabInfo(
"Channel",
R.drawable.ic_twotone_contactless_24,
@@ -348,28 +336,6 @@ class MainActivity : AppCompatActivity(), Logging,
}
}
-
- /// Ask user to rate in play store
- private fun askToRate() {
- exceptionReporter { // Got one IllegalArgumentException from inside this lib, but we don't want to crash our app because of bugs in this optional feature
-
- val hasGooglePlay = GoogleApiAvailability.getInstance()
- .isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING
-
- val rater = AppRate.with(this)
- .setInstallDays(10.toByte()) // default is 10, 0 means install day, 10 means app is launched 10 or more days later than installation
- .setLaunchTimes(10.toByte()) // default is 10, 3 means app is launched 3 or more times
- .setRemindInterval(1.toByte()) // default is 1, 1 means app is launched 1 or more days after neutral button clicked
- .setRemindLaunchesNumber(1.toByte()) // default is 0, 1 means app is launched 1 or more times after neutral button clicked
- .setStoreType(if (hasGooglePlay) StoreType.GOOGLEPLAY else StoreType.AMAZON)
-
- rater.monitor() // Monitors the app launch times
-
- // Only ask to rate if the user has a suitable store
- AppRate.showRateDialogIfMeetsConditions(this) // Shows the Rate Dialog when conditions are met
- }
- }
-
private val isInTestLab: Boolean by lazy {
(application as GeeksvilleApplication).isInTestLab
}
@@ -431,8 +397,6 @@ class MainActivity : AppCompatActivity(), Logging,
// Handle any intent
handleIntent(intent)
-
- askToRate()
}
private fun initToolbar() {
@@ -532,13 +496,6 @@ class MainActivity : AppCompatActivity(), Logging,
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
when (requestCode) {
- RC_SIGN_IN -> {
- // The Task returned from this call is always completed, no need to attach
- // a listener.
- val task: Task<GoogleSignInAccount> =
- GoogleSignIn.getSignedInAccountFromIntent(data)
- handleSignInResult(task)
- }
(65536 + RC_SELECT_DEVICE) -> when (resultCode) {
Activity.RESULT_OK -> {
// User has chosen to pair with the Bluetooth device.
@@ -580,19 +537,6 @@ class MainActivity : AppCompatActivity(), Logging,
}
}
- private fun handleSignInResult(completedTask: Task<GoogleSignInAccount>) {
- /*
- try {
- val account = completedTask.getResult(ApiException::class.java)
- // Signed in successfully, show authenticated UI.
- //updateUI(account)
- } catch (e: ApiException) { // The ApiException status code indicates the detailed failure reason.
-// Please refer to the GoogleSignInStatusCodes class reference for more information.
- warn("signInResult:failed code=" + e.statusCode)
- //updateUI(null)
- } */
- }
-
private
var receiverRegistered = false
diff --git a/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt b/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt
index e0a9bd8..21841f6 100644
--- a/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt
+++ b/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt
@@ -6,8 +6,6 @@ import com.geeksville.android.BuildUtils.isEmulator
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.util.Exceptions
-import com.google.firebase.crashlytics.FirebaseCrashlytics
-import com.mapbox.mapboxsdk.Mapbox
class MeshUtilApplication : GeeksvilleApplication() {
@@ -20,37 +18,13 @@ class MeshUtilApplication : GeeksvilleApplication() {
// We default to off in the manifest - we turn on here if the user approves
// leave off when running in the debugger
if (!isEmulator && (!BuildConfig.DEBUG || !Debug.isDebuggerConnected())) {
- val crashlytics = FirebaseCrashlytics.getInstance()
- crashlytics.setCrashlyticsCollectionEnabled(isAnalyticsAllowed)
- crashlytics.setCustomKey("debug_build", BuildConfig.DEBUG)
val pref = AppPrefs(this)
- crashlytics.setUserId(pref.getInstallId()) // be able to group all bugs per anonymous user
- // We always send our log messages to the crashlytics lib, but they only get sent to the server if we report an exception
- // This makes log messages work properly if someone turns on analytics just before they click report bug.
- // send all log messages through crashyltics, so if we do crash we'll have those in the report
val standardLogger = Logging.printlog
Logging.printlog = { level, tag, message ->
- crashlytics.log("$tag: $message")
standardLogger(level, tag, message)
}
-
- fun sendCrashReports() {
- if (isAnalyticsAllowed)
- crashlytics.sendUnsentReports()
- }
-
- // Send any old reports if user approves
- sendCrashReports()
-
- // Attach to our exception wrapper
- Exceptions.reporter = { exception, _, _ ->
- crashlytics.recordException(exception)
- sendCrashReports() // Send the new report
- }
}
-
- Mapbox.getInstance(this, getString(R.string.mapbox_access_token))
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt
index 981e49f..acbc57c 100644
--- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt
+++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt
@@ -11,11 +11,9 @@ import android.os.RemoteException
import android.widget.Toast
import androidx.annotation.UiThread
import androidx.core.content.edit
-import com.geeksville.analytics.DataPair
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.android.ServiceClient
-import com.geeksville.android.isGooglePlayAvailable
import com.geeksville.concurrent.handledLaunch
import com.geeksville.mesh.*
import com.geeksville.mesh.MeshProtos.MeshPacket
@@ -26,12 +24,6 @@ import com.geeksville.mesh.database.entity.Packet
import com.geeksville.mesh.model.DeviceVersion
import com.geeksville.mesh.service.SoftwareUpdateService.Companion.ProgressNotStarted
import com.geeksville.util.*
-import com.google.android.gms.common.api.ApiException
-import com.google.android.gms.common.api.ResolvableApiException
-import com.google.android.gms.location.FusedLocationProviderClient
-import com.google.android.gms.location.LocationRequest
-import com.google.android.gms.location.LocationServices
-import com.google.android.gms.location.LocationSettingsRequest
import com.google.protobuf.ByteString
import com.google.protobuf.InvalidProtocolBufferException
import kotlinx.coroutines.*
@@ -120,8 +112,6 @@ class MeshService : Service(), Logging {
/// A database of received packets - used only for debug log
private var packetRepo: PacketRepository? = null
- private var fusedLocationClient: FusedLocationProviderClient? = null
-
// If we've ever read a valid region code from our device it will be here
var curRegionValue = RadioConfigProtos.RegionCode.Unset_VALUE
@@ -132,12 +122,6 @@ class MeshService : Service(), Logging {
}
}
- private val locationCallback = MeshServiceLocationCallback(
- ::perhapsSendPosition,
- onSendPositionFailed = { onConnectionChanged(ConnectionState.DEVICE_SLEEP) },
- getNodeNum = { myNodeNum }
- )
-
private fun getSenderName(packet: DataPacket?): String {
val name = nodeDBbyID[packet?.from]?.user?.longName
return name ?: "Unknown username"
@@ -191,84 +175,6 @@ class MeshService : Service(), Logging {
}
}
- /**
- * start our location requests (if they weren't already running)
- *
- * per https://developer.android.com/training/location/change-location-settings
- */
- @SuppressLint("MissingPermission")
- @UiThread
- private fun startLocationRequests(requestInterval: Long) {
- // FIXME - currently we don't support location reading without google play
- if (fusedLocationClient == null && isGooglePlayAvailable(this)) {
- GeeksvilleApplication.analytics.track("location_start") // Figure out how many users needed to use the phone GPS
-
- locationIntervalMsec = requestInterval
- val request = LocationRequest.create().apply {
- interval = requestInterval
- priority = LocationRequest.PRIORITY_HIGH_ACCURACY
- }
- val builder = LocationSettingsRequest.Builder().addLocationRequest(request)
- val locationClient = LocationServices.getSettingsClient(this)
- val locationSettingsResponse = locationClient.checkLocationSettings(builder.build())
-
- locationSettingsResponse.addOnSuccessListener {
- debug("We are now successfully listening to the GPS")
- }
-
- locationSettingsResponse.addOnFailureListener { exception ->
- errormsg("Failed to listen to GPS")
-
- when (exception) {
- is ResolvableApiException ->
- exceptionReporter {
- // Location settings are not satisfied, but this can be fixed
- // by showing the user a dialog.
-
- // Show the dialog by calling startResolutionForResult(),
- // and check the result in onActivityResult().
- // exception.startResolutionForResult(this@MainActivity, REQUEST_CHECK_SETTINGS)
-
- // For now just punt and show a dialog
- warnUserAboutLocation()
- }
- is ApiException ->
- when (exception.statusCode) {
- 17 ->
- // error: cancelled by user
- errormsg("User cancelled location access", exception)
- 8502 ->
- // error: settings change unavailable
- errormsg(
- "Settings-change-unavailable, user disabled location access (globally?)",
- exception
- )
- else ->
- Exceptions.report(exception)
- }
- else ->
- Exceptions.report(exception)
- }
- }
-
- val client = LocationServices.getFusedLocationProviderClient(this)
-
- // FIXME - should we use Looper.myLooper() in the third param per https://github.com/android/location-samples/blob/432d3b72b8c058f220416958b444274ddd186abd/LocationUpdatesForegroundService/app/src/main/java/com/google/android/gms/location/sample/locationupdatesforegroundservice/LocationUpdatesService.java
- client.requestLocationUpdates(request, locationCallback, null)
-
- fusedLocationClient = client
- }
- }
-
- private fun stopLocationRequests() {
- if (fusedLocationClient != null) {
- debug("Stopping location requests")
- GeeksvilleApplication.analytics.track("location_stop")
- fusedLocationClient?.removeLocationUpdates(locationCallback)
- fusedLocationClient = null
- }
- }
-
/// Safely access the radio service, if not connected an exception will be thrown
private val connectedRadio: IRadioInterfaceService
get() = (if (connectionState == ConnectionState.CONNECTED) radio.serviceP else null)
@@ -813,17 +719,6 @@ class MeshService : Service(), Logging {
// We always tell other apps when new data packets arrive
if (shouldBroadcast)
serviceBroadcasts.broadcastReceivedData(dataPacket)
-
- GeeksvilleApplication.analytics.track(
- "num_data_receive",
- DataPair(1)
- )
-
- GeeksvilleApplication.analytics.track(
- "data_receive",
- DataPair("num_bytes", bytes.size),
- DataPair("type", data.portnumValue)
- )
}
}
}
@@ -1018,7 +913,6 @@ class MeshService : Service(), Logging {
}
private fun setupLocationRequest() {
- stopLocationRequests()
val mi = myNodeInfo
val prefs = radioConfig?.preferences
if (mi != null && prefs != null) {
@@ -1041,7 +935,6 @@ class MeshService : Service(), Logging {
if (desiredInterval != 0L) {
info("desired GPS assistance interval $desiredInterval")
- startLocationRequests(desiredInterval)
} else {
info("No GPS assistance desired, but sending UTC time to mesh")
sendPosition()
@@ -1049,28 +942,6 @@ class MeshService : Service(), Logging {
}
}
-
- /**
- * Send in analytics about mesh connection
- */
- private fun reportConnection() {
- val radioModel = DataPair("radio_model", myNodeInfo?.model ?: "unknown")
- GeeksvilleApplication.analytics.track(
- "mesh_connect",
- DataPair("num_nodes", numNodes),
- DataPair("num_online", numOnlineNodes),
- radioModel
- )
-
- // Once someone connects to hardware start tracking the approximate number of nodes in their mesh
- // this allows us to collect stats on what typical mesh size is and to tell difference between users who just
- // downloaded the app, vs has connected it to some hardware.
- GeeksvilleApplication.analytics.setUserInfo(
- DataPair("num_nodes", numNodes),
- radioModel
- )
- }
-
private var sleepTimeout: Job? = null
/// msecs since 1970 we started this connection
@@ -1084,18 +955,9 @@ class MeshService : Service(), Logging {
fun startDeviceSleep() {
// Just in case the user uncleanly reboots the phone, save now (we normally save in onDestroy)
saveSettings()
-
- // lost radio connection, therefore no need to keep listening to GPS
- stopLocationRequests()
-
if (connectTimeMsec != 0L) {
val now = System.currentTimeMillis()
connectTimeMsec = 0L
-
- GeeksvilleApplication.analytics.track(
- "connected_seconds",
- DataPair((now - connectTimeMsec) / 1000.0)
- )
}
// Have our timeout fire in the approprate number of seconds
@@ -1121,13 +983,6 @@ class MeshService : Service(), Logging {
// Just in case the user uncleanly reboots the phone, save now (we normally save in onDestroy)
saveSettings()
- GeeksvilleApplication.analytics.track(
- "mesh_disconnect",
- DataPair("num_nodes", numNodes),
- DataPair("num_online", numOnlineNodes)
- )
- GeeksvilleApplication.analytics.track("num_nodes", DataPair(numNodes))
-
// broadcast an intent with our new connection state
serviceBroadcasts.broadcastConnection()
}
@@ -1342,34 +1197,6 @@ class MeshService : Service(), Logging {
}
}
- private fun sendAnalytics() {
- val myInfo = rawMyNodeInfo
- val mi = myNodeInfo
- if (myInfo != null && mi != null) {
- /// Track types of devices and firmware versions in use
- GeeksvilleApplication.analytics.setUserInfo(
- // DataPair("region", mi.region),
- DataPair("firmware", mi.firmwareVersion),
- DataPair("has_gps", mi.hasGPS),
- DataPair("hw_model", mi.model),
- DataPair("dev_error_count", myInfo.errorCount)
- )
-
- if (myInfo.errorCode.number != 0) {
- GeeksvilleApplication.analytics.track(
- "dev_error",
- DataPair("code", myInfo.errorCode.number),
- DataPair("address", myInfo.errorAddress),
-
- // We also include this info, because it is required to correctly decode address from the map file
- DataPair("firmware", mi.firmwareVersion),
- DataPair("hw_model", mi.model)
- // DataPair("region", mi.region)
- )
- }
- }
- }
-
/// If found, the old region string of the form 1.0-EU865 etc...
private var legacyRegion: String? = null
@@ -1478,7 +1305,6 @@ class MeshService : Service(), Logging {
// broadcast an intent with our new connection state
serviceBroadcasts.broadcastConnection()
onNodeDBChanged()
- reportConnection()
updateRegion()
@@ -1512,8 +1338,6 @@ class MeshService : Service(), Logging {
regenMyNodeInfo() // we have a node db now, so can possibly find a better hwmodel
myNodeInfo = newMyNodeInfo // we might have just updated myNodeInfo
- sendAnalytics()
-
if (deviceVersion < minFirmwareVersion) {
info("Device firmware is too old, faking config so firmware update can occur")
onHasSettings()
@@ -1835,17 +1659,6 @@ class MeshService : Service(), Logging {
else -> // sleeping or disconnected
enqueueForSending(p)
}
-
- GeeksvilleApplication.analytics.track(
- "data_send",
- DataPair("num_bytes", p.bytes.size),
- DataPair("type", p.dataType)
- )
-
- GeeksvilleApplication.analytics.track(
- "num_data_sent",
- DataPair(1)
- )
}
}
diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshServiceLocationCallback.kt b/app/src/main/java/com/geeksville/mesh/service/MeshServiceLocationCallback.kt
deleted file mode 100644
index bb7e4bc..0000000
--- a/app/src/main/java/com/geeksville/mesh/service/MeshServiceLocationCallback.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.geeksville.mesh.service
-
-import android.location.Location
-import android.os.RemoteException
-import com.geeksville.mesh.DataPacket
-import com.google.android.gms.location.LocationCallback
-import com.google.android.gms.location.LocationResult
-
-val Location.isAccurateForMesh: Boolean get() = !this.hasAccuracy() || this.accuracy < 200
-
-private fun List<Location>.filterAccurateForMesh() = filter { it.isAccurateForMesh }
-
-private fun LocationResult.lastLocationOrBestEffort(): Location? {
- return lastLocation ?: locations.filterAccurateForMesh().lastOrNull()
-}
-
-typealias SendPosition = (Double, Double, Int, Int, Boolean) -> Unit // Lat, Lon, alt, destNum, wantResponse
-typealias OnSendFailure = () -> Unit
-typealias GetNodeNum = () -> Int
-
-class MeshServiceLocationCallback(
- private val onSendPosition: SendPosition,
- private val onSendPositionFailed: OnSendFailure,
- private val getNodeNum: GetNodeNum
-) : LocationCallback() {
-
- companion object {
- const val DEFAULT_SEND_RATE_LIMIT = 30
- }
-
- private var lastSendTimeMs: Long = 0L
-
- override fun onLocationResult(locationResult: LocationResult) {
- super.onLocationResult(locationResult)
-
- locationResult.lastLocationOrBestEffort()?.let { location ->
- MeshService.info("got phone location")
- if (location.isAccurateForMesh) { // if within 200 meters, or accuracy is unknown
-
- try {
- // Do we want to broadcast this position globally, or are we just telling the local node what its current position is (
- val shouldBroadcast =
- true // no need to rate limit, because we are just sending at the interval requested by the preferences
- val destinationNumber =
- if (shouldBroadcast) DataPacket.NODENUM_BROADCAST else getNodeNum()
-
- // Note: we never want this message sent as a reliable message, because it is low value and we'll be sending one again later anyways
- sendPosition(location, destinationNumber, wantResponse = false)
-
- } catch (ex: RemoteException) { // Really a RadioNotConnected exception, but it has changed into this type via remoting
- MeshService.warn("Lost connection to radio, stopping location requests")
- onSendPositionFailed()
- } catch (ex: BLEException) { // Really a RadioNotConnected exception, but it has changed into this type via remoting
- MeshService.warn("BLE exception, stopping location requests $ex")
- onSendPositionFailed()
- }
- } else {
- MeshService.warn("accuracy ${location.accuracy} is too poor to use")
- }
- }
- }
-
- private fun sendPosition(location: Location, destinationNumber: Int, wantResponse: Boolean) {
- onSendPosition(
- location.latitude,
- location.longitude,
- location.altitude.toInt(),
- destinationNumber,
- wantResponse // wantResponse?
- )
- }
-}
diff --git a/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt b/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt
index 9467187..05ae31a 100644
--- a/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt
+++ b/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt
@@ -263,11 +263,6 @@ class RadioInterfaceService : Service(), Logging {
warn("Ignoring setBondedDevice $address, because we are already using that device")
false
} else {
- // Record that this use has configured a new radio
- GeeksvilleApplication.analytics.track(
- "mesh_bond"
- )
-
// Ignore any errors that happen while closing old device
ignoreException {
stopInterface()
diff --git a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt
index 5dc982a..3761bc8 100644
--- a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt
+++ b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt
@@ -101,7 +101,6 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
private val mHandler: Handler = Handler(Looper.getMainLooper())
fun restartBle() {
- GeeksvilleApplication.analytics.track("ble_restart") // record # of times we needed to use this nasty hack
errormsg("Doing emergency BLE restart")
context.bluetoothManager?.adapter?.let { adp ->
if (adp.isEnabled) {
diff --git a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt
index c3a7453..de31623 100644
--- a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt
+++ b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt
@@ -13,7 +13,6 @@ import android.view.inputmethod.EditorInfo
import android.widget.ArrayAdapter
import android.widget.ImageView
import androidx.fragment.app.activityViewModels
-import com.geeksville.analytics.DataPair
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.android.hideKeyboard
@@ -131,11 +130,6 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
private fun shareChannel() {
model.channels.value?.let { channels ->
- GeeksvilleApplication.analytics.track(
- "share",
- DataPair("content_type", "channel")
- ) // track how many times users share channels
-
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, channels.getChannelUrl().toString())
diff --git a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt
deleted file mode 100644
index f40c78b..0000000
--- a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt
+++ /dev/null
@@ -1,237 +0,0 @@
-package com.geeksville.mesh.ui
-
-import android.graphics.Color
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.core.content.ContextCompat
-import androidx.fragment.app.activityViewModels
-import androidx.lifecycle.Observer
-import com.geeksville.android.GeeksvilleApplication
-import com.geeksville.android.Logging
-import com.geeksville.mesh.NodeInfo
-import com.geeksville.mesh.R
-import com.geeksville.mesh.model.UIViewModel
-import com.geeksville.util.formatAgo
-import com.mapbox.geojson.Feature
-import com.mapbox.geojson.FeatureCollection
-import com.mapbox.geojson.Point
-import com.mapbox.mapboxsdk.camera.CameraPosition
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
-import com.mapbox.mapboxsdk.geometry.LatLng
-import com.mapbox.mapboxsdk.geometry.LatLngBounds
-import com.mapbox.mapboxsdk.maps.MapView
-import com.mapbox.mapboxsdk.maps.MapboxMap
-import com.mapbox.mapboxsdk.maps.Style
-import com.mapbox.mapboxsdk.style.expressions.Expression
-import com.mapbox.mapboxsdk.style.layers.Property
-import com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_TOP
-import com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_AUTO
-import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
-import com.mapbox.mapboxsdk.style.layers.SymbolLayer
-import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
-
-
-class MapFragment : ScreenFragment("Map"), Logging {
-
- private val model: UIViewModel by activityViewModels()
-
- private val nodeSourceId = "node-positions"
- private val nodeLayerId = "node-layer"
- private val labelLayerId = "label-layer"
- private val markerImageId = "my-marker-image"
-
- private val nodePositions = GeoJsonSource(nodeSourceId)
-
- private val nodeLayer = SymbolLayer(nodeLayerId, nodeSourceId).withProperties(
- iconImage(markerImageId),
- iconAnchor(Property.ICON_ANCHOR_BOTTOM),
- iconAllowOverlap(true)
- )
-
- private val labelLayer = SymbolLayer(labelLayerId, nodeSourceId).withProperties(
- textField(Expression.get("name")),
- textSize(12f),
- textColor(Color.RED),
- textVariableAnchor(arrayOf(TEXT_ANCHOR_TOP)),
- textJustify(TEXT_JUSTIFY_AUTO),
- textAllowOverlap(true)
- )
-
-
- private fun onNodesChanged(map: MapboxMap, nodes: Collection<NodeInfo>) {
- val nodesWithPosition = nodes.filter { it.validPosition != null }
-
- /**
- * Using the latest nodedb, generate geojson features
- */
- fun getCurrentNodes(): FeatureCollection {
- // Find all nodes with valid locations
-
- val locations = nodesWithPosition.map { node ->
- val p = node.position!!
- debug("Showing on map: $node")
-
- val f = Feature.fromGeometry(
- Point.fromLngLat(
- p.longitude,
- p.latitude
- )
- )
- node.user?.let {
- f.addStringProperty("name", it.longName + " " + formatAgo(p.time))
- }
- f
- }
-
- return FeatureCollection.fromFeatures(locations)
- }
-
-
-
- nodePositions.setGeoJson(getCurrentNodes()) // Update node positions
- }
-
- fun zoomToNodes(map: MapboxMap) {
- val nodesWithPosition =
- model.nodeDB.nodes.value?.values?.filter { it.validPosition != null }
- if (nodesWithPosition != null && nodesWithPosition.isNotEmpty()) {
- val update = if (nodesWithPosition.size >= 2) {
- // Multiple nodes, make them all fit on the map view
- val bounds = LatLngBounds.Builder()
-
- // Add all positions
- bounds.includes(nodesWithPosition.map { it.position!! }
- .map { LatLng(it.latitude, it.longitude) })
-
- CameraUpdateFactory.newLatLngBounds(bounds.build(), 150)
- } else {
- // Only one node, just zoom in on it
- val it = nodesWithPosition[0].position!!
-
- val cameraPos = CameraPosition.Builder().target(
- LatLng(it.latitude, it.longitude)
- ).zoom(9.0).build()
- CameraUpdateFactory.newCameraPosition(cameraPos)
- }
- map.animateCamera(update, 1000)
- }
- }
-
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
- // We can't allow mapbox if user doesn't want analytics
- val id =
- if ((requireContext().applicationContext as GeeksvilleApplication).isAnalyticsAllowed) {
- // Mapbox Access token
- R.layout.map_view
- } else {
- R.layout.map_not_allowed
- }
-
- return inflater.inflate(id, container, false)
- }
-
- var mapView: MapView? = null
-
- /**
- * Mapbox native code can crash painfully if you ever call a mapbox view function while the view is not actively being show
- */
- private val isViewVisible: Boolean
- get() = !(mapView?.isDestroyed ?: true)
-
- override fun onViewCreated(viewIn: View, savedInstanceState: Bundle?) {
- super.onViewCreated(viewIn, savedInstanceState)
-
- // We might not have a real mapview if running with analytics
- if ((requireContext().applicationContext as GeeksvilleApplication).isAnalyticsAllowed) {
- val vIn = viewIn.findViewById<MapView>(R.id.mapView)
- mapView = vIn
- mapView?.let { v ->
- v.onCreate(savedInstanceState)
-
- // Each time the pane is shown start fetching new map info (we do this here instead of
- // onCreate because getMapAsync can die in native code if the view goes away)
- v.getMapAsync { map ->
-
- if (view != null) { // it might have gone away by now
- // val markerIcon = BitmapFactory.decodeResource(context.resources, R.drawable.ic_twotone_person_pin_24)
- val markerIcon =
- ContextCompat.getDrawable(
- requireActivity(),
- R.drawable.ic_twotone_person_pin_24
- )!!
-
- map.setStyle(Style.OUTDOORS) { style ->
- style.addSource(nodePositions)
- style.addImage(markerImageId, markerIcon)
- style.addLayer(nodeLayer)
- style.addLayer(labelLayer)
- }
-
- map.uiSettings.isRotateGesturesEnabled = false
- // Provide initial positions
- model.nodeDB.nodes.value?.let { nodes ->
- onNodesChanged(map, nodes.values)
- }
- }
-
- // Any times nodes change update our map
- model.nodeDB.nodes.observe(viewLifecycleOwner, Observer { nodes ->
- if (isViewVisible)
- onNodesChanged(map, nodes.values)
- })
- zoomToNodes(map)
- }
- }
- }
- }
-
- override fun onPause() {
- mapView?.onPause()
- super.onPause()
- }
-
- override fun onStart() {
- super.onStart()
- mapView?.onStart()
- }
-
- override fun onStop() {
- mapView?.onStop()
- super.onStop()
- }
-
- override fun onResume() {
- super.onResume()
- mapView?.onResume()
- }
-
- override fun onDestroyView() {
- super.onDestroyView()
- mapView?.onDestroy()
- }
-
- override fun onSaveInstanceState(outState: Bundle) {
- mapView?.let {
- if (!it.isDestroyed)
- it.onSaveInstanceState(outState)
- }
- super.onSaveInstanceState(outState)
- }
-
- override fun onLowMemory() {
- mapView?.let {
- if (!it.isDestroyed)
- it.onLowMemory()
- }
- super.onLowMemory()
- }
-}
-
-
-
-
diff --git a/app/src/main/java/com/geeksville/mesh/ui/ScreenFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ScreenFragment.kt
index f02a499..b232144 100644
--- a/app/src/main/java/com/geeksville/mesh/ui/ScreenFragment.kt
+++ b/app/src/main/java/com/geeksville/mesh/ui/ScreenFragment.kt
@@ -12,11 +12,9 @@ open class ScreenFragment(private val screenName: String) : Fragment() {
override fun onResume() {
super.onResume()
- GeeksvilleApplication.analytics.sendScreenView(screenName)
}
override fun onPause() {
- GeeksvilleApplication.analytics.endScreenView()
super.onPause()
}
}
diff --git a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt
index 7a2544e..529b72e 100644
--- a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt
+++ b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt
@@ -30,7 +30,6 @@ import androidx.lifecycle.Observer
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.android.hideKeyboard
-import com.geeksville.android.isGooglePlayAvailable
import com.geeksville.mesh.MainActivity
import com.geeksville.mesh.R
import com.geeksville.mesh.RadioConfigProtos
@@ -45,9 +44,6 @@ import com.geeksville.mesh.service.SoftwareUpdateService.Companion.ProgressSucce
import com.geeksville.util.anonymize
import com.geeksville.util.exceptionReporter
import com.geeksville.util.exceptionToSnackbar
-import com.google.android.gms.location.LocationRequest
-import com.google.android.gms.location.LocationServices
-import com.google.android.gms.location.LocationSettingsRequest
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.hoho.android.usbserial.driver.UsbSerialDriver
import kotlinx.coroutines.CoroutineScope
@@ -496,7 +492,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (model.isConnected.value == MeshService.ConnectionState.CONNECTED && info != null && info.shouldUpdate && info.couldUpdate && service != null) {
binding.updateFirmwareButton.visibility = View.VISIBLE
binding.updateFirmwareButton.text =
- getString(R.string.update_to).format(getString(R.string.short_firmware_version))
+ getString(R.string.update_to).format(getString(R.string.cur_firmware_version))
val progress = service.updateStatus
@@ -871,67 +867,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
initClassicScan()
}
- /**
- * If the user has not turned on location access throw up a toast warning
- */
- private fun checkLocationEnabled() {
- // If they don't have google play FIXME for now we don't check for location access
- if (isGooglePlayAvailable(requireContext())) {
- // We do this painful process because LocationManager.isEnabled is only SDK28 or latet
- val builder = LocationSettingsRequest.Builder()
- builder.setNeedBle(true)
-
- val request = LocationRequest.create().apply {
- priority = LocationRequest.PRIORITY_HIGH_ACCURACY
- }
- builder.addLocationRequest(request) // Make sure we are granted high accuracy permission
-
- val locationSettingsResponse = LocationServices.getSettingsClient(requireActivity())
- .checkLocationSettings(builder.build())
-
- fun weNeedAccess() {
- context?.let { c ->
- warn("Telling user we need need location accesss")
- Toast.makeText(
- c,
- getString(R.string.location_disabled_warning),
- Toast.LENGTH_SHORT
- ).show()
- }
- }
-
- locationSettingsResponse.addOnSuccessListener {
- if(!it.locationSettingsStates.isBleUsable || !it.locationSettingsStates.isLocationUsable)
- weNeedAccess()
- else
- debug("We have location access")
- }
-
- locationSettingsResponse.addOnFailureListener { _ ->
- errormsg("Failed to get location access")
- // We always show the toast regardless of what type of exception we receive. Because even non
- // resolvable api exceptions mean user still needs to fix something.
-
- ///if (exception is ResolvableApiException) {
-
- // Location settings are not satisfied, but this can be fixed
- // by showing the user a dialog.
-
- // Show the dialog by calling startResolutionForResult(),
- // and check the result in onActivityResult().
- // exception.startResolutionForResult(this@MainActivity, REQUEST_CHECK_SETTINGS)
-
- // For now just punt and show a dialog
-
- // The context might be gone (if activity is going away) by the time this handler is called
- weNeedAccess()
-
- //} else
- // Exceptions.report(exception)
- }
- }
- }
-
private val updateProgressFilter = IntentFilter(ACTION_UPDATE_PROGRESS)
private val updateProgressReceiver: BroadcastReceiver = object : BroadcastReceiver() {
@@ -969,8 +904,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
R.string.error_bluetooth,
Toast.LENGTH_SHORT
).show()
- } else {
- checkLocationEnabled()
}
}
}
diff --git a/app/src/main/res/layout/map_not_allowed.xml b/app/src/main/res/layout/map_not_allowed.xml
deleted file mode 100644
index b90ab12..0000000
--- a/app/src/main/res/layout/map_not_allowed.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <TextView
- android:id="@+id/textView"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginTop="16dp"
- android:layout_marginEnd="16dp"
- android:autoLink="web"
- android:text="@string/map_not_allowed"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/map_view.xml b/app/src/main/res/layout/map_view.xml
deleted file mode 100644
index 608b011..0000000
--- a/app/src/main/res/layout/map_view.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:mapbox="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/mapFrame"> <!-- tab layout requires a unique ID -->
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clickable="true" android:focusable="true"
- mapbox:mapbox_uiZoomGestures="true"
- mapbox:mapbox_uiScrollGestures="true"></com.mapbox.mapboxsdk.maps.MapView>
-
-</FrameLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/curfirmwareversion.xml b/app/src/main/res/values/curfirmwareversion.xml
deleted file mode 120000
index f65f229..0000000
--- a/app/src/main/res/values/curfirmwareversion.xml
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../meshtastic-esp32/release/latest/curfirmwareversion.xml
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index d1cb147..c460b62 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,18 +17,9 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
- // Add the Crashlytics Gradle plugin.
- // Check that you have the Google Services Gradle plugin v4.3.2 or later
- // (if not, add it).
- classpath 'com.google.gms:google-services:4.3.5'
- classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
-
// protobuf plugin - docs here https://github.com/google/protobuf-gradle-plugin
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.15'
- //classpath "app.brant:amazonappstorepublisher:0.1.0"
- classpath 'com.github.triplet.gradle:play-publisher:2.8.0'
-
// for unit testing https://github.com/bjoernQ/unmock-plugin
classpath 'com.github.bjoernq:unmockplugin:0.7.6'
}
@@ -36,20 +27,6 @@ buildscript {
allprojects {
repositories {
- maven {
- // Per https://docs.mapbox.com/android/maps/guides/install/ we now need to signin to download mapbox lib
- url 'https://api.mapbox.com/downloads/v2/releases/maven'
- authentication {
- basic(BasicAuthentication)
- }
- credentials {
- // Do not change the username below.
- // This should always be `mapbox` (not your username).
- username = 'mapbox'
- // Use the secret token you stored in gradle.properties as the password
- password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
- }
- }
google()
jcenter()
maven { url 'https://jitpack.io' }
diff --git a/geeksville-androidlib b/geeksville-androidlib
index 9571ac9..d6f4744 160000
--- a/geeksville-androidlib
+++ b/geeksville-androidlib
@@ -1 +1 @@
-Subproject commit 9571ac92b6f893632627109a57b197a44a2d74f8
+Subproject commit d6f4744a3550febc7ca965cddf842abad16f4269
--
2.31.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment