Fix after review part 2
This commit is contained in:
parent
7773335722
commit
5b08660b5e
6 changed files with 30 additions and 44 deletions
|
@ -119,16 +119,6 @@ public class Algorithms {
|
||||||
return def;
|
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) {
|
public static int parseIntSilently(String input, int def) {
|
||||||
if (input != null && input.length() > 0) {
|
if (input != null && input.length() > 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -798,6 +788,10 @@ public class Algorithms {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInt(double d) {
|
||||||
|
return (d == Math.floor(d)) && !Double.isInfinite(d);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInt(String value) {
|
public static boolean isInt(String value) {
|
||||||
int length = value.length();
|
int length = value.length();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
|
|
@ -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" />
|
|
|
@ -5,6 +5,20 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
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
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/content_padding" />
|
android:layout_height="@dimen/content_padding" />
|
||||||
|
|
|
@ -121,19 +121,22 @@ public class OsmAndFormatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFormattedTimeInterval(OsmandApplication app, double interval) {
|
public static String getFormattedTimeInterval(OsmandApplication app, double interval) {
|
||||||
String units;
|
String unitsStr;
|
||||||
double intervalInUnits;
|
double intervalInUnits;
|
||||||
if (interval < 60) {
|
if (interval < 60) {
|
||||||
units = app.getString(R.string.shared_string_sec);
|
unitsStr = app.getString(R.string.shared_string_sec);
|
||||||
intervalInUnits = interval;
|
intervalInUnits = interval;
|
||||||
} else if (interval % 60 == 0) {
|
} else if (interval % 60 == 0) {
|
||||||
units = app.getString(R.string.int_min);
|
unitsStr = app.getString(R.string.int_min);
|
||||||
intervalInUnits = (interval / 60);
|
intervalInUnits = (interval / 60);
|
||||||
} else {
|
} else {
|
||||||
units = app.getString(R.string.int_min);
|
unitsStr = app.getString(R.string.int_min);
|
||||||
intervalInUnits = (interval / 60f);
|
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) {
|
public static String getFormattedDistanceInterval(OsmandApplication app, double interval) {
|
||||||
|
|
|
@ -145,7 +145,10 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
|
||||||
Drawable transparencyIcon = getTransparencyIcon(app, color);
|
Drawable transparencyIcon = getTransparencyIcon(app, color);
|
||||||
Drawable colorIcon = app.getUIUtilities().getPaintedIcon(R.drawable.bg_point_circle, color);
|
Drawable colorIcon = app.getUIUtilities().getPaintedIcon(R.drawable.bg_point_circle, color);
|
||||||
Drawable layeredIcon = UiUtilities.getLayeredIcon(transparencyIcon, colorIcon);
|
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);
|
double contrastRatio = ColorUtils.calculateContrast(color, listBgColor);
|
||||||
if (contrastRatio < MINIMUM_CONTRAST_RATIO) {
|
if (contrastRatio < MINIMUM_CONTRAST_RATIO) {
|
||||||
backgroundCircle.setBackgroundResource(nightMode ? R.drawable.circle_contour_bg_dark : R.drawable.circle_contour_bg_light);
|
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);
|
colorsListPreference.setStringsListForProfile(appMode, colorNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ColorRes
|
|
||||||
private int getListBackgroundColorId() {
|
|
||||||
return nightMode ?
|
|
||||||
R.color.card_and_list_background_dark :
|
|
||||||
R.color.card_and_list_background_light;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -96,10 +96,6 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
items.add(new TitleItem(getString(R.string.gpx_split_interval)));
|
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);
|
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
|
||||||
View view = themedInflater.inflate(R.layout.track_split_interval, null);
|
View view = themedInflater.inflate(R.layout.track_split_interval, null);
|
||||||
|
|
Loading…
Reference in a new issue