forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -261,6 +261,5 @@ limitations under the License.
|
|||||||
android:authorities="com.google.android.maps.mytracks.search"
|
android:authorities="com.google.android.maps.mytracks.search"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:name="com.google.android.apps.mytracks.content.SearchEngineProvider" />
|
android:name="com.google.android.apps.mytracks.content.SearchEngineProvider" />
|
||||||
<uses-library android:name="com.google.android.maps" />
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -11,6 +11,6 @@
|
|||||||
split.density=false
|
split.density=false
|
||||||
proguard.config=proguard.cfg
|
proguard.config=proguard.cfg
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:16
|
target=android-16
|
||||||
android.library.reference.1=../MyTracksLib
|
android.library.reference.1=../MyTracksLib
|
||||||
android.library.reference.2=../google_play_services_lib
|
android.library.reference.2=../google_play_services_lib
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 881 B |
Binary file not shown.
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -25,11 +25,11 @@ limitations under the License.
|
|||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:paddingTop="2dp" >
|
android:paddingTop="2dp" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/confirm_sharing_text_view"
|
|
||||||
android:autoLink="web"
|
android:autoLink="web"
|
||||||
|
android:id="@+id/confirm_dialog_message"
|
||||||
style="@style/TextMedium" />
|
style="@style/TextMedium" />
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/confirm_sharing_check_box"
|
android:id="@+id/confirm_dialog_check_box"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -25,7 +25,8 @@ limitations under the License.
|
|||||||
android:id="@+id/map_message"
|
android:id="@+id/map_message"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:padding="8dp"
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
android:textColor="@android:color/primary_text_dark"
|
android:textColor="@android:color/primary_text_dark"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
style="@style/TextMedium.WithIcon" />
|
style="@style/TextMedium.WithIcon" />
|
||||||
@@ -34,7 +35,7 @@ limitations under the License.
|
|||||||
android:contentDescription="@string/icon_my_location"
|
android:contentDescription="@string/icon_my_location"
|
||||||
android:id="@+id/map_my_location"
|
android:id="@+id/map_my_location"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_below="@id/map_message"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ limitations under the License.
|
|||||||
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
||||||
<string name="send_to_maps_key">sendToMaps</string>
|
<string name="send_to_maps_key">sendToMaps</string>
|
||||||
<string name="sensor_type_key">sensorType</string>
|
<string name="sensor_type_key">sensorType</string>
|
||||||
|
<string name="show_confirm_play_earth_dialog_key">showConfirmPlayDialog</string>
|
||||||
<string name="show_confirm_sharing_dialog_key">showConfrimSharingDialog</string>
|
<string name="show_confirm_sharing_dialog_key">showConfrimSharingDialog</string>
|
||||||
<string name="split_frequency_key">splitFrequency</string>
|
<string name="split_frequency_key">splitFrequency</string>
|
||||||
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
|
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
|
||||||
|
|||||||
@@ -758,12 +758,12 @@ limitations under the License.
|
|||||||
<string name="gps_wait_for_better_signal"
|
<string name="gps_wait_for_better_signal"
|
||||||
translation_description="In the main view, the message on the top indicating My Tracks is
|
translation_description="In the main view, the message on the top indicating My Tracks is
|
||||||
waiting for a better GPS signal.">
|
waiting for a better GPS signal.">
|
||||||
Waiting for a better GPS signal. Make sure the sky is visible.
|
Waiting for a better GPS signal.
|
||||||
</string>
|
</string>
|
||||||
<string name="gps_wait_for_signal"
|
<string name="gps_wait_for_signal"
|
||||||
translation_description="In the main view, the message on the top indicating My Tracks is
|
translation_description="In the main view, the message on the top indicating My Tracks is
|
||||||
waiting for a better GPS signal.">
|
waiting for GPS signal.">
|
||||||
Waiting for GPS signal. Make sure the sky is visible.
|
Waiting for GPS signal.
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
<!-- Help page -->
|
<!-- Help page -->
|
||||||
@@ -846,7 +846,7 @@ limitations under the License.
|
|||||||
</string>
|
</string>
|
||||||
<string name="help_gps_signal_question"
|
<string name="help_gps_signal_question"
|
||||||
translation_description="In the 'Help' page, the question on the GPS signal message.">
|
translation_description="In the 'Help' page, the question on the GPS signal message.">
|
||||||
Why does the application sometimes display “Waiting for a better GPS signal.”?
|
Why does the application sometimes display “Waiting for GPS signal.”?
|
||||||
</string>
|
</string>
|
||||||
<string name="help_location_precision_answer"
|
<string name="help_location_precision_answer"
|
||||||
translation_description="In the 'Help' page, the answer on location precision.">
|
translation_description="In the 'Help' page, the answer on location precision.">
|
||||||
@@ -2267,6 +2267,10 @@ limitations under the License.
|
|||||||
translation_description="In the track detail page, the title of the tab showing the map.">
|
translation_description="In the track detail page, the title of the tab showing the map.">
|
||||||
Map
|
Map
|
||||||
</string>
|
</string>
|
||||||
|
<string name="track_detail_play_confirm_message"
|
||||||
|
translation_description="The confirmation message when playing a track in Google Earth.">
|
||||||
|
Play in Google Earth will save your track to external storage.
|
||||||
|
</string>
|
||||||
<string name="track_detail_stats_tab"
|
<string name="track_detail_stats_tab"
|
||||||
translation_description="In the track detail page, the title of the tab showing the stats.">
|
translation_description="In the track detail page, the title of the tab showing the stats.">
|
||||||
Stats
|
Stats
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
|||||||
import com.google.android.apps.mytracks.fragments.ChartFragment;
|
import com.google.android.apps.mytracks.fragments.ChartFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseUploadServiceDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ChooseUploadServiceDialogFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ConfirmPlayDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
||||||
@@ -321,12 +322,8 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
|||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_play:
|
case R.id.track_detail_play:
|
||||||
if (isEarthInstalled()) {
|
if (isEarthInstalled()) {
|
||||||
AnalyticsUtils.sendPageViews(this, "/action/play");
|
ConfirmPlayDialogFragment.newInstance(trackId)
|
||||||
intent = IntentUtils.newIntent(this, SaveActivity.class)
|
.show(getSupportFragmentManager(), ConfirmPlayDialogFragment.CONFIRM_PLAY_DIALOG_TAG);
|
||||||
.putExtra(SaveActivity.EXTRA_TRACK_ID, trackId)
|
|
||||||
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.KML)
|
|
||||||
.putExtra(SaveActivity.EXTRA_PLAY_TRACK, true);
|
|
||||||
startActivity(intent);
|
|
||||||
} else {
|
} else {
|
||||||
new InstallEarthDialogFragment().show(
|
new InstallEarthDialogFragment().show(
|
||||||
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.google.android.apps.mytracks.content.TrackDataListener;
|
|||||||
import com.google.android.apps.mytracks.content.TrackDataType;
|
import com.google.android.apps.mytracks.content.TrackDataType;
|
||||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||||
import com.google.android.apps.mytracks.content.Waypoint;
|
import com.google.android.apps.mytracks.content.Waypoint;
|
||||||
import com.google.android.apps.mytracks.fragments.CheckUnitsDialogFragment;
|
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment;
|
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
||||||
@@ -48,6 +47,7 @@ import com.google.android.maps.mytracks.R;
|
|||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
@@ -87,6 +87,7 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
|||||||
|
|
||||||
private static final String TAG = TrackListActivity.class.getSimpleName();
|
private static final String TAG = TrackListActivity.class.getSimpleName();
|
||||||
private static final String START_GPS_KEY = "start_gps_key";
|
private static final String START_GPS_KEY = "start_gps_key";
|
||||||
|
private static final int GOOGLE_PLAY_SERVICES_REQUEST_CODE = 0;
|
||||||
private static final String[] PROJECTION = new String[] { TracksColumns._ID, TracksColumns.NAME,
|
private static final String[] PROJECTION = new String[] { TracksColumns._ID, TracksColumns.NAME,
|
||||||
TracksColumns.DESCRIPTION, TracksColumns.CATEGORY, TracksColumns.STARTTIME,
|
TracksColumns.DESCRIPTION, TracksColumns.CATEGORY, TracksColumns.STARTTIME,
|
||||||
TracksColumns.TOTALDISTANCE, TracksColumns.TOTALTIME, TracksColumns.ICON };
|
TracksColumns.TOTALDISTANCE, TracksColumns.TOTALTIME, TracksColumns.ICON };
|
||||||
@@ -163,7 +164,8 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
|||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
|
boolean isRecording = recordingTrackId
|
||||||
|
!= PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
|
||||||
updateMenuItems(isRecording);
|
updateMenuItems(isRecording);
|
||||||
resourceCursorAdapter.notifyDataSetChanged();
|
resourceCursorAdapter.notifyDataSetChanged();
|
||||||
trackController.update(isRecording, recordingTrackPaused);
|
trackController.update(isRecording, recordingTrackPaused);
|
||||||
@@ -434,13 +436,6 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
|||||||
updateMenuItems(isRecording);
|
updateMenuItems(isRecording);
|
||||||
resourceCursorAdapter.notifyDataSetChanged();
|
resourceCursorAdapter.notifyDataSetChanged();
|
||||||
trackController.update(isRecording, recordingTrackPaused);
|
trackController.update(isRecording, recordingTrackPaused);
|
||||||
|
|
||||||
// Check Google Play Services
|
|
||||||
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
|
|
||||||
if (code != ConnectionResult.SUCCESS) {
|
|
||||||
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(code, this, 0);
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -474,6 +469,15 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
|||||||
outState.putBoolean(START_GPS_KEY, startGps);
|
outState.putBoolean(START_GPS_KEY, startGps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (requestCode == GOOGLE_PLAY_SERVICES_REQUEST_CODE) {
|
||||||
|
checkGooglePlayServices();
|
||||||
|
} else {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.track_list, menu);
|
getMenuInflater().inflate(R.menu.track_list, menu);
|
||||||
@@ -595,19 +599,31 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
|||||||
new WelcomeDialogFragment().show(
|
new WelcomeDialogFragment().show(
|
||||||
getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
} else if (EulaUtils.getShowCheckUnits(this)) {
|
|
||||||
Fragment fragment = getSupportFragmentManager()
|
|
||||||
.findFragmentByTag(CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
|
|
||||||
if (fragment == null) {
|
|
||||||
new CheckUnitsDialogFragment().show(
|
|
||||||
getSupportFragmentManager(), CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Before the welcome sequence, the empty view is not visible so that it
|
* Before the welcome sequence, the empty view is not visible so that it
|
||||||
* doesn't show through.
|
* doesn't show through.
|
||||||
*/
|
*/
|
||||||
findViewById(R.id.track_list_empty_view).setVisibility(View.VISIBLE);
|
findViewById(R.id.track_list_empty_view).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
checkGooglePlayServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkGooglePlayServices() {
|
||||||
|
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
|
||||||
|
if (code != ConnectionResult.SUCCESS) {
|
||||||
|
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
|
||||||
|
code, this, GOOGLE_PLAY_SERVICES_REQUEST_CODE, new DialogInterface.OnCancelListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialogInterface) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (dialog != null) {
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.fragments;
|
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.TrackListActivity;
|
|
||||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A DialogFragment to check preferred units.
|
|
||||||
*
|
|
||||||
* @author Jimmy Shih
|
|
||||||
*/
|
|
||||||
public class CheckUnitsDialogFragment extends DialogFragment {
|
|
||||||
|
|
||||||
public static final String CHECK_UNITS_DIALOG_TAG = "checkUnitsDialog";
|
|
||||||
|
|
||||||
private FragmentActivity activity;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface arg0) {
|
|
||||||
onDone();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
activity = getActivity();
|
|
||||||
|
|
||||||
Locale defaultLocale = Locale.getDefault();
|
|
||||||
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
|
|
||||||
PreferencesUtils.setBoolean(activity, R.string.metric_units_key, defaultMetric);
|
|
||||||
final String metric = getString(R.string.settings_stats_units_metric);
|
|
||||||
final String imperial = getString(R.string.settings_stats_units_imperial);
|
|
||||||
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
|
|
||||||
: new CharSequence[] { imperial, metric };
|
|
||||||
return new AlertDialog.Builder(activity).setPositiveButton(
|
|
||||||
R.string.generic_ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
|
||||||
PreferencesUtils.setBoolean(
|
|
||||||
activity, R.string.metric_units_key, items[position].equals(metric));
|
|
||||||
onDone();
|
|
||||||
}
|
|
||||||
}).setSingleChoiceItems(items, 0, null).setTitle(R.string.settings_stats_units_title)
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tasks to perform when done.
|
|
||||||
*/
|
|
||||||
private void onDone() {
|
|
||||||
EulaUtils.setShowCheckUnits(activity);
|
|
||||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
|
||||||
trackListActivity.showStartupDialogs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.io.file.SaveActivity;
|
||||||
|
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
|
||||||
|
import com.google.android.apps.mytracks.util.AnalyticsUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DialogFragment to confirm play in Google Earth.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
public class ConfirmPlayDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String CONFIRM_PLAY_DIALOG_TAG = "confirmPlayDialog";
|
||||||
|
private static final String KEY_TRACK_ID = "trackId";
|
||||||
|
|
||||||
|
private FragmentActivity activity;
|
||||||
|
private CheckBox checkBox;
|
||||||
|
|
||||||
|
public static ConfirmPlayDialogFragment newInstance(long trackId) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(KEY_TRACK_ID, trackId);
|
||||||
|
|
||||||
|
ConfirmPlayDialogFragment confirmPlayDialogFragment = new ConfirmPlayDialogFragment();
|
||||||
|
confirmPlayDialogFragment.setArguments(bundle);
|
||||||
|
return confirmPlayDialogFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
activity = getActivity();
|
||||||
|
if (!PreferencesUtils.getBoolean(getActivity(), R.string.show_confirm_play_earth_dialog_key,
|
||||||
|
PreferencesUtils.SHOW_CONFIRM_PLAY_DIALOG_DEFAULT)) {
|
||||||
|
dismiss();
|
||||||
|
playTrack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playTrack() {
|
||||||
|
long trackId = getArguments().getLong(KEY_TRACK_ID);
|
||||||
|
AnalyticsUtils.sendPageViews(activity, "/action/play");
|
||||||
|
Intent intent = IntentUtils.newIntent(activity, SaveActivity.class)
|
||||||
|
.putExtra(SaveActivity.EXTRA_TRACK_ID, trackId)
|
||||||
|
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.KML)
|
||||||
|
.putExtra(SaveActivity.EXTRA_PLAY_TRACK, true);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
View view = activity.getLayoutInflater().inflate(R.layout.confirm_dialog, null);
|
||||||
|
TextView textView = (TextView) view.findViewById(R.id.confirm_dialog_message);
|
||||||
|
textView.setText(R.string.track_detail_play_confirm_message);
|
||||||
|
checkBox = (CheckBox) view.findViewById(R.id.confirm_dialog_check_box);
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(activity)
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
PreferencesUtils.setBoolean(
|
||||||
|
activity, R.string.show_confirm_play_earth_dialog_key, !checkBox.isChecked());
|
||||||
|
playTrack();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTitle(R.string.generic_confirm_title)
|
||||||
|
.setView(view)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.fragments;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.TrackListActivity;
|
import com.google.android.apps.mytracks.TrackListActivity;
|
||||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@@ -27,6 +28,8 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DialogFragment to show EULA.
|
* A DialogFragment to show EULA.
|
||||||
*
|
*
|
||||||
@@ -84,6 +87,8 @@ public class EulaDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
EulaUtils.setAcceptEula(activity);
|
EulaUtils.setAcceptEula(activity);
|
||||||
|
PreferencesUtils.setBoolean(
|
||||||
|
activity, R.string.metric_units_key, !Locale.US.equals(Locale.getDefault()));
|
||||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||||
trackListActivity.showStartupDialogs();
|
trackListActivity.showStartupDialogs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,14 +120,14 @@ public class SaveActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
onPostResultDialog();
|
finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int arg1) {
|
public void onClick(DialogInterface dialog, int arg1) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
onPostResultDialog();
|
finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setTitle(success ? R.string.generic_success_title : R.string.generic_error_title);
|
.setTitle(success ? R.string.generic_success_title : R.string.generic_error_title);
|
||||||
@@ -163,7 +163,17 @@ public class SaveActivity extends Activity {
|
|||||||
this.messageId = aMessageId;
|
this.messageId = aMessageId;
|
||||||
this.savedPath = aSavedPath;
|
this.savedPath = aSavedPath;
|
||||||
removeDialog(DIALOG_PROGRESS_ID);
|
removeDialog(DIALOG_PROGRESS_ID);
|
||||||
showDialog(DIALOG_RESULT_ID);
|
if (success && playTrack && savedPath != null) {
|
||||||
|
Intent intent = new Intent()
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.putExtra(GOOGLE_EARTH_TOUR_FEATURE_ID, KmlTrackWriter.TOUR_FEATURE_ID)
|
||||||
|
.setClassName(GOOGLE_EARTH_PACKAGE, GOOGLE_EARTH_CLASS)
|
||||||
|
.setDataAndType(Uri.fromFile(new File(savedPath)), GOOGLE_EARTH_KML_MIME_TYPE);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
showDialog(DIALOG_RESULT_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,19 +196,4 @@ public class SaveActivity extends Activity {
|
|||||||
progressDialog.setProgress(Math.min(number, max));
|
progressDialog.setProgress(Math.min(number, max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To be invoked after showing the result dialog.
|
|
||||||
*/
|
|
||||||
private void onPostResultDialog() {
|
|
||||||
if (success && playTrack && savedPath != null) {
|
|
||||||
Intent intent = new Intent()
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
.putExtra(GOOGLE_EARTH_TOUR_FEATURE_ID, KmlTrackWriter.TOUR_FEATURE_ID)
|
|
||||||
.setClassName(GOOGLE_EARTH_PACKAGE, GOOGLE_EARTH_CLASS)
|
|
||||||
.setDataAndType(Uri.fromFile(new File(savedPath)), GOOGLE_EARTH_KML_MIME_TYPE);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2009 Google Inc. All Rights Reserved.
|
// Copyright 2009 Google Inc. All Rights Reserved.
|
||||||
package com.google.android.apps.mytracks.io.gdata.maps;
|
package com.google.android.apps.mytracks.io.gdata.maps;
|
||||||
|
|
||||||
import com.google.android.maps.GeoPoint;
|
import android.location.Location;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
@@ -32,17 +32,8 @@ public class MapsFeature {
|
|||||||
/** The local feature id for this feature, if needed. */
|
/** The local feature id for this feature, if needed. */
|
||||||
private String androidId;
|
private String androidId;
|
||||||
|
|
||||||
/**
|
// Points of this feature in order.
|
||||||
* The latitudes of the points of this feature in order, specified in
|
private final Vector<Location> points = new Vector<Location>();
|
||||||
* millionths of a degree north.
|
|
||||||
*/
|
|
||||||
private final Vector<Integer> latitudeE6 = new Vector<Integer>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The longitudes of the points of this feature in order, specified in
|
|
||||||
* millionths of a degree east.
|
|
||||||
*/
|
|
||||||
private final Vector<Integer> longitudeE6 = new Vector<Integer>();
|
|
||||||
|
|
||||||
/** The metadata of this feature in a format efficient for transmission. */
|
/** The metadata of this feature in a format efficient for transmission. */
|
||||||
private MapsFeatureMetadata featureInfo = new MapsFeatureMetadata();
|
private MapsFeatureMetadata featureInfo = new MapsFeatureMetadata();
|
||||||
@@ -60,11 +51,10 @@ public class MapsFeature {
|
|||||||
/**
|
/**
|
||||||
* Adds a new point to the end of this feature.
|
* Adds a new point to the end of this feature.
|
||||||
*
|
*
|
||||||
* @param point The new point to add
|
* @param location the new point to add
|
||||||
*/
|
*/
|
||||||
public void addPoint(GeoPoint point) {
|
public void addPoint(Location location) {
|
||||||
latitudeE6.add(point.getLatitudeE6());
|
points.add(location);
|
||||||
longitudeE6.add(point.getLongitudeE6());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,26 +97,22 @@ public class MapsFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the point at the given index for this feature.
|
* Gets the point at a given index.
|
||||||
*
|
*
|
||||||
* @param index The index of the point desired
|
* @param index the index
|
||||||
* @return A {@link GeoPoint} representing the point or null if that point
|
|
||||||
* doesn't exist
|
|
||||||
*/
|
*/
|
||||||
public GeoPoint getPoint(int index) {
|
public Location getPoint(int index) {
|
||||||
if (latitudeE6.size() <= index) {
|
if (index >= points.size()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new GeoPoint(latitudeE6.get(index), longitudeE6.get(index));
|
return points.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts the number of points in this feature and return that count.
|
* Gets the number of points.
|
||||||
*
|
|
||||||
* @return The number of points in this feature
|
|
||||||
*/
|
*/
|
||||||
public int getPointCount() {
|
public int getPointCount() {
|
||||||
return latitudeE6.size();
|
return points.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ public class MapsGDataConverter {
|
|||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
pointBuilder.append('\n');
|
pointBuilder.append('\n');
|
||||||
}
|
}
|
||||||
pointBuilder.append(feature.getPoint(i).getLongitudeE6() / 1e6);
|
pointBuilder.append(feature.getPoint(i).getLongitude());
|
||||||
pointBuilder.append(',');
|
pointBuilder.append(',');
|
||||||
pointBuilder.append(feature.getPoint(i).getLatitudeE6() / 1e6);
|
pointBuilder.append(feature.getPoint(i).getLatitude());
|
||||||
pointBuilder.append(",0.000000");
|
pointBuilder.append(",0.000000");
|
||||||
}
|
}
|
||||||
String pointString = pointBuilder.toString();
|
String pointString = pointBuilder.toString();
|
||||||
@@ -157,9 +157,9 @@ public class MapsGDataConverter {
|
|||||||
xmlSerializer.endTag(null, "tessellate");
|
xmlSerializer.endTag(null, "tessellate");
|
||||||
xmlSerializer.startTag(null, "coordinates");
|
xmlSerializer.startTag(null, "coordinates");
|
||||||
xmlSerializer.text(pointString + "\n"
|
xmlSerializer.text(pointString + "\n"
|
||||||
+ Double.toString(feature.getPoint(0).getLongitudeE6() / 1e6)
|
+ Double.toString(feature.getPoint(0).getLongitude())
|
||||||
+ ","
|
+ ","
|
||||||
+ Double.toString(feature.getPoint(0).getLatitudeE6() / 1e6)
|
+ Double.toString(feature.getPoint(0).getLatitude())
|
||||||
+ ",0.000000");
|
+ ",0.000000");
|
||||||
xmlSerializer.endTag(null, "coordinates");
|
xmlSerializer.endTag(null, "coordinates");
|
||||||
xmlSerializer.endTag(null, "LinearRing");
|
xmlSerializer.endTag(null, "LinearRing");
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.google.android.apps.mytracks.io.gdata.maps.MapsClient;
|
|||||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
||||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsGDataConverter;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsGDataConverter;
|
||||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsMapMetadata;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsMapMetadata;
|
||||||
import com.google.android.maps.GeoPoint;
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.wireless.gdata.client.HttpException;
|
import com.google.wireless.gdata.client.HttpException;
|
||||||
import com.google.wireless.gdata.data.Entry;
|
import com.google.wireless.gdata.data.Entry;
|
||||||
@@ -108,7 +107,7 @@ public class SendMapsUtils {
|
|||||||
MapsGDataConverter mapsGDataConverter) throws ParseException, HttpException, IOException {
|
MapsGDataConverter mapsGDataConverter) throws ParseException, HttpException, IOException {
|
||||||
String featuresFeed = MapsClient.getFeaturesFeed(mapId);
|
String featuresFeed = MapsClient.getFeaturesFeed(mapId);
|
||||||
MapsFeature mapsFeature = buildMapsMarkerFeature(
|
MapsFeature mapsFeature = buildMapsMarkerFeature(
|
||||||
title, description, iconUrl, getGeoPoint(location));
|
title, description, iconUrl, location);
|
||||||
Entry entry = mapsGDataConverter.getEntryForFeature(mapsFeature);
|
Entry entry = mapsGDataConverter.getEntryForFeature(mapsFeature);
|
||||||
try {
|
try {
|
||||||
mapsClient.createEntry(featuresFeed, authToken, entry);
|
mapsClient.createEntry(featuresFeed, authToken, entry);
|
||||||
@@ -135,7 +134,7 @@ public class SendMapsUtils {
|
|||||||
throws ParseException, HttpException, IOException {
|
throws ParseException, HttpException, IOException {
|
||||||
String featuresFeed = MapsClient.getFeaturesFeed(mapId);
|
String featuresFeed = MapsClient.getFeaturesFeed(mapId);
|
||||||
MapsFeature feature = buildMapsMarkerFeature(waypoint.getName(), waypoint.getDescription(),
|
MapsFeature feature = buildMapsMarkerFeature(waypoint.getName(), waypoint.getDescription(),
|
||||||
waypoint.getIcon(), getGeoPoint(waypoint.getLocation()));
|
waypoint.getIcon(), waypoint.getLocation());
|
||||||
Entry entry = mapsGDataConverter.getEntryForFeature(feature);
|
Entry entry = mapsGDataConverter.getEntryForFeature(feature);
|
||||||
try {
|
try {
|
||||||
mapsClient.createEntry(featuresFeed, authToken, entry);
|
mapsClient.createEntry(featuresFeed, authToken, entry);
|
||||||
@@ -179,11 +178,11 @@ public class SendMapsUtils {
|
|||||||
* @param title feature title
|
* @param title feature title
|
||||||
* @param description the feature description
|
* @param description the feature description
|
||||||
* @param iconUrl the feature icon URL
|
* @param iconUrl the feature icon URL
|
||||||
* @param geoPoint the marker
|
* @param location the marker
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static MapsFeature buildMapsMarkerFeature(
|
static MapsFeature buildMapsMarkerFeature(
|
||||||
String title, String description, String iconUrl, GeoPoint geoPoint) {
|
String title, String description, String iconUrl, Location location) {
|
||||||
MapsFeature mapsFeature = new MapsFeature();
|
MapsFeature mapsFeature = new MapsFeature();
|
||||||
mapsFeature.setType(MapsFeature.MARKER);
|
mapsFeature.setType(MapsFeature.MARKER);
|
||||||
mapsFeature.generateAndroidId();
|
mapsFeature.generateAndroidId();
|
||||||
@@ -191,7 +190,7 @@ public class SendMapsUtils {
|
|||||||
mapsFeature.setTitle(TextUtils.isEmpty(title) ? EMPTY_TITLE : title);
|
mapsFeature.setTitle(TextUtils.isEmpty(title) ? EMPTY_TITLE : title);
|
||||||
mapsFeature.setDescription(description.replaceAll("\n", "<br>"));
|
mapsFeature.setDescription(description.replaceAll("\n", "<br>"));
|
||||||
mapsFeature.setIconUrl(iconUrl);
|
mapsFeature.setIconUrl(iconUrl);
|
||||||
mapsFeature.addPoint(geoPoint);
|
mapsFeature.addPoint(location);
|
||||||
return mapsFeature;
|
return mapsFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,19 +209,8 @@ public class SendMapsUtils {
|
|||||||
mapsFeature.setTitle(TextUtils.isEmpty(title) ? EMPTY_TITLE : title);
|
mapsFeature.setTitle(TextUtils.isEmpty(title) ? EMPTY_TITLE : title);
|
||||||
mapsFeature.setColor(LINE_COLOR);
|
mapsFeature.setColor(LINE_COLOR);
|
||||||
for (Location location : locations) {
|
for (Location location : locations) {
|
||||||
mapsFeature.addPoint(getGeoPoint(location));
|
mapsFeature.addPoint(location);
|
||||||
}
|
}
|
||||||
return mapsFeature;
|
return mapsFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a {@link GeoPoint} from a {@link Location}.
|
|
||||||
*
|
|
||||||
* @param location the location
|
|
||||||
*/
|
|
||||||
@VisibleForTesting
|
|
||||||
static GeoPoint getGeoPoint(Location location) {
|
|
||||||
return new GeoPoint(
|
|
||||||
(int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -60,13 +60,13 @@ public class ConfirmSharingActivity extends Activity {
|
|||||||
if (id != DIALOG_ID) {
|
if (id != DIALOG_ID) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
View view = getLayoutInflater().inflate(R.layout.confirm_sharing, null);
|
View view = getLayoutInflater().inflate(R.layout.confirm_dialog, null);
|
||||||
|
|
||||||
TextView textView = (TextView) view.findViewById(R.id.confirm_sharing_text_view);
|
TextView textView = (TextView) view.findViewById(R.id.confirm_dialog_message);
|
||||||
textView.setText(StringUtils.getHtml(
|
textView.setText(StringUtils.getHtml(
|
||||||
this, R.string.share_track_confirm_message, R.string.maps_public_unlisted_url));
|
this, R.string.share_track_confirm_message, R.string.maps_public_unlisted_url));
|
||||||
|
|
||||||
checkBox = (CheckBox) view.findViewById(R.id.confirm_sharing_check_box);
|
checkBox = (CheckBox) view.findViewById(R.id.confirm_dialog_check_box);
|
||||||
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int button) {
|
public void onClick(DialogInterface dialog, int button) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public class EulaUtils {
|
|||||||
// Accepting Google mobile terms of service
|
// Accepting Google mobile terms of service
|
||||||
private static final String ACCEPT_EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
|
private static final String ACCEPT_EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
|
||||||
private static final String SHOW_WELCOME_PREFERENCE_KEY = "showWelcome";
|
private static final String SHOW_WELCOME_PREFERENCE_KEY = "showWelcome";
|
||||||
private static final String SHOW_CHECK_UNITS_PREFERENCE_KEY = "showCheckUnits";
|
|
||||||
|
|
||||||
private EulaUtils() {}
|
private EulaUtils() {}
|
||||||
|
|
||||||
@@ -51,14 +50,6 @@ public class EulaUtils {
|
|||||||
setValue(context, SHOW_WELCOME_PREFERENCE_KEY, false);
|
setValue(context, SHOW_WELCOME_PREFERENCE_KEY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getShowCheckUnits(Context context) {
|
|
||||||
return getValue(context, SHOW_CHECK_UNITS_PREFERENCE_KEY, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setShowCheckUnits(Context context) {
|
|
||||||
setValue(context, SHOW_CHECK_UNITS_PREFERENCE_KEY, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean getValue(Context context, String key, boolean defaultValue) {
|
private static boolean getValue(Context context, String key, boolean defaultValue) {
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||||
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2009 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
package com.google.android.apps.mytracks.util;
|
|
||||||
|
|
||||||
import com.google.android.maps.GeoPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A rectangle in geographical space.
|
|
||||||
*/
|
|
||||||
public class GeoRect {
|
|
||||||
public int top;
|
|
||||||
public int left;
|
|
||||||
public int bottom;
|
|
||||||
public int right;
|
|
||||||
|
|
||||||
public GeoRect() {
|
|
||||||
top = 0;
|
|
||||||
left = 0;
|
|
||||||
bottom = 0;
|
|
||||||
right = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GeoRect(GeoPoint center, int latSpan, int longSpan) {
|
|
||||||
top = center.getLatitudeE6() - latSpan / 2;
|
|
||||||
left = center.getLongitudeE6() - longSpan / 2;
|
|
||||||
bottom = center.getLatitudeE6() + latSpan / 2;
|
|
||||||
right = center.getLongitudeE6() + longSpan / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GeoPoint getCenter() {
|
|
||||||
return new GeoPoint(top / 2 + bottom / 2, left / 2 + right / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLatSpan() {
|
|
||||||
return bottom - top;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLongSpan() {
|
|
||||||
return right - left;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(GeoPoint geoPoint) {
|
|
||||||
if (geoPoint.getLatitudeE6() >= top
|
|
||||||
&& geoPoint.getLatitudeE6() <= bottom
|
|
||||||
&& geoPoint.getLongitudeE6() >= left
|
|
||||||
&& geoPoint.getLongitudeE6() <= right) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,14 +17,11 @@ package com.google.android.apps.mytracks.util;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
|
||||||
import com.google.android.maps.GeoPoint;
|
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +30,9 @@ import java.util.Stack;
|
|||||||
* @author Leif Hendrik Wilden
|
* @author Leif Hendrik Wilden
|
||||||
*/
|
*/
|
||||||
public class LocationUtils {
|
public class LocationUtils {
|
||||||
|
|
||||||
|
private LocationUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the distance on the two sphere between the point c0 and the line
|
* Computes the distance on the two sphere between the point c0 and the line
|
||||||
* segment c1 to c2.
|
* segment c1 to c2.
|
||||||
@@ -42,8 +42,7 @@ public class LocationUtils {
|
|||||||
* @param c2 the end of the lone segment
|
* @param c2 the end of the lone segment
|
||||||
* @return the distance in m (assuming spherical earth)
|
* @return the distance in m (assuming spherical earth)
|
||||||
*/
|
*/
|
||||||
public static double distance(
|
private static double distance(final Location c0, final Location c1, final Location c2) {
|
||||||
final Location c0, final Location c1, final Location c2) {
|
|
||||||
if (c1.equals(c2)) {
|
if (c1.equals(c2)) {
|
||||||
return c2.distanceTo(c0);
|
return c2.distanceTo(c0);
|
||||||
}
|
}
|
||||||
@@ -57,9 +56,8 @@ public class LocationUtils {
|
|||||||
|
|
||||||
double s2s1lat = s2lat - s1lat;
|
double s2s1lat = s2lat - s1lat;
|
||||||
double s2s1lng = s2lng - s1lng;
|
double s2s1lng = s2lng - s1lng;
|
||||||
final double u =
|
final double u = ((s0lat - s1lat) * s2s1lat + (s0lng - s1lng) * s2s1lng)
|
||||||
((s0lat - s1lat) * s2s1lat + (s0lng - s1lng) * s2s1lng)
|
/ (s2s1lat * s2s1lat + s2s1lng * s2s1lng);
|
||||||
/ (s2s1lat * s2s1lat + s2s1lng * s2s1lng);
|
|
||||||
if (u <= 0) {
|
if (u <= 0) {
|
||||||
return c0.distanceTo(c1);
|
return c0.distanceTo(c1);
|
||||||
}
|
}
|
||||||
@@ -83,8 +81,8 @@ public class LocationUtils {
|
|||||||
* @param locations input
|
* @param locations input
|
||||||
* @param decimated output
|
* @param decimated output
|
||||||
*/
|
*/
|
||||||
public static void decimate(double tolerance, ArrayList<Location> locations,
|
private static void decimate(
|
||||||
ArrayList<Location> decimated) {
|
double tolerance, ArrayList<Location> locations, ArrayList<Location> decimated) {
|
||||||
final int n = locations.size();
|
final int n = locations.size();
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
return;
|
return;
|
||||||
@@ -100,16 +98,14 @@ public class LocationUtils {
|
|||||||
int[] current;
|
int[] current;
|
||||||
|
|
||||||
if (n > 2) {
|
if (n > 2) {
|
||||||
int[] stackVal = new int[] {0, (n - 1)};
|
int[] stackVal = new int[] { 0, (n - 1) };
|
||||||
stack.push(stackVal);
|
stack.push(stackVal);
|
||||||
while (stack.size() > 0) {
|
while (stack.size() > 0) {
|
||||||
current = stack.pop();
|
current = stack.pop();
|
||||||
maxDist = 0;
|
maxDist = 0;
|
||||||
for (idx = current[0] + 1; idx < current[1]; ++idx) {
|
for (idx = current[0] + 1; idx < current[1]; ++idx) {
|
||||||
dist = LocationUtils.distance(
|
dist = LocationUtils.distance(
|
||||||
locations.get(idx),
|
locations.get(idx), locations.get(current[0]), locations.get(current[1]));
|
||||||
locations.get(current[0]),
|
|
||||||
locations.get(current[1]));
|
|
||||||
if (dist > maxDist) {
|
if (dist > maxDist) {
|
||||||
maxDist = dist;
|
maxDist = dist;
|
||||||
maxIdx = idx;
|
maxIdx = idx;
|
||||||
@@ -117,9 +113,9 @@ public class LocationUtils {
|
|||||||
}
|
}
|
||||||
if (maxDist > tolerance) {
|
if (maxDist > tolerance) {
|
||||||
dists[maxIdx] = maxDist;
|
dists[maxIdx] = maxDist;
|
||||||
int[] stackValCurMax = {current[0], maxIdx};
|
int[] stackValCurMax = { current[0], maxIdx };
|
||||||
stack.push(stackValCurMax);
|
stack.push(stackValCurMax);
|
||||||
int[] stackValMaxCur = {maxIdx, current[1]};
|
int[] stackValMaxCur = { maxIdx, current[1] };
|
||||||
stack.push(stackValMaxCur);
|
stack.push(stackValMaxCur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,8 +131,7 @@ public class LocationUtils {
|
|||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
Log.d(Constants.TAG, "Decimating " + n + " points to " + i
|
Log.d(Constants.TAG, "Decimating " + n + " points to " + i + " w/ tolerance = " + tolerance);
|
||||||
+ " w/ tolerance = " + tolerance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,72 +146,11 @@ public class LocationUtils {
|
|||||||
track.setLocations(decimated);
|
track.setLocations(decimated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Limits number of points by dropping any points beyond the given number of
|
|
||||||
* points. Note: That'll actually discard points.
|
|
||||||
*
|
|
||||||
* @param track a track
|
|
||||||
* @param numberOfPoints maximum number of points
|
|
||||||
*/
|
|
||||||
public static void cut(Track track, int numberOfPoints) {
|
|
||||||
ArrayList<Location> locations = track.getLocations();
|
|
||||||
while (locations.size() > numberOfPoints) {
|
|
||||||
locations.remove(locations.size() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Splits a track in multiple tracks where each piece has less or equal than
|
|
||||||
* maxPoints.
|
|
||||||
*
|
|
||||||
* @param track the track to split
|
|
||||||
* @param maxPoints maximum number of points for each piece
|
|
||||||
* @return a list of one or more track pieces
|
|
||||||
*/
|
|
||||||
public static ArrayList<Track> split(Track track, int maxPoints) {
|
|
||||||
ArrayList<Track> result = new ArrayList<Track>();
|
|
||||||
final int nTotal = track.getLocations().size();
|
|
||||||
int n = 0;
|
|
||||||
Track piece = null;
|
|
||||||
do {
|
|
||||||
piece = new Track();
|
|
||||||
TripStatistics pieceStats = piece.getTripStatistics();
|
|
||||||
piece.setId(track.getId());
|
|
||||||
piece.setName(track.getName());
|
|
||||||
piece.setDescription(track.getDescription());
|
|
||||||
piece.setCategory(track.getCategory());
|
|
||||||
List<Location> pieceLocations = piece.getLocations();
|
|
||||||
for (int i = n; i < nTotal && pieceLocations.size() < maxPoints; i++) {
|
|
||||||
piece.addLocation(track.getLocations().get(i));
|
|
||||||
}
|
|
||||||
int nPointsPiece = pieceLocations.size();
|
|
||||||
if (nPointsPiece >= 2) {
|
|
||||||
pieceStats.setStartTime(pieceLocations.get(0).getTime());
|
|
||||||
pieceStats.setStopTime(pieceLocations.get(nPointsPiece - 1).getTime());
|
|
||||||
result.add(piece);
|
|
||||||
}
|
|
||||||
n += (pieceLocations.size() - 1);
|
|
||||||
} while (n < nTotal && piece.getLocations().size() > 1);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if a given GeoPoint is valid, i.e. within physical bounds.
|
|
||||||
*
|
|
||||||
* @param geoPoint the point to be tested
|
|
||||||
* @return true, if it is a physical location on earth.
|
|
||||||
*/
|
|
||||||
public static boolean isValidGeoPoint(GeoPoint geoPoint) {
|
|
||||||
return Math.abs(geoPoint.getLatitudeE6()) < 90E6
|
|
||||||
&& Math.abs(geoPoint.getLongitudeE6()) <= 180E6;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a given location is a valid (i.e. physically possible) location
|
* Checks if a given location is a valid (i.e. physically possible) location
|
||||||
* on Earth. Note: The special separator locations (which have latitude =
|
* on Earth. Note: The special separator locations (which have latitude = 100)
|
||||||
* 100) will not qualify as valid. Neither will locations with lat=0 and lng=0
|
* will not qualify as valid. Neither will locations with lat=0 and lng=0 as
|
||||||
* as these are most likely "bad" measurements which often cause trouble.
|
* these are most likely "bad" measurements which often cause trouble.
|
||||||
*
|
*
|
||||||
* @param location the location to test
|
* @param location the location to test
|
||||||
* @return true if the location is a valid location.
|
* @return true if the location is a valid location.
|
||||||
@@ -225,28 +159,4 @@ public class LocationUtils {
|
|||||||
return location != null && Math.abs(location.getLatitude()) <= 90
|
return location != null && Math.abs(location.getLatitude()) <= 90
|
||||||
&& Math.abs(location.getLongitude()) <= 180;
|
&& Math.abs(location.getLongitude()) <= 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a location from a GeoPoint.
|
|
||||||
*
|
|
||||||
* @param p a GeoPoint
|
|
||||||
* @return the corresponding location
|
|
||||||
*/
|
|
||||||
public static Location getLocation(GeoPoint p) {
|
|
||||||
Location result = new Location("");
|
|
||||||
result.setLatitude(p.getLatitudeE6() / 1.0E6);
|
|
||||||
result.setLongitude(p.getLongitudeE6() / 1.0E6);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GeoPoint getGeoPoint(Location location) {
|
|
||||||
return new GeoPoint((int) (location.getLatitude() * 1E6),
|
|
||||||
(int) (location.getLongitude() * 1E6));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a utility class w/ only static members.
|
|
||||||
*/
|
|
||||||
private LocationUtils() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class PreferencesUtils {
|
|||||||
|
|
||||||
public static final String SENSOR_TYPE_DEFAULT = "NONE";
|
public static final String SENSOR_TYPE_DEFAULT = "NONE";
|
||||||
|
|
||||||
|
public static final boolean SHOW_CONFIRM_PLAY_DIALOG_DEFAULT = true;
|
||||||
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
|
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
|
||||||
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -9,4 +9,4 @@
|
|||||||
|
|
||||||
android.library=true
|
android.library=true
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:16
|
target=android-16
|
||||||
|
|||||||
@@ -10,4 +10,4 @@
|
|||||||
# Indicates whether an apk should be generated for each density.
|
# Indicates whether an apk should be generated for each density.
|
||||||
split.density=false
|
split.density=false
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:16
|
target=android-16
|
||||||
|
|||||||
+1
-1
@@ -234,7 +234,7 @@ public class EndToEndTestUtils {
|
|||||||
* Checks whether the Google Play Services need update.
|
* Checks whether the Google Play Services need update.
|
||||||
*/
|
*/
|
||||||
private static boolean isGooglePlayServicesLatest() {
|
private static boolean isGooglePlayServicesLatest() {
|
||||||
return !SOLO.searchText(activityMytracks.getString(R.string.common_google_play_services_update_text));
|
return !SOLO.searchText("Google Play services");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.android.apps.mytracks.io.maps;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
||||||
import com.google.android.maps.GeoPoint;
|
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
@@ -59,50 +58,59 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||||
* GeoPoint)} with a title.
|
* Location)} with a title.
|
||||||
*/
|
*/
|
||||||
public void testBuildMapsMarkerFeature_with_title() {
|
public void testBuildMapsMarkerFeature_with_title() {
|
||||||
|
Location location = new Location("test");
|
||||||
|
location.setLatitude(123.0);
|
||||||
|
location.setLongitude(456.0);
|
||||||
MapsFeature mapFeature = SendMapsUtils.buildMapsMarkerFeature(
|
MapsFeature mapFeature = SendMapsUtils.buildMapsMarkerFeature(
|
||||||
"name", "this\nmap\ndescription", "url", new GeoPoint(123, 456));
|
"name", "this\nmap\ndescription", "url", location);
|
||||||
assertEquals(MapsFeature.MARKER, mapFeature.getType());
|
assertEquals(MapsFeature.MARKER, mapFeature.getType());
|
||||||
assertNotNull(mapFeature.getAndroidId());
|
assertNotNull(mapFeature.getAndroidId());
|
||||||
assertEquals("name", mapFeature.getTitle());
|
assertEquals("name", mapFeature.getTitle());
|
||||||
assertEquals("this<br>map<br>description", mapFeature.getDescription());
|
assertEquals("this<br>map<br>description", mapFeature.getDescription());
|
||||||
assertEquals("url", mapFeature.getIconUrl());
|
assertEquals("url", mapFeature.getIconUrl());
|
||||||
assertEquals(123, mapFeature.getPoint(0).getLatitudeE6());
|
assertEquals(123.0, mapFeature.getPoint(0).getLatitude());
|
||||||
assertEquals(456, mapFeature.getPoint(0).getLongitudeE6());
|
assertEquals(456.0, mapFeature.getPoint(0).getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||||
* GeoPoint)} with an empty title.
|
* Location)} with an empty title.
|
||||||
*/
|
*/
|
||||||
public void testBuildMapsMarkerFeature_empty_title() {
|
public void testBuildMapsMarkerFeature_empty_title() {
|
||||||
|
Location location = new Location("test");
|
||||||
|
location.setLatitude(123.0);
|
||||||
|
location.setLongitude(456.0);
|
||||||
MapsFeature mapFeature = SendMapsUtils.buildMapsMarkerFeature(
|
MapsFeature mapFeature = SendMapsUtils.buildMapsMarkerFeature(
|
||||||
"", "description", "url", new GeoPoint(123, 456));
|
"", "description", "url", location);
|
||||||
assertEquals(MapsFeature.MARKER, mapFeature.getType());
|
assertEquals(MapsFeature.MARKER, mapFeature.getType());
|
||||||
assertNotNull(mapFeature.getAndroidId());
|
assertNotNull(mapFeature.getAndroidId());
|
||||||
assertEquals("-", mapFeature.getTitle());
|
assertEquals("-", mapFeature.getTitle());
|
||||||
assertEquals("description", mapFeature.getDescription());
|
assertEquals("description", mapFeature.getDescription());
|
||||||
assertEquals("url", mapFeature.getIconUrl());
|
assertEquals("url", mapFeature.getIconUrl());
|
||||||
assertEquals(123, mapFeature.getPoint(0).getLatitudeE6());
|
assertEquals(123.0, mapFeature.getPoint(0).getLatitude());
|
||||||
assertEquals(456, mapFeature.getPoint(0).getLongitudeE6());
|
assertEquals(456.0, mapFeature.getPoint(0).getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||||
* GeoPoint)} with a null title.
|
* Location)} with a null title.
|
||||||
*/
|
*/
|
||||||
public void testBuildMapsMarkerFeature_null_title() {
|
public void testBuildMapsMarkerFeature_null_title() {
|
||||||
|
Location location = new Location("test");
|
||||||
|
location.setLatitude(123.0);
|
||||||
|
location.setLongitude(456.0);
|
||||||
MapsFeature mapFeature = SendMapsUtils.buildMapsMarkerFeature(
|
MapsFeature mapFeature = SendMapsUtils.buildMapsMarkerFeature(
|
||||||
null, "description", "url", new GeoPoint(123, 456));
|
null, "description", "url", location);
|
||||||
assertEquals(MapsFeature.MARKER, mapFeature.getType());
|
assertEquals(MapsFeature.MARKER, mapFeature.getType());
|
||||||
assertNotNull(mapFeature.getAndroidId());
|
assertNotNull(mapFeature.getAndroidId());
|
||||||
assertEquals("-", mapFeature.getTitle());
|
assertEquals("-", mapFeature.getTitle());
|
||||||
assertEquals("description", mapFeature.getDescription());
|
assertEquals("description", mapFeature.getDescription());
|
||||||
assertEquals("url", mapFeature.getIconUrl());
|
assertEquals("url", mapFeature.getIconUrl());
|
||||||
assertEquals(123, mapFeature.getPoint(0).getLatitudeE6());
|
assertEquals(123.0, mapFeature.getPoint(0).getLatitude());
|
||||||
assertEquals(456, mapFeature.getPoint(0).getLongitudeE6());
|
assertEquals(456.0, mapFeature.getPoint(0).getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,8 +120,8 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
public void testBuildMapsLineFeature_with_title() {
|
public void testBuildMapsLineFeature_with_title() {
|
||||||
ArrayList<Location> locations = new ArrayList<Location>();
|
ArrayList<Location> locations = new ArrayList<Location>();
|
||||||
Location location = new Location("test");
|
Location location = new Location("test");
|
||||||
location.setLatitude(50);
|
location.setLatitude(50.0);
|
||||||
location.setLongitude(100);
|
location.setLongitude(100.0);
|
||||||
locations.add(location);
|
locations.add(location);
|
||||||
MapsFeature mapFeature = SendMapsUtils.buildMapsLineFeature("name", locations);
|
MapsFeature mapFeature = SendMapsUtils.buildMapsLineFeature("name", locations);
|
||||||
|
|
||||||
@@ -121,8 +129,8 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
assertNotNull(mapFeature.getAndroidId());
|
assertNotNull(mapFeature.getAndroidId());
|
||||||
assertEquals("name", mapFeature.getTitle());
|
assertEquals("name", mapFeature.getTitle());
|
||||||
assertEquals(0x80FF0000, mapFeature.getColor());
|
assertEquals(0x80FF0000, mapFeature.getColor());
|
||||||
assertEquals(50000000, mapFeature.getPoint(0).getLatitudeE6());
|
assertEquals(50.0, mapFeature.getPoint(0).getLatitude());
|
||||||
assertEquals(100000000, mapFeature.getPoint(0).getLongitudeE6());
|
assertEquals(100.0, mapFeature.getPoint(0).getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,8 +140,8 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
public void testBuildMapsLineFeature_empty_title() {
|
public void testBuildMapsLineFeature_empty_title() {
|
||||||
ArrayList<Location> locations = new ArrayList<Location>();
|
ArrayList<Location> locations = new ArrayList<Location>();
|
||||||
Location location = new Location("test");
|
Location location = new Location("test");
|
||||||
location.setLatitude(50);
|
location.setLatitude(50.0);
|
||||||
location.setLongitude(100);
|
location.setLongitude(100.0);
|
||||||
locations.add(location);
|
locations.add(location);
|
||||||
MapsFeature mapFeature = SendMapsUtils.buildMapsLineFeature("", locations);
|
MapsFeature mapFeature = SendMapsUtils.buildMapsLineFeature("", locations);
|
||||||
|
|
||||||
@@ -141,8 +149,8 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
assertNotNull(mapFeature.getAndroidId());
|
assertNotNull(mapFeature.getAndroidId());
|
||||||
assertEquals("-", mapFeature.getTitle());
|
assertEquals("-", mapFeature.getTitle());
|
||||||
assertEquals(0x80FF0000, mapFeature.getColor());
|
assertEquals(0x80FF0000, mapFeature.getColor());
|
||||||
assertEquals(50000000, mapFeature.getPoint(0).getLatitudeE6());
|
assertEquals(50.0, mapFeature.getPoint(0).getLatitude());
|
||||||
assertEquals(100000000, mapFeature.getPoint(0).getLongitudeE6());
|
assertEquals(100.0, mapFeature.getPoint(0).getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,8 +160,8 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
public void testBuildMapsLineFeature_null_title() {
|
public void testBuildMapsLineFeature_null_title() {
|
||||||
ArrayList<Location> locations = new ArrayList<Location>();
|
ArrayList<Location> locations = new ArrayList<Location>();
|
||||||
Location location = new Location("test");
|
Location location = new Location("test");
|
||||||
location.setLatitude(50);
|
location.setLatitude(50.0);
|
||||||
location.setLongitude(100);
|
location.setLongitude(100.0);
|
||||||
locations.add(location);
|
locations.add(location);
|
||||||
MapsFeature mapFeature = SendMapsUtils.buildMapsLineFeature(null, locations);
|
MapsFeature mapFeature = SendMapsUtils.buildMapsLineFeature(null, locations);
|
||||||
|
|
||||||
@@ -161,19 +169,7 @@ public class SendMapsUtilsTest extends TestCase {
|
|||||||
assertNotNull(mapFeature.getAndroidId());
|
assertNotNull(mapFeature.getAndroidId());
|
||||||
assertEquals("-", mapFeature.getTitle());
|
assertEquals("-", mapFeature.getTitle());
|
||||||
assertEquals(0x80FF0000, mapFeature.getColor());
|
assertEquals(0x80FF0000, mapFeature.getColor());
|
||||||
assertEquals(50000000, mapFeature.getPoint(0).getLatitudeE6());
|
assertEquals(50.0, mapFeature.getPoint(0).getLatitude());
|
||||||
assertEquals(100000000, mapFeature.getPoint(0).getLongitudeE6());
|
assertEquals(100.0, mapFeature.getPoint(0).getLongitude());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test {@link SendMapsUtils#getGeoPoint(Location)}.
|
|
||||||
*/
|
|
||||||
public void testGeoPoint() {
|
|
||||||
Location location = new Location("test");
|
|
||||||
location.setLatitude(50);
|
|
||||||
location.setLongitude(100);
|
|
||||||
GeoPoint geoPoint = SendMapsUtils.getGeoPoint(location);
|
|
||||||
assertEquals(50000000, geoPoint.getLatitudeE6());
|
|
||||||
assertEquals(100000000, geoPoint.getLongitudeE6());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user