Re-implemented landscape mode.

Fixes #32.
This commit is contained in:
Dennis Guse
2020-07-05 18:12:24 +02:00
parent 23c3a4d651
commit 13e07696b9
4 changed files with 55 additions and 25 deletions
+3 -10
View File
@@ -85,13 +85,9 @@ limitations under the License.
android:resource="@xml/searchable" />
</activity>
<activity
android:name=".TrackRecordedActivity"
android:screenOrientation="userPortrait" />
<activity android:name=".TrackRecordedActivity" />
<activity
android:name=".TrackRecordingActivity"
android:screenOrientation="userPortrait" />
<activity android:name=".TrackRecordingActivity" />
<activity android:name=".TrackEditActivity" />
@@ -105,10 +101,7 @@ limitations under the License.
android:value=".SearchListActivity" />
</activity>
<activity
android:name=".AggregatedStatisticsActivity"
android:screenOrientation="userPortrait"
android:label="@string/menu_aggregated_statistics"/>
<activity android:name=".AggregatedStatisticsActivity" />
<activity
android:name=".io.file.exporter.ExportActivity"
@@ -51,7 +51,6 @@ public class TrackController {
private boolean isPaused;
private long totalTime = 0;
// the timestamp for the toal time
private long totalTimeTimestamp = 0;
private boolean isResumed = false;
@@ -57,10 +57,11 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
private ViewPager pager;
private TrackController trackController;
// From intent
// Initialized from Intent; if a new track recording is started new TrackId will be provided by TrackRecordingService
private long trackId;
// Preferences
@Deprecated //TODO Do we really need two trackIds here?
private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
private boolean recordingTrackPaused;
@@ -208,8 +209,9 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
return getString(R.string.settings_chart_by_time);
case 2:
return getString(R.string.settings_chart_by_distance);
default:
throw new RuntimeException("There isn't Fragment associated with the position: " + position);
}
return "Unknown Tab";
}
};
pager = findViewById(R.id.track_detail_activity_view_pager);
@@ -272,12 +274,23 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
// Update UI
this.invalidateOptionsMenu();
//TODO Temporary fix, so that the TrackController is initialized properly after rotation when a new recording was started.
if (trackId == -1L && trackId != recordingTrackId) {
trackId = recordingTrackId;
}
if (trackId != -1L) {
trackDataHub.loadTrack(trackId);
trackController.onResume(true, recordingTrackPaused);
}
startRecording();
/*
* If the binding has happened, then invoke the callback to start a new recording.
* If the binding hasn't happened, then invoking the callback will have no effect.
* But when the binding occurs, the callback will get invoked.
*/
trackRecordingServiceConnection.startAndBind(this);
bindChangedCallback.run();
}
@Override
@@ -403,15 +416,4 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
String category = getString(TrackIconUtils.getIconActivityType(iconValue));
TrackUtils.updateTrack(this, track, null, category, null, contentProviderUtils);
}
private void startRecording() {
trackRecordingServiceConnection.startAndBind(this);
/*
* If the binding has happened, then invoke the callback to start a new recording.
* If the binding hasn't happened, then invoking the callback will have no effect.
* But when the binding occurs, the callback will get invoked.
*/
bindChangedCallback.run();
}
}
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<include layout="@layout/track_controller" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/track_detail_activity_tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@color/holo_orange_dark" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/track_detail_activity_view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>