forked from upstream-mirrors/OpenTracks
Give user the option to not show the confirmation dialog when
playing a track in Google Earth.
This commit is contained in:
@@ -25,11 +25,11 @@ limitations under the License.
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="2dp" >
|
||||
<TextView
|
||||
android:id="@+id/confirm_sharing_text_view"
|
||||
android:autoLink="web"
|
||||
android:id="@+id/confirm_dialog_message"
|
||||
style="@style/TextMedium" />
|
||||
<CheckBox
|
||||
android:id="@+id/confirm_sharing_check_box"
|
||||
android:id="@+id/confirm_dialog_check_box"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_width="match_parent"
|
||||
@@ -43,6 +43,7 @@ limitations under the License.
|
||||
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
||||
<string name="send_to_maps_key">sendToMaps</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="split_frequency_key">splitFrequency</string>
|
||||
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
|
||||
|
||||
@@ -2267,6 +2267,10 @@ limitations under the License.
|
||||
translation_description="In the track detail page, the title of the tab showing the map.">
|
||||
Map
|
||||
</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"
|
||||
translation_description="In the track detail page, the title of the tab showing the 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.ChooseActivityDialogFragment;
|
||||
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.DeleteOneTrackCaller;
|
||||
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
||||
@@ -321,12 +322,8 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
return true;
|
||||
case R.id.track_detail_play:
|
||||
if (isEarthInstalled()) {
|
||||
AnalyticsUtils.sendPageViews(this, "/action/play");
|
||||
intent = IntentUtils.newIntent(this, 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);
|
||||
ConfirmPlayDialogFragment.newInstance(trackId)
|
||||
.show(getSupportFragmentManager(), ConfirmPlayDialogFragment.CONFIRM_PLAY_DIALOG_TAG);
|
||||
} else {
|
||||
new InstallEarthDialogFragment().show(
|
||||
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
||||
|
||||
+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();
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,6 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaUtils.setAcceptEula(activity);
|
||||
Locale locale = Locale.getDefault();
|
||||
PreferencesUtils.setBoolean(
|
||||
activity, R.string.metric_units_key, !Locale.US.equals(Locale.getDefault()));
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
|
||||
@@ -120,14 +120,14 @@ public class SaveActivity extends Activity {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
onPostResultDialog();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int arg1) {
|
||||
dialog.dismiss();
|
||||
onPostResultDialog();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.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.savedPath = aSavedPath;
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -60,13 +60,13 @@ public class ConfirmSharingActivity extends Activity {
|
||||
if (id != DIALOG_ID) {
|
||||
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(
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int button) {
|
||||
|
||||
@@ -76,6 +76,7 @@ public class PreferencesUtils {
|
||||
|
||||
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 int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SendMapsUtilsTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||
* GeoPoint)} with a title.
|
||||
* Location)} with a title.
|
||||
*/
|
||||
public void testBuildMapsMarkerFeature_with_title() {
|
||||
Location location = new Location("test");
|
||||
@@ -77,7 +77,7 @@ public class SendMapsUtilsTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||
* GeoPoint)} with an empty title.
|
||||
* Location)} with an empty title.
|
||||
*/
|
||||
public void testBuildMapsMarkerFeature_empty_title() {
|
||||
Location location = new Location("test");
|
||||
@@ -96,7 +96,7 @@ public class SendMapsUtilsTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||
* GeoPoint)} with a null title.
|
||||
* Location)} with a null title.
|
||||
*/
|
||||
public void testBuildMapsMarkerFeature_null_title() {
|
||||
Location location = new Location("test");
|
||||
|
||||
Reference in New Issue
Block a user