forked from upstream-mirrors/OpenTracks
Move dialogs in TrackDetail to fragments.
Move all fragments to com.google.android.apps.mytracks.fragments package.
This commit is contained in:
@@ -13,15 +13,21 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
import static com.google.android.apps.mytracks.Constants.CHART_TAB_TAG;
|
import static com.google.android.apps.mytracks.Constants.CHART_TAB_TAG;
|
||||||
import static com.google.android.apps.mytracks.Constants.MAP_TAB_TAG;
|
import static com.google.android.apps.mytracks.Constants.MAP_TAB_TAG;
|
||||||
import static com.google.android.apps.mytracks.Constants.STATS_TAB_TAG;
|
import static com.google.android.apps.mytracks.Constants.STATS_TAB_TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
|
||||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ChartFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ChartSettingsDialogFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.MapFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.StatsFragment;
|
||||||
import com.google.android.apps.mytracks.io.file.SaveActivity;
|
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.io.file.TrackWriterFactory.TrackFileFormat;
|
||||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
|
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
|
||||||
@@ -31,19 +37,14 @@ import com.google.android.apps.mytracks.services.ServiceUtils;
|
|||||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||||
import com.google.android.apps.mytracks.util.AnalyticsUtils;
|
import com.google.android.apps.mytracks.util.AnalyticsUtils;
|
||||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||||
import com.google.android.apps.mytracks.util.DialogUtils;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
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;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -54,8 +55,6 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.RadioGroup;
|
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -76,10 +75,6 @@ public class TrackDetailActivity extends FragmentActivity {
|
|||||||
private static final String TAG = TrackDetailActivity.class.getSimpleName();
|
private static final String TAG = TrackDetailActivity.class.getSimpleName();
|
||||||
private static final String CURRENT_TAG_KEY = "tab";
|
private static final String CURRENT_TAG_KEY = "tab";
|
||||||
|
|
||||||
private static final int DIALOG_INSTALL_EARTH_ID = 0;
|
|
||||||
private static final int DIALOG_DELETE_CURRENT_ID = 1;
|
|
||||||
private static final int DIALOG_CHART_SETTINGS_ID = 2;
|
|
||||||
|
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
private TrackDataHub trackDataHub;
|
private TrackDataHub trackDataHub;
|
||||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||||
@@ -204,80 +199,6 @@ public class TrackDetailActivity extends FragmentActivity {
|
|||||||
trackRecordingServiceConnection.unbind();
|
trackRecordingServiceConnection.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Dialog onCreateDialog(int id) {
|
|
||||||
switch (id) {
|
|
||||||
case DIALOG_INSTALL_EARTH_ID:
|
|
||||||
return new AlertDialog.Builder(this).setCancelable(true)
|
|
||||||
.setMessage(R.string.track_detail_install_earth_message)
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
Intent intent = new Intent()
|
|
||||||
.setData(Uri.parse(SaveActivity.GOOGLE_EARTH_MARKET_URL));
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
case DIALOG_DELETE_CURRENT_ID:
|
|
||||||
return DialogUtils.createConfirmationDialog(this,
|
|
||||||
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
deleteCurrentTrack();
|
|
||||||
startTrackListActivity();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
case DIALOG_CHART_SETTINGS_ID:
|
|
||||||
return createChartSettingsDialog();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dialog createChartSettingsDialog() {
|
|
||||||
final ChartFragment chartFragment = (ChartFragment) getSupportFragmentManager()
|
|
||||||
.findFragmentByTag(CHART_TAB_TAG);
|
|
||||||
View view = getLayoutInflater().inflate(R.layout.chart_settings, null);
|
|
||||||
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.chart_settings_x);
|
|
||||||
radioGroup
|
|
||||||
.check(chartFragment.getMode() == ChartView.Mode.BY_DISTANCE ? R.id.chart_settings_by_distance
|
|
||||||
: R.id.chart_settings_by_time);
|
|
||||||
|
|
||||||
final CheckBox[] checkBoxes = new CheckBox[ChartView.NUM_SERIES];
|
|
||||||
checkBoxes[ChartView.ELEVATION_SERIES] = (CheckBox) view
|
|
||||||
.findViewById(R.id.chart_settings_elevation);
|
|
||||||
checkBoxes[ChartView.SPEED_SERIES] = (CheckBox) view.findViewById(R.id.chart_settings_speed);
|
|
||||||
checkBoxes[ChartView.POWER_SERIES] = (CheckBox) view.findViewById(R.id.chart_settings_power);
|
|
||||||
checkBoxes[ChartView.CADENCE_SERIES] = (CheckBox) view
|
|
||||||
.findViewById(R.id.chart_settings_cadence);
|
|
||||||
checkBoxes[ChartView.HEART_RATE_SERIES] = (CheckBox) view
|
|
||||||
.findViewById(R.id.chart_settings_heart_rate);
|
|
||||||
|
|
||||||
// set checkboxes values
|
|
||||||
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
|
||||||
checkBoxes[i].setChecked(chartFragment.isChartValueSeriesEnabled(i));
|
|
||||||
}
|
|
||||||
checkBoxes[ChartView.SPEED_SERIES].setText(chartFragment.isReportSpeed() ? R.string.stat_speed
|
|
||||||
: R.string.stat_pace);
|
|
||||||
|
|
||||||
return new AlertDialog.Builder(this).setCancelable(true)
|
|
||||||
.setNegativeButton(R.string.generic_cancel, null)
|
|
||||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
chartFragment
|
|
||||||
.setMode(radioGroup.getCheckedRadioButtonId() == R.id.chart_settings_by_distance ? ChartView.Mode.BY_DISTANCE
|
|
||||||
: ChartView.Mode.BY_TIME);
|
|
||||||
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
|
||||||
chartFragment.setChartValueSeriesEnabled(i, checkBoxes[i].isChecked());
|
|
||||||
}
|
|
||||||
chartFragment.update();
|
|
||||||
}
|
|
||||||
}).setTitle(R.string.menu_chart_settings).setView(view).create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.track_detail, menu);
|
getMenuInflater().inflate(R.menu.track_detail, menu);
|
||||||
@@ -353,7 +274,8 @@ public class TrackDetailActivity extends FragmentActivity {
|
|||||||
.putExtra(SaveActivity.EXTRA_PLAY_TRACK, true);
|
.putExtra(SaveActivity.EXTRA_PLAY_TRACK, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
showDialog(DIALOG_INSTALL_EARTH_ID);
|
new InstallEarthDialogFragment().show(
|
||||||
|
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_share_map:
|
case R.id.track_detail_share_map:
|
||||||
@@ -405,7 +327,8 @@ public class TrackDetailActivity extends FragmentActivity {
|
|||||||
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId));
|
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId));
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_delete:
|
case R.id.track_detail_delete:
|
||||||
showDialog(DIALOG_DELETE_CURRENT_ID);
|
DeleteOneTrackDialogFragment.newInstance(trackId).show(
|
||||||
|
getSupportFragmentManager(), DeleteOneTrackDialogFragment.DELETE_ONE_TRACK_DIALOG_TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_my_location:
|
case R.id.track_detail_my_location:
|
||||||
mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MAP_TAB_TAG);
|
mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MAP_TAB_TAG);
|
||||||
@@ -420,7 +343,8 @@ public class TrackDetailActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_chart_settings:
|
case R.id.track_detail_chart_settings:
|
||||||
showDialog(DIALOG_CHART_SETTINGS_ID);
|
new ChartSettingsDialogFragment().show(
|
||||||
|
getSupportFragmentManager(), ChartSettingsDialogFragment.CHART_SETTINGS_DIALOG_TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_sensor_state:
|
case R.id.track_detail_sensor_state:
|
||||||
startActivity(new Intent(this, SensorStateActivity.class));
|
startActivity(new Intent(this, SensorStateActivity.class));
|
||||||
@@ -558,13 +482,6 @@ public class TrackDetailActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the current track.
|
|
||||||
*/
|
|
||||||
private void deleteCurrentTrack() {
|
|
||||||
MyTracksProviderUtils.Factory.get(TrackDetailActivity.this).deleteTrack(trackId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the {@link TrackListActivity}.
|
* Starts the {@link TrackListActivity}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteAllDialogFragment;
|
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.EulaDialogFragment;
|
import com.google.android.apps.mytracks.fragments.EulaDialogFragment;
|
||||||
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
|
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
|
||||||
import com.google.android.apps.mytracks.services.ITrackRecordingService;
|
import com.google.android.apps.mytracks.services.ITrackRecordingService;
|
||||||
@@ -339,8 +339,8 @@ public class TrackListActivity extends FragmentActivity {
|
|||||||
ExportActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.TCX));
|
ExportActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.TCX));
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_list_delete_all:
|
case R.id.track_list_delete_all:
|
||||||
new DeleteAllDialogFragment().show(
|
new DeleteAllTrackDialogFragment().show(
|
||||||
getSupportFragmentManager(), DeleteAllDialogFragment.DELETE_ALL_DIALOG_TAG);
|
getSupportFragmentManager(), DeleteAllTrackDialogFragment.DELETE_ALL_TRACK_DIALOG_TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_list_aggregated_statistics:
|
case R.id.track_list_aggregated_statistics:
|
||||||
startActivity(new Intent(this, AggregatedStatsActivity.class));
|
startActivity(new Intent(this, AggregatedStatsActivity.class));
|
||||||
|
|||||||
+4
-1
@@ -14,9 +14,12 @@
|
|||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.ChartView;
|
||||||
import com.google.android.apps.mytracks.ChartView.Mode;
|
import com.google.android.apps.mytracks.ChartView.Mode;
|
||||||
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.MyTracksApplication;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||||
import com.google.android.apps.mytracks.content.Sensor;
|
import com.google.android.apps.mytracks.content.Sensor;
|
||||||
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* 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 static com.google.android.apps.mytracks.Constants.CHART_TAB_TAG;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.ChartView;
|
||||||
|
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.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DialogFragment to show chart settings.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
public class ChartSettingsDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String CHART_SETTINGS_DIALOG_TAG = "chartSettingsDialog";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final ChartFragment chartFragment = (ChartFragment) getActivity()
|
||||||
|
.getSupportFragmentManager().findFragmentByTag(CHART_TAB_TAG);
|
||||||
|
View view = getActivity().getLayoutInflater().inflate(R.layout.chart_settings, null);
|
||||||
|
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.chart_settings_x);
|
||||||
|
radioGroup.check(chartFragment.getMode() == ChartView.Mode.BY_DISTANCE
|
||||||
|
? R.id.chart_settings_by_distance : R.id.chart_settings_by_time);
|
||||||
|
|
||||||
|
final CheckBox[] checkBoxes = new CheckBox[ChartView.NUM_SERIES];
|
||||||
|
checkBoxes[ChartView.ELEVATION_SERIES] = (CheckBox) view.findViewById(
|
||||||
|
R.id.chart_settings_elevation);
|
||||||
|
checkBoxes[ChartView.SPEED_SERIES] = (CheckBox) view.findViewById(R.id.chart_settings_speed);
|
||||||
|
checkBoxes[ChartView.POWER_SERIES] = (CheckBox) view.findViewById(R.id.chart_settings_power);
|
||||||
|
checkBoxes[ChartView.CADENCE_SERIES] = (CheckBox) view.findViewById(
|
||||||
|
R.id.chart_settings_cadence);
|
||||||
|
checkBoxes[ChartView.HEART_RATE_SERIES] = (CheckBox) view.findViewById(
|
||||||
|
R.id.chart_settings_heart_rate);
|
||||||
|
|
||||||
|
// set checkboxes values
|
||||||
|
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
||||||
|
checkBoxes[i].setChecked(chartFragment.isChartValueSeriesEnabled(i));
|
||||||
|
}
|
||||||
|
checkBoxes[ChartView.SPEED_SERIES].setText(chartFragment.isReportSpeed()
|
||||||
|
? R.string.stat_speed : R.string.stat_pace);
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setCancelable(true)
|
||||||
|
.setNegativeButton(R.string.generic_cancel, null)
|
||||||
|
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
chartFragment.setMode(
|
||||||
|
radioGroup.getCheckedRadioButtonId() == R.id.chart_settings_by_distance
|
||||||
|
? ChartView.Mode.BY_DISTANCE : ChartView.Mode.BY_TIME);
|
||||||
|
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
||||||
|
chartFragment.setChartValueSeriesEnabled(i, checkBoxes[i].isChecked());
|
||||||
|
}
|
||||||
|
chartFragment.update();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTitle(R.string.menu_chart_settings)
|
||||||
|
.setView(view)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -30,9 +30,9 @@ import android.support.v4.app.DialogFragment;
|
|||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
public class DeleteAllDialogFragment extends DialogFragment {
|
public class DeleteAllTrackDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
public static final String DELETE_ALL_DIALOG_TAG = "deleteAllDialog";
|
public static final String DELETE_ALL_TRACK_DIALOG_TAG = "deleteAllTrackDialog";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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.content.MyTracksProviderUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.DialogUtils;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DialogFragment to delete one track.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String DELETE_ONE_TRACK_DIALOG_TAG = "deleteOneTrackDialog";
|
||||||
|
private static final String KEY_TRACK_ID = "trackId";
|
||||||
|
|
||||||
|
public static DeleteOneTrackDialogFragment newInstance(long trackId) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(KEY_TRACK_ID, trackId);
|
||||||
|
|
||||||
|
DeleteOneTrackDialogFragment deleteTrackDialogFragment = new DeleteOneTrackDialogFragment();
|
||||||
|
deleteTrackDialogFragment.setArguments(bundle);
|
||||||
|
return deleteTrackDialogFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||||
|
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
MyTracksProviderUtils.Factory.get(getActivity())
|
||||||
|
.deleteTrack(getArguments().getLong(KEY_TRACK_ID));
|
||||||
|
startActivity(new Intent(getActivity(), TrackListActivity.class).addFlags(
|
||||||
|
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DialogFragment to install Google Earth.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
public class InstallEarthDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String INSTALL_EARTH_DIALOG_TAG = "installEarthDialog";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setCancelable(true)
|
||||||
|
.setMessage(R.string.track_detail_install_earth_message)
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
startActivity(new Intent().setData(Uri.parse(SaveActivity.GOOGLE_EARTH_MARKET_URL)));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-1
@@ -14,8 +14,11 @@
|
|||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.MapOverlay;
|
||||||
|
import com.google.android.apps.mytracks.MyTracksApplication;
|
||||||
|
import com.google.android.apps.mytracks.TrackDetailActivity;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.Factory;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.Factory;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
+4
-1
@@ -14,8 +14,11 @@
|
|||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.MyTracksApplication;
|
||||||
|
import com.google.android.apps.mytracks.StatsUtilities;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||||
import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
|
import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
|
||||||
Reference in New Issue
Block a user