forked from upstream-mirrors/OpenTracks
During import, add photo markers to gallery
This commit is contained in:
@@ -30,8 +30,8 @@ import com.google.android.apps.mytracks.fragments.ExportDialogFragment;
|
|||||||
import com.google.android.apps.mytracks.fragments.ExportDialogFragment.ExportCaller;
|
import com.google.android.apps.mytracks.fragments.ExportDialogFragment.ExportCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.ExportDialogFragment.ExportType;
|
import com.google.android.apps.mytracks.fragments.ExportDialogFragment.ExportType;
|
||||||
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.PlayMultipleDialogFragment;
|
|
||||||
import com.google.android.apps.mytracks.fragments.MyTracksMapFragment;
|
import com.google.android.apps.mytracks.fragments.MyTracksMapFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.PlayMultipleDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.StatsFragment;
|
import com.google.android.apps.mytracks.fragments.StatsFragment;
|
||||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||||
import com.google.android.apps.mytracks.io.file.exporter.SaveActivity;
|
import com.google.android.apps.mytracks.io.file.exporter.SaveActivity;
|
||||||
@@ -140,9 +140,7 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
|||||||
hasPhoto = false;
|
hasPhoto = false;
|
||||||
|
|
||||||
if (id != -1L) {
|
if (id != -1L) {
|
||||||
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
FileUtils.updateMediaScanner(TrackDetailActivity.this, photoUri);
|
||||||
mediaScanIntent.setData(photoUri);
|
|
||||||
sendBroadcast(mediaScanIntent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.io.file.exporter.KmzTrackExporter;
|
|||||||
import com.google.android.apps.mytracks.util.FileUtils;
|
import com.google.android.apps.mytracks.util.FileUtils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -184,12 +185,15 @@ public class KmzTrackImporter implements TrackImporter {
|
|||||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||||
FileUtils.ensureDirectoryExists(dir);
|
FileUtils.ensureDirectoryExists(dir);
|
||||||
|
|
||||||
fileOutputStream = new FileOutputStream(new File(dir, fileName));
|
File file = new File(dir, fileName);
|
||||||
|
fileOutputStream = new FileOutputStream(file);
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
int count;
|
int count;
|
||||||
while ((count = zipInputStream.read(buffer)) != -1) {
|
while ((count = zipInputStream.read(buffer)) != -1) {
|
||||||
fileOutputStream.write(buffer, 0, count);
|
fileOutputStream.write(buffer, 0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileUtils.updateMediaScanner(context, Uri.fromFile(file));
|
||||||
} finally {
|
} finally {
|
||||||
if (fileOutputStream != null) {
|
if (fileOutputStream != null) {
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.util;
|
package com.google.android.apps.mytracks.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -173,6 +176,12 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
return fileName.substring(index + 1);
|
return fileName.substring(index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateMediaScanner(Context context, Uri uri) {
|
||||||
|
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||||
|
mediaScanIntent.setData(uri);
|
||||||
|
context.sendBroadcast(mediaScanIntent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a filename with the given base and the given extension, possibly
|
* Builds a filename with the given base and the given extension, possibly
|
||||||
|
|||||||
Reference in New Issue
Block a user