SD-216 - fix back button functionality for recordings and history tabs #16

Merged
Bogdan merged 1 commits from fix/SD-216-back-navigation-broken into develop 2022-03-31 04:21:59 +00:00
2 changed files with 23 additions and 3 deletions
Showing only changes of commit 3a0fe96708 - Show all commits

View File

@ -3,6 +3,7 @@ package com.safemobile.safedispatch;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.app.DatePickerDialog; import android.app.DatePickerDialog;
import android.app.Dialog; import android.app.Dialog;
import android.graphics.Color; import android.graphics.Color;
@ -124,6 +125,18 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14)); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
} }
@Override
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.exit))
.setCancelable(false)
.setNeutralButton(getString(R.string.logout), (dialog, id) -> parentTab.whenBackPressed(AppParams.ActivityResult.logout))
.setPositiveButton(getString(R.string.ext), (dialog, id) -> parentTab.whenBackPressed(AppParams.ActivityResult.exit))
.setNegativeButton(getString(R.string.cancel), (dialog, id) -> dialog.cancel());
AlertDialog alert = builder.create();
alert.show();
}
private void setDate() { private void setDate() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
endDate = calendar.getTime(); endDate = calendar.getTime();

View File

@ -42,6 +42,7 @@ public class RecordingsActivity extends Activity {
private GridView gridView; private GridView gridView;
private RecordingsGridViewAdapter adapter; private RecordingsGridViewAdapter adapter;
private View convertViewRecording; private View convertViewRecording;
private boolean isRecordingPlaying = false;
private int playingPosition = -1; private int playingPosition = -1;
@ -89,6 +90,7 @@ public class RecordingsActivity extends Activity {
gridView.setAdapter(adapter); gridView.setAdapter(adapter);
gridView.setOnItemClickListener(onItemClickListener); gridView.setOnItemClickListener(onItemClickListener);
gridView.setOnTouchListener((v, event) -> isRecordingPlaying);
if (recHandle == null && !AppParams.DEMO) if (recHandle == null && !AppParams.DEMO)
recHandle = new RecordingHandle(AppParams.IP); recHandle = new RecordingHandle(AppParams.IP);
@ -171,12 +173,17 @@ public class RecordingsActivity extends Activity {
SM.Debug("onResume"); SM.Debug("onResume");
} }
private final OnItemClickListener onItemClickListener = new OnItemClickListener() { private final OnItemClickListener onItemClickListener = new OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) { public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
// disable grid scrolling and item click // disable grid scrolling and item click
gridView.setEnabled(false); if (isRecordingPlaying)
return;
isRecordingPlaying = true;
setConvertViewRecording(view); setConvertViewRecording(view);
// change background to playing // change background to playing
@ -262,7 +269,7 @@ public class RecordingsActivity extends Activity {
adapter.changePlaying(getPlayingPosition(), false); adapter.changePlaying(getPlayingPosition(), false);
// enable grid // enable grid
gridView.setEnabled(true); isRecordingPlaying = false;
// set playing Recording position to -1 // set playing Recording position to -1
setPlayingPosition(-1); setPlayingPosition(-1);