Fix after review part 2

This commit is contained in:
nazar-kutz 2021-03-09 15:10:10 +02:00
parent 7773335722
commit 5b08660b5e
6 changed files with 30 additions and 44 deletions

View file

@ -119,16 +119,6 @@ public class Algorithms {
return def;
}
public static String formatDoubleWithoutExtraZeros(double d) {
return isInt(d) ?
String.format(Locale.US, "%d", (long) d) :
String.format("%s", d);
}
public static boolean isInt(double d) {
return (d == Math.floor(d)) && !Double.isInfinite(d);
}
public static int parseIntSilently(String input, int def) {
if (input != null && input.length() > 0) {
try {
@ -798,6 +788,10 @@ public class Algorithms {
return false;
}
public static boolean isInt(double d) {
return (d == Math.floor(d)) && !Double.isInfinite(d);
}
public static boolean isInt(String value) {
int length = value.length();
for (int i = 0; i < length; i++) {

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:linksClickable="true"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
tools:text="Some long description"
android:paddingEnd="@dimen/content_padding"
android:paddingStart="@dimen/content_padding" />

View file

@ -5,6 +5,20 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
android:text="@string/gpx_split_interval_descr"
android:paddingEnd="@dimen/content_padding"
android:paddingStart="@dimen/content_padding" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/content_padding" />

View file

@ -121,19 +121,22 @@ public class OsmAndFormatter {
}
public static String getFormattedTimeInterval(OsmandApplication app, double interval) {
String units;
String unitsStr;
double intervalInUnits;
if (interval < 60) {
units = app.getString(R.string.shared_string_sec);
unitsStr = app.getString(R.string.shared_string_sec);
intervalInUnits = interval;
} else if (interval % 60 == 0) {
units = app.getString(R.string.int_min);
unitsStr = app.getString(R.string.int_min);
intervalInUnits = (interval / 60);
} else {
units = app.getString(R.string.int_min);
unitsStr = app.getString(R.string.int_min);
intervalInUnits = (interval / 60f);
}
return Algorithms.formatDoubleWithoutExtraZeros(intervalInUnits) + " " + units;
String formattedInterval = Algorithms.isInt(intervalInUnits) ?
String.format(Locale.US, "%d", (long) intervalInUnits) :
String.format("%s", intervalInUnits);
return formattedInterval + " " + unitsStr;
}
public static String getFormattedDistanceInterval(OsmandApplication app, double interval) {

View file

@ -145,7 +145,10 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
Drawable transparencyIcon = getTransparencyIcon(app, color);
Drawable colorIcon = app.getUIUtilities().getPaintedIcon(R.drawable.bg_point_circle, color);
Drawable layeredIcon = UiUtilities.getLayeredIcon(transparencyIcon, colorIcon);
int listBgColor = ContextCompat.getColor(app, getListBackgroundColorId());
int listBgColorId = nightMode ?
R.color.card_and_list_background_dark :
R.color.card_and_list_background_light;
int listBgColor = getResolvedColor(listBgColorId);
double contrastRatio = ColorUtils.calculateContrast(color, listBgColor);
if (contrastRatio < MINIMUM_CONTRAST_RATIO) {
backgroundCircle.setBackgroundResource(nightMode ? R.drawable.circle_contour_bg_dark : R.drawable.circle_contour_bg_light);
@ -267,11 +270,4 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
colorsListPreference.setStringsListForProfile(appMode, colorNames);
}
}
@ColorRes
private int getListBackgroundColorId() {
return nightMode ?
R.color.card_and_list_background_dark :
R.color.card_and_list_background_light;
}
}

View file

@ -96,10 +96,6 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(getString(R.string.gpx_split_interval)));
items.add(new LongDescriptionItem.Builder()
.setDescription(getString(R.string.gpx_split_interval_descr))
.setLayoutId(R.layout.bottom_sheet_item_description_long_without_min_height)
.create());
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
View view = themedInflater.inflate(R.layout.track_split_interval, null);