ask user what to do with an empty recording (see #21)
parent
2f39017b76
commit
28e75ecf66
|
@ -266,9 +266,20 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
// user chose CLEAR
|
// user chose CLEAR
|
||||||
handleStateAfterClear();
|
handleStateAfterClear();
|
||||||
LogHelper.v(LOG_TAG, "Save dialog result: CLEAR");
|
LogHelper.v(LOG_TAG, "Clear map dialog result: CLEAR");
|
||||||
} else if (resultCode == Activity.RESULT_CANCELED){
|
} else if (resultCode == Activity.RESULT_CANCELED){
|
||||||
LogHelper.v(LOG_TAG, "Clear map: User chose CANCEL.");
|
LogHelper.v(LOG_TAG, "Clear map dialog result: User chose CANCEL.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RESULT_EMPTY_RECORDING_DIALOG:
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
// User chose RESUME RECORDING
|
||||||
|
handleResumeButtonClick((View)mFloatingActionButtonMain);
|
||||||
|
LogHelper.v(LOG_TAG, "Empty recording dialog result: RESUME");
|
||||||
|
} else if (resultCode == Activity.RESULT_CANCELED){
|
||||||
|
// User chose CANCEL - do nothing just hide the sub menu
|
||||||
|
showFloatingActionButtonMenu(false);
|
||||||
|
LogHelper.v(LOG_TAG, "Empty recording dialog result: CANCEL");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -341,9 +352,6 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
|
||||||
|
|
||||||
/* Handles the visual state after a save action */
|
/* Handles the visual state after a save action */
|
||||||
private void handleStateAfterClear() {
|
private void handleStateAfterClear() {
|
||||||
// notify user
|
|
||||||
Toast.makeText(this, getString(R.string.toast_message_track_clear), Toast.LENGTH_LONG).show();
|
|
||||||
|
|
||||||
// dismiss notification
|
// dismiss notification
|
||||||
dismissNotification();
|
dismissNotification();
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.osmdroid.views.overlay.ItemizedIconOverlay;
|
||||||
import org.osmdroid.views.overlay.compass.CompassOverlay;
|
import org.osmdroid.views.overlay.compass.CompassOverlay;
|
||||||
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider;
|
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider;
|
||||||
import org.y20k.trackbook.core.Track;
|
import org.y20k.trackbook.core.Track;
|
||||||
|
import org.y20k.trackbook.helpers.DialogHelper;
|
||||||
import org.y20k.trackbook.helpers.LocationHelper;
|
import org.y20k.trackbook.helpers.LocationHelper;
|
||||||
import org.y20k.trackbook.helpers.LogHelper;
|
import org.y20k.trackbook.helpers.LogHelper;
|
||||||
import org.y20k.trackbook.helpers.MapHelper;
|
import org.y20k.trackbook.helpers.MapHelper;
|
||||||
|
@ -55,6 +56,8 @@ import org.y20k.trackbook.helpers.TrackbookKeys;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
@ -326,7 +329,12 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
break;
|
break;
|
||||||
case RESULT_CLEAR_DIALOG:
|
case RESULT_CLEAR_DIALOG:
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
// User chose CLEAR - clear map, DO NOT save track
|
// User chose CLEAR
|
||||||
|
if (mTrack.getSize() > 0) {
|
||||||
|
// Track is not empty - notify user
|
||||||
|
Toast.makeText(mActivity, getString(R.string.toast_message_track_clear), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
// clear map, DO NOT save track
|
||||||
clearMap(false);
|
clearMap(false);
|
||||||
// handle FloatingActionButton state in MainActivity
|
// handle FloatingActionButton state in MainActivity
|
||||||
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
|
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
|
||||||
|
@ -334,6 +342,10 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
LogHelper.v(LOG_TAG, "Clear dialog result: CANCEL");
|
LogHelper.v(LOG_TAG, "Clear dialog result: CANCEL");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case RESULT_EMPTY_RECORDING_DIALOG:
|
||||||
|
// handle FloatingActionButton state and possible Resume-Action in MainActivity
|
||||||
|
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,11 +466,16 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
|
|
||||||
/* Handles case when user chose to save recording with zero waypoints */ // todo implement
|
/* Handles case when user chose to save recording with zero waypoints */ // todo implement
|
||||||
private void handleEmptyRecordingSaveRequest() {
|
private void handleEmptyRecordingSaveRequest() {
|
||||||
// todo ask user what to do
|
// prepare empty recording dialog ("Unable to save")
|
||||||
Toast.makeText(mActivity, " Error. Empty recording. Clearing Map.", Toast.LENGTH_LONG).show(); // todo user alert (clear track?)
|
int dialogTitle = R.string.dialog_error_empty_recording_title;
|
||||||
// todo change (solution for now: insta-clear)
|
String dialogMessage = getString(R.string.dialog_error_empty_recording_content);
|
||||||
clearMap(false);
|
int dialogPositiveButton = R.string.dialog_error_empty_recording_action_resume;
|
||||||
((MainActivity)mActivity).onFloatingActionButtonResult(RESULT_CLEAR_DIALOG, Activity.RESULT_OK);
|
int dialogNegativeButton = R.string.dialog_default_action_cancel;
|
||||||
|
// show empty recording dialog
|
||||||
|
DialogFragment dialogFragment = DialogHelper.newInstance(dialogTitle, dialogMessage, dialogPositiveButton, dialogNegativeButton);
|
||||||
|
dialogFragment.setTargetFragment(this, RESULT_EMPTY_RECORDING_DIALOG);
|
||||||
|
dialogFragment.show(((AppCompatActivity)mActivity).getSupportFragmentManager(), "EmptyRecordingDialog");
|
||||||
|
// results of dialog are handled by onActivityResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ public interface TrackbookKeys {
|
||||||
int RESULT_CLEAR_DIALOG = 2;
|
int RESULT_CLEAR_DIALOG = 2;
|
||||||
int RESULT_DELETE_DIALOG = 3;
|
int RESULT_DELETE_DIALOG = 3;
|
||||||
int RESULT_EXPORT_DIALOG = 4;
|
int RESULT_EXPORT_DIALOG = 4;
|
||||||
|
int RESULT_EMPTY_RECORDING_DIALOG = 5;
|
||||||
|
|
||||||
/* CONSTANTS */
|
/* CONSTANTS */
|
||||||
long ONE_SECOND_IN_NANOSECOND = 1000000000L;
|
long ONE_SECOND_IN_NANOSECOND = 1000000000L;
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">Datei existiert bereits. Exportieren und überschreiben Sie diese Aufzeichnung als GPX-Strecke.</string>
|
<string name="dialog_export_content_overwrite">Datei existiert bereits. Exportieren und überschreiben Sie diese Aufzeichnung als GPX-Strecke.</string>
|
||||||
<string name="dialog_export_action_overwrite">Exportieren und überschreiben</string>
|
<string name="dialog_export_action_overwrite">Exportieren und überschreiben</string>
|
||||||
<string name="dialog_share_gpx">GPX-Datei öffnen mit</string>
|
<string name="dialog_share_gpx">GPX-Datei öffnen mit</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Speichern nicht möglich</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook hat noch keine Wegpunkte aufgezeichnet.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Aufzeichnung fortsetzen</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">Berechtigungen erteilt.</string>
|
<string name="toast_message_permissions_granted">Berechtigungen erteilt.</string>
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
|
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
|
||||||
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
|
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
|
||||||
<string name="dialog_share_gpx">Share GPX file with</string>
|
<string name="dialog_share_gpx">Share GPX file with</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Unable to save</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">Permissions granted.</string>
|
<string name="toast_message_permissions_granted">Permissions granted.</string>
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">Il file esiste già. Esportare e sovrascrivere questa registrazione come traccia GPX.</string>
|
<string name="dialog_export_content_overwrite">Il file esiste già. Esportare e sovrascrivere questa registrazione come traccia GPX.</string>
|
||||||
<string name="dialog_export_action_overwrite">Esporta e sovrascrivi</string>
|
<string name="dialog_export_action_overwrite">Esporta e sovrascrivi</string>
|
||||||
<string name="dialog_share_gpx">Share GPX file with</string>
|
<string name="dialog_share_gpx">Share GPX file with</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Unable to save</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">Permessi acquisiti.</string>
|
<string name="toast_message_permissions_granted">Permessi acquisiti.</string>
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">ファイルは既に存在します。エクスポートし、GPX トラックとしてこの記録を上書きします。</string>
|
<string name="dialog_export_content_overwrite">ファイルは既に存在します。エクスポートし、GPX トラックとしてこの記録を上書きします。</string>
|
||||||
<string name="dialog_export_action_overwrite">エクスポートして上書き</string>
|
<string name="dialog_export_action_overwrite">エクスポートして上書き</string>
|
||||||
<string name="dialog_share_gpx">Share GPX file with</string>
|
<string name="dialog_share_gpx">Share GPX file with</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Unable to save</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">アクセス許可を付与しました。</string>
|
<string name="toast_message_permissions_granted">アクセス許可を付与しました。</string>
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">Fila finnes allerede. Eksporter og overskriv dette opptaket som en GPX-tur.</string>
|
<string name="dialog_export_content_overwrite">Fila finnes allerede. Eksporter og overskriv dette opptaket som en GPX-tur.</string>
|
||||||
<string name="dialog_export_action_overwrite">Eksporter og overskriv</string>
|
<string name="dialog_export_action_overwrite">Eksporter og overskriv</string>
|
||||||
<string name="dialog_share_gpx">Share GPX file with</string>
|
<string name="dialog_share_gpx">Share GPX file with</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Unable to save</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">Tilgang gitt.</string>
|
<string name="toast_message_permissions_granted">Tilgang gitt.</string>
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
|
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
|
||||||
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
|
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
|
||||||
<string name="dialog_share_gpx">Share GPX file with</string>
|
<string name="dialog_share_gpx">Share GPX file with</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Unable to save</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">Rechten verleend.</string>
|
<string name="toast_message_permissions_granted">Rechten verleend.</string>
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
|
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
|
||||||
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
|
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
|
||||||
<string name="dialog_share_gpx">Share GPX file with</string>
|
<string name="dialog_share_gpx">Share GPX file with</string>
|
||||||
|
<string name="dialog_error_empty_recording_title">Unable to save</string>
|
||||||
|
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
|
||||||
|
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
|
||||||
|
|
||||||
<!-- toast messages -->
|
<!-- toast messages -->
|
||||||
<string name="toast_message_permissions_granted">Permissions granted.</string>
|
<string name="toast_message_permissions_granted">Permissions granted.</string>
|
||||||
|
|
Loading…
Reference in New Issue