Recording stats layout customizable.

Users can select the order, visibility and importance (primary or secondary) of all stats for recording layout from the Settings.
Also, users can select the number of columns per row in the recording layout: 1, 2 or 3.
Finally, show altitude/coordinate from settings have been removed (not needed anymore).
Fixes #659.
Fixes #302.
Fixes #820.
This commit is contained in:
Román Martínez
2021-06-19 21:29:06 +02:00
parent 7f10ae5c3f
commit 9c4c8131f5
93 changed files with 2146 additions and 1126 deletions
@@ -0,0 +1,41 @@
package de.dennisguse.opentracks.util;
import android.content.Context;
import android.content.SharedPreferences;
import de.dennisguse.opentracks.R;
public class PreferencesOpenHelper {
private final Context context;
private final SharedPreferences sharedPreferences;
private static final int PREFERENCES_VERSION = 1;
private PreferencesOpenHelper(Context context, SharedPreferences sharedPreferences) {
this.context = context;
this.sharedPreferences = sharedPreferences;
}
public static PreferencesOpenHelper newInstance(Context context, SharedPreferences sharedPreferences) {
return new PreferencesOpenHelper(context, sharedPreferences);
}
public void checkForUpgrade() {
int lastVersion = PreferencesUtils.getInt(sharedPreferences, context, R.string.prefs_last_version_key, 0);
if (PREFERENCES_VERSION > lastVersion) {
onUpgrade();
}
}
private void onUpgrade() {
PreferencesUtils.setInt(sharedPreferences, context, R.string.prefs_last_version_key, PREFERENCES_VERSION);
switch (PREFERENCES_VERSION) {
case 1:
upgradeFrom0to1();
}
}
private void upgradeFrom0to1() {
PreferencesUtils.setString(sharedPreferences, context, R.string.stats_custom_layout_fields_key, PreferencesUtils.buildDefaultLayout(context));
}
}