Skip to content

Commit

Permalink
Fix merge incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynovikov committed Dec 19, 2023
1 parent 9a195de commit b4cbc1b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
4 changes: 1 addition & 3 deletions app/src/main/java/mobi/maptrek/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4634,8 +4634,6 @@ private double movingAverage(double current, double previous) {

@Subscribe
public void onNewPluginEntry(Pair<String, Pair<Drawable, Intent>> entry) {
if (BuildConfig.FULL_VERSION) {
mPluginRepository.addPluginEntry(entry);
}
mPluginRepository.addPluginEntry(entry);
}
}
65 changes: 37 additions & 28 deletions app/src/main/java/mobi/maptrek/MapTrek.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,30 +164,7 @@ public void onCreate() {
AppCompatDelegate.setDefaultNightMode(Configuration.getNightModeState());

if (BuildConfig.DEBUG) {
// Look for test maps and import them
File dir = getExternalFilesDir("native");
File[] mapFiles = dir.listFiles(new NativeMapFilenameFilter());
for (File mapFile : mapFiles) {
if (mapFile.getName().matches("\\d+-\\d+\\.mtiles")) {
Uri uri = Uri.fromFile(mapFile);
logger.error("Found debug map: {}", mapFile.getAbsolutePath());
Intent importIntent = new Intent(Intent.ACTION_INSERT, uri, this, MapService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Data data = new Data.Builder()
.putString(MapWorker.KEY_ACTION, Intent.ACTION_INSERT)
.putString(MapWorker.KEY_FILE_URI, mapFile.getAbsolutePath())
.build();
OneTimeWorkRequest importWorkRequest = new OneTimeWorkRequest.Builder(MapWorker.class)
.setInputData(data)
.build();
WorkManager.getInstance(this).enqueue(importWorkRequest);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(importIntent);
} else {
startService(importIntent);
}
}
}
findDebugMaps();
}
}

Expand Down Expand Up @@ -218,6 +195,7 @@ public static MapTrek getApplication() {
return mSelf;
}

/** @noinspection unused*/
public void restart(@NonNull Context context, Class<?> cls) {
Intent intent = new Intent(context, cls);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Expand Down Expand Up @@ -359,12 +337,41 @@ public OsmcSymbolFactory getOsmcSymbolFactory() {
public PluginRepository getPluginRepository() {
if (mPluginRepository == null) {
mPluginRepository = new PluginRepository(this);
mPluginRepository.initializePlugins();
}
return mPluginRepository;
}

if (BuildConfig.FULL_VERSION) {
mPluginRepository.initializePlugins();
private void findDebugMaps() {
// Look for test maps and import them
File dir = getExternalFilesDir("native");
if (dir == null)
return;
File[] mapFiles = dir.listFiles(new NativeMapFilenameFilter());
if (mapFiles == null)
return;
for (File mapFile : mapFiles) {
if (mapFile.getName().matches("\\d+-\\d+\\.mtiles")) {
Uri uri = Uri.fromFile(mapFile);
logger.error("Found debug map: {}", mapFile.getAbsolutePath());
Intent importIntent = new Intent(Intent.ACTION_INSERT, uri, this, MapService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Data data = new Data.Builder()
.putString(MapWorker.KEY_ACTION, Intent.ACTION_INSERT)
.putString(MapWorker.KEY_FILE_URI, mapFile.getAbsolutePath())
.build();
OneTimeWorkRequest importWorkRequest = new OneTimeWorkRequest.Builder(MapWorker.class)
.setInputData(data)
.build();
WorkManager.getInstance(this).enqueue(importWorkRequest);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(importIntent);
} else {
startService(importIntent);
}
}
}
return mPluginRepository;

}

@Nullable
Expand Down Expand Up @@ -397,6 +404,7 @@ public void setBitmapLayerMaps(@NonNull List<MapFile> bitmapLayerMaps) {
@SuppressWarnings("SameParameterValue")
private void copyAsset(String asset, File outFile) throws IOException {
InputStream in = getAssets().open(asset);
//noinspection IOStreamConstructor
OutputStream out = new FileOutputStream(outFile);
byte[] buffer = new byte[1024];
int read;
Expand Down Expand Up @@ -552,7 +560,8 @@ void caughtException(final Thread thread, final Throwable ex) {
.append(thread.toString())
.append("\nException :\n\n");

if (mExceptionLog.getParentFile().canWrite()) {
File file = mExceptionLog.getParentFile();
if (file != null && file.canWrite()) {
BufferedWriter writer = new BufferedWriter(new FileWriter(mExceptionLog, false));
writer.write(msg.toString());
ex.printStackTrace(new PrintWriter(writer));
Expand Down

0 comments on commit b4cbc1b

Please sign in to comment.