diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index b7237fd462..6eaa64d670 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -40,7 +40,7 @@
-
0) {
if (size != file.length() && !firstTime) {
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;
}
} else {
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;
@@ -262,7 +262,7 @@ public class AppInitializer implements IProgress {
public void checkVectorIndexesDownloaded(final Activity ctx) {
OsmandApplication app = (OsmandApplication)ctx.getApplication();
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);
// do not show each time
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() {
@Override
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);
diff --git a/OsmAnd/src/net/osmand/plus/NotificationHelper.java b/OsmAnd/src/net/osmand/plus/NotificationHelper.java
index 9451710b39..8e5e46317b 100644
--- a/OsmAnd/src/net/osmand/plus/NotificationHelper.java
+++ b/OsmAnd/src/net/osmand/plus/NotificationHelper.java
@@ -1,19 +1,23 @@
package net.osmand.plus;
-import android.app.Notification;
-import android.support.v4.app.NotificationCompat.Builder;
-import android.support.v4.app.NotificationManagerCompat;
+import java.util.ArrayList;
+import java.util.List;
import net.osmand.plus.notifications.GpxNotification;
import net.osmand.plus.notifications.NavigationNotification;
import net.osmand.plus.notifications.OsmandNotification;
import net.osmand.plus.notifications.OsmandNotification.NotificationType;
-
-import java.util.ArrayList;
-import java.util.List;
+import android.annotation.TargetApi;
+import android.app.Notification;
+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 static final String NOTIFICATION_CHANEL_ID = "osmand_background_service";
private OsmandApplication app;
private NavigationNotification navigationNotification;
@@ -128,4 +132,17 @@ public class NotificationHelper {
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);
+ }
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java
index a1f368d89a..e30033785e 100644
--- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java
+++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java
@@ -1,6 +1,8 @@
package net.osmand.plus.api;
import net.osmand.plus.OsmandApplication;
+import android.annotation.SuppressLint;
+import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
@@ -12,10 +14,12 @@ public class SQLiteAPIImpl implements SQLiteAPI {
this.app = app;
}
+ @SuppressLint("InlinedApi")
@Override
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
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) {
return null;
}
diff --git a/OsmAnd/src/net/osmand/plus/api/SettingsAPIImpl.java b/OsmAnd/src/net/osmand/plus/api/SettingsAPIImpl.java
index b1801f4b33..456d2ba3d4 100644
--- a/OsmAnd/src/net/osmand/plus/api/SettingsAPIImpl.java
+++ b/OsmAnd/src/net/osmand/plus/api/SettingsAPIImpl.java
@@ -15,7 +15,7 @@ public class SettingsAPIImpl implements SettingsAPI {
@Override
public Object getPreferenceObject(String key) {
- return app.getSharedPreferences(key, Context.MODE_WORLD_READABLE);
+ return app.getSharedPreferences(key, Context.MODE_PRIVATE);
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
index aa0eadd273..2d2b63ad11 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
@@ -3,6 +3,7 @@ package net.osmand.plus.download;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
@@ -19,11 +20,11 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Toast;
-
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.map.WorldRegion;
import net.osmand.map.WorldRegion.RegionParams;
+import net.osmand.plus.NotificationHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
@@ -113,7 +114,10 @@ public class DownloadIndexesThread {
Intent contentIntent = new Intent(app, DownloadActivity.class);
PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent,
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);
if(!isFinished) {
msg = task.getDescription();
diff --git a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java
index 4e981d5822..ffdd0cad52 100644
--- a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java
+++ b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java
@@ -10,10 +10,11 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
+
import android.os.Build;
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.BigTextStyle;
import android.view.View;
import net.osmand.plus.NavigationService;
diff --git a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java
index db43e602ce..99df78bb80 100644
--- a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java
+++ b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java
@@ -1,14 +1,18 @@
package net.osmand.plus.notifications;
+import android.annotation.SuppressLint;
import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.NotificationCompat;
-
+import net.osmand.plus.NotificationHelper;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
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_GPX_NOTIFICATION_SERVICE_ID = 1006;
+
protected OsmandApplication app;
protected boolean ongoing = true;
@@ -57,12 +62,15 @@ public abstract class OsmandNotification {
this.top = top;
}
+ @SuppressLint("InlinedApi")
protected Builder createBuilder(boolean wearable) {
Intent contentIntent = new Intent(app, MapActivity.class);
PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
-
- Builder builder = new Builder(app)
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+ app.getNotificationHelper().createNotificationChannel();
+ }
+ Builder builder = new Builder(app, NotificationHelper.NOTIFICATION_CHANEL_ID)
.setVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(top ? NotificationCompat.PRIORITY_HIGH : getPriority())
.setOngoing(ongoing && !wearable)