Skip to content

Commit

Permalink
Merge pull request #948 from gerhardol/feature/prepare-android-10
Browse files Browse the repository at this point in the history
Target Android 10, update permission handling
gerhardol authored Jul 30, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 4dacde4 + ccf6de6 commit 7fd3a9d
Showing 25 changed files with 693 additions and 714 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
env:
global:
- ANDROID_API=28
- ANDROID_BUILD_TOOLS=29.0.3
- ANDROID_API=29
- ANDROID_BUILD_TOOLS=30.0.1
- ADB_INSTALL_TIMEOUT=5
language: android
jdk:
17 changes: 12 additions & 5 deletions app/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -25,8 +25,10 @@

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" android:minSdkVersion="29"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" android:minSdkVersion="29"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
@@ -38,7 +40,7 @@
<uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" android:minSdkVersion="28"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
@@ -227,8 +229,13 @@
android:value=".view.SettingsActivity"/>
</activity>

<service android:name=".tracker.Tracker"/>
<service android:name=".export.RunnerUpLiveSynchronizer$LiveService"/>
<service
android:name=".tracker.Tracker"
android:foregroundServiceType="location" />

<service
android:name=".export.RunnerUpLiveSynchronizer$LiveService"
android:foregroundServiceType="location" />

<receiver
android:name=".tracker.component.HeadsetButtonReceiver"
25 changes: 22 additions & 3 deletions app/assets/changes.html
Original file line number Diff line number Diff line change
@@ -5,15 +5,34 @@
</head>
<body>
<h1>What's new</h1>
<h2>v2.1.0.1</h2>
<h2>v2.2.0.0</h2>
<p>
<ul>
<li>#947 AndroidX and AppCompatActivity migration</li>
<li>Version changed to 2.2 for Play release, previous production is 2.1.0.0</li>
<li>#949 Play console crashe corrections</li>
<li>#948 Target Android 10, update permission handling
<br>Changes required to target Android 10 and prepare for Android 11/R, required to update the app in Play.
<ul>
<li> Use SDK 29 scooped storage for external files, Google is limiting the file system use from Android 10/11
<br>For FileSynchronizer, save exports to a subdirectory of Documents, similar to the previous defaults.
<br>For db import/export use hardcoded getExternalFilesDir() and let the user copy files.</li>
<li>Permissions for activity and background for Android 10
<br>If permissions are denied, give motivation and let the user try again
(unless "don't ask again" is ticked)
<br>Remove snackbar as it will not rerequest permissions if the user ticks "don't ask again".
Instead use a popup that asks the user to go to system settings,
without starting the workout. (Linking to system settings is not
recommended in the Google guidelines.)
</li>
</ul>
</li>
<li>#947 AndroidX and AppCompatActivity migration
<br>Internal change, support libraries replaced with Google's updated libraries</li>
</ul>
<h2>v2.1.0.0</h2>
<p>
<ul>
<li>Minor version number changed to 2.1 to prepare for Play release, previous production is 2.0.2.1</li>
<li>Minor version number changed to 2.1 for Play release, previous production is 2.0.2.1</li>
<li>#946 Play console feedback
<ul>
<li>Translations update: Czech cue, Romanian, Indonesian </li>
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -54,7 +54,8 @@ android {

splits {
abi {
enable rootProject.ext.allowNonFree && gradle.startParameter.taskNames.contains("assembleLatestRelease")
// Disable, app bundles used in play
// enable rootProject.ext.allowNonFree && gradle.startParameter.taskNames.contains("assembleLatestRelease")
// relevant archs only - these are the only available anyway for newer NDK
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
2 changes: 1 addition & 1 deletion app/res/layout/filepermission.xml
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:text="URL"
android:text="URI"
tools:ignore="HardcodedText"/>

<EditText
32 changes: 23 additions & 9 deletions app/src/main/org/runnerup/db/DBHelper.java
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@

package org.runnerup.db;

import androidx.appcompat.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Context;
@@ -27,6 +26,7 @@
import android.database.sqlite.SQLiteOpenHelper;
import android.os.AsyncTask;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;

import org.json.JSONException;
import org.json.JSONObject;
@@ -51,6 +51,7 @@
import org.runnerup.util.FileUtil;
import org.runnerup.workout.FileFormats;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -624,6 +625,11 @@ public static String getDbPath(Context ctx) {
return ctx.getFilesDir().getPath() + "/../databases/" + DBNAME;
}

private static String getDefaultBackupPath(Context ctx) {
// A path that can be used with SDK 29 scooped storage
return ctx.getExternalFilesDir(null) + File.separator + "runnerup.db.export";
}

public static void importDatabase(Context ctx, String from) {
final DBHelper mDBHelper = DBHelper.getHelper(ctx);
final SQLiteDatabase db = mDBHelper.getWritableDatabase();
@@ -637,16 +643,20 @@ public void onClick(DialogInterface dialog, int which) {
}
};

if (from == null) {
from = getDefaultBackupPath(ctx);
}
AlertDialog.Builder builder = new AlertDialog.Builder(ctx)
.setTitle("Import " + DBNAME + " from " + from);
.setTitle("Import " + DBNAME);
try {
String to = getDbPath(ctx);
int cnt = FileUtil.copyFile(to, from);
builder.setMessage("Copied " + cnt + " bytes")
builder.setMessage("Copied " + cnt + " bytes from " + from +
"\n\nRestart to use the database")
.setPositiveButton(ctx.getString(R.string.OK), listener);
} catch (IOException e) {
builder.setMessage("Exception: " + e.toString())
.setNegativeButton(ctx.getString(R.string.OK), listener);
builder.setMessage("Exception: " + e.toString() + " for " + from)
.setNegativeButton(ctx.getString(R.string.Cancel), listener);
}
builder.show();
}
@@ -659,16 +669,20 @@ public void onClick(DialogInterface dialog, int which) {
}
};

if (to == null) {
to = getDefaultBackupPath(ctx);
}
AlertDialog.Builder builder = new AlertDialog.Builder(ctx)
.setTitle("Export " + DBNAME + " to " + to);
.setTitle("Export " + DBNAME);
try {
String from = getDbPath(ctx);
int cnt = FileUtil.copyFile(to, from);
builder.setMessage("Copied " + cnt + " bytes")
builder.setMessage("Exported " + cnt + " bytes to " + to +
"\n\nNote that the file will be deleted at uninstall")
.setPositiveButton(ctx.getString(R.string.OK), listener);
} catch (IOException e) {
builder.setMessage("Exception: " + e.toString())
.setNegativeButton(ctx.getString(R.string.OK), listener);
builder.setMessage("Exception: " + e.toString() + " for " + to)
.setNegativeButton(ctx.getString(R.string.Cancel), listener);
}
builder.show();
}
Loading

0 comments on commit 7fd3a9d

Please sign in to comment.