diff --git a/app/res/layout/start.xml b/app/res/layout/start.xml index c43578aac..890cfff70 100644 --- a/app/res/layout/start.xml +++ b/app/res/layout/start.xml @@ -213,7 +213,9 @@ android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" - android:layout_centerVertical="true" + android:layout_alignParentTop="true" + android:layout_marginTop="2dp" + android:layout_marginRight="64dp" tools:ignore="RelativeOverlap" /> diff --git a/app/src/main/org/runnerup/view/MainLayout.java b/app/src/main/org/runnerup/view/MainLayout.java index 34c71d692..974b28be9 100644 --- a/app/src/main/org/runnerup/view/MainLayout.java +++ b/app/src/main/org/runnerup/view/MainLayout.java @@ -219,18 +219,6 @@ public void handleOnBackPressed() { return; } - // If on the first page (StartFragment) and GPS logging is active but not auto-started, - // stop GPS instead of exiting the app. - Fragment fragment = getCurrentFragment(); - - if (fragment instanceof StartFragment startFragment) { - if (!startFragment.getAutoStartGps() && startFragment.isGpsLogging()) { - startFragment.stopGps(); - startFragment.updateView(); - return; - } - } - // Temporarily disable this callback to allow the system to handle the next back press // for exiting the app. this.setEnabled(false); diff --git a/app/src/main/org/runnerup/view/StartFragment.java b/app/src/main/org/runnerup/view/StartFragment.java index d00e18729..dbecdc961 100644 --- a/app/src/main/org/runnerup/view/StartFragment.java +++ b/app/src/main/org/runnerup/view/StartFragment.java @@ -665,6 +665,11 @@ private void startWorkout() { private final OnClickListener gpsEnableClick = v -> { + if (mGpsStatus.isStarted()) { + stopGps(); + updateView(); + return; + } if (checkPermissions(true)) { // Handle view update etc in permission callback return; @@ -922,23 +927,15 @@ private void updateStartButtonView() { startButton.setVisibility(View.GONE); } - private void updateStartGpsButtonView() { - do { - if (mGpsStatus.isStarted()) { - break; - } - - // - if (mGpsStatus.isEnabled()) { - gpsEnable.setText(org.runnerup.common.R.string.Start_GPS); - } else { - gpsEnable.setText(org.runnerup.common.R.string.Enable_GPS); - } - gpsEnable.setVisibility(View.VISIBLE); - return; - } while (false); + private int getStartButtonTextResId() { + if (mGpsStatus.isStarted()) return org.runnerup.common.R.string.Stop_GPS; + return mGpsStatus.isEnabled() + ? org.runnerup.common.R.string.Start_GPS + : org.runnerup.common.R.string.Enable_GPS; + } - gpsEnable.setVisibility(View.GONE); + private void updateStartGpsButtonView() { + gpsEnable.setText(getStartButtonTextResId()); } private void updateGPSView() { diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 19b38ed8f..eda109b04 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -82,6 +82,7 @@ Acceptable GPS Good GPS Start GPS + Stop GPS Duration Cancel value