android 11 part 3, split api 10/19
This commit is contained in:
parent
ae120c9f5a
commit
f6e014f61d
17 changed files with 446 additions and 93 deletions
|
@ -7,8 +7,6 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "btools.routingapp"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
|
||||
versionCode 41
|
||||
versionName project.version
|
||||
|
@ -19,27 +17,27 @@ android {
|
|||
}
|
||||
|
||||
if(project.hasProperty("RELEASE_STORE_FILE")) {
|
||||
signingConfigs {
|
||||
// this uses a file ~/.gradle/gradle.properties
|
||||
// with content:
|
||||
// RELEASE_STORE_FILE={path to your keystore}
|
||||
// RELEASE_STORE_PASSWORD=*****
|
||||
// RELEASE_KEY_ALIAS=*****
|
||||
// RELEASE_KEY_PASSWORD=*****
|
||||
//
|
||||
release {
|
||||
// enable signingConfig in buildTypes to get a signed apk file
|
||||
storeFile file(RELEASE_STORE_FILE)
|
||||
storePassword RELEASE_STORE_PASSWORD
|
||||
keyAlias RELEASE_KEY_ALIAS
|
||||
keyPassword RELEASE_KEY_PASSWORD
|
||||
signingConfigs {
|
||||
// this uses a file ~/.gradle/gradle.properties
|
||||
// with content:
|
||||
// RELEASE_STORE_FILE={path to your keystore}
|
||||
// RELEASE_STORE_PASSWORD=*****
|
||||
// RELEASE_KEY_ALIAS=*****
|
||||
// RELEASE_KEY_PASSWORD=*****
|
||||
//
|
||||
release {
|
||||
// enable signingConfig in buildTypes to get a signed apk file
|
||||
storeFile file(RELEASE_STORE_FILE)
|
||||
storePassword RELEASE_STORE_PASSWORD
|
||||
keyAlias RELEASE_KEY_ALIAS
|
||||
keyPassword RELEASE_KEY_PASSWORD
|
||||
|
||||
// Optional, specify signing versions used
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
// Optional, specify signing versions used
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
@ -60,18 +58,35 @@ android {
|
|||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
checkReleaseBuilds false //added this line to the build.gradle under the /android/app/build.gradle
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
flavorDimensions "api"
|
||||
productFlavors {
|
||||
api10 {
|
||||
dimension "api"
|
||||
|
||||
minSdkVersion 10
|
||||
targetSdkVersion 19
|
||||
}
|
||||
api19 {
|
||||
dimension "api"
|
||||
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
api19Implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
|
||||
implementation project(':brouter-mapaccess')
|
||||
implementation project(':brouter-core')
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.os.StatFs;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class BInstallerMainActivity extends Activity {
|
||||
|
||||
|
||||
static public long getAvailableSpace (String baseDir) {
|
||||
StatFs stat = new StatFs(baseDir);
|
||||
return (long)stat.getAvailableBlocks()*stat.getBlockSize();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.os.StatFs;
|
||||
import android.widget.EditText;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import btools.router.OsmNodeNamed;
|
||||
|
||||
public class BRouterMainActivity extends Activity
|
||||
{
|
||||
|
||||
public boolean checkSelfPermission (Context context, String perm ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getStorageState(File f ) {
|
||||
return Environment.getExternalStorageState();
|
||||
}
|
||||
|
||||
public ArrayList<File> getStorageDirectories() {
|
||||
List<String> list = getFilesDirs();
|
||||
ArrayList<File> flist = new ArrayList<>();
|
||||
for (String s: list) {
|
||||
File f = new File(s);
|
||||
flist.add(f);
|
||||
}
|
||||
return flist;
|
||||
}
|
||||
|
||||
private List<String> getFilesDirs()
|
||||
{
|
||||
ArrayList<String> res = new ArrayList<String>();
|
||||
|
||||
// check write access on internal sd
|
||||
try
|
||||
{
|
||||
File sd = Environment.getExternalStorageDirectory();
|
||||
File testDir = new File( sd, "brouter" );
|
||||
boolean didExist = testDir.isDirectory();
|
||||
if ( !didExist )
|
||||
{
|
||||
testDir.mkdir();
|
||||
}
|
||||
File testFile = new File( testDir, "test" + System.currentTimeMillis() );
|
||||
testFile.createNewFile();
|
||||
if ( testFile.exists() )
|
||||
{
|
||||
testFile.delete();
|
||||
res.add( sd.getPath() );
|
||||
}
|
||||
if ( !didExist )
|
||||
{
|
||||
testDir.delete();
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
/*
|
||||
// not on api 10
|
||||
try
|
||||
{
|
||||
Method method = Context.class.getDeclaredMethod("getExternalFilesDirs", new Class[]{ String.class } );
|
||||
File[] paths = (File[])method.invoke( this, new Object[1] );
|
||||
for( File path : paths )
|
||||
{
|
||||
res.add( path.getPath() );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
res.add( e.toString() );
|
||||
res.add( Environment.getExternalStorageDirectory().getPath() );
|
||||
}
|
||||
*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioAttributes;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
|
||||
public class NotificationHelper {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public static String BRouterNotificationChannel1 = "brouter_channel_01";
|
||||
|
||||
private Context mContext;
|
||||
private int NOTIFICATION_ID = 111;
|
||||
private Notification mNotification;
|
||||
private NotificationManager mNotificationManager;
|
||||
private PendingIntent mContentIntent;
|
||||
private CharSequence mContentTitle;
|
||||
|
||||
public NotificationHelper(Context context)
|
||||
{
|
||||
if (DEBUG) Log.d("NH", "init " );
|
||||
mContext = context;
|
||||
createNotificationChannels();
|
||||
}
|
||||
|
||||
public void startNotification(Service service) {
|
||||
if (DEBUG) Log.d("NH", "startNotification " );
|
||||
|
||||
mNotification = createNotification("BRouter Download", "Download some files");
|
||||
if (mNotification != null) {
|
||||
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
}
|
||||
}
|
||||
|
||||
public void progressUpdate(String text) {
|
||||
mNotification = createNotification("BRouter Download", text);
|
||||
|
||||
if (mNotification != null) {
|
||||
mNotification.flags = Notification.FLAG_NO_CLEAR |
|
||||
Notification.FLAG_ONGOING_EVENT;
|
||||
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Notification createNotification(String title, String desc) {
|
||||
|
||||
Intent resultIntent = new Intent(mContext, BInstallerActivity.class);
|
||||
|
||||
Intent notificationIntent = new Intent();
|
||||
mContentIntent = PendingIntent.getActivity(mContext, 0, resultIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
Notification.Builder builder ;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
builder = new Notification.Builder(mContext);
|
||||
builder.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||
.setContentTitle(title)
|
||||
.setContentText(desc)
|
||||
.setOnlyAlertOnce(true)
|
||||
.setContentIntent(mContentIntent);
|
||||
|
||||
if(Build.VERSION.SDK_INT>=11 && Build.VERSION.SDK_INT<=15)
|
||||
return builder.getNotification();
|
||||
else if (Build.VERSION.SDK_INT > 15)
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* create notification channels
|
||||
*/
|
||||
public void createNotificationChannels() {
|
||||
if (DEBUG) Log.d("NH", "createNotificationChannels " );
|
||||
|
||||
}
|
||||
|
||||
public void stopNotification() {
|
||||
if (DEBUG) Log.d("NH", "stopNotification " );
|
||||
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
mNotificationManager.deleteNotificationChannel(BRouterNotificationChannel1);
|
||||
}
|
||||
mNotificationManager.cancel(NOTIFICATION_ID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.os.StatFs;
|
||||
import android.util.Log;
|
||||
|
||||
public class BInstallerMainActivity extends Activity implements OnInitListener {
|
||||
|
||||
|
||||
@Override
|
||||
public void onInit(int i)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static public long getAvailableSpace (String baseDir) {
|
||||
StatFs stat = new StatFs(baseDir);
|
||||
|
||||
return (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.os.StatFs;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.os.EnvironmentCompat;
|
||||
|
||||
import btools.router.OsmNodeNamed;
|
||||
|
||||
public class BRouterMainActivity extends Activity implements OnInitListener, ActivityCompat.OnRequestPermissionsResultCallback
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onInit( int i )
|
||||
{
|
||||
}
|
||||
|
||||
public boolean checkSelfPermission (Context context, String perm ) {
|
||||
boolean b = checkSelfPermission(context, perm);
|
||||
if (b) {
|
||||
ActivityCompat.requestPermissions (this, new String[]{perm}, 0);
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
public String getStorageState(File f) {
|
||||
return EnvironmentCompat.getStorageState(f); //Environment.MEDIA_MOUNTED
|
||||
}
|
||||
|
||||
public File[] getExternFilesDirs(String d) {
|
||||
return getExternalFilesDirs(null);
|
||||
}
|
||||
|
||||
public ArrayList<File> getStorageDirectories () {
|
||||
ArrayList<File> list = null;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
list = new ArrayList<File>(Arrays.asList(getExternalMediaDirs()));
|
||||
} else {
|
||||
list = new ArrayList<File>(Arrays.asList(getExternFilesDirs(null)));
|
||||
}
|
||||
ArrayList<File> res = new ArrayList<File>();
|
||||
|
||||
for (File f : list) {
|
||||
if (f != null) {
|
||||
if (getStorageState(f).equals(Environment.MEDIA_MOUNTED))
|
||||
res.add (f);
|
||||
}
|
||||
}
|
||||
|
||||
// res.add(getContext().getFilesDir());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +18,8 @@
|
|||
<activity android:name=".BRouterActivity"
|
||||
android:label="@string/app_name"
|
||||
android:exported="true"
|
||||
android:screenOrientation="unspecified" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
android:screenOrientation="unspecified"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -38,7 +39,7 @@
|
|||
android:process=":brouter_service" />
|
||||
<service android:name="btools.routingapp.DownloadService"
|
||||
android:label="Download Service"
|
||||
android:icon="@drawable/icon"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:enabled="true"
|
||||
/>
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ import android.os.Bundle;
|
|||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.os.StatFs;
|
||||
import android.util.Log;
|
||||
|
||||
public class BInstallerActivity extends Activity implements OnInitListener {
|
||||
public class BInstallerActivity extends BInstallerMainActivity {
|
||||
|
||||
public static final String DOWNLOAD_ACTION = "btools.routingapp.download";
|
||||
|
||||
|
@ -101,11 +102,6 @@ public class BInstallerActivity extends Activity implements OnInitListener {
|
|||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit(int i)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Dialog onCreateDialog( int id )
|
||||
|
@ -154,4 +150,5 @@ public class BInstallerActivity extends Activity implements OnInitListener {
|
|||
showDialog( id );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -269,8 +269,9 @@ public class BInstallerView extends View
|
|||
availableSize = -1;
|
||||
try
|
||||
{
|
||||
StatFs stat = new StatFs(baseDir.getAbsolutePath ());
|
||||
availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong();
|
||||
availableSize = (long)((BInstallerActivity)getContext()).getAvailableSpace(baseDir.getAbsolutePath ());
|
||||
//StatFs stat = new StatFs(baseDir.getAbsolutePath ());
|
||||
//availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong();
|
||||
}
|
||||
catch (Exception e) { /* ignore */ }
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -30,12 +32,11 @@ import android.util.Log;
|
|||
import android.view.KeyEvent;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import btools.router.OsmNodeNamed;
|
||||
|
||||
public class BRouterActivity extends Activity implements OnInitListener, ActivityCompat.OnRequestPermissionsResultCallback
|
||||
{
|
||||
public class BRouterActivity extends BRouterMainActivity {
|
||||
|
||||
private static final int DIALOG_SELECTPROFILE_ID = 1;
|
||||
private static final int DIALOG_EXCEPTION_ID = 2;
|
||||
private static final int DIALOG_SHOW_DM_INFO_ID = 3;
|
||||
|
@ -138,7 +139,7 @@ public class BRouterActivity extends Activity implements OnInitListener, Activit
|
|||
{
|
||||
Intent intent = new Intent( BRouterActivity.this, BInstallerActivity.class );
|
||||
startActivity( intent );
|
||||
finish();
|
||||
// finish();
|
||||
}
|
||||
} ).setNegativeButton( "Cancel", new DialogInterface.OnClickListener()
|
||||
{
|
||||
|
@ -666,19 +667,4 @@ public class BRouterActivity extends Activity implements OnInitListener, Activit
|
|||
mWakeLock.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit( int i )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult (int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (requestCode == 0) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
mBRouterView.startSetup(null, true);
|
||||
} else {
|
||||
mBRouterView.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
@ -102,9 +103,9 @@ public class BRouterService extends Service
|
|||
try
|
||||
{
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
baos.write( "z64".getBytes(StandardCharsets.UTF_8) ); // marker prefix
|
||||
baos.write( "z64".getBytes(Charset.forName("UTF-8")) ); // marker prefix
|
||||
OutputStream os = new GZIPOutputStream( baos );
|
||||
byte[] ab = gpxMessage.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ab = gpxMessage.getBytes(Charset.forName("UTF-8")); //StandardCharsets.UTF_8
|
||||
gpxMessage = null;
|
||||
os.write( ab );
|
||||
ab = null;
|
||||
|
|
|
@ -37,9 +37,6 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.os.EnvironmentCompat;
|
||||
|
||||
import btools.expressions.BExpressionContextWay;
|
||||
import btools.expressions.BExpressionMetaData;
|
||||
|
@ -131,7 +128,7 @@ public class BRouterView extends View
|
|||
if (brd.getAbsolutePath().contains("/Android/data/")) {
|
||||
String message = "(previous basedir " + baseDir + " has to migrate )" ;
|
||||
|
||||
( (BRouterActivity) getContext() ).selectBasedir( getStorageDirectories(), guessBaseDir(), message );
|
||||
( (BRouterActivity) getContext() ).selectBasedir( ( (BRouterActivity) getContext() ).getStorageDirectories(), guessBaseDir(), message );
|
||||
waitingForSelection = true;
|
||||
waitingForMigration = true;
|
||||
oldMigrationPath = brd.getAbsolutePath();
|
||||
|
@ -145,7 +142,7 @@ public class BRouterView extends View
|
|||
String message = baseDir == null ? "(no basedir configured previously)" : "(previous basedir " + baseDir
|
||||
+ ( bdValid ? " does not contain 'brouter' subfolder)" : " is not valid)" );
|
||||
|
||||
( (BRouterActivity) getContext() ).selectBasedir( getStorageDirectories(), guessBaseDir(), message );
|
||||
( (BRouterActivity) getContext() ).selectBasedir( ( (BRouterActivity) getContext() ).getStorageDirectories(), guessBaseDir(), message );
|
||||
waitingForSelection = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -179,11 +176,11 @@ public class BRouterView extends View
|
|||
}
|
||||
|
||||
if ( !td.isDirectory() ) {
|
||||
if (ContextCompat.checkSelfPermission (getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
|
||||
if ( ( (BRouterActivity) getContext() ).checkSelfPermission (getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// if (ContextCompat.checkSelfPermission (getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
|
||||
retryBaseDir = baseDir;
|
||||
ActivityCompat.requestPermissions ((BRouterActivity) getContext(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
} else {
|
||||
( (BRouterActivity) getContext() ).selectBasedir( getStorageDirectories (), guessBaseDir(), "Cannot access " + baseDir.getAbsolutePath () + "; select another");
|
||||
( (BRouterActivity) getContext() ).selectBasedir( ( (BRouterActivity) getContext() ).getStorageDirectories (), guessBaseDir(), "Cannot access " + baseDir.getAbsolutePath () + "; select another");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1175,23 +1172,4 @@ public class BRouterView extends View
|
|||
}
|
||||
}
|
||||
|
||||
private ArrayList<File> getStorageDirectories () {
|
||||
ArrayList<File> list = null;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
list = new ArrayList<File>(Arrays.asList(getContext().getExternalMediaDirs()));
|
||||
} else {
|
||||
list = new ArrayList<File>(Arrays.asList(getContext().getExternalFilesDirs(null)));
|
||||
}
|
||||
ArrayList<File> res = new ArrayList<File>();
|
||||
|
||||
for (File f : list) {
|
||||
if (f != null) {
|
||||
if (EnvironmentCompat.getStorageState(f).equals(Environment.MEDIA_MOUNTED))
|
||||
res.add (f);
|
||||
}
|
||||
}
|
||||
|
||||
// res.add(getContext().getFilesDir());
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@ public class BRouterWorker
|
|||
private List<OsmNodeNamed> readPoisList(Bundle params )
|
||||
{
|
||||
// lon,lat,name|...
|
||||
String pois = params.getString( "pois", null );
|
||||
String pois = params.getString( "pois" );
|
||||
if ( pois == null ) return null;
|
||||
|
||||
String[] lonLatNameList = pois.split("\\|");
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.NotificationManager;
|
|||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
|
@ -88,8 +89,9 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
availableSize = -1;
|
||||
try
|
||||
{
|
||||
StatFs stat = new StatFs(baseDir);
|
||||
availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong();
|
||||
availableSize = BInstallerActivity.getAvailableSpace(baseDir);
|
||||
//StatFs stat = new StatFs(baseDir);
|
||||
//availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong();
|
||||
}
|
||||
catch (Exception e) { /* ignore */ }
|
||||
|
||||
|
@ -228,7 +230,9 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
{
|
||||
try
|
||||
{
|
||||
TrafficStats.setThreadStatsTag(1);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
TrafficStats.setThreadStatsTag(1);
|
||||
}
|
||||
|
||||
int slidx = surl.lastIndexOf( "segments4/" );
|
||||
String name = surl.substring( slidx+10 );
|
||||
|
@ -249,6 +253,7 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
URL urlDelta = new URL(surlDelta);
|
||||
|
||||
connection = (HttpURLConnection) urlDelta.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.connect();
|
||||
|
||||
// 404 kind of expected here, means there's no delta file
|
||||
|
@ -262,11 +267,12 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
|
||||
if ( connection == null )
|
||||
{
|
||||
updateProgress( "Connecting.." + surl );
|
||||
updateProgress( "Connecting.." + name );
|
||||
|
||||
delta = false;
|
||||
URL url = new URL(surl);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.connect();
|
||||
}
|
||||
|
||||
|
@ -333,7 +339,7 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
tmp_file = new File( fname + "_tmp" );
|
||||
Rd5DiffTool.recoverFromDelta( fname, diffFile, tmp_file, this );
|
||||
diffFile.delete();
|
||||
}
|
||||
}
|
||||
if (isCanceled())
|
||||
{
|
||||
return "Canceled!";
|
||||
|
@ -348,7 +354,7 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
}
|
||||
return check_result;
|
||||
}
|
||||
|
||||
if (fname.exists()) fname.delete();
|
||||
if ( !tmp_file.renameTo( fname ) )
|
||||
{
|
||||
return "Could not rename to " + fname.getAbsolutePath();
|
||||
|
@ -429,12 +435,15 @@ public class DownloadService extends Service implements ProgressListener {
|
|||
{
|
||||
try
|
||||
{
|
||||
TrafficStats.setThreadStatsTag(1);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
TrafficStats.setThreadStatsTag(1);
|
||||
}
|
||||
|
||||
if ( connection == null )
|
||||
{
|
||||
URL url = new URL(surl);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.connect();
|
||||
}
|
||||
// expect HTTP 200 OK, so we don't mistakenly save error report
|
||||
|
|
|
@ -52,7 +52,10 @@ distributions {
|
|||
include 'readmes/*'
|
||||
include 'profiles2/*'
|
||||
}
|
||||
from ('../brouter-routing-app/build/outputs/apk/release') {
|
||||
from ('../brouter-routing-app/build/outputs/apk/api10/release') {
|
||||
include '*.apk'
|
||||
}
|
||||
from ('../brouter-routing-app/build/outputs/apk/api19/release') {
|
||||
include '*.apk'
|
||||
}
|
||||
from ('../brouter-server/build/libs') {
|
||||
|
|
|
@ -8,7 +8,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.0'
|
||||
classpath 'com.android.tools.build:gradle:7.0.1'
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
Loading…
Reference in a new issue