TrackStoppedActivity: added discard button option. Fixes #1267.

This commit is contained in:
Román Ginés
2022-06-01 15:45:03 +02:00
committed by Román Martínez
parent 28abe360cb
commit ecd7405a8c
8 changed files with 258 additions and 147 deletions
@@ -88,11 +88,14 @@ public abstract class AbstractTrackDeleteActivity extends AbstractActivity imple
if (deleteStatus.isFinished() && trackDeleteServiceConnection != null) {
trackDeleteServiceConnection.unbind(this);
trackDeleteServiceConnection = null;
onDeleteFinished();
}
}
protected abstract void onDeleteConfirmed();
protected abstract void onDeleteFinished();
protected abstract Track.Id getRecordingTrackId();
@Override
@@ -445,6 +445,11 @@ public class TrackListActivity extends AbstractTrackDeleteActivity implements Co
// Do nothing
}
@Override
protected void onDeleteFinished() {
// Do nothing
}
@Nullable
@Override
protected Track.Id getRecordingTrackId() {
@@ -244,6 +244,11 @@ public class TrackRecordedActivity extends AbstractTrackDeleteActivity implement
runOnUiThread(this::finish);
}
@Override
protected void onDeleteFinished() {
// Do nothing
}
/**
* Gets the {@link TrackDataHub}.
*/
@@ -15,13 +15,14 @@ import de.dennisguse.opentracks.databinding.TrackStoppedBinding;
import de.dennisguse.opentracks.fragments.ChooseActivityTypeDialogFragment;
import de.dennisguse.opentracks.services.TrackRecordingServiceConnection;
import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.ui.aggregatedStatistics.ConfirmDeleteDialogFragment;
import de.dennisguse.opentracks.util.ExportUtils;
import de.dennisguse.opentracks.util.IntentUtils;
import de.dennisguse.opentracks.util.StringUtils;
import de.dennisguse.opentracks.util.TrackIconUtils;
import de.dennisguse.opentracks.util.TrackUtils;
public class TrackStoppedActivity extends AbstractActivity implements ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller {
public class TrackStoppedActivity extends AbstractTrackDeleteActivity implements ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller {
private static final String TAG = TrackStoppedActivity.class.getSimpleName();
@@ -31,6 +32,8 @@ public class TrackStoppedActivity extends AbstractActivity implements ChooseActi
private Track.Id trackId;
private boolean isDiscarding = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -94,13 +97,16 @@ public class TrackStoppedActivity extends AbstractActivity implements ChooseActi
finish();
});
viewBinding.resumeButton.setOnClickListener(v -> {
resumeTrackAndFinish();
});
viewBinding.resumeButton.setOnClickListener(v -> resumeTrackAndFinish());
viewBinding.discardButton.setOnClickListener(v -> ConfirmDeleteDialogFragment.showDialog(getSupportFragmentManager(), trackId));
}
@Override
public void onBackPressed() {
if (isDiscarding) {
return;
}
super.onBackPressed();
resumeTrackAndFinish();
}
@@ -134,4 +140,22 @@ public class TrackStoppedActivity extends AbstractActivity implements ChooseActi
finish();
}).startAndBind(this);
}
}
@Override
protected void onDeleteConfirmed() {
isDiscarding = true;
viewBinding.loadingLayout.loadingText.setText(getString(R.string.track_discarding));
viewBinding.contentLinearLayout.setVisibility(View.GONE);
viewBinding.loadingLayout.loadingIndeterminate.setVisibility(View.VISIBLE);
}
@Override
protected void onDeleteFinished() {
finish();
}
@Override
protected Track.Id getRecordingTrackId() {
return null;
}
}
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loading_indeterminate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/loading_text"
style="@style/TextAppearance.MaterialComponents.Headline5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/loading_indicator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="Text" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/loading_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:layout_constraintTop_toBottomOf="@id/loading_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:indeterminate="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
+174 -142
View File
@@ -7,187 +7,219 @@
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView style="@style/ScrollView.WithBottomButtons">
<include
android:id="@+id/loading_layout"
layout="@layout/loading_indeterminate"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<LinearLayout
android:id="@+id/content_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/textInputOutlinedStyle"
android:hint="@string/generic_name"
android:imeOptions="actionNext"
android:importantForAutofill="no"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/track_edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:selectAllOnFocus="true" />
</com.google.android.material.textfield.TextInputLayout>
<ScrollView style="@style/ScrollView.WithBottomButtons">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="vertical"
android:padding="8dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/textInputOutlinedExposedDropdownMenuStyle"
style="?attr/textInputOutlinedStyle"
android:hint="@string/generic_name"
android:imeOptions="actionNext"
android:importantForAutofill="no"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/track_edit_activity_type"
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/track_edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:hint="@string/track_edit_activity_type_hint"
android:imeOptions="actionNext"
android:inputType="textCapSentences"
android:selectAllOnFocus="true" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/track_edit_activity_type_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
tools:src="@drawable/ic_activity_bike_24dp"/>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/textInputOutlinedStyle"
android:hint="@string/generic_description"
android:imeOptions="actionNext"
android:importantForAutofill="no"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/track_edit_description"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:selectAllOnFocus="true" />
android:orientation="horizontal">
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
style="?attr/textInputOutlinedExposedDropdownMenuStyle"
android:imeOptions="actionNext"
android:importantForAutofill="no"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/track_edit_activity_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:hint="@string/track_edit_activity_type_hint"
android:imeOptions="actionNext"
android:selectAllOnFocus="true" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/track_edit_activity_type_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
tools:src="@drawable/ic_activity_bike_24dp"/>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/textInputOutlinedStyle"
android:hint="@string/generic_description"
android:imeOptions="actionNext"
android:importantForAutofill="no"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/track_edit_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:selectAllOnFocus="true" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<!-- Time -->
<TextView
android:id="@+id/time"
style="?attr/textAppearanceHeadline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="04:54:36" />
<!-- Distance -->
<TextView
android:id="@+id/distance"
style="?attr/textAppearanceHeadline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/distance_unit"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time"
tools:layout_editor_absoluteX="52dp"
tools:text="130" />
<TextView
android:id="@+id/distance_unit"
style="@style/TextAppearance.OpenTracks.PrimaryUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/distance"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintStart_toEndOf="@+id/distance"
tools:text="km" />
<!-- Average moving speed -->
<TextView
android:id="@+id/speed"
style="?attr/textAppearanceHeadline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/speed_unit"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/guideline"
app:layout_constraintTop_toBottomOf="@id/time"
tools:text="26,5" />
<TextView
android:id="@+id/speed_unit"
style="@style/TextAppearance.OpenTracks.PrimaryUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/speed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/speed"
tools:text="km/h" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
android:layout_height="match_parent"
android:padding="8dp">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:id="@+id/buttons_guideline"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<!-- Time -->
<TextView
android:id="@+id/time"
style="?attr/textAppearanceHeadline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
<ImageView
android:id="@+id/discard_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="52dp"
android:contentDescription="@string/image_discard"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/resume_button"
app:layout_constraintTop_toTopOf="parent"
tools:text="04:54:36" />
app:srcCompat="@drawable/ic_delete_forever_24dp" />
<!-- Distance -->
<TextView
android:id="@+id/distance"
style="?attr/textAppearanceHeadline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/distance_unit"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time"
tools:layout_editor_absoluteX="52dp"
tools:text="130" />
<ImageView
android:id="@+id/resume_button"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/image_record"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/buttons_guideline"
app:layout_constraintStart_toEndOf="@id/buttons_guideline"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_button_resume" />
<TextView
android:id="@+id/distance_unit"
style="@style/TextAppearance.OpenTracks.PrimaryUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/distance"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintStart_toEndOf="@+id/distance"
tools:text="km" />
<!-- Average moving speed -->
<TextView
android:id="@+id/speed"
style="?attr/textAppearanceHeadline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/speed_unit"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/guideline"
app:layout_constraintTop_toBottomOf="@id/time"
tools:text="26,5" />
<TextView
android:id="@+id/speed_unit"
style="@style/TextAppearance.OpenTracks.PrimaryUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/speed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/speed"
tools:text="km/h" />
<ImageView
android:id="@+id/finish_button"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/image_stop"
android:layout_marginStart="36dp"
app:layout_constraintBottom_toBottomOf="@id/resume_button"
app:layout_constraintStart_toEndOf="@id/resume_button"
app:layout_constraintTop_toTopOf="@id/resume_button"
app:srcCompat="@drawable/ic_button_done" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">
<ImageView
android:id="@+id/resume_button"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/image_record"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/finish_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_button_resume" />
<ImageView
android:id="@+id/finish_button"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/image_stop"
app:layout_constraintBottom_toBottomOf="@id/resume_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/resume_button"
app:layout_constraintTop_toTopOf="@id/resume_button"
app:srcCompat="@drawable/ic_button_done" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
+2
View File
@@ -259,6 +259,7 @@ limitations under the License.
<string name="image_photo_marker">Photo marker</string>
<string name="image_record">Record</string>
<string name="image_stop">Stop</string>
<string name="image_discard">Discard</string>
<string name="image_track">Track</string>
<!-- Import -->
<string name="import_thread_interrupted">Thread interrupted</string>
@@ -491,6 +492,7 @@ limitations under the License.
<string name="track_delete_progress_message">Deleting&#8230;</string>
<string name="track_delete_progress">%1$d/%2$d</string>
<string name="track_delete_not_recording">This track cannot be deleted as it is currently recorded.</string>
<string name="track_discarding">Discarding Track</string>
<!-- Track Detail -->
<string name="track_detail_stats_tab">Stats</string>
<string name="track_detail_intervals_tab">Intervals</string>