forked from upstream-mirrors/OpenTracks
Address comments.
This commit is contained in:
@@ -891,7 +891,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
* Inserts a waypoint marker.
|
||||
*
|
||||
* @return Id of the inserted statistics marker.
|
||||
* @throws RemoteException
|
||||
* @throws RemoteException If the call on the service failed.
|
||||
*/
|
||||
public long insertWaypoint(WaypointCreationRequest request) throws RemoteException {
|
||||
if (trackRecordingService == null) {
|
||||
|
||||
@@ -42,7 +42,7 @@ import android.widget.ImageView;
|
||||
public class MyTracksWaypointDetails extends Activity
|
||||
implements OnClickListener {
|
||||
|
||||
public static final String WAYPOINT_ID_EXTRA = "waypointid";
|
||||
public static final String WAYPOINT_ID_EXTRA = "com.google.android.apps.mytracks.WAYPOINT_ID";
|
||||
|
||||
/**
|
||||
* The id of the way point being edited (taken from bundle, "waypointid")
|
||||
|
||||
@@ -189,11 +189,13 @@ public class MyTracksWaypointsList extends ListActivity
|
||||
Log.e(MyTracksConstants.TAG, "Cannot insert marker.", e);
|
||||
return;
|
||||
}
|
||||
if (id >= 0) {
|
||||
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
||||
intent.putExtra(MyTracksWaypointDetails.WAYPOINT_ID_EXTRA, id);
|
||||
startActivity(intent);
|
||||
if (id < 0) {
|
||||
Log.e(MyTracksConstants.TAG, "Failed to insert marker.");
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
||||
intent.putExtra(MyTracksWaypointDetails.WAYPOINT_ID_EXTRA, id);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void setListAdapter() {
|
||||
|
||||
@@ -889,10 +889,10 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
|
||||
private void buildMarker(Waypoint wpt, WaypointCreationRequest request) {
|
||||
wpt.setType(Waypoint.TYPE_WAYPOINT);
|
||||
if (request.getIcon() == null) {
|
||||
if (request.getIconUrl() == null) {
|
||||
wpt.setIcon(getString(R.string.waypoint_icon_url));
|
||||
} else {
|
||||
wpt.setIcon(request.getIcon());
|
||||
wpt.setIcon(request.getIconUrl());
|
||||
}
|
||||
if (request.getName() == null) {
|
||||
wpt.setName(getString(R.string.waypoint));
|
||||
|
||||
+31
-19
@@ -33,7 +33,7 @@ public class WaypointCreationRequest implements Parcelable {
|
||||
private WaypointType type;
|
||||
private String name;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String iconUrl;
|
||||
|
||||
public final static WaypointCreationRequest DEFAULT_MARKER =
|
||||
new WaypointCreationRequest(WaypointType.MARKER);
|
||||
@@ -44,6 +44,15 @@ public class WaypointCreationRequest implements Parcelable {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public WaypointCreationRequest(WaypointType type, String name,
|
||||
String description, String iconUrl) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public static class Creator implements Parcelable.Creator<WaypointCreationRequest> {
|
||||
|
||||
public WaypointCreationRequest createFromParcel(Parcel source) {
|
||||
@@ -52,9 +61,17 @@ public class WaypointCreationRequest implements Parcelable {
|
||||
throw new IllegalArgumentException("Could not find waypoint type: " + i);
|
||||
}
|
||||
WaypointCreationRequest request = new WaypointCreationRequest(WaypointType.values()[i]);
|
||||
request.description = maybeReadStringToParcel(source);
|
||||
request.iconUrl = maybeReadStringToParcel(source);
|
||||
request.name = maybeReadStringToParcel(source);
|
||||
return request;
|
||||
}
|
||||
|
||||
private String maybeReadStringToParcel(Parcel parcel) {
|
||||
return parcel.readByte() > 0 ? parcel.readString() : null;
|
||||
}
|
||||
|
||||
|
||||
public WaypointCreationRequest[] newArray(int size) {
|
||||
return new WaypointCreationRequest[size];
|
||||
}
|
||||
@@ -70,37 +87,32 @@ public class WaypointCreationRequest implements Parcelable {
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int arg1) {
|
||||
parcel.writeInt(type.ordinal());
|
||||
// TODO: Pack all of available bits into one byte.
|
||||
maybeWriteStringToParcel(parcel, description);
|
||||
maybeWriteStringToParcel(parcel, iconUrl);
|
||||
maybeWriteStringToParcel(parcel, name);
|
||||
}
|
||||
|
||||
private void maybeWriteStringToParcel(Parcel parcel, String s) {
|
||||
parcel.writeByte(s == null ? (byte) 0 : (byte) 1);
|
||||
if (s != null) {
|
||||
parcel.writeString(s);
|
||||
}
|
||||
}
|
||||
|
||||
public WaypointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WaypointType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,6 @@ limitations under the License.
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="com.google.android.apps.mytracks.TRACK_NOTIFICATIONS" />
|
||||
<uses-permission android:name="com.google.android.apps.mytracks.READ_TRACK_DATA" />
|
||||
<uses-permission android:name="com.google.android.apps.mytracks.WRITE_TRACK_DATA" />
|
||||
<uses-feature android:name="android.hardware.telephony" android:required="true"/>
|
||||
<uses-feature android:name="android.hardware.telephony.gsm" android:required="false"/>
|
||||
|
||||
+2
-4
@@ -169,10 +169,8 @@ public class SignalStrengthService extends Service
|
||||
|
||||
// Create a waypoint.
|
||||
WaypointCreationRequest request =
|
||||
new WaypointCreationRequest(WaypointCreationRequest.WaypointType.MARKER);
|
||||
request.setName("Signal Strength");
|
||||
request.setIcon(icon);
|
||||
request.setDescription(description);
|
||||
new WaypointCreationRequest(WaypointCreationRequest.WaypointType.MARKER,
|
||||
"Signal Strength", icon, description);
|
||||
waypointId = mytracksService.insertWaypoint(request);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user