forked from upstream-mirrors/OpenTracks
Code cleanup.
This commit is contained in:
@@ -27,6 +27,7 @@ import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragme
|
|||||||
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.ConfirmDeleteDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ConfirmDeleteDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.MarkerDetailFragment;
|
||||||
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.services.TrackRecordingServiceConnection;
|
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||||
|
|||||||
+11
-15
@@ -477,23 +477,19 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (waypoint != null) {
|
if (waypoint != null && waypoint.hasPhoto()) {
|
||||||
String photoUrl = waypoint.getPhotoUrl();
|
Uri uri = waypoint.getPhotoURI();
|
||||||
if (photoUrl != null && !photoUrl.equals("")) {
|
File file = new File(uri.getPath());
|
||||||
Uri uri = Uri.parse(photoUrl);
|
if (file.exists()) {
|
||||||
File file = new File(uri.getPath());
|
File parent = file.getParentFile();
|
||||||
if (file.exists()) {
|
file.delete();
|
||||||
File parent = file.getParentFile();
|
FileUtils.updateMediaScanner(context, uri);
|
||||||
file.delete();
|
if (parent.listFiles().length == 0) {
|
||||||
FileUtils.updateMediaScanner(context, uri);
|
parent.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) });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-2
@@ -32,8 +32,7 @@ import android.provider.BaseColumns;
|
|||||||
public interface TrackPointsColumns extends BaseColumns {
|
public interface TrackPointsColumns extends BaseColumns {
|
||||||
|
|
||||||
String TABLE_NAME = "trackpoints";
|
String TABLE_NAME = "trackpoints";
|
||||||
Uri CONTENT_URI = Uri.parse(
|
Uri CONTENT_URI = Uri.parse("content://com.google.android.maps.mytracks/trackpoints");
|
||||||
"content://com.google.android.maps.mytracks/trackpoints");
|
|
||||||
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.trackpoint";
|
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.trackpoint";
|
||||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.trackpoint";
|
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.trackpoint";
|
||||||
String DEFAULT_SORT_ORDER = "_id";
|
String DEFAULT_SORT_ORDER = "_id";
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
/**
|
/**
|
||||||
* Tracks provider uri.
|
* Tracks provider uri.
|
||||||
*/
|
*/
|
||||||
Uri CONTENT_URI = Uri.parse(
|
Uri CONTENT_URI = Uri.parse("content://com.google.android.maps.mytracks/tracks");
|
||||||
"content://com.google.android.maps.mytracks/tracks");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Track content type.
|
* Track content type.
|
||||||
|
|||||||
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.content;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A waypoint.
|
* A waypoint.
|
||||||
*
|
*
|
||||||
@@ -243,6 +246,14 @@ public final class Waypoint implements Parcelable {
|
|||||||
return photoUrl;
|
return photoUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri getPhotoURI() {
|
||||||
|
return Uri.parse(photoUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPhoto() {
|
||||||
|
return photoUrl != null && !"".equals(photoUrl);
|
||||||
|
}
|
||||||
|
|
||||||
public void setPhotoUrl(String photoUrl) {
|
public void setPhotoUrl(String photoUrl) {
|
||||||
this.photoUrl = photoUrl;
|
this.photoUrl = photoUrl;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-9
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.fragments;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -184,9 +183,7 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
|
|
||||||
updateWaypoint(false);
|
updateWaypoint(false);
|
||||||
|
|
||||||
String photoUrl = waypoint.getPhotoUrl();
|
menu.findItem(R.id.marker_detail_view_photo).setVisible(waypoint.hasPhoto());
|
||||||
boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
|
|
||||||
menu.findItem(R.id.marker_detail_view_photo).setVisible(hasPhoto);
|
|
||||||
|
|
||||||
TrackIconUtils.setMenuIconColor(menu);
|
TrackIconUtils.setMenuIconColor(menu);
|
||||||
}
|
}
|
||||||
@@ -215,7 +212,7 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
case R.id.marker_detail_view_photo:
|
case R.id.marker_detail_view_photo:
|
||||||
intent = new Intent();
|
intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(Uri.parse(waypoint.getPhotoUrl()), "image/*");
|
intent.setDataAndType(waypoint.getPhotoURI(), "image/*");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@@ -250,8 +247,7 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE);
|
statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
if (isWaypoint) {
|
if (isWaypoint) {
|
||||||
String photoUrl = waypoint.getPhotoUrl();
|
boolean hasPhoto = waypoint.hasPhoto();
|
||||||
boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
|
|
||||||
photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
||||||
textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
||||||
waypointInfo.setVisibility(View.VISIBLE);
|
waypointInfo.setVisibility(View.VISIBLE);
|
||||||
@@ -259,8 +255,7 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
if (hasPhoto) {
|
if (hasPhoto) {
|
||||||
handler.removeCallbacks(hideText);
|
handler.removeCallbacks(hideText);
|
||||||
Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay();
|
Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay();
|
||||||
PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(),
|
PhotoUtils.setImageView(photo, waypoint.getPhotoURI(), defaultDisplay.getWidth(), defaultDisplay.getHeight(), true);
|
||||||
defaultDisplay.getHeight(), true);
|
|
||||||
handler.postDelayed(hideText, HIDE_TEXT_DELAY);
|
handler.postDelayed(hideText, HIDE_TEXT_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -169,16 +169,12 @@ public class KmlTrackWriter implements TrackWriter {
|
|||||||
@Override
|
@Override
|
||||||
public void writeWaypoint(Waypoint waypoint) {
|
public void writeWaypoint(Waypoint waypoint) {
|
||||||
if (printWriter != null) {
|
if (printWriter != null) {
|
||||||
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE
|
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE : WAYPOINT_STYLE;
|
||||||
: WAYPOINT_STYLE;
|
if (waypoint.hasPhoto()) {
|
||||||
String photoUrl = waypoint.getPhotoUrl();
|
|
||||||
if (photoUrl != null && !photoUrl.equals("")) {
|
|
||||||
float heading = getHeading(waypoint.getTrackId(), waypoint.getLocation());
|
float heading = getHeading(waypoint.getTrackId(), waypoint.getLocation());
|
||||||
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
|
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), styleName, waypoint.getLocation(), waypoint.getPhotoUrl(), heading);
|
||||||
styleName, waypoint.getLocation(), photoUrl, heading);
|
|
||||||
} else {
|
} else {
|
||||||
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
|
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), styleName, waypoint.getLocation());
|
||||||
styleName, waypoint.getLocation());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -122,9 +122,8 @@ public class KmzTrackExporter implements TrackExporter {
|
|||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
}
|
}
|
||||||
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
||||||
String photoUrl = waypoint.getPhotoUrl();
|
if (waypoint.hasPhoto()) {
|
||||||
if (photoUrl != null && !photoUrl.equals("")) {
|
addImage(zipOutputStream, waypoint.getPhotoUrl());
|
||||||
addImage(zipOutputStream, photoUrl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ public class ListItemUtils {
|
|||||||
photo.getLayoutParams().height = photoHeight;
|
photo.getLayoutParams().height = photoHeight;
|
||||||
photo.setImageResource(android.R.color.transparent);
|
photo.setImageResource(android.R.color.transparent);
|
||||||
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
||||||
PhotoUtils.setImageVew(
|
PhotoUtils.setImageView(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), photoHeight, false);
|
||||||
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), photoHeight, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set icon
|
// Set icon
|
||||||
|
|||||||
@@ -43,13 +43,10 @@ public class PhotoUtils {
|
|||||||
* entire image (no cropping). False to fill the entire target area.
|
* entire image (no cropping). False to fill the entire target area.
|
||||||
* (allow cropping).
|
* (allow cropping).
|
||||||
*/
|
*/
|
||||||
public static void setImageVew(
|
public static void setImageView(ImageView imageView, Uri uri, int targetWidth, int targetHeight, boolean fitWithin) {
|
||||||
ImageView imageView, Uri uri, int targetWidth, int targetHeight, boolean fitWithin) {
|
|
||||||
if (cancelBitmapLoader(imageView, uri)) {
|
if (cancelBitmapLoader(imageView, uri)) {
|
||||||
BitmapLoader bitmapLoader = new BitmapLoader(
|
BitmapLoader bitmapLoader = new BitmapLoader(imageView, uri, targetWidth, targetHeight, fitWithin);
|
||||||
imageView, uri, targetWidth, targetHeight, fitWithin);
|
WeakReference<BitmapLoader> bitmapLoaderReference = new WeakReference<>(bitmapLoader);
|
||||||
WeakReference<BitmapLoader> bitmapLoaderReference = new WeakReference<>(
|
|
||||||
bitmapLoader);
|
|
||||||
imageView.setTag(bitmapLoaderReference);
|
imageView.setTag(bitmapLoaderReference);
|
||||||
bitmapLoader.execute();
|
bitmapLoader.execute();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user