Skip to content

Commit

Permalink
DashboardAPI: report if track is recording and start Dashboard on sam…
Browse files Browse the repository at this point in the history
…e task.

Necessary for Picture-in-Picture mode.
  • Loading branch information
dennisguse committed Aug 3, 2020
1 parent 2042312 commit 1d2fde6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ private boolean handleContextItem(int itemId, long[] trackIds) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -41,7 +42,7 @@ private 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;
}
Expand All @@ -56,10 +57,10 @@ public static void startDashboard(Context context, long[] trackIds) {
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));
}

Expand All @@ -72,10 +73,6 @@ public static void startDashboard(Context context, long[] trackIds) {
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);
Expand Down

0 comments on commit 1d2fde6

Please sign in to comment.