Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-05-02 21:33:10 +02:00
commit 72f0320613
9 changed files with 56 additions and 22 deletions

View file

@ -40,7 +40,7 @@
<uses-feature android:name="com.sec.feature.spen_usp" android:required="false"/> <uses-feature android:name="com.sec.feature.spen_usp" android:required="false"/>
<!-- com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs --> <!-- com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs -->
<uses-sdk android:targetSdkVersion="23" android:minSdkVersion="15" <uses-sdk android:targetSdkVersion="26" android:minSdkVersion="15"
tools:overrideLibrary=""/> tools:overrideLibrary=""/>
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" <supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"

View file

@ -58,7 +58,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15
targetSdkVersion 23 targetSdkVersion 26
versionCode 300 versionCode 300
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
multiDexEnabled true multiDexEnabled true

View file

@ -150,7 +150,7 @@ public class AppInitializer implements IProgress {
} }
startPrefs = app.getSharedPreferences( startPrefs = app.getSharedPreferences(
getLocalClassName(app.getAppCustomization().getMapActivity().getName()), getLocalClassName(app.getAppCustomization().getMapActivity().getName()),
Context.MODE_WORLD_WRITEABLE); Context.MODE_PRIVATE);
if(!startPrefs.contains(NUMBER_OF_STARTS)) { if(!startPrefs.contains(NUMBER_OF_STARTS)) {
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit(); startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
} else { } else {
@ -241,18 +241,18 @@ public class AppInitializer implements IProgress {
public boolean checkPreviousRunsForExceptions(Activity activity, boolean writeFileSize) { public boolean checkPreviousRunsForExceptions(Activity activity, boolean writeFileSize) {
initVariables(); initVariables();
long size = activity.getPreferences(Context.MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0); long size = activity.getPreferences(Context.MODE_PRIVATE).getLong(EXCEPTION_FILE_SIZE, 0);
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH); final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
if (file.exists() && file.length() > 0) { if (file.exists() && file.length() > 0) {
if (size != file.length() && !firstTime) { if (size != file.length() && !firstTime) {
if (writeFileSize) { if (writeFileSize) {
activity.getPreferences(Context.MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit(); activity.getPreferences(Context.MODE_PRIVATE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
} }
return true; return true;
} }
} else { } else {
if (size > 0) { if (size > 0) {
activity.getPreferences(Context.MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit(); activity.getPreferences(Context.MODE_PRIVATE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit();
} }
} }
return false; return false;
@ -262,7 +262,7 @@ public class AppInitializer implements IProgress {
public void checkVectorIndexesDownloaded(final Activity ctx) { public void checkVectorIndexesDownloaded(final Activity ctx) {
OsmandApplication app = (OsmandApplication)ctx.getApplication(); OsmandApplication app = (OsmandApplication)ctx.getApplication();
MapRenderRepositories maps = app.getResourceManager().getRenderer(); MapRenderRepositories maps = app.getResourceManager().getRenderer();
SharedPreferences pref = ctx.getPreferences(Context.MODE_WORLD_WRITEABLE); SharedPreferences pref = ctx.getPreferences(Context.MODE_PRIVATE);
boolean check = pref.getBoolean(VECTOR_INDEXES_CHECK, true); boolean check = pref.getBoolean(VECTOR_INDEXES_CHECK, true);
// do not show each time // do not show each time
if (check && new Random().nextInt() % 5 == 1) { if (check && new Random().nextInt() % 5 == 1) {
@ -285,7 +285,7 @@ public class AppInitializer implements IProgress {
builder.setNeutralButton(R.string.shared_string_no_thanks, new DialogInterface.OnClickListener() { builder.setNeutralButton(R.string.shared_string_no_thanks, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
ctx.getPreferences(Context.MODE_WORLD_WRITEABLE).edit().putBoolean(VECTOR_INDEXES_CHECK, false).commit(); ctx.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(VECTOR_INDEXES_CHECK, false).commit();
} }
}); });
builder.setNegativeButton(R.string.first_time_continue, null); builder.setNegativeButton(R.string.first_time_continue, null);

View file

@ -1,19 +1,23 @@
package net.osmand.plus; package net.osmand.plus;
import android.app.Notification; import java.util.ArrayList;
import android.support.v4.app.NotificationCompat.Builder; import java.util.List;
import android.support.v4.app.NotificationManagerCompat;
import net.osmand.plus.notifications.GpxNotification; import net.osmand.plus.notifications.GpxNotification;
import net.osmand.plus.notifications.NavigationNotification; import net.osmand.plus.notifications.NavigationNotification;
import net.osmand.plus.notifications.OsmandNotification; import net.osmand.plus.notifications.OsmandNotification;
import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.notifications.OsmandNotification.NotificationType;
import android.annotation.TargetApi;
import java.util.ArrayList; import android.app.Notification;
import java.util.List; import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat;
public class NotificationHelper { public class NotificationHelper {
public static final String NOTIFICATION_CHANEL_ID = "osmand_background_service";
private OsmandApplication app; private OsmandApplication app;
private NavigationNotification navigationNotification; private NavigationNotification navigationNotification;
@ -128,4 +132,17 @@ public class NotificationHelper {
notification.removeNotification(); notification.removeNotification();
} }
} }
@TargetApi(26)
public void createNotificationChannel() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANEL_ID,
app.getString(R.string.osmand_service), NotificationManager.IMPORTANCE_LOW);
channel.enableVibration(false);
channel.setDescription(app.getString(R.string.osmand_service_descr));
NotificationManager mNotificationManager = (NotificationManager) app
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(channel);
}
}
} }

View file

@ -1,6 +1,8 @@
package net.osmand.plus.api; package net.osmand.plus.api;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import android.annotation.SuppressLint;
import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
@ -12,10 +14,12 @@ public class SQLiteAPIImpl implements SQLiteAPI {
this.app = app; this.app = app;
} }
@SuppressLint("InlinedApi")
@Override @Override
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) { public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name, android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name,
readOnly ? SQLiteDatabase.OPEN_READONLY : (SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING), null); Context.MODE_PRIVATE |
(readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null);
if(db == null) { if(db == null) {
return null; return null;
} }

View file

@ -15,7 +15,7 @@ public class SettingsAPIImpl implements SettingsAPI {
@Override @Override
public Object getPreferenceObject(String key) { public Object getPreferenceObject(String key) {
return app.getSharedPreferences(key, Context.MODE_WORLD_READABLE); return app.getSharedPreferences(key, Context.MODE_PRIVATE);
} }
@Override @Override

View file

@ -3,6 +3,7 @@ package net.osmand.plus.download;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
@ -19,11 +20,11 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.map.WorldRegion; import net.osmand.map.WorldRegion;
import net.osmand.map.WorldRegion.RegionParams; import net.osmand.map.WorldRegion.RegionParams;
import net.osmand.plus.NotificationHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.OsmandSettings.OsmandPreference;
@ -113,7 +114,10 @@ public class DownloadIndexesThread {
Intent contentIntent = new Intent(app, DownloadActivity.class); Intent contentIntent = new Intent(app, DownloadActivity.class);
PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent, PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
Builder bld = new NotificationCompat.Builder(app); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
app.getNotificationHelper().createNotificationChannel();
}
Builder bld = new NotificationCompat.Builder(app, NotificationHelper.NOTIFICATION_CHANEL_ID);
String msg = Version.getAppName(app); String msg = Version.getAppName(app);
if(!isFinished) { if(!isFinished) {
msg = task.getDescription(); msg = task.getDescription();

View file

@ -10,10 +10,11 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.BigTextStyle;
import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationCompat.BigTextStyle;
import android.view.View; import android.view.View;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;

View file

@ -1,14 +1,18 @@
package net.osmand.plus.notifications; package net.osmand.plus.notifications;
import android.annotation.SuppressLint;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import net.osmand.plus.NotificationHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
public abstract class OsmandNotification { public abstract class OsmandNotification {
@ -19,6 +23,7 @@ public abstract class OsmandNotification {
public final static int WEAR_NAVIGATION_NOTIFICATION_SERVICE_ID = 1005; public final static int WEAR_NAVIGATION_NOTIFICATION_SERVICE_ID = 1005;
public final static int WEAR_GPX_NOTIFICATION_SERVICE_ID = 1006; public final static int WEAR_GPX_NOTIFICATION_SERVICE_ID = 1006;
protected OsmandApplication app; protected OsmandApplication app;
protected boolean ongoing = true; protected boolean ongoing = true;
@ -57,12 +62,15 @@ public abstract class OsmandNotification {
this.top = top; this.top = top;
} }
@SuppressLint("InlinedApi")
protected Builder createBuilder(boolean wearable) { protected Builder createBuilder(boolean wearable) {
Intent contentIntent = new Intent(app, MapActivity.class); Intent contentIntent = new Intent(app, MapActivity.class);
PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent, PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Builder builder = new Builder(app) app.getNotificationHelper().createNotificationChannel();
}
Builder builder = new Builder(app, NotificationHelper.NOTIFICATION_CHANEL_ID)
.setVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(top ? NotificationCompat.PRIORITY_HIGH : getPriority()) .setPriority(top ? NotificationCompat.PRIORITY_HIGH : getPriority())
.setOngoing(ongoing && !wearable) .setOngoing(ongoing && !wearable)