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.
|
* Inserts a waypoint marker.
|
||||||
*
|
*
|
||||||
* @return Id of the inserted statistics 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 {
|
public long insertWaypoint(WaypointCreationRequest request) throws RemoteException {
|
||||||
if (trackRecordingService == null) {
|
if (trackRecordingService == null) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import android.widget.ImageView;
|
|||||||
public class MyTracksWaypointDetails extends Activity
|
public class MyTracksWaypointDetails extends Activity
|
||||||
implements OnClickListener {
|
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")
|
* 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);
|
Log.e(MyTracksConstants.TAG, "Cannot insert marker.", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (id >= 0) {
|
if (id < 0) {
|
||||||
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
Log.e(MyTracksConstants.TAG, "Failed to insert marker.");
|
||||||
intent.putExtra(MyTracksWaypointDetails.WAYPOINT_ID_EXTRA, id);
|
return;
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
|
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
||||||
|
intent.putExtra(MyTracksWaypointDetails.WAYPOINT_ID_EXTRA, id);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListAdapter() {
|
private void setListAdapter() {
|
||||||
|
|||||||
@@ -889,10 +889,10 @@ public class TrackRecordingService extends Service implements LocationListener {
|
|||||||
|
|
||||||
private void buildMarker(Waypoint wpt, WaypointCreationRequest request) {
|
private void buildMarker(Waypoint wpt, WaypointCreationRequest request) {
|
||||||
wpt.setType(Waypoint.TYPE_WAYPOINT);
|
wpt.setType(Waypoint.TYPE_WAYPOINT);
|
||||||
if (request.getIcon() == null) {
|
if (request.getIconUrl() == null) {
|
||||||
wpt.setIcon(getString(R.string.waypoint_icon_url));
|
wpt.setIcon(getString(R.string.waypoint_icon_url));
|
||||||
} else {
|
} else {
|
||||||
wpt.setIcon(request.getIcon());
|
wpt.setIcon(request.getIconUrl());
|
||||||
}
|
}
|
||||||
if (request.getName() == null) {
|
if (request.getName() == null) {
|
||||||
wpt.setName(getString(R.string.waypoint));
|
wpt.setName(getString(R.string.waypoint));
|
||||||
|
|||||||
+31
-19
@@ -33,7 +33,7 @@ public class WaypointCreationRequest implements Parcelable {
|
|||||||
private WaypointType type;
|
private WaypointType type;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private String icon;
|
private String iconUrl;
|
||||||
|
|
||||||
public final static WaypointCreationRequest DEFAULT_MARKER =
|
public final static WaypointCreationRequest DEFAULT_MARKER =
|
||||||
new WaypointCreationRequest(WaypointType.MARKER);
|
new WaypointCreationRequest(WaypointType.MARKER);
|
||||||
@@ -44,6 +44,15 @@ public class WaypointCreationRequest implements Parcelable {
|
|||||||
this.type = type;
|
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 static class Creator implements Parcelable.Creator<WaypointCreationRequest> {
|
||||||
|
|
||||||
public WaypointCreationRequest createFromParcel(Parcel source) {
|
public WaypointCreationRequest createFromParcel(Parcel source) {
|
||||||
@@ -52,9 +61,17 @@ public class WaypointCreationRequest implements Parcelable {
|
|||||||
throw new IllegalArgumentException("Could not find waypoint type: " + i);
|
throw new IllegalArgumentException("Could not find waypoint type: " + i);
|
||||||
}
|
}
|
||||||
WaypointCreationRequest request = new WaypointCreationRequest(WaypointType.values()[i]);
|
WaypointCreationRequest request = new WaypointCreationRequest(WaypointType.values()[i]);
|
||||||
|
request.description = maybeReadStringToParcel(source);
|
||||||
|
request.iconUrl = maybeReadStringToParcel(source);
|
||||||
|
request.name = maybeReadStringToParcel(source);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String maybeReadStringToParcel(Parcel parcel) {
|
||||||
|
return parcel.readByte() > 0 ? parcel.readString() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public WaypointCreationRequest[] newArray(int size) {
|
public WaypointCreationRequest[] newArray(int size) {
|
||||||
return new WaypointCreationRequest[size];
|
return new WaypointCreationRequest[size];
|
||||||
}
|
}
|
||||||
@@ -70,37 +87,32 @@ public class WaypointCreationRequest implements Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel parcel, int arg1) {
|
public void writeToParcel(Parcel parcel, int arg1) {
|
||||||
parcel.writeInt(type.ordinal());
|
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() {
|
public WaypointType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(WaypointType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public String getIconUrl() {
|
||||||
this.description = description;
|
return iconUrl;
|
||||||
}
|
|
||||||
|
|
||||||
public String getIcon() {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIcon(String icon) {
|
|
||||||
this.icon = icon;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,6 @@ limitations under the License.
|
|||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<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.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-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" android:required="true"/>
|
||||||
<uses-feature android:name="android.hardware.telephony.gsm" android:required="false"/>
|
<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.
|
// Create a waypoint.
|
||||||
WaypointCreationRequest request =
|
WaypointCreationRequest request =
|
||||||
new WaypointCreationRequest(WaypointCreationRequest.WaypointType.MARKER);
|
new WaypointCreationRequest(WaypointCreationRequest.WaypointType.MARKER,
|
||||||
request.setName("Signal Strength");
|
"Signal Strength", icon, description);
|
||||||
request.setIcon(icon);
|
|
||||||
request.setDescription(description);
|
|
||||||
waypointId = mytracksService.insertWaypoint(request);
|
waypointId = mytracksService.insertWaypoint(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user