forked from upstream-mirrors/OpenTracks
Compare resourceIds via if rather than switch.
As of ADT 14 as well as Gradle Plugin 5.0 those are not final anymore. Fixes #544.
This commit is contained in:
@@ -227,16 +227,17 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == R.id.marker_edit_insert_photo) {
|
||||||
case R.id.marker_edit_insert_photo:
|
createMarkerWithPicture();
|
||||||
createMarkerWithPicture();
|
return true;
|
||||||
return true;
|
|
||||||
case R.id.marker_edit_insert_gallery_img:
|
|
||||||
createMarkerWithGalleryImage();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.marker_edit_insert_gallery_img) {
|
||||||
|
createMarkerWithGalleryImage();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -252,7 +253,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
if (resultCode == RESULT_CANCELED) {
|
if (resultCode == RESULT_CANCELED) {
|
||||||
Toast.makeText(this, R.string.marker_add_photo_canceled, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.marker_add_photo_canceled, Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
} else if (resultCode == RESULT_OK) {
|
} else if (resultCode == RESULT_OK) {
|
||||||
Uri srcUri = data.getData();
|
Uri srcUri = data.getData();
|
||||||
try (ParcelFileDescriptor parcelFd = getContentResolver().openFileDescriptor(srcUri, "r")) {
|
try (ParcelFileDescriptor parcelFd = getContentResolver().openFileDescriptor(srcUri, "r")) {
|
||||||
FileDescriptor srcFd = parcelFd.getFileDescriptor();
|
FileDescriptor srcFd = parcelFd.getFileDescriptor();
|
||||||
@@ -261,7 +262,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
|
|
||||||
photoUri = FileUtils.getUriForFile(this, dstFile);
|
photoUri = FileUtils.getUriForFile(this, dstFile);
|
||||||
setMarkerImageView(photoUri);
|
setMarkerImageView(photoUri);
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
Toast.makeText(this, R.string.marker_add_canceled, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.marker_add_canceled, Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
@@ -273,7 +274,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks and hide/shows all buttons/options about marker photo options.
|
* Checks and hide/shows all buttons/options about marker photo options.
|
||||||
*
|
* <p>
|
||||||
* If a photo is set then one's options are shown, otherwise another ones are shown.
|
* If a photo is set then one's options are shown, otherwise another ones are shown.
|
||||||
*/
|
*/
|
||||||
private void hideAndShowOptions() {
|
private void hideAndShowOptions() {
|
||||||
|
|||||||
@@ -320,43 +320,45 @@ public class TrackListActivity extends AbstractListActivity implements ConfirmDe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Intent intent;
|
if (item.getItemId() == R.id.track_list_start_gps) {
|
||||||
switch (item.getItemId()) {
|
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
||||||
case R.id.track_list_start_gps:
|
if (locationManager != null && !locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||||
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||||
if (locationManager != null && !locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
} else {
|
||||||
intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
// Invoke trackRecordingService
|
||||||
startActivity(intent);
|
if (!isGpsStarted()) {
|
||||||
|
trackRecordingServiceConnection.startAndBind(this);
|
||||||
|
bindChangedCallback.run();
|
||||||
} else {
|
} else {
|
||||||
// Invoke trackRecordingService
|
TrackRecordingServiceInterface trackRecordingService = trackRecordingServiceConnection.getServiceIfBound();
|
||||||
if (!isGpsStarted()) {
|
if (trackRecordingService != null) {
|
||||||
trackRecordingServiceConnection.startAndBind(this);
|
trackRecordingService.stopGps();
|
||||||
bindChangedCallback.run();
|
|
||||||
} else {
|
|
||||||
TrackRecordingServiceInterface trackRecordingService = trackRecordingServiceConnection.getServiceIfBound();
|
|
||||||
if (trackRecordingService != null) {
|
|
||||||
trackRecordingService.stopGps();
|
|
||||||
}
|
|
||||||
trackRecordingServiceConnection.unbindAndStop(this);
|
|
||||||
}
|
}
|
||||||
|
trackRecordingServiceConnection.unbindAndStop(this);
|
||||||
// Update menu after starting or stopping gps
|
|
||||||
this.invalidateOptionsMenu();
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
case R.id.track_list_aggregated_stats:
|
// Update menu after starting or stopping gps
|
||||||
intent = IntentUtils.newIntent(this, AggregatedStatisticsActivity.class);
|
this.invalidateOptionsMenu();
|
||||||
startActivity(intent);
|
}
|
||||||
return true;
|
|
||||||
case R.id.track_list_markers:
|
return true;
|
||||||
intent = IntentUtils.newIntent(this, MarkerListActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_list_settings:
|
|
||||||
intent = IntentUtils.newIntent(this, SettingsActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_list_aggregated_stats) {
|
||||||
|
startActivity(IntentUtils.newIntent(this, AggregatedStatisticsActivity.class));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_list_markers) {
|
||||||
|
startActivity(IntentUtils.newIntent(this, MarkerListActivity.class));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_list_settings) {
|
||||||
|
startActivity(IntentUtils.newIntent(this, SettingsActivity.class));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.util.Log;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewParent;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -147,43 +146,51 @@ public class TrackRecordedActivity extends AbstractListActivity implements Confi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Intent intent;
|
if (item.getItemId() == R.id.track_detail_share) {
|
||||||
switch (item.getItemId()) {
|
Intent intent = Intent.createChooser(IntentUtils.newShareFileIntent(this, trackId), null);
|
||||||
case R.id.track_detail_share:
|
startActivity(intent);
|
||||||
intent = IntentUtils.newShareFileIntent(this, trackId);
|
return true;
|
||||||
intent = Intent.createChooser(intent, null);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_menu_show_on_map:
|
|
||||||
IntentDashboardUtils.startDashboard(this, false, trackId);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_markers:
|
|
||||||
intent = IntentUtils.newIntent(this, MarkerListActivity.class)
|
|
||||||
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_edit:
|
|
||||||
intent = IntentUtils.newIntent(this, TrackEditActivity.class)
|
|
||||||
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_delete:
|
|
||||||
deleteTracks(trackId);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_resume_track:
|
|
||||||
Intent newIntent = IntentUtils.newIntent(TrackRecordedActivity.this, TrackRecordingActivity.class)
|
|
||||||
.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId);
|
|
||||||
startActivity(newIntent);
|
|
||||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_settings:
|
|
||||||
intent = IntentUtils.newIntent(this, SettingsActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_menu_show_on_map) {
|
||||||
|
IntentDashboardUtils.startDashboard(this, false, trackId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_markers) {
|
||||||
|
Intent intent = IntentUtils.newIntent(this, MarkerListActivity.class)
|
||||||
|
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_edit) {
|
||||||
|
Intent intent = IntentUtils.newIntent(this, TrackEditActivity.class)
|
||||||
|
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_delete) {
|
||||||
|
deleteTracks(trackId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_resume_track) {
|
||||||
|
Intent newIntent = IntentUtils.newIntent(TrackRecordedActivity.this, TrackRecordingActivity.class)
|
||||||
|
.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId);
|
||||||
|
startActivity(newIntent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_settings) {
|
||||||
|
startActivity(IntentUtils.newIntent(this, SettingsActivity.class));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -278,34 +278,41 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Intent intent;
|
if (item.getItemId() == R.id.track_detail_insert_marker) {
|
||||||
switch (item.getItemId()) {
|
Intent intent = IntentUtils
|
||||||
case R.id.track_detail_insert_marker:
|
.newIntent(this, MarkerEditActivity.class)
|
||||||
intent = IntentUtils
|
.putExtra(MarkerEditActivity.EXTRA_TRACK_ID, trackId);
|
||||||
.newIntent(this, MarkerEditActivity.class)
|
startActivity(intent);
|
||||||
.putExtra(MarkerEditActivity.EXTRA_TRACK_ID, trackId);
|
return true;
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_menu_show_on_map:
|
|
||||||
IntentDashboardUtils.startDashboard(this, true, trackId);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_markers:
|
|
||||||
intent = IntentUtils.newIntent(this, MarkerListActivity.class)
|
|
||||||
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_edit:
|
|
||||||
intent = IntentUtils.newIntent(this, TrackEditActivity.class)
|
|
||||||
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_settings:
|
|
||||||
intent = IntentUtils.newIntent(this, SettingsActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_menu_show_on_map) {
|
||||||
|
IntentDashboardUtils.startDashboard(this, true, trackId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_markers) {
|
||||||
|
Intent intent = IntentUtils.newIntent(this, MarkerListActivity.class)
|
||||||
|
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_edit) {
|
||||||
|
Intent intent = IntentUtils.newIntent(this, TrackEditActivity.class)
|
||||||
|
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.track_detail_settings) {
|
||||||
|
Intent intent = IntentUtils.newIntent(this, SettingsActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -184,29 +184,34 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Marker.Id markerId = getArguments().getParcelable(KEY_MARKER_ID); //TODO Should only happen in onCreate?
|
Marker.Id markerId = getArguments().getParcelable(KEY_MARKER_ID); //TODO Should only happen in onCreate?
|
||||||
FragmentActivity fragmentActivity = getActivity();
|
FragmentActivity fragmentActivity = getActivity();
|
||||||
Intent intent;
|
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == R.id.marker_detail_show_on_map) {
|
||||||
case R.id.marker_detail_show_on_map:
|
IntentUtils.showCoordinateOnMap(getContext(), marker);
|
||||||
IntentUtils.showCoordinateOnMap(getContext(), marker);
|
return true;
|
||||||
return true;
|
|
||||||
case R.id.marker_detail_edit:
|
|
||||||
intent = IntentUtils.newIntent(fragmentActivity, MarkerEditActivity.class)
|
|
||||||
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId);
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.marker_detail_share:
|
|
||||||
if (marker.hasPhoto()) {
|
|
||||||
intent = IntentUtils.newShareImageIntent(getContext(), marker.getPhotoURI());
|
|
||||||
intent = Intent.createChooser(intent, null);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.marker_detail_delete:
|
|
||||||
DeleteMarkerDialogFragment.showDialog(getChildFragmentManager(), markerId);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.marker_detail_edit) {
|
||||||
|
Intent intent = IntentUtils.newIntent(fragmentActivity, MarkerEditActivity.class)
|
||||||
|
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.marker_detail_share) {
|
||||||
|
if (marker.hasPhoto()) {
|
||||||
|
Intent intent = IntentUtils.newShareImageIntent(getContext(), marker.getPhotoURI());
|
||||||
|
intent = Intent.createChooser(intent, null);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getItemId() == R.id.marker_detail_delete) {
|
||||||
|
DeleteMarkerDialogFragment.showDialog(getChildFragmentManager(), markerId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMarker(boolean refresh) {
|
private void updateMarker(boolean refresh) {
|
||||||
|
|||||||
Reference in New Issue
Block a user