Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #50 from rilling/group10
Browse files Browse the repository at this point in the history
Update GenericStatisticsViewHolder.java
  • Loading branch information
dinesh-07 authored Oct 15, 2023
2 parents 6748aa2 + d8b8e63 commit 72eb3f3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ limitations under the License.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

Expand Down
122 changes: 62 additions & 60 deletions src/main/java/de/dennisguse/opentracks/TrackListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,60 @@ public void onDestroy() {
viewBinding.trackListFabAction.setVisibility(View.VISIBLE);
viewBinding.bottomAppBar.performShow(true);
}

/**
* Handles a context item selection.
*
* @param itemId the menu item id
* @param longTrackIds the track ids
* @return true if handled.
*/
private boolean handleContextItem(int itemId, long... longTrackIds) {
Track.Id[] trackIds = new Track.Id[longTrackIds.length];
for (int i = 0; i < longTrackIds.length; i++) {
trackIds[i] = new Track.Id(longTrackIds[i]);
}

if (itemId == R.id.list_context_menu_show_on_map) {
IntentDashboardUtils.showTrackOnMap(this, false, trackIds);
return true;
}

if (itemId == R.id.list_context_menu_share) {
Intent intent = ShareUtils.newShareFileIntent(this, trackIds);
intent = Intent.createChooser(intent, null);
startActivity(intent);
return true;
}

if (itemId == R.id.list_context_menu_edit) {
Intent intent = IntentUtils.newIntent(this, TrackEditActivity.class)
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackIds[0]);
startActivity(intent);
return true;
}

if (itemId == R.id.list_context_menu_delete) {
deleteTracks(trackIds);
return true;
}

if (itemId == R.id.list_context_menu_aggregated_stats) {
Intent intent = IntentUtils.newIntent(this, AggregatedStatisticsActivity.class)
.putParcelableArrayListExtra(AggregatedStatisticsActivity.EXTRA_TRACK_IDS, new ArrayList<>(Arrays.asList(trackIds)));
startActivity(intent);
return true;
}

if (itemId == R.id.list_context_menu_select_all) {
for (int i = 0; i < viewBinding.trackList.getCount(); i++) {
viewBinding.trackList.setItemChecked(i, true);
}
return false;
}

return false;
}
};

private final OnSharedPreferenceChangeListener sharedPreferenceChangeListener = (sharedPreferences, key) -> {
Expand Down Expand Up @@ -166,7 +220,7 @@ protected void onCreate(Bundle savedInstanceState) {

trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback);

viewBinding.aggregatedStatsButton.setOnClickListener((view) -> startActivity(IntentUtils.newIntent(this, AggregatedStatisticsActivity.class)));
viewBinding.aggregatedStatsButton.setOnClickListener((view) -> startActivity(IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) this, AggregatedStatisticsActivity.class)));
viewBinding.sensorStartButton.setOnClickListener((view) -> {
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
if (locationManager != null && !locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Expand All @@ -185,12 +239,12 @@ protected void onCreate(Bundle savedInstanceState) {
Track.Id trackId = new Track.Id(trackIdId);
if (recordingStatus.isRecording() && trackId.equals(recordingStatus.getTrackId())) {
// Is recording -> open record activity.
Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class)
Intent newIntent = IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) TrackListActivity.this, TrackRecordingActivity.class)
.putExtra(TrackRecordedActivity.EXTRA_TRACK_ID, trackId);
startActivity(newIntent);
} else {
// Not recording -> open detail activity.
Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordedActivity.class)
Intent newIntent = IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) TrackListActivity.this, TrackRecordedActivity.class)
.putExtra(TrackRecordedActivity.EXTRA_TRACK_ID, trackId);
ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(
this,
Expand Down Expand Up @@ -249,7 +303,7 @@ public void bindView(View view, Context context, Cursor cursor) {
new TrackRecordingServiceConnection((service, connection) -> {
Track.Id trackId = service.startNewTrack();

Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class);
Intent newIntent = IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) TrackListActivity.this, TrackRecordingActivity.class);
newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId);
startActivity(newIntent);

Expand Down Expand Up @@ -343,12 +397,12 @@ public boolean onPrepareOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.track_list_markers) {
startActivity(IntentUtils.newIntent(this, MarkerListActivity.class));
startActivity(IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) this, MarkerListActivity.class));
return true;
}

if (item.getItemId() == R.id.track_list_settings) {
startActivity(IntentUtils.newIntent(this, SettingsActivity.class));
startActivity(IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) this, SettingsActivity.class));
return true;
}

Expand All @@ -360,7 +414,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

if (item.getItemId() == R.id.track_list_help) {
startActivity(IntentUtils.newIntent(this, HelpActivity.class));
startActivity(IntentUtils.newIntent((ActivityUtils.ContextualActionModeCallback) this, HelpActivity.class));
return true;
}

Expand Down Expand Up @@ -445,59 +499,7 @@ private void updateGpsMenuItem(boolean isGpsStarted, boolean isRecording) {
}
}

/**
* Handles a context item selection.
*
* @param itemId the menu item id
* @param longTrackIds the track ids
* @return true if handled.
*/
private boolean handleContextItem(int itemId, long... longTrackIds) {
Track.Id[] trackIds = new Track.Id[longTrackIds.length];
for (int i = 0; i < longTrackIds.length; i++) {
trackIds[i] = new Track.Id(longTrackIds[i]);
}

if (itemId == R.id.list_context_menu_show_on_map) {
IntentDashboardUtils.showTrackOnMap(this, false, trackIds);
return true;
}

if (itemId == R.id.list_context_menu_share) {
Intent intent = ShareUtils.newShareFileIntent(this, trackIds);
intent = Intent.createChooser(intent, null);
startActivity(intent);
return true;
}

if (itemId == R.id.list_context_menu_edit) {
Intent intent = IntentUtils.newIntent(this, TrackEditActivity.class)
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackIds[0]);
startActivity(intent);
return true;
}

if (itemId == R.id.list_context_menu_delete) {
deleteTracks(trackIds);
return true;
}

if (itemId == R.id.list_context_menu_aggregated_stats) {
Intent intent = IntentUtils.newIntent(this, AggregatedStatisticsActivity.class)
.putParcelableArrayListExtra(AggregatedStatisticsActivity.EXTRA_TRACK_IDS, new ArrayList<>(Arrays.asList(trackIds)));
startActivity(intent);
return true;
}

if (itemId == R.id.list_context_menu_select_all) {
for (int i = 0; i < viewBinding.trackList.getCount(); i++) {
viewBinding.trackList.setItemChecked(i, true);
}
return false;
}

return false;
}

private class TrackLoaderCallBack implements LoaderManager.LoaderCallbacks<Cursor> {

Expand Down Expand Up @@ -562,4 +564,4 @@ private void onRecordingStatusChanged(RecordingStatus status) {
recordingStatus = status;
setFloatButton();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ public void configureUI(DataField dataField) {

@Override
public void onChanged(UnitSystem unitSystem, RecordingData data) {
throw new UnsupportedOperationException();
//We don't have enough information or context to provide a complete implementation in the base class or interface for this mothod.
}

}

0 comments on commit 72eb3f3

Please sign in to comment.