DashboardAPI: report if track is recording and start Dashboard on same task.

Necessary for Picture-in-Picture mode.
This commit is contained in:
Dennis Guse
2020-08-01 22:58:47 +02:00
parent 20423121ee
commit 1d2fde6e69
4 changed files with 7 additions and 10 deletions
@@ -458,7 +458,7 @@ public class TrackListActivity extends AbstractListActivity implements ConfirmDe
Intent intent;
switch (itemId) {
case R.id.list_context_menu_show_on_map:
IntentDashboardUtils.startDashboard(this, trackIds);
IntentDashboardUtils.startDashboard(this, trackIds, false);
return true;
case R.id.list_context_menu_share:
intent = IntentUtils.newShareFileIntent(this, trackIds);
@@ -187,7 +187,7 @@ public class TrackRecordedActivity extends AbstractListActivity implements Choos
startActivity(intent);
return true;
case R.id.track_detail_menu_show_on_map:
IntentDashboardUtils.startDashboard(this, trackId);
IntentDashboardUtils.startDashboard(this, new long[]{trackId}, false);
return true;
case R.id.track_detail_markers:
intent = IntentUtils.newIntent(this, MarkerListActivity.class)
@@ -314,7 +314,7 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
startActivity(intent);
return true;
case R.id.track_detail_menu_show_on_map:
IntentDashboardUtils.startDashboard(this, trackId);
IntentDashboardUtils.startDashboard(this, new long[]{trackId}, true);
return true;
case R.id.track_detail_markers:
intent = IntentUtils.newIntent(this, MarkerListActivity.class)
@@ -24,6 +24,7 @@ public class IntentDashboardUtils {
private static final String ACTION_DASHBOARD_PAYLOAD = ACTION_DASHBOARD + ".Payload";
private static final String EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK = "EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK";
private static final String EXTRAS_SHOULD_KEEP_SCREEN_ON = "EXTRAS_SHOULD_KEEP_SCREEN_ON";
private static final String EXTRAS_SHOW_WHEN_LOCKED = "EXTRAS_SHOULD_KEEP_SCREEN_ON";
private static final String EXTRAS_SHOW_FULLSCREEN = "EXTRAS_SHOULD_FULLSCREEN";
@@ -41,7 +42,7 @@ public class IntentDashboardUtils {
* @param context the context
* @param trackIds the track ids
*/
public static void startDashboard(Context context, long[] trackIds) {
public static void startDashboard(Context context, long[] trackIds, boolean isRecording) {
if (trackIds.length == 0) {
return;
}
@@ -56,10 +57,10 @@ public class IntentDashboardUtils {
Intent intent = new Intent(ACTION_DASHBOARD);
intent.putParcelableArrayListExtra(ACTION_DASHBOARD_PAYLOAD, uris);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRAS_SHOULD_KEEP_SCREEN_ON, PreferencesUtils.shouldKeepScreenOn(context));
intent.putExtra(EXTRAS_SHOW_WHEN_LOCKED, PreferencesUtils.shouldShowStatsOnLockscreen(context));
if (PreferencesUtils.isRecording(context)) {
intent.putExtra(EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK, isRecording);
if (isRecording) {
intent.putExtra(EXTRAS_SHOW_FULLSCREEN, PreferencesUtils.shouldUseFullscreen(context));
}
@@ -72,10 +73,6 @@ public class IntentDashboardUtils {
context.startActivity(intent);
}
public static void startDashboard(Context context, long trackId) {
startDashboard(context, new long[]{trackId});
}
public static long[] extractTrackIdsFromIntent(@NonNull Intent intent) {
final ArrayList<Uri> uris = intent.getParcelableArrayListExtra(ACTION_DASHBOARD_PAYLOAD);
final Uri tracksUri = uris.get(TRACK_URI_INDEX);