forked from upstream-mirrors/OpenTracks
Cleanup.
This commit is contained in:
@@ -34,7 +34,6 @@ import androidx.preference.PreferenceManager;
|
|||||||
import com.google.android.material.color.DynamicColors;
|
import com.google.android.material.color.DynamicColors;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -61,6 +60,7 @@ import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayoutIO;
|
|||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
|
//TODO Separate layout-related preferences into a class
|
||||||
public class PreferencesUtils {
|
public class PreferencesUtils {
|
||||||
|
|
||||||
private final static String TAG = PreferencesUtils.class.getSimpleName();
|
private final static String TAG = PreferencesUtils.class.getSimpleName();
|
||||||
@@ -808,7 +808,7 @@ public class PreferencesUtils {
|
|||||||
return resources.getInteger(R.integer.stats_custom_layout_columns_default);
|
return resources.getInteger(R.integer.stats_custom_layout_columns_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<TypedArray> getMultiTypedArray() {
|
private static List<TypedArray> getLayoutDataFields() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
R.array.stats_custom_layout_fields_default_value_0,
|
R.array.stats_custom_layout_fields_default_value_0,
|
||||||
R.array.stats_custom_layout_fields_default_value_1,
|
R.array.stats_custom_layout_fields_default_value_1,
|
||||||
@@ -836,7 +836,7 @@ public class PreferencesUtils {
|
|||||||
|
|
||||||
@SuppressLint("ResourceType")
|
@SuppressLint("ResourceType")
|
||||||
private static String buildDefaultFields() {
|
private static String buildDefaultFields() {
|
||||||
List<TypedArray> fieldsArrays = getMultiTypedArray();
|
List<TypedArray> fieldsArrays = getLayoutDataFields();
|
||||||
return fieldsArrays.stream().map(i -> i.getString(0) + CsvLayoutUtils.PROPERTY_SEPARATOR + i.getString(1)).collect(Collectors.joining(CsvLayoutUtils.ITEM_SEPARATOR))
|
return fieldsArrays.stream().map(i -> i.getString(0) + CsvLayoutUtils.PROPERTY_SEPARATOR + i.getString(1)).collect(Collectors.joining(CsvLayoutUtils.ITEM_SEPARATOR))
|
||||||
+ CsvLayoutUtils.ITEM_SEPARATOR;
|
+ CsvLayoutUtils.ITEM_SEPARATOR;
|
||||||
}
|
}
|
||||||
@@ -895,14 +895,10 @@ public class PreferencesUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<RecordingLayout> getAllCustomLayouts() {
|
public static List<RecordingLayout> getAllCustomLayouts() {
|
||||||
List<RecordingLayout> recordingLayouts = new ArrayList<>();
|
|
||||||
String csvCustomLayout = getString(R.string.stats_custom_layouts_key, buildDefaultLayout());
|
String csvCustomLayout = getString(R.string.stats_custom_layouts_key, buildDefaultLayout());
|
||||||
String[] csvLines = csvCustomLayout.split(CsvLayoutUtils.LINE_SEPARATOR);
|
String[] csvLines = csvCustomLayout.split(CsvLayoutUtils.LINE_SEPARATOR);
|
||||||
for (String line : csvLines) {
|
|
||||||
recordingLayouts.add(RecordingLayoutIO.fromCsv(line, resources));
|
|
||||||
}
|
|
||||||
|
|
||||||
return recordingLayouts;
|
return Arrays.stream(csvLines).map(line -> RecordingLayoutIO.fromCsv(line, resources)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getAllCustomLayoutNames() {
|
public static List<String> getAllCustomLayoutNames() {
|
||||||
@@ -919,13 +915,6 @@ public class PreferencesUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Check if resetPreferences can be used instead.
|
|
||||||
@Deprecated
|
|
||||||
@VisibleForTesting
|
|
||||||
public static void clear() {
|
|
||||||
sharedPreferences.edit().clear().commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getTotalRowsDeleted() {
|
public static int getTotalRowsDeleted() {
|
||||||
return getInt(R.string.total_rows_deleted_key, 0);
|
return getInt(R.string.total_rows_deleted_key, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user