Skip to content

Commit

Permalink
fix class not found (#19)
Browse files Browse the repository at this point in the history
* by adding some Paho files for proguard to keep
* also, request background location permission in Android 10+
  • Loading branch information
ostrya committed Dec 14, 2019
1 parent 3d90711 commit 9d2f243
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ android {
applicationId getBuildApplicationId()
minSdkVersion 14
targetSdkVersion 29
versionCode 23
versionName '1.7.0'
versionCode 24
versionName '1.7.1'
}
signingConfigs {
release getSigningConfig()
Expand Down
7 changes: 7 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# seems these classes (as specified in the Paho client JAR META-INF\services\org.eclipse.paho.client.mqttv3.spi.NetworkModuleFactory)
# need to be manually kept
-keep public class org.eclipse.paho.client.mqttv3.internal.TCPNetworkModuleFactory
-keep public class org.eclipse.paho.client.mqttv3.internal.SSLNetworkModuleFactory
-keep public class org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketNetworkModuleFactory
-keep public class org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModuleFactory
14 changes: 12 additions & 2 deletions app/src/main/java/org/ostrya/presencepublisher/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,16 @@ private void checkLocationPermissionAndAccessAndBatteryOptimizationAndStartWorke

ConfirmationDialogFragment fragment = ConfirmationDialogFragment.getInstance(ok -> {
if (ok) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_CODE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION},
PERMISSION_REQUEST_CODE);
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSION_REQUEST_CODE);
}
}
}, R.string.permission_dialog_title, R.string.permission_dialog_message);
fragment.show(fm, null);
Expand All @@ -160,7 +169,8 @@ private void checkLocationPermissionAndAccessAndBatteryOptimizationAndStartWorke

private void checkLocationAccessAndBatteryOptimizationAndStartWorker() {
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && (locationManager == null || !(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
&& (locationManager == null || !(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|| locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)))) {
HyperLog.d(TAG, "Location service not yet enabled, asking user ...");
FragmentManager fm = getSupportFragmentManager();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/play/release-notes/en-US/default.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.7.1
• Fix crash due to missing classes.

v1.7.0
Updated the app to fully support Android 10.
• The Content tab has been renamed to Conditions and allows both adding networks and configuring their message.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<string name="message_schedule_summary">Zeit zwischen Benachrichtigungen in Minuten.</string>
<string name="message_schedule_dialog_text">Die Periode auf unter 15 Minuten zu setzen wird den Batterieverbrauch erhöhen. Fortfahren?</string>
<string name="permission_dialog_title">Standortberechtigung</string>
<string name="permission_dialog_message">Bitte erlaube den Zugriff auf genaue Position. Andernfalls kann diese App den
<string name="permission_dialog_message">Bitte erlaube den dauerhaften Zugriff auf genaue Position. Andernfalls kann diese App den
Namen des aktuell verbundenen WLANs nicht bestimmen. Du kannst das Setzen der Berechtigung überspringen, aber
in diesem Fall wird die App keine Benachrichtigungen senden.
</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<string name="message_schedule_summary">The time between messages in minutes.</string>
<string name="message_schedule_dialog_text">Setting the interval lower than 15 minutes will increase your battery usage. Do you want to continue?</string>
<string name="permission_dialog_title">Location permission</string>
<string name="permission_dialog_message">Please allow access to fine location. Otherwise, this app will not be able to
<string name="permission_dialog_message">Please allow access to fine location all the time. Otherwise, this app will not be able to
retrieve the currently connected WiFi name. You can skip granting the permission, but then the app will not send
any notifications.
</string>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.android.tools.build:gradle:3.5.3'


// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 9d2f243

Please sign in to comment.