Added option to show statistics while recording without unlocking the device.

This commit is contained in:
Dennis Guse
2019-09-02 18:36:31 +02:00
parent 0a046fc100
commit c8ae3b83b5
5 changed files with 48 additions and 8 deletions
@@ -22,6 +22,7 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Pair;
@@ -29,6 +30,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ShareActionProvider;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@@ -94,6 +96,8 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
// Preferences
private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
private boolean recordingTrackPaused = PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT;
private boolean showOnLockScreen = PreferencesUtils.SHOW_TRACKDETAIL_WHILE_RECORDING_ON_LOCKSCREEN;
private final Runnable bindChangedCallback = new Runnable() {
@Override
public void run() {
@@ -132,6 +136,11 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
recordingTrackPaused = PreferencesUtils.getBoolean(TrackDetailActivity.this, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
}
if (key == null || key.equals(PreferencesUtils.getKey(TrackDetailActivity.this, R.string.trackdetail_show_on_lockscreen_while_recording))) {
showOnLockScreen = PreferencesUtils.getBoolean(TrackDetailActivity.this, R.string.trackdetail_show_on_lockscreen_while_recording, PreferencesUtils.SHOW_TRACKDETAIL_WHILE_RECORDING_ON_LOCKSCREEN);
setLockscreenPolicy();
}
if (key == null) return;
runOnUiThread(new Runnable() {
@@ -214,6 +223,22 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
trackController = new TrackController(this, trackRecordingServiceConnection, false, recordListener, stopListener);
}
@Override
public void onAttachedToWindow() {
setLockscreenPolicy();
super.onAttachedToWindow();
}
private void setLockscreenPolicy() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(showOnLockScreen);
} else {
if (showOnLockScreen)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
else getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
}
@Override
protected void onStart() {
super.onStart();
@@ -83,6 +83,8 @@ public class PreferencesUtils {
public static final String TRACK_NAME_DEFAULT = "DATE_ISO_8601";
public static final boolean SHOW_TRACKDETAIL_WHILE_RECORDING_ON_LOCKSCREEN = false;
// Track widget
public static final int TRACK_WIDGET_ITEM1_DEFAULT = 3; // moving time
public static final int TRACK_WIDGET_ITEM2_DEFAULT = 0; // distance
+2
View File
@@ -28,10 +28,12 @@ limitations under the License.
<string name="recording_distance_interval_key" translatable="false">recordingDistanceInterval</string>
<string name="recording_gps_accuracy_key" translatable="false">recordingGpsAccuracy</string>
<string name="split_frequency_key" translatable="false">splitFrequency</string>
<string name="stats_rate_key" translatable="false">statsRate</string>
<string name="stats_show_coordinate_key" translatable="false">statsShowCoordinate</string>
<string name="stats_show_grade_elevation_key" translatable="false">statsShowGradeElevation</string>
<string name="stats_units_key" translatable="false">statsUnits</string>
<string name="trackdetail_show_on_lockscreen_while_recording" translatable="false">trackdetail_show_on_lockscreen_while_recording</string>
<string name="track_name_key" translatable="false">trackName</string>
<string name="track_widget_item1" translatable="false">trackWidgetItem1</string>
<string name="track_widget_item2" translatable="false">trackWidgetItem2</string>
+9 -3
View File
@@ -1085,10 +1085,16 @@ limitations under the License.
X axis
</string>
<!-- Settings Map -->
<!-- Settings Recording -->
<string name="settings_recording" translation_description="In the 'Settings' page, the option to change the recording settings.
<string name="settings_recording_show_on_lockscreen_while_recording_title" translation_description="In the 'Settings' page, the option to change the 'show on lockscreen' behavior while recording.">
Show statistics on lockscreen
</string>
<string name="settings_recording_show_on_lockscreen_while_recording_summary" translation_description="In the 'Settings' page, the option to change the 'show on lockscreen' behavior while recording.">
While recording, show statistics without unlocking the device.
</string>
<string name="settings_recording" translation_description="In the 'Settings' page, the option to change the recording settings.
Character limit: ~26 (1 line)">
Recording
+10 -5
View File
@@ -35,11 +35,6 @@ limitations under the License.
android:key="@string/track_name_key"
android:summary="%s"
android:title="@string/settings_recording_track_name_title" />
<de.dennisguse.opentracks.settings.ActivityTypePreference
android:defaultValue="@string/activity_type_running"
android:key="@string/default_activity_key"
android:summary="%s"
android:title="@string/settings_recording_default_activity_title" />
<ListPreference
android:defaultValue="0"
android:entryValues="@array/min_recording_interval_values"
@@ -70,4 +65,14 @@ limitations under the License.
android:key="@string/auto_resume_track_timeout_key"
android:summary="%s"
android:title="@string/settings_recording_auto_resume_track_timeout_title" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/trackdetail_show_on_lockscreen_while_recording"
android:summary="@string/settings_recording_show_on_lockscreen_while_recording_summary"
android:title="@string/settings_recording_show_on_lockscreen_while_recording_title" />
<de.dennisguse.opentracks.settings.ActivityTypePreference
android:defaultValue="@string/activity_type_running"
android:key="@string/default_activity_key"
android:summary="%s"
android:title="@string/settings_recording_default_activity_title" />
</PreferenceScreen>