Vehicle parameters numeric dialog
This commit is contained in:
parent
fe32670e44
commit
d6143e100e
4 changed files with 13 additions and 7 deletions
|
@ -89,8 +89,6 @@
|
|||
<dimen name="measurement_tool_button_padding">12dp</dimen>
|
||||
<dimen name="measurement_tool_button_height">54dp</dimen>
|
||||
|
||||
<dimen name="shadow_height">8dp</dimen>
|
||||
|
||||
<!--Route info-->
|
||||
<dimen name="route_info_buttons_padding_left_right">33dp</dimen>
|
||||
<dimen name="route_info_button_go_margin">5dp</dimen>
|
||||
|
|
|
@ -275,6 +275,7 @@
|
|||
<dimen name="bottom_sheet_text_spacing_multiplier" format="float">1.25</dimen>
|
||||
<dimen name="bottom_sheet_info_spacing_multiplier" format="float">1.5</dimen>
|
||||
<dimen name="bottom_sheet_big_item_height">128dp</dimen>
|
||||
<dimen name="bottom_sheet_top_shadow_height">8dp</dimen>
|
||||
|
||||
<dimen name="action_bar_image_width_land">236dp</dimen>
|
||||
<dimen name="action_bar_image_top_margin_land">68dp</dimen>
|
||||
|
@ -285,7 +286,6 @@
|
|||
<dimen name="map_markers_recycler_view_padding_bottom">52dp</dimen>
|
||||
<dimen name="map_markers_recycler_view_padding_top">10dp</dimen>
|
||||
|
||||
<dimen name="shadow_height">5dp</dimen>
|
||||
<dimen name="map_marker_title_height">28dp</dimen>
|
||||
|
||||
<dimen name="fab_recycler_view_padding_bottom">88dp</dimen>
|
||||
|
|
|
@ -39,7 +39,9 @@ import net.osmand.util.Algorithms;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
||||
|
||||
|
@ -78,7 +80,7 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
|||
final TextView metric = mainView.findViewById(R.id.metric);
|
||||
metric.setText(app.getString(preference.getAssets().getMetricRes()));
|
||||
final RecyclerView recyclerView = mainView.findViewById(R.id.recycler_view);
|
||||
final DecimalFormat df = new DecimalFormat("#.####");
|
||||
final DecimalFormat df = new DecimalFormat("#.####", new DecimalFormatSymbols(Locale.US));
|
||||
text = mainView.findViewById(R.id.text_edit);
|
||||
try {
|
||||
currentValue = Float.parseFloat(preference.getValue());
|
||||
|
@ -157,17 +159,18 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
|||
}
|
||||
|
||||
private ViewTreeObserver.OnGlobalLayoutListener getOnGlobalLayoutListener() {
|
||||
final int buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height);
|
||||
return new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
Rect visibleDisplayFrame = new Rect();
|
||||
int buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height);
|
||||
int shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height);
|
||||
final ScrollView scrollView = getView().findViewById(R.id.scroll_view);
|
||||
scrollView.getWindowVisibleDisplayFrame(visibleDisplayFrame);
|
||||
boolean showTopShadow;
|
||||
int contentHeight = visibleDisplayFrame.bottom - visibleDisplayFrame.top - buttonsHeight;
|
||||
if (contentHeightPrevious != contentHeight) {
|
||||
if (scrollView.getHeight() > contentHeight) {
|
||||
if (scrollView.getHeight() + shadowHeight > contentHeight) {
|
||||
scrollView.getLayoutParams().height = contentHeight;
|
||||
showTopShadow = false;
|
||||
} else {
|
||||
|
|
|
@ -7,6 +7,10 @@ import androidx.preference.DialogPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.bottomsheets.VehicleSizeAssets;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SizePreference extends DialogPreference {
|
||||
|
||||
private String[] entries;
|
||||
|
@ -85,7 +89,8 @@ public class SizePreference extends DialogPreference {
|
|||
String persistedString = getValue();
|
||||
if (!persistedString.equals(defaultValue)) {
|
||||
try {
|
||||
persistedString = String.valueOf(Float.parseFloat(persistedString) + 0.01f);
|
||||
final DecimalFormat df = new DecimalFormat("#.####", new DecimalFormatSymbols(Locale.US));
|
||||
persistedString = String.valueOf(df.format(Float.parseFloat(persistedString) + 0.01f));
|
||||
summary = String.format(getContext().getString(R.string.ltr_or_rtl_combine_via_space),
|
||||
persistedString, getContext().getString(assets.getMetricShortRes()));
|
||||
} catch (NumberFormatException e) {
|
||||
|
|
Loading…
Reference in a new issue