mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
@@ -14,7 +14,6 @@ import de.dennisguse.opentracks.content.data.Altitude;
|
||||
import de.dennisguse.opentracks.content.data.Distance;
|
||||
import de.dennisguse.opentracks.content.data.Speed;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.fragments.TrackStubUtils;
|
||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package de.dennisguse.opentracks.fragments;
|
||||
package de.dennisguse.opentracks.chart;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@@ -27,7 +27,7 @@ import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
*
|
||||
* @author Youtao Liu
|
||||
*/
|
||||
public class TrackStubUtils {
|
||||
class TrackStubUtils {
|
||||
|
||||
public static final double INITIAL_ALTITUDE = 22;
|
||||
public static final long INITIAL_TIME = 1000L;
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package de.dennisguse.opentracks;
|
||||
|
||||
import android.view.Menu;
|
||||
|
||||
/**
|
||||
* Callback when items in the contextual action mode are selected.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public interface ContextualActionModeCallback {
|
||||
|
||||
/**
|
||||
* Invoked to prepare the menu for the selected items.
|
||||
*
|
||||
* @param menu the menu
|
||||
* @param positions the selected items' positions
|
||||
* @param ids the selected items' ids, if available
|
||||
* @param showSelectAll true to show select all
|
||||
*/
|
||||
void onPrepare(Menu menu, int[] positions, long[] ids, boolean showSelectAll);
|
||||
|
||||
/**
|
||||
* Invoked when items are selected.
|
||||
*
|
||||
* @param itemId the context menu item id
|
||||
* @param positions the selected items' positions
|
||||
* @param ids the selected items' ids, if available
|
||||
*/
|
||||
boolean onClick(int itemId, int[] positions, long[] ids);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class TrackListActivity extends AbstractTrackDeleteActivity implements Co
|
||||
private TrackRecordingService.RecordingStatus recordingStatus = TrackRecordingService.STATUS_DEFAULT;
|
||||
|
||||
// Callback when an item is selected in the contextual action mode
|
||||
private final ContextualActionModeCallback contextualActionModeCallback = new ContextualActionModeCallback() {
|
||||
private final ActivityUtils.ContextualActionModeCallback contextualActionModeCallback = new ActivityUtils.ContextualActionModeCallback() {
|
||||
|
||||
@Override
|
||||
public void onPrepare(Menu menu, int[] positions, long[] trackIds, boolean showSelectAll) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
|
||||
import de.dennisguse.opentracks.chart.ChartFragment;
|
||||
import de.dennisguse.opentracks.chart.TrackDataHubInterface;
|
||||
import de.dennisguse.opentracks.content.TrackDataHub;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
@@ -57,7 +58,7 @@ import de.dennisguse.opentracks.util.IntentUtils;
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
//TODO Should not use TrackRecordingServiceConnection; only used to determine if there is NO current recording, to enable resume functionality.
|
||||
public class TrackRecordedActivity extends AbstractTrackDeleteActivity implements ConfirmDeleteDialogFragment.ConfirmDeleteCaller, TrackActivityDataHubInterface {
|
||||
public class TrackRecordedActivity extends AbstractTrackDeleteActivity implements ConfirmDeleteDialogFragment.ConfirmDeleteCaller, TrackDataHubInterface {
|
||||
|
||||
private static final String TAG = TrackRecordedActivity.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.chart.ChartFragment;
|
||||
import de.dennisguse.opentracks.chart.TrackDataHubInterface;
|
||||
import de.dennisguse.opentracks.content.TrackDataHub;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
@@ -48,7 +49,7 @@ import de.dennisguse.opentracks.util.TrackUtils;
|
||||
*/
|
||||
//NOTE: This activity does NOT react to preference changes of R.string.recording_track_id_key.
|
||||
//This mode of communication should be removed anyhow.
|
||||
public class TrackRecordingActivity extends AbstractActivity implements ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller, TrackActivityDataHubInterface, ControllerFragment.Callback {
|
||||
public class TrackRecordingActivity extends AbstractActivity implements ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller, TrackDataHubInterface, ControllerFragment.Callback {
|
||||
|
||||
public static final String EXTRA_TRACK_ID = "track_id";
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.TrackActivityDataHubInterface;
|
||||
import de.dennisguse.opentracks.content.TrackDataHub;
|
||||
import de.dennisguse.opentracks.content.TrackDataListener;
|
||||
import de.dennisguse.opentracks.content.data.Altitude;
|
||||
@@ -242,7 +241,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
* Needs to be synchronized because trackDataHub can be accessed by multiple threads.
|
||||
*/
|
||||
private synchronized void resumeTrackDataHub() {
|
||||
trackDataHub = ((TrackActivityDataHubInterface) getActivity()).getTrackDataHub();
|
||||
trackDataHub = ((TrackDataHubInterface) getActivity()).getTrackDataHub();
|
||||
trackDataHub.registerTrackDataListener(this);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package de.dennisguse.opentracks;
|
||||
package de.dennisguse.opentracks.chart;
|
||||
|
||||
import de.dennisguse.opentracks.content.TrackDataHub;
|
||||
|
||||
/**
|
||||
* Interface for communication between activities that use {@link de.dennisguse.opentracks.content.TrackDataHub} and their fragments that need thi data hub.
|
||||
*/
|
||||
public interface TrackActivityDataHubInterface {
|
||||
public interface TrackDataHubInterface {
|
||||
TrackDataHub getTrackDataHub();
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
|
||||
import de.dennisguse.opentracks.AbstractActivity;
|
||||
import de.dennisguse.opentracks.ContextualActionModeCallback;
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.MarkerColumns;
|
||||
@@ -74,7 +73,7 @@ public class MarkerListActivity extends AbstractActivity implements DeleteMarker
|
||||
.observe(MarkerListActivity.this, this::onRecordingStatusChanged);
|
||||
|
||||
// Callback when an item is selected in the contextual action mode
|
||||
private final ContextualActionModeCallback contextualActionModeCallback = new ContextualActionModeCallback() {
|
||||
private final ActivityUtils.ContextualActionModeCallback contextualActionModeCallback = new ActivityUtils.ContextualActionModeCallback() {
|
||||
@Override
|
||||
public void onPrepare(Menu menu, int[] positions, long[] ids, boolean showSelectAll) {
|
||||
boolean isSingleSelection = ids.length == 1;
|
||||
|
||||
@@ -21,7 +21,6 @@ import androidx.appcompat.widget.SearchView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.dennisguse.opentracks.ContextualActionModeCallback;
|
||||
import de.dennisguse.opentracks.R;
|
||||
|
||||
public class ActivityUtils {
|
||||
@@ -102,4 +101,31 @@ public class ActivityUtils {
|
||||
vibrator.vibrate(milliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback when items in the contextual action mode are selected.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public interface ContextualActionModeCallback {
|
||||
|
||||
/**
|
||||
* Invoked to prepare the menu for the selected items.
|
||||
*
|
||||
* @param menu the menu
|
||||
* @param positions the selected items' positions
|
||||
* @param ids the selected items' ids, if available
|
||||
* @param showSelectAll true to show select all
|
||||
*/
|
||||
void onPrepare(Menu menu, int[] positions, long[] ids, boolean showSelectAll);
|
||||
|
||||
/**
|
||||
* Invoked when items are selected.
|
||||
*
|
||||
* @param itemId the context menu item id
|
||||
* @param positions the selected items' positions
|
||||
* @param ids the selected items' ids, if available
|
||||
*/
|
||||
boolean onClick(int itemId, int[] positions, long[] ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user