fix display of the button "Start online monitoring"

This commit is contained in:
Skalii 2021-03-25 12:56:50 +02:00
parent eff2d35a7f
commit 27bf5e7809
2 changed files with 20 additions and 25 deletions

View file

@ -507,7 +507,8 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
STOP(R.string.shared_string_control_stop, R.drawable.ic_action_rec_stop),
STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop),
STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file),
STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark),
START_ONLINE(R.string.live_monitoring_start, R.drawable.ic_world_globe_dark),
STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_action_offline),
CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close),
CLOSE(R.string.shared_string_close, R.drawable.ic_action_close),
START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement),

View file

@ -51,8 +51,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme
private SelectedGpxFile selectedGpxFile;
private final Handler handler = new Handler();
private Runnable updatingTimeTrackSaved;
private int indexButtonOnline = -1;
private int indexButtonOnlineDivider = -1;
private GPXFile getGPXFile() {
return selectedGpxFile.getGpxFile();
@ -91,7 +89,8 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme
buttonClear = createItem(inflater, ItemType.CLEAR_DATA, hasDataToSave());
final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD);
final View buttonOnline = createItem(inflater, ItemType.STOP_ONLINE, hasDataToSave());
final View buttonOnline = createItem(inflater, settings.LIVE_MONITORING.get()
? ItemType.STOP_ONLINE : ItemType.START_ONLINE);
buttonSave = createItem(inflater, ItemType.SAVE, hasDataToSave());
final View buttonSegment = createItem(inflater, ItemType.START_NEW_SEGMENT, wasTrackMonitored());
@ -131,27 +130,19 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme
items.add(new DividerSpaceItem(app, dp36));
if (app.getLiveMonitoringHelper().isLiveMonitoringEnabled()) {
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(buttonOnline)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
settings.LIVE_MONITORING.set(false);
if (indexButtonOnline != -1) {
AndroidUiHelper.updateVisibility(items.get(indexButtonOnline).getView(), false);
}
if (indexButtonOnlineDivider != -1) {
AndroidUiHelper.updateVisibility(items.get(indexButtonOnlineDivider).getView(), false);
}
boolean wasOnlineMonitored = !settings.LIVE_MONITORING.get();
settings.LIVE_MONITORING.set(wasOnlineMonitored);
createItem(buttonOnline, wasOnlineMonitored ? ItemType.STOP_ONLINE : ItemType.START_ONLINE);
}
})
.create());
indexButtonOnline = items.size() - 1;
items.add(new DividerSpaceItem(app, dp36));
indexButtonOnlineDivider = items.size() - 1;
}
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(buttonSave)
@ -181,7 +172,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme
.create());
items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small)));
}
@Override
@ -243,6 +233,10 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme
}
}
private void createItem(View view, ItemType type) {
TripRecordingBottomSheet.createItem(app, nightMode, view, type, true, null);
}
private View createItem(LayoutInflater inflater, ItemType type, boolean enabled) {
return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type, enabled, null);
}