Update material libtrary to beta01
This commit is contained in:
parent
19e5db7b0a
commit
45e192b62e
4 changed files with 82 additions and 66 deletions
|
@ -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')
|
||||
|
|
|
@ -275,7 +275,7 @@
|
|||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="3" />
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
<com.google.android.material.slider.RangeSlider
|
||||
android:id="@+id/zoom_slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -37,6 +37,7 @@ import androidx.core.graphics.drawable.DrawableCompat;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.widget.TintableCompoundButton;
|
||||
|
||||
import com.google.android.material.slider.RangeSlider;
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar;
|
||||
import com.google.android.material.slider.Slider;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
@ -524,29 +525,63 @@ public class UiUtilities {
|
|||
activeColor = AndroidUtils.getColorFromAttr(ctx, R.attr.active_color_basic);
|
||||
}
|
||||
int activeDisableColor = getColorWithAlpha(activeColor, 0.25f);
|
||||
ColorStateList activeCsl = new ColorStateList(states,
|
||||
new int[] {activeColor, activeDisableColor});
|
||||
int inactiveColor = ContextCompat.getColor(ctx,
|
||||
nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states,
|
||||
new int[] {inactiveColor, inactiveColor});
|
||||
slider.setTrackColorActive(activeCsl);
|
||||
slider.setTrackColorInactive(inactiveCsl);
|
||||
slider.setHaloColor(activeCsl);
|
||||
slider.setThumbColor(activeCsl);
|
||||
ColorStateList activeCsl = new ColorStateList(states, new int[] {activeColor, activeDisableColor});
|
||||
int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states, new int[] {inactiveColor, inactiveColor});
|
||||
slider.setTrackActiveTintList(activeCsl);
|
||||
slider.setTrackInactiveTintList(inactiveCsl);
|
||||
slider.setHaloTintList(activeCsl);
|
||||
slider.setThumbTintList(activeCsl);
|
||||
int colorBlack = ContextCompat.getColor(ctx, R.color.color_black);
|
||||
int ticksColor = showTicks ?
|
||||
(nightMode ? colorBlack : getColorWithAlpha(colorBlack, 0.5f)) :
|
||||
Color.TRANSPARENT;
|
||||
slider.setTickColor(new ColorStateList(states, new int[] {ticksColor, ticksColor}));
|
||||
slider.setTickTintList(new ColorStateList(states, new int[] {ticksColor, ticksColor}));
|
||||
|
||||
// sizes
|
||||
int thumbRadius = ctx.getResources().getDimensionPixelSize(R.dimen.slider_thumb_size);
|
||||
int haloRadius = ctx.getResources().getDimensionPixelSize(R.dimen.slider_thumb_halo_size);
|
||||
int trackHeight = ctx.getResources().getDimensionPixelSize(R.dimen.slider_track_height);
|
||||
slider.setThumbRadius(thumbRadius);
|
||||
slider.setHaloRadius(haloRadius);
|
||||
slider.setTrackHeight(trackHeight);
|
||||
slider.setThumbRadius(ctx.getResources().getDimensionPixelSize(R.dimen.slider_thumb_size));
|
||||
slider.setHaloRadius(ctx.getResources().getDimensionPixelSize(R.dimen.slider_thumb_halo_size));
|
||||
slider.setTrackHeight(ctx.getResources().getDimensionPixelSize(R.dimen.slider_track_height));
|
||||
|
||||
// label behavior
|
||||
slider.setLabelBehavior(Slider.LABEL_GONE);
|
||||
}
|
||||
|
||||
public static void setupSlider(RangeSlider slider, boolean nightMode,
|
||||
@ColorInt Integer activeColor, boolean showTicks) {
|
||||
Context ctx = slider.getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
int themeId = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
ctx = new ContextThemeWrapper(ctx, themeId);
|
||||
|
||||
// colors
|
||||
int[][] states = new int[][] {
|
||||
new int[] {android.R.attr.state_enabled},
|
||||
new int[] {-android.R.attr.state_enabled}
|
||||
};
|
||||
if (activeColor == null) {
|
||||
activeColor = AndroidUtils.getColorFromAttr(ctx, R.attr.active_color_basic);
|
||||
}
|
||||
int activeDisableColor = getColorWithAlpha(activeColor, 0.25f);
|
||||
ColorStateList activeCsl = new ColorStateList(states, new int[] {activeColor, activeDisableColor});
|
||||
int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states, new int[] {inactiveColor, inactiveColor});
|
||||
slider.setTrackActiveTintList(activeCsl);
|
||||
slider.setTrackInactiveTintList(inactiveCsl);
|
||||
slider.setHaloTintList(activeCsl);
|
||||
slider.setThumbTintList(activeCsl);
|
||||
int colorBlack = ContextCompat.getColor(ctx, R.color.color_black);
|
||||
int ticksColor = showTicks ?
|
||||
(nightMode ? colorBlack : getColorWithAlpha(colorBlack, 0.5f)) :
|
||||
Color.TRANSPARENT;
|
||||
slider.setTickTintList(new ColorStateList(states, new int[] {ticksColor, ticksColor}));
|
||||
|
||||
// sizes
|
||||
slider.setThumbRadius(ctx.getResources().getDimensionPixelSize(R.dimen.slider_thumb_size));
|
||||
slider.setHaloRadius(ctx.getResources().getDimensionPixelSize(R.dimen.slider_thumb_halo_size));
|
||||
slider.setTrackHeight(ctx.getResources().getDimensionPixelSize(R.dimen.slider_track_height));
|
||||
|
||||
// label behavior
|
||||
slider.setLabelBehavior(Slider.LABEL_GONE);
|
||||
|
|
|
@ -27,6 +27,7 @@ import androidx.appcompat.widget.SwitchCompat;
|
|||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
|
||||
import com.google.android.material.slider.RangeSlider;
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -62,7 +63,7 @@ import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM;
|
|||
|
||||
|
||||
public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener,
|
||||
Slider.OnSliderTouchListener, Slider.OnChangeListener, DownloadIndexesThread.DownloadEvents {
|
||||
DownloadIndexesThread.DownloadEvents {
|
||||
|
||||
public static final String TAG = TerrainFragment.class.getSimpleName();
|
||||
private static final Log LOG = PlatformUtil.getLog(TerrainFragment.class.getSimpleName());
|
||||
|
@ -101,12 +102,35 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
|||
private View downloadTopDivider;
|
||||
private View downloadBottomDivider;
|
||||
private Slider transparencySlider;
|
||||
private Slider zoomSlider;
|
||||
private RangeSlider zoomSlider;
|
||||
private ObservableListView observableListView;
|
||||
private View bottomEmptySpace;
|
||||
|
||||
private ArrayAdapter<ContextMenuItem> 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<Float> 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<Float> 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<Float> 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) {
|
||||
|
|
Loading…
Reference in a new issue