From 5c90fc92d95c5458489f541f0bf442d4aca131a0 Mon Sep 17 00:00:00 2001 From: Deniz Date: Tue, 14 Nov 2023 22:21:18 -0500 Subject: [PATCH 01/44] #183: [ADD] Ignore IDE files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fc0db155f..82e9e5a54 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ captures/ /out/ # User-specific configurations +.idea .idea/.name .idea/caches/ .idea/compiler.xml From 141361e9a184c3398aaa8d90b72841656029fcf8 Mon Sep 17 00:00:00 2001 From: jatin51997 Date: Fri, 17 Nov 2023 18:09:54 -0500 Subject: [PATCH 02/44] initial changes to start screen --- .../opentracks/TrackListActivity.java | 38 ++++++- .../opentracks/TrackRecordingActivity.java | 100 ++++++++++++++---- src/main/res/layout/track_recording.xml | 7 +- 3 files changed, 123 insertions(+), 22 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java index bf10ba549..25c20d000 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java @@ -247,10 +247,9 @@ public void bindView(View view, Context context, Cursor cursor) { // Not Recording -> Recording updateGpsMenuItem(false, true); new TrackRecordingServiceConnection((service, connection) -> { - Track.Id trackId = service.startNewTrack(); - + // Track.Id trackId = service.startNewTrack(); Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); - newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); + //newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); startActivity(newIntent); connection.unbind(this); @@ -271,7 +270,22 @@ public void bindView(View view, Context context, Cursor cursor) { }); setSupportActionBar(viewBinding.trackListToolbar); + if (recordingStatus.isRecording()) { + Toast.makeText(TrackListActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); + return; + } + // Not Recording -> Recording + updateGpsMenuItem(false, true); + new TrackRecordingServiceConnection((service, connection) -> { + //Track.Id trackId = service.startNewTrack(); + + Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); +// newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); + startActivity(newIntent); + + connection.unbind(this); + }).startAndBind(this, true); loadData(getIntent()); } @@ -329,6 +343,24 @@ public boolean onCreateOptionsMenu(Menu menu) { return super.onCreateOptionsMenu(menu); } + void startRecording() { + if (recordingStatus.isRecording()) { + Toast.makeText(TrackListActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); + return; + } + + // Not Recording -> Recording + updateGpsMenuItem(false, true); + new TrackRecordingServiceConnection((service, connection) -> { + Track.Id trackId = service.startNewTrack(); + + Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); + newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); + startActivity(newIntent); + + connection.unbind(this); + }).startAndBind(this, true); + } @Override public boolean onPrepareOptionsMenu(Menu menu) { diff --git a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java index d6e686008..dc7733a41 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java @@ -5,11 +5,11 @@ 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; @@ -112,25 +112,25 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); contentProviderUtils = new ContentProviderUtils(this); - 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(); - } + // 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(); +// } - trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); + // 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)); - } + 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)); +// } viewBinding.trackRecordingFabAction.setImageResource(R.drawable.ic_baseline_stop_24); viewBinding.trackRecordingFabAction.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); @@ -149,8 +149,72 @@ protected void onCreate(Bundle savedInstanceState) { viewBinding.bottomAppBar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_24); setSupportActionBar(viewBinding.bottomAppBar); + Button startRecordingButton = findViewById(R.id.startRecordingButton); + startRecordingButton.setOnClickListener(v -> startRecording(pagerAdapter)); + + startRecordingButton.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; + }); + + viewBinding.bottomAppBar.setVisibility(View.GONE); + viewBinding.trackRecordingFabAction.hide(); + } + void startRecording(CustomFragmentPagerAdapter pagerAdapter) { +// // ((TrackListActivity) getParent()).startRecording(); +// new TrackRecordingServiceConnection((service, connection) -> { +// Track.Id trackId = service.startNewTrack(); +// +//// Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); +//// newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); +//// startActivity(newIntent); +// +// connection.unbind(this); +// }).startAndBind(this, true); + + + 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); + + //trackId = trackId; +// Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); +// newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); +// startActivity(newIntent); + + // connection.unbind(this); + }).startAndBind(this, true); + // CustomFragmentPagerAdapter pagerAdapter = new CustomFragmentPagerAdapter(this); + // viewBinding.trackDetailActivityViewPager.setAdapter(pagerAdapter); + new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, + (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); + viewBinding.bottomAppBar.setVisibility(View.VISIBLE); + Button startRecordingButton = findViewById(R.id.startRecordingButton); + + startRecordingButton.setText("Stop Recording"); + +//// Change text color +// startRecordingButton.setTextColor(getResources().getColor(R.color.your_text_color)); +// +//// Change background color +// startRecordingButton.setBackgroundColor(getResources().getColor(R.color.your_background_color)); + + } @Override public void onAttachedToWindow() { setLockscreenPolicy(); @@ -208,7 +272,7 @@ protected void onStart() { PreferencesUtils.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); - trackRecordingServiceConnection.startConnection(this); + // trackRecordingServiceConnection.startConnection(this); trackDataHub.start(); } @@ -225,7 +289,7 @@ protected void onResume() { trackDataHub.setRecordingStatus(recordingStatus); } - trackRecordingServiceConnection.startAndBindWithCallback(this); + // trackRecordingServiceConnection.startAndBindWithCallback(this); } @Override diff --git a/src/main/res/layout/track_recording.xml b/src/main/res/layout/track_recording.xml index 360a056dc..e7d41e3c7 100644 --- a/src/main/res/layout/track_recording.xml +++ b/src/main/res/layout/track_recording.xml @@ -28,7 +28,12 @@ android:layout_height="match_parent" /> - +