forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
+4
-2
@@ -88,9 +88,11 @@ public class DeleteMarkerDialogFragment extends DialogFragment {
|
|||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(
|
||||||
|
fragmentActivity);
|
||||||
for (long markerId : markerIds) {
|
for (long markerId : markerIds) {
|
||||||
MyTracksProviderUtils.Factory.get(fragmentActivity)
|
myTracksProviderUtils.deleteWaypoint(
|
||||||
.deleteWaypoint(markerId, new DescriptionGeneratorImpl(fragmentActivity));
|
markerId, new DescriptionGeneratorImpl(fragmentActivity));
|
||||||
}
|
}
|
||||||
caller.onDeleteMarkerDone();
|
caller.onDeleteMarkerDone();
|
||||||
}
|
}
|
||||||
|
|||||||
+39
@@ -19,6 +19,7 @@ package com.google.android.apps.mytracks.content;
|
|||||||
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
|
import com.google.android.apps.mytracks.util.FileUtils;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -28,6 +29,7 @@ import android.location.Location;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@@ -180,6 +182,9 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, null, null);
|
contentResolver.delete(WaypointsColumns.CONTENT_URI, null, null);
|
||||||
// Delete tracks last since it triggers a database vaccum call
|
// Delete tracks last since it triggers a database vaccum call
|
||||||
contentResolver.delete(TracksColumns.CONTENT_URI, null, null);
|
contentResolver.delete(TracksColumns.CONTENT_URI, null, null);
|
||||||
|
|
||||||
|
File dir = new File(FileUtils.getPath(FileUtils.PICTURES_DIR));
|
||||||
|
deleteDirectoryRecurse(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -208,6 +213,26 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
}
|
}
|
||||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
||||||
new String[] { Long.toString(trackId) });
|
new String[] { Long.toString(trackId) });
|
||||||
|
|
||||||
|
File dir = new File(
|
||||||
|
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(trackId)));
|
||||||
|
deleteDirectoryRecurse(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the directory recursively.
|
||||||
|
*
|
||||||
|
* @param dir the directory
|
||||||
|
*/
|
||||||
|
private void deleteDirectoryRecurse(File dir) {
|
||||||
|
if (FileUtils.isDirectory(dir)) {
|
||||||
|
for (File child : dir.listFiles()) {
|
||||||
|
deleteDirectoryRecurse(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dir.exists()) {
|
||||||
|
dir.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -499,6 +524,20 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (waypoint != null) {
|
||||||
|
String photoUrl = waypoint.getPhotoUrl();
|
||||||
|
if (photoUrl != null && !photoUrl.equals("")) {
|
||||||
|
Uri uri = Uri.parse(photoUrl);
|
||||||
|
File file = new File(uri.getPath());
|
||||||
|
if (file.exists()) {
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
file.delete();
|
||||||
|
if (parent.listFiles().length == 0) {
|
||||||
|
parent.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns._ID + "=?",
|
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns._ID + "=?",
|
||||||
new String[] { Long.toString(waypointId) });
|
new String[] { Long.toString(waypointId) });
|
||||||
}
|
}
|
||||||
|
|||||||
-6
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.util;
|
package com.google.android.apps.mytracks.util;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -43,14 +41,12 @@ public class FileUtils {
|
|||||||
/**
|
/**
|
||||||
* The My Tracks external storage directory.
|
* The My Tracks external storage directory.
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
|
||||||
static final String SDCARD_TOP_DIR = "MyTracks";
|
static final String SDCARD_TOP_DIR = "MyTracks";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum FAT32 path length. See the FAT32 spec at
|
* The maximum FAT32 path length. See the FAT32 spec at
|
||||||
* http://msdn.microsoft.com/en-us/windows/hardware/gg463080
|
* http://msdn.microsoft.com/en-us/windows/hardware/gg463080
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
|
||||||
static final int MAX_FAT32_PATH_LENGTH = 260;
|
static final int MAX_FAT32_PATH_LENGTH = 260;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +202,6 @@ public class FileUtils {
|
|||||||
*
|
*
|
||||||
* @param name name
|
* @param name name
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
|
||||||
static String sanitizeFileName(String name) {
|
static String sanitizeFileName(String name) {
|
||||||
StringBuffer buffer = new StringBuffer(name.length());
|
StringBuffer buffer = new StringBuffer(name.length());
|
||||||
for (int i = 0; i < name.length(); i++) {
|
for (int i = 0; i < name.length(); i++) {
|
||||||
@@ -266,7 +261,6 @@ public class FileUtils {
|
|||||||
* @param name name
|
* @param name name
|
||||||
* @param suffix suffix
|
* @param suffix suffix
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
|
||||||
static String truncateFileName(File directory, String name, String suffix) {
|
static String truncateFileName(File directory, String name, String suffix) {
|
||||||
// 1 at the end accounts for the FAT32 filename trailing NUL character
|
// 1 at the end accounts for the FAT32 filename trailing NUL character
|
||||||
int requiredLength = directory.getPath().length() + suffix.length() + 1;
|
int requiredLength = directory.getPath().length() + suffix.length() + 1;
|
||||||
Reference in New Issue
Block a user