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"/>
<!-- 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=""/>
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"

View file

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

View file

@ -150,7 +150,7 @@ public class AppInitializer implements IProgress {
}
startPrefs = app.getSharedPreferences(
getLocalClassName(app.getAppCustomization().getMapActivity().getName()),
Context.MODE_WORLD_WRITEABLE);
Context.MODE_PRIVATE);
if(!startPrefs.contains(NUMBER_OF_STARTS)) {
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
} else {
@ -241,18 +241,18 @@ public class AppInitializer implements IProgress {
public boolean checkPreviousRunsForExceptions(Activity activity, boolean writeFileSize) {
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);
if (file.exists() && file.length() > 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);

View file

@ -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);
}
}
}

View file

@ -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;
}

View file

@ -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

View file

@ -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();

View file

@ -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;

View file

@ -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 {
@ -20,6 +24,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;
protected int color;
@ -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)