From 6a8f86668c59f49e3a596b7e5ce7389badc83f1f Mon Sep 17 00:00:00 2001 From: pranjalesh <31514465+pranjalesh@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:37:19 -0500 Subject: [PATCH 01/11] Added resume and finish button in pause mode --- src/main/res/layout/track_stopped.xml | 40 +++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/res/layout/track_stopped.xml b/src/main/res/layout/track_stopped.xml index 4aca4c419..b0c5d3804 100644 --- a/src/main/res/layout/track_stopped.xml +++ b/src/main/res/layout/track_stopped.xml @@ -197,27 +197,33 @@ app:tint="?attr/colorOnBackground" app:srcCompat="@drawable/ic_delete_forever_24dp" /> - + app:layout_constraintEnd_toStartOf="@+id/finish_button" + app:layout_constraintTop_toTopOf="parent" /> - + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_marginTop="16dp" + android:layout_marginEnd="40dp" + android:backgroundTint="#070707" + android:fontFamily="monospace" + android:text="FINISH" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> From a00027b2cfe2989d7646427708d25d894479f446 Mon Sep 17 00:00:00 2001 From: Praful Nair <51130135+prafulnair@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:48:35 -0500 Subject: [PATCH 02/11] Changed and added Start button and linked it. Created separate start button to track workout --- src/main/res/layout/track_list.xml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/res/layout/track_list.xml b/src/main/res/layout/track_list.xml index 91e315454..060cbae0a 100644 --- a/src/main/res/layout/track_list.xml +++ b/src/main/res/layout/track_list.xml @@ -32,6 +32,7 @@ limitations under the License. - - - \ No newline at end of file + android:layout_weight="1" + android:backgroundTint="#0B0A0A" + android:fontFamily="monospace" + android:text="START WORKOUT" + android:textStyle="bold" + app:layout_anchor="@+id/bottom_app_bar" + app:layout_anchorGravity="center" /> + + From 6ee8101195d692fecf93873372a4658d008936d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Craahuljohn=E2=80=9D?= Date: Wed, 15 Nov 2023 19:53:47 -0500 Subject: [PATCH 03/11] Changed START button functionalities --- .../java/de/dennisguse/opentracks/TrackListActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java index bf10ba549..c4934e9a6 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java @@ -107,7 +107,7 @@ public void onPrepare(Menu menu, int[] positions, long[] trackIds, boolean showS boolean isSingleSelection = trackIds.length == 1; viewBinding.bottomAppBar.performHide(true); - viewBinding.trackListFabAction.setVisibility(View.INVISIBLE); + viewBinding.button.setVisibility(View.INVISIBLE); menu.findItem(R.id.list_context_menu_edit).setVisible(isSingleSelection); menu.findItem(R.id.list_context_menu_select_all).setVisible(showSelectAll); @@ -120,7 +120,7 @@ public boolean onClick(int itemId, int[] positions, long[] trackIds) { @Override public void onDestroy() { - viewBinding.trackListFabAction.setVisibility(View.VISIBLE); + viewBinding.button.setVisibility(View.VISIBLE); viewBinding.bottomAppBar.performShow(true); } }; @@ -238,7 +238,7 @@ public void bindView(View view, Context context, Cursor cursor) { viewBinding.trackList.setAdapter(resourceCursorAdapter); ActivityUtils.configureListViewContextualMenu(viewBinding.trackList, contextualActionModeCallback); - viewBinding.trackListFabAction.setOnClickListener((view) -> { + viewBinding.button.setOnClickListener((view) -> { if (recordingStatus.isRecording()) { Toast.makeText(TrackListActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); return; @@ -256,7 +256,7 @@ public void bindView(View view, Context context, Cursor cursor) { connection.unbind(this); }).startAndBind(this, true); }); - viewBinding.trackListFabAction.setOnLongClickListener((view) -> { + viewBinding.button.setOnLongClickListener((view) -> { if (!recordingStatus.isRecording()) { return false; } From ea6440ec2544b2e0e241243d0804bbea10a33da7 Mon Sep 17 00:00:00 2001 From: Ishan-3213 Date: Wed, 15 Nov 2023 20:08:55 -0500 Subject: [PATCH 04/11] Mondified button functionality along with colors. --- .../dennisguse/opentracks/TrackListActivity.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java index bf10ba549..d0a0d3c92 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java @@ -265,8 +265,8 @@ public void bindView(View view, Context context, Cursor cursor) { ActivityUtils.vibrate(this, 1000); updateGpsMenuItem(false, false); trackRecordingServiceConnection.stopRecording(TrackListActivity.this); - viewBinding.trackListFabAction.setImageResource(R.drawable.ic_baseline_record_24); - viewBinding.trackListFabAction.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.red_dark)); + // viewBinding.button.setImageResource(R.drawable.ic_baseline_record_24); + viewBinding.button.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.red_dark)); return true; }); @@ -553,13 +553,13 @@ public void onGpsStatusChanged(GpsStatusValue newStatus) { updateGpsMenuItem(true, recordingStatus.isRecording()); } - private void setFloatButton() { - viewBinding.trackListFabAction.setImageResource(recordingStatus.isRecording() ? R.drawable.ic_baseline_stop_24 : R.drawable.ic_baseline_record_24); - viewBinding.trackListFabAction.setBackgroundTintList(ContextCompat.getColorStateList(this, recordingStatus.isRecording() ? R.color.opentracks : R.color.red_dark)); - } + // private void setFloatButton() { + // viewBinding.button.setImageResource(recordingStatus.isRecording() ? R.drawable.ic_baseline_stop_24 : R.drawable.ic_baseline_record_24); + // viewBinding.button.setBackgroundTintList(ContextCompat.getColorStateList(this, recordingStatus.isRecording() ? R.color.opentracks : R.color.red_dark)); + // } private void onRecordingStatusChanged(RecordingStatus status) { recordingStatus = status; - setFloatButton(); + // setFloatButton(); } -} +} \ No newline at end of file From 8fbb9f7bd04fed8cc4865f0d95e79685ecc17528 Mon Sep 17 00:00:00 2001 From: Shivangi Arul Date: Wed, 15 Nov 2023 20:12:25 -0500 Subject: [PATCH 05/11] Changed the colours and layout of the button --- .../de/dennisguse/opentracks/TrackRecordingActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java index d6e686008..a4c6739e3 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java @@ -132,10 +132,10 @@ protected void onCreate(Bundle savedInstanceState) { viewBinding.trackDetailActivityViewPager.setCurrentItem(savedInstanceState.getInt(CURRENT_TAB_TAG_KEY)); } - viewBinding.trackRecordingFabAction.setImageResource(R.drawable.ic_baseline_stop_24); - viewBinding.trackRecordingFabAction.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); - viewBinding.trackRecordingFabAction.setBackgroundColor(ContextCompat.getColor(this, R.color.opentracks)); - viewBinding.trackRecordingFabAction.setOnLongClickListener((view) -> { + // viewBinding.holdToStopButton.setImageResource(R.drawable.ic_baseline_stop_24); + // viewBinding.holdToStopButton.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); + // viewBinding.holdToStopButton.setBackgroundColor(ContextCompat.getColor(this, R.color.opentracks)); + viewBinding.holdToStopButton.setOnLongClickListener((view) -> { ActivityUtils.vibrate(this, 1000); trackRecordingServiceConnection.stopRecording(TrackRecordingActivity.this); Intent newIntent = IntentUtils.newIntent(TrackRecordingActivity.this, TrackStoppedActivity.class) From 2b94f71996a53808b395a570a6e04d347206a684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Craahuljohn=E2=80=9D?= Date: Wed, 15 Nov 2023 20:22:03 -0500 Subject: [PATCH 06/11] changed string file --- src/main/res/values/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4db8181a7..12e86597d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -678,6 +678,8 @@ limitations under the License. I think you might be interested in this image. Hold to stop + Hold to Pause + Export track to storage after recording is finished Instant post-workout export From 2038d42828b65caf6add6f5fe606d9f832ab8aa2 Mon Sep 17 00:00:00 2001 From: marium19 <56446202+marium19@users.noreply.github.com> Date: Wed, 15 Nov 2023 21:17:01 -0500 Subject: [PATCH 07/11] Modified hold to pause button to be more descriptive --- src/main/res/layout/track_recording.xml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/res/layout/track_recording.xml b/src/main/res/layout/track_recording.xml index 360a056dc..95931a43b 100644 --- a/src/main/res/layout/track_recording.xml +++ b/src/main/res/layout/track_recording.xml @@ -6,6 +6,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - - - \ No newline at end of file + android:backgroundTint="#020202" + android:fontFamily="monospace" + android:text="HOLD TO PAUSE" + android:textStyle="bold" + android:translationX="-20dp" + app:layout_anchor="@+id/bottom_app_bar" + app:layout_anchorGravity="end|center" /> + + From 0f50770b20a122d66c84c2904ab672dc5789e1b7 Mon Sep 17 00:00:00 2001 From: urvishkapadiya Date: Thu, 16 Nov 2023 17:45:53 -0500 Subject: [PATCH 08/11] Changes in the Start button, modifying onClick listener event to apply changes --- .../java/de/dennisguse/opentracks/TrackRecordingActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java index a4c6739e3..e3ce00f1b 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java @@ -145,7 +145,7 @@ protected void onCreate(Bundle savedInstanceState) { finish(); return true; }); - viewBinding.trackRecordingFabAction.setOnClickListener((view) -> Toast.makeText(TrackRecordingActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show()); + viewBinding.holdToStopButton.setOnClickListener((view) -> Toast.makeText(TrackRecordingActivity.this, getString(R.string.hold_to_pause), Toast.LENGTH_LONG).show()); viewBinding.bottomAppBar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_24); setSupportActionBar(viewBinding.bottomAppBar); From dac7dabe4aacd42b9cad724da865b95615988851 Mon Sep 17 00:00:00 2001 From: pranjalesh <31514465+pranjalesh@users.noreply.github.com> Date: Sun, 19 Nov 2023 19:59:19 -0500 Subject: [PATCH 09/11] Modified a line to fix incorrect call --- src/main/java/de/dennisguse/opentracks/TrackListActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java index bf10ba549..5fc60abb7 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java @@ -296,7 +296,7 @@ protected void onResume() { LoaderManager.getInstance(this).restartLoader(0, null, loaderCallbacks); // Float button - setFloatButton(); +// setFloatButton(); } @Override From fd9d9b205e98ed3047a53da5d71a7cd04acadea7 Mon Sep 17 00:00:00 2001 From: pranjalesh <31514465+pranjalesh@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:08:35 -0500 Subject: [PATCH 10/11] Bug fixes --- src/main/java/de/dennisguse/opentracks/TrackListActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java index 00aece7ef..ddb649616 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java @@ -706,7 +706,7 @@ private void onRecordingStatusChanged(RecordingStatus status) { recordingStatus = status; // setFloatButton(); } -} + // Add a new method for handling the start recording action private void startRecording() { From af9a981de5e32b5b9e065e39ea617b0086fb8b7b Mon Sep 17 00:00:00 2001 From: pranjalesh <31514465+pranjalesh@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:16:34 -0500 Subject: [PATCH 11/11] bug fixes --- .../opentracks/TrackRecordingActivity.java | 117 ++++-------------- 1 file changed, 22 insertions(+), 95 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java index af8b529bb..754eebce3 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java @@ -5,15 +5,14 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Build; import android.os.Bundle; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; -import android.widget.Button; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.appcompat.widget.SearchView; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; @@ -113,44 +112,30 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); contentProviderUtils = new ContentProviderUtils(this); - if(getIntent().getParcelableExtra(EXTRA_TRACK_ID)!=null){ - trackId = getIntent().getParcelableExtra(EXTRA_TRACK_ID); - trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); + trackId = getIntent().getParcelableExtra(EXTRA_TRACK_ID); + if (trackId == null) { + throw new RuntimeException("TrackId is mandatory"); + } + if (contentProviderUtils.getTrack(trackId) == null) { + Log.w(TAG, "TrackId does not exists."); + finish(); } - -// if (trackId == null) { -// throw new RuntimeException("TrackId is mandatory"); -// } -// if (contentProviderUtils.getTrack(trackId) == null) { -// Log.w(TAG, "TrackId does not exists."); -// finish(); -// } - - + trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); trackDataHub = new TrackDataHub(this); CustomFragmentPagerAdapter pagerAdapter = new CustomFragmentPagerAdapter(this); viewBinding.trackDetailActivityViewPager.setAdapter(pagerAdapter); -// new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, -// (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); -// if (savedInstanceState != null) { -// viewBinding.trackDetailActivityViewPager.setCurrentItem(savedInstanceState.getInt(CURRENT_TAB_TAG_KEY)); -// } - - if(getIntent().getParcelableExtra(EXTRA_TRACK_ID)!=null){ - viewBinding.trackRecordingFabAction.setImageResource(R.drawable.stop); - }else{ - viewBinding.trackRecordingFabAction.setImageResource(R.drawable.start); + new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, + (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); + if (savedInstanceState != null) { + viewBinding.trackDetailActivityViewPager.setCurrentItem(savedInstanceState.getInt(CURRENT_TAB_TAG_KEY)); } - // viewBinding.holdToStopButton.setImageResource(R.drawable.ic_baseline_stop_24); - // viewBinding.holdToStopButton.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); - // viewBinding.holdToStopButton.setBackgroundColor(ContextCompat.getColor(this, R.color.opentracks)); +// viewBinding.holdToStopButton.setImageResource(R.drawable.ic_baseline_stop_24); +// viewBinding.holdToStopButton.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); +// viewBinding.holdToStopButton.setBackgroundColor(ContextCompat.getColor(this, R.color.opentracks)); viewBinding.holdToStopButton.setOnLongClickListener((view) -> { - viewBinding.trackRecordingFabAction.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); - viewBinding.trackRecordingFabAction.setBackgroundColor(ContextCompat.getColor(this, R.color.opentracks)); - viewBinding.trackRecordingFabAction.setOnClickListener((view) -> { ActivityUtils.vibrate(this, 1000); trackRecordingServiceConnection.stopRecording(TrackRecordingActivity.this); Intent newIntent = IntentUtils.newIntent(TrackRecordingActivity.this, TrackStoppedActivity.class) @@ -158,47 +143,14 @@ protected void onCreate(Bundle savedInstanceState) { startActivity(newIntent); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); finish(); + return true; }); - viewBinding.holdToStopButton.setOnClickListener((view) -> Toast.makeText(TrackRecordingActivity.this, getString(R.string.hold_to_pause), Toast.LENGTH_LONG).show()); + viewBinding.holdToStopButton.setOnClickListener((view) -> Toast.makeText(TrackRecordingActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show()); viewBinding.bottomAppBar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_24); setSupportActionBar(viewBinding.bottomAppBar); - setSupportActionBar(viewBinding.trackListToolbar); - viewBinding.trackRecordingFabAction.setOnClickListener(v -> startRecording(pagerAdapter)); - - viewBinding.trackRecordingFabAction.setOnLongClickListener((view) -> { - ActivityUtils.vibrate(this, 1000); - trackRecordingServiceConnection.stopRecording(TrackRecordingActivity.this); - Intent newIntent = IntentUtils.newIntent(TrackRecordingActivity.this, TrackStoppedActivity.class) - .putExtra(TrackStoppedActivity.EXTRA_TRACK_ID, trackId); - startActivity(newIntent); - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - finish(); - return true; - }); - } - void startRecording(CustomFragmentPagerAdapter pagerAdapter) { - if (recordingStatus.isRecording()) { - Toast.makeText(TrackRecordingActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); - return; - } - // Not Recording -> Recording - // updateGpsMenuItem(false, true); - new TrackRecordingServiceConnection((service, connection) -> { - trackId = service.startNewTrack(); - trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); - trackRecordingServiceConnection.startConnection(this); - }).startAndBind(this, true); - new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, - (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); - viewBinding.bottomAppBar.setVisibility(View.VISIBLE); - - viewBinding.trackRecordingFabAction.setImageResource(R.drawable.stop); - - - } @Override public void onAttachedToWindow() { setLockscreenPolicy(); @@ -256,10 +208,7 @@ protected void onStart() { PreferencesUtils.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); - if (trackRecordingServiceConnection != null) { - trackRecordingServiceConnection.startConnection(this); - } - + trackRecordingServiceConnection.startConnection(this); trackDataHub.start(); } @@ -276,10 +225,7 @@ protected void onResume() { trackDataHub.setRecordingStatus(recordingStatus); } - if (trackRecordingServiceConnection != null) { - trackRecordingServiceConnection.startAndBindWithCallback(this); - } - + trackRecordingServiceConnection.startAndBindWithCallback(this); } @Override @@ -288,19 +234,11 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { outState.putInt(CURRENT_TAB_TAG_KEY, viewBinding.trackDetailActivityViewPager.getCurrentItem()); } - @Override - protected void onPause() { - super.onPause(); - if (trackRecordingServiceConnection != null) { - trackRecordingServiceConnection.unbind(this); - } - } - @Override protected void onStop() { super.onStop(); PreferencesUtils.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); - + trackRecordingServiceConnection.unbind(this); trackDataHub.stop(); } @@ -319,7 +257,7 @@ protected View getRootView() { @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.track_menu_custom, menu); + getMenuInflater().inflate(R.menu.track_record, menu); return super.onCreateOptionsMenu(menu); } @@ -367,17 +305,6 @@ public boolean onOptionsItemSelected(MenuItem item) { return true; } - if (item.getItemId() == R.id.track_list_settings) { - startActivity(IntentUtils.newIntent(this, SettingsActivity.class)); - return true; - } - - - if (item.getItemId() == R.id.track_list_help) { - startActivity(IntentUtils.newIntent(this, HelpActivity.class)); - return true; - } - return super.onOptionsItemSelected(item); }