diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 6bebf5f67b..79c1027c84 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -524,7 +524,7 @@ dependencies { implementation 'androidx.gridlayout:gridlayout:1.0.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.2.0-alpha06' + implementation 'com.google.android.material:material:1.2.0-beta01' implementation 'androidx.browser:browser:1.0.0' implementation 'androidx.preference:preference:1.1.0' implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs') diff --git a/OsmAnd/res/layout/fragment_terrain.xml b/OsmAnd/res/layout/fragment_terrain.xml index c077d1a765..11fa1aa1f0 100644 --- a/OsmAnd/res/layout/fragment_terrain.xml +++ b/OsmAnd/res/layout/fragment_terrain.xml @@ -275,7 +275,7 @@ android:textSize="@dimen/default_list_text_size" tools:text="3" /> - listAdapter; + private Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() { + @Override + public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { + if (fromUser) { + String transparencyStr = (int) value + "%"; + transparencyValueTv.setText(transparencyStr); + srtmPlugin.setTerrainTransparency((int) Math.ceil(value * 2.55), srtmPlugin.getTerrainMode()); + } + } + }; + + private RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() { + @Override + public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) { + List values = slider.getValues(); + if (values.size() > 0) { + minZoomTv.setText(String.valueOf(values.get(0).intValue())); + maxZoomTv.setText(String.valueOf(values.get(1).intValue())); + srtmPlugin.setTerrainZoomValues(values.get(0).intValue(), values.get(1).intValue(), srtmPlugin.getTerrainMode()); + } + } + }; + @Override public void onCreate(@Nullable Bundle savedInstanceState) { app = requireMyApplication(); @@ -175,10 +199,8 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL UiUtilities.setupSlider(transparencySlider, nightMode, colorProfile); UiUtilities.setupSlider(zoomSlider, nightMode, colorProfile, true); - transparencySlider.addOnSliderTouchListener(this); - zoomSlider.addOnSliderTouchListener(this); - transparencySlider.addOnChangeListener(this); - zoomSlider.addOnChangeListener(this); + transparencySlider.addOnChangeListener(transparencySliderChangeListener); + zoomSlider.addOnChangeListener(zoomSliderChangeListener); transparencySlider.setValueTo(100); transparencySlider.setValueFrom(0); zoomSlider.setValueTo(TERRAIN_MAX_ZOOM); @@ -207,47 +229,6 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL } } - @Override - public void onStartTrackingTouch(@NonNull Slider slider) { - - } - - @Override - public void onStopTrackingTouch(@NonNull Slider slider) { - switch (slider.getId()) { - case R.id.transparency_slider: - double d = slider.getValue() * 2.55; - srtmPlugin.setTerrainTransparency((int) Math.ceil(d), srtmPlugin.getTerrainMode()); - break; - case R.id.zoom_slider: - List values = slider.getValues(); - if (values.size() > 0) { - srtmPlugin.setTerrainZoomValues(values.get(0).intValue(), values.get(1).intValue(), srtmPlugin.getTerrainMode()); - } - break; - } - updateLayers(); - } - - @Override - public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { - if (fromUser) { - switch (slider.getId()) { - case R.id.transparency_slider: - String transparency = (int) value + "%"; - transparencyValueTv.setText(transparency); - break; - case R.id.zoom_slider: - List values = slider.getValues(); - if (values.size() > 0) { - minZoomTv.setText(String.valueOf(values.get(0).intValue())); - maxZoomTv.setText(String.valueOf(values.get(1).intValue())); - } - break; - } - } - } - private void updateUiMode() { TerrainMode mode = srtmPlugin.getTerrainMode(); if (terrainEnabled) {