Merge pull request #8822 from osmandapp/PaintSeekbar
Replace all SeekBars with Material Components Sliders
This commit is contained in:
commit
0c3bc8aa87
24 changed files with 235 additions and 433 deletions
|
@ -183,8 +183,9 @@
|
|||
android:layout_marginBottom="@dimen/map_button_size"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/map_transparency_seekbar"
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/map_transparency_slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="@dimen/map_trans_seek_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
|
|
@ -80,11 +80,13 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/speed_seekbar"
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/speed_slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginRight="@dimen/content_padding_small"
|
||||
android:paddingBottom="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
|
@ -34,9 +34,10 @@
|
|||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginStart="@dimen/dialog_content_margin" />
|
||||
|
||||
<SeekBar
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/Speedup"
|
||||
android:layout_width="fill_parent"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dialog_content_margin"
|
||||
android:layout_marginTop="@dimen/map_small_button_margin"
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
|
@ -36,10 +36,10 @@
|
|||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/slider"
|
||||
style="@style/Widget.MaterialComponents.Slider"
|
||||
android:theme="@style/Theme.MaterialComponents"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
osmand:labelBehavior="gone" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -21,8 +21,9 @@
|
|||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginStart="10dp" />
|
||||
|
||||
<SeekBar
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/ZoomToDownload"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
|
|
|
@ -198,17 +198,14 @@
|
|||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/transparency_slider"
|
||||
style="@style/Widget.MaterialComponents.Slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/list_header_settings_top_margin"
|
||||
android:paddingBottom="@dimen/dialog_content_margin"
|
||||
android:stepSize="1"
|
||||
android:theme="@style/Theme.MaterialComponents"
|
||||
app:haloRadius="@dimen/slider_thumb_size"
|
||||
app:thumbRadius="@dimen/slider_thumb_size"
|
||||
app:tickColor="@android:color/transparent"
|
||||
app:trackHeight="@dimen/slider_track_height" />
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:stepSize="1" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
|
@ -281,16 +278,13 @@
|
|||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/zoom_slider"
|
||||
style="@style/Widget.MaterialComponents.Slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:stepSize="1"
|
||||
android:theme="@style/Theme.MaterialComponents"
|
||||
app:haloRadius="@dimen/slider_thumb_size"
|
||||
app:thumbRadius="@dimen/slider_thumb_size"
|
||||
app:tickColor="@color/color_black"
|
||||
app:trackHeight="@dimen/slider_track_height" />
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:stepSize="1" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/zoom_value_max"
|
||||
|
|
|
@ -33,14 +33,16 @@
|
|||
android:layout_height="wrap_content"
|
||||
tools:src="@drawable/ic_action_opacity"/>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekbar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="255"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:max="255"
|
||||
android:layout_marginStart="@dimen/content_padding_half"
|
||||
android:layout_marginEnd="@dimen/content_padding" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -98,15 +98,14 @@
|
|||
android:layout_marginBottom="@dimen/map_button_size"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/map_transparency_seekbar"
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/map_transparency_slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="@dimen/map_trans_seek_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="6dp" />
|
||||
android:layout_marginLeft="@dimen/dashPadding"
|
||||
android:layout_marginRight="@dimen/dashPadding"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -118,11 +118,15 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/angle_seekbar"
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/angle_slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:valueTo="90"
|
||||
android:stepSize="5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="90"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginRight="@dimen/content_padding_small"
|
||||
android:paddingBottom="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
13
OsmAnd/res/layout/slider.xml
Normal file
13
OsmAnd/res/layout/slider.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slider_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/slider"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</FrameLayout>
|
|
@ -361,9 +361,10 @@
|
|||
<dimen name="setting_select_icon_button_height">128dp</dimen>
|
||||
<dimen name="setting_select_icon_button_width">164dp</dimen>
|
||||
|
||||
<dimen name="slider_thumb_size">8dp</dimen>
|
||||
<dimen name="slider_thumb_size">6dp</dimen>
|
||||
<dimen name="slider_thumb_halo_size">12dp</dimen>
|
||||
<dimen name="slider_track_height">2dp</dimen>
|
||||
<dimen name="mtrl_slider_track_side_padding">@dimen/slider_thumb_size</dimen>
|
||||
|
||||
<dimen name="list_item_move_header_min_height">65dp</dimen>
|
||||
</resources>
|
|
@ -112,6 +112,11 @@
|
|||
<item name="divider_color">@color/divider_color_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- MaterialComponents Widgets override -->
|
||||
<style name="Widget.Styled.Slider" parent="Widget.MaterialComponents.Slider">
|
||||
<item name="android:theme">@style/Theme.MaterialComponents</item>
|
||||
</style>
|
||||
|
||||
<!-- Osmand themes styles -->
|
||||
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
|
||||
<item name="android:textDirection">locale</item>
|
||||
|
|
|
@ -16,7 +16,6 @@ import android.widget.CompoundButton;
|
|||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
|
@ -28,6 +27,8 @@ import androidx.appcompat.widget.AppCompatImageView;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.activities.HelpActivity;
|
||||
|
@ -464,33 +465,26 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
if (convertView.findViewById(R.id.seekbar) != null) {
|
||||
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
||||
Slider slider = (Slider) convertView.findViewById(R.id.slider);
|
||||
if (slider != null) {
|
||||
if (item.getProgress() != ContextMenuItem.INVALID_ID) {
|
||||
seekBar.setProgress(item.getProgress());
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
slider.setValue(item.getProgress());
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
OnIntegerValueChangedListener listener = item.getIntegerListener();
|
||||
int progress = (int) value;
|
||||
item.setProgress(progress);
|
||||
if (listener != null && fromUser) {
|
||||
listener.onIntegerValueChangedListener(progress);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
seekBar.setVisibility(View.VISIBLE);
|
||||
} else if (seekBar != null) {
|
||||
seekBar.setVisibility(View.GONE);
|
||||
slider.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
slider.setVisibility(View.GONE);
|
||||
}
|
||||
UiUtilities.setupSeekBar(app, seekBar, nightMode, profileDependent);
|
||||
UiUtilities.setupSlider(slider, nightMode, currentModeColor);
|
||||
}
|
||||
|
||||
View progressBar = convertView.findViewById(R.id.ProgressBar);
|
||||
|
|
|
@ -4,12 +4,14 @@ package net.osmand.plus;
|
|||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
|
@ -55,15 +57,17 @@ public class OsmAndLocationSimulation {
|
|||
if (useGpx) {
|
||||
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
ApplicationMode appMode = app.getSettings().getApplicationMode();
|
||||
int selectedModeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ma, themeRes));
|
||||
builder.setTitle(R.string.animate_route);
|
||||
|
||||
final View view = ma.getLayoutInflater().inflate(R.layout.animate_route, null);
|
||||
((TextView) view.findViewById(R.id.MinSpeedup)).setText("1"); //$NON-NLS-1$
|
||||
((TextView) view.findViewById(R.id.MaxSpeedup)).setText("4"); //$NON-NLS-1$
|
||||
final SeekBar speedup = (SeekBar) view.findViewById(R.id.Speedup);
|
||||
speedup.setMax(3);
|
||||
UiUtilities.setupSeekBar(app, speedup, nightMode, true);
|
||||
final Slider speedup = (Slider) view.findViewById(R.id.Speedup);
|
||||
speedup.setValueTo(3);
|
||||
UiUtilities.setupSlider(speedup, nightMode, selectedModeColor, true);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
|
||||
|
@ -74,7 +78,7 @@ public class OsmAndLocationSimulation {
|
|||
@Override
|
||||
public boolean processResult(GPXUtilities.GPXFile[] result) {
|
||||
GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(result[0], app.getSettings());
|
||||
startAnimationThread(app, builder.getPoints(), true, speedup.getProgress() + 1);
|
||||
startAnimationThread(app, builder.getPoints(), true, speedup.getValue() + 1);
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import androidx.core.view.ViewCompat;
|
|||
import androidx.core.widget.TintableCompoundButton;
|
||||
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar;
|
||||
import com.google.android.material.slider.Slider;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.snackbar.SnackbarContentLayout;
|
||||
|
||||
|
@ -495,32 +496,57 @@ public class UiUtilities {
|
|||
}
|
||||
compoundButton.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
public static void setupSeekBar(@NonNull OsmandApplication app, @NonNull SeekBar seekBar,
|
||||
boolean nightMode, boolean profileDependent) {
|
||||
int activeColor = ContextCompat.getColor(app, profileDependent ?
|
||||
app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode) :
|
||||
nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||
setupSeekBar(seekBar, activeColor, nightMode);
|
||||
|
||||
public static ViewGroup createSliderView(@NonNull Context ctx, boolean nightMode) {
|
||||
return (ViewGroup) getInflater(ctx, nightMode).inflate(R.layout.slider, null, false);
|
||||
}
|
||||
|
||||
public static void setupSeekBar(@NonNull SeekBar seekBar, @ColorInt int activeColor, boolean nightMode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
int backgroundColor = ContextCompat.getColor(seekBar.getContext(), nightMode
|
||||
? R.color.icon_color_secondary_dark : R.color.icon_color_default_light);
|
||||
if (seekBar.getProgressDrawable() instanceof LayerDrawable) {
|
||||
LayerDrawable progressDrawable = (LayerDrawable) seekBar.getProgressDrawable();
|
||||
Drawable background = progressDrawable.findDrawableByLayerId(android.R.id.background);
|
||||
if (background != null) {
|
||||
background.setColorFilter(backgroundColor, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
Drawable progress = progressDrawable.findDrawableByLayerId(android.R.id.progress);
|
||||
if (progress != null) {
|
||||
progress.setColorFilter(activeColor, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
seekBar.getThumb().setColorFilter(activeColor, PorterDuff.Mode.SRC_IN);
|
||||
public static void setupSlider(Slider slider, boolean nightMode, @ColorInt Integer activeColor) {
|
||||
setupSlider(slider, nightMode, activeColor, false);
|
||||
}
|
||||
|
||||
public static void setupSlider(Slider 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 = AndroidUtils.getColorFromAttr(ctx, R.attr.default_icon_color);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states,
|
||||
new int[] {inactiveColor, inactiveColor});
|
||||
slider.setTrackColorActive(activeCsl);
|
||||
slider.setTrackColorInactive(inactiveCsl);
|
||||
slider.setHaloColor(activeCsl);
|
||||
slider.setThumbColor(activeCsl);
|
||||
int ticksColor = showTicks ? ContextCompat.getColor(ctx,
|
||||
nightMode ? R.color.color_black : R.color.color_white) :
|
||||
Color.TRANSPARENT;
|
||||
slider.setTickColor(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);
|
||||
|
||||
// label behavior
|
||||
slider.setLabelBehavior(Slider.LABEL_GONE);
|
||||
}
|
||||
|
||||
public static void setupDialogButton(boolean nightMode, View buttonView, DialogButtonType buttonType, @StringRes int buttonTextId) {
|
||||
|
|
|
@ -5,12 +5,14 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -71,37 +73,28 @@ public class DownloadTilesDialog {
|
|||
|
||||
((TextView)view.findViewById(R.id.MinZoom)).setText(zoom+""); //$NON-NLS-1$
|
||||
((TextView)view.findViewById(R.id.MaxZoom)).setText(max+""); //$NON-NLS-1$
|
||||
final SeekBar seekBar = (SeekBar) view.findViewById(R.id.ZoomToDownload);
|
||||
seekBar.setMax(max - zoom);
|
||||
seekBar.setProgress((max - zoom) / 2);
|
||||
final Slider slider = (Slider) view.findViewById(R.id.ZoomToDownload);
|
||||
slider.setValueTo(max - zoom);
|
||||
int progress = (max - zoom) / 2;
|
||||
slider.setValue(progress);
|
||||
|
||||
final TextView downloadText = ((TextView) view.findViewById(R.id.DownloadDescription));
|
||||
final String template = ctx.getString(R.string.tiles_to_download_estimated_size);
|
||||
|
||||
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, seekBar.getProgress());
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
|
||||
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) slider.getValue());
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, progress);
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
builder.setPositiveButton(R.string.shared_string_download, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
run(zoom, seekBar.getProgress(), rb.getLatLonBounds(), mapSource);
|
||||
run(zoom, (int) slider.getValue(), rb.getLatLonBounds(), mapSource);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
|
|
@ -31,7 +31,6 @@ import net.osmand.plus.OsmandSettings.OsmandPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.profiles.AppProfileArrayAdapter;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.views.SeekBarPreference;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -61,7 +60,6 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
private Map<String, OsmandPreference<Boolean>> booleanPreferences = new LinkedHashMap<String, OsmandPreference<Boolean>>();
|
||||
private Map<String, OsmandPreference<?>> listPreferences = new LinkedHashMap<String, OsmandPreference<?>>();
|
||||
private Map<String, OsmandPreference<String>> editTextPreferences = new LinkedHashMap<String, OsmandPreference<String>>();
|
||||
private Map<String, OsmandPreference<Integer>> seekBarPreferences = new LinkedHashMap<String, OsmandPreference<Integer>>();
|
||||
|
||||
private Map<String, Map<String, ?>> listPrefValues = new LinkedHashMap<String, Map<String, ?>>();
|
||||
|
||||
|
@ -114,13 +112,6 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
booleanPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public void registerSeekBarPreference(OsmandPreference<Integer> b, PreferenceScreen screen) {
|
||||
SeekBarPreference p = (SeekBarPreference) screen.findPreference(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
seekBarPreferences.put(b.getId(), b);
|
||||
}
|
||||
|
||||
public static String getRoutingStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||
try {
|
||||
|
@ -209,18 +200,6 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
return propertyValue;
|
||||
}
|
||||
|
||||
public SeekBarPreference createSeekBarPreference(OsmandPreference<Integer> b, int title, int summary, int dialogTextId, int defValue,
|
||||
int maxValue) {
|
||||
SeekBarPreference p = new SeekBarPreference(this, dialogTextId, defValue, maxValue);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setSummary(summary);
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
seekBarPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public <T> void registerListPreference(OsmandPreference<T> b, PreferenceGroup screen, String[] names, T[] values) {
|
||||
ListPreference p = (ListPreference) screen.findPreference(b.getId());
|
||||
prepareListPreference(b, names, values, p);
|
||||
|
@ -531,11 +510,6 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
pref.setChecked(b.get());
|
||||
}
|
||||
|
||||
for (OsmandPreference<Integer> b : seekBarPreferences.values()) {
|
||||
SeekBarPreference pref = (SeekBarPreference) screenPreferences.get(b.getId());
|
||||
pref.setValue(b.get());
|
||||
}
|
||||
|
||||
for (OsmandPreference<?> p : listPreferences.values()) {
|
||||
ListPreference listPref = (ListPreference) screenPreferences.get(p.getId());
|
||||
Map<String, ?> prefValues = listPrefValues.get(p.getId());
|
||||
|
@ -563,13 +537,10 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// handle boolean preferences
|
||||
OsmandPreference<Boolean> boolPref = booleanPreferences.get(preference.getKey());
|
||||
OsmandPreference<Integer> seekPref = seekBarPreferences.get(preference.getKey());
|
||||
OsmandPreference<Object> listPref = (OsmandPreference<Object>) listPreferences.get(preference.getKey());
|
||||
OsmandPreference<String> editPref = editTextPreferences.get(preference.getKey());
|
||||
if (boolPref != null) {
|
||||
boolPref.set((Boolean) newValue);
|
||||
} else if (seekPref != null) {
|
||||
seekPref.set((Integer) newValue);
|
||||
} else if (editPref != null) {
|
||||
editPref.set((String) newValue);
|
||||
} else if (listPref != null) {
|
||||
|
|
|
@ -21,8 +21,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -30,6 +28,8 @@ import androidx.annotation.NonNull;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
|
@ -829,70 +829,71 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
final int[] minValue, final int[] defaultValue, final int[] maxValue,
|
||||
final int min, final int max, View seekbarView, final boolean nightMode,
|
||||
final int activeColor) {
|
||||
View seekbarLayout;
|
||||
View sliderLayout;
|
||||
int titleId;
|
||||
final int[] speedValue;
|
||||
switch (type) {
|
||||
case DEFAULT_SPEED_ONLY:
|
||||
speedValue = defaultValue;
|
||||
seekbarLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
sliderLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
titleId = R.string.default_speed_setting_title;
|
||||
break;
|
||||
case MIN_SPEED:
|
||||
speedValue = minValue;
|
||||
seekbarLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
sliderLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
titleId = R.string.shared_string_min_speed;
|
||||
break;
|
||||
case MAX_SPEED:
|
||||
speedValue = maxValue;
|
||||
seekbarLayout = seekbarView.findViewById(R.id.max_speed_layout);
|
||||
sliderLayout = seekbarView.findViewById(R.id.max_speed_layout);
|
||||
titleId = R.string.shared_string_max_speed;
|
||||
break;
|
||||
default:
|
||||
speedValue = defaultValue;
|
||||
seekbarLayout = seekbarView.findViewById(R.id.default_speed_layout);
|
||||
sliderLayout = seekbarView.findViewById(R.id.default_speed_layout);
|
||||
titleId = R.string.default_speed_setting_title;
|
||||
break;
|
||||
}
|
||||
final SeekBar speedSeekBar = seekbarLayout.findViewById(R.id.speed_seekbar);
|
||||
final TextView speedTitleTv = seekbarLayout.findViewById(R.id.speed_title);
|
||||
final TextView speedMinTv = seekbarLayout.findViewById(R.id.speed_seekbar_min_text);
|
||||
final TextView speedMaxTv = seekbarLayout.findViewById(R.id.speed_seekbar_max_text);
|
||||
final TextView speedUnitsTv = seekbarLayout.findViewById(R.id.speed_units);
|
||||
final TextView speedTv = seekbarLayout.findViewById(R.id.speed_text);
|
||||
final Slider slider = sliderLayout.findViewById(R.id.speed_slider);
|
||||
final TextView speedTitleTv = sliderLayout.findViewById(R.id.speed_title);
|
||||
final TextView speedMinTv = sliderLayout.findViewById(R.id.speed_seekbar_min_text);
|
||||
final TextView speedMaxTv = sliderLayout.findViewById(R.id.speed_seekbar_max_text);
|
||||
final TextView speedUnitsTv = sliderLayout.findViewById(R.id.speed_units);
|
||||
final TextView speedTv = sliderLayout.findViewById(R.id.speed_text);
|
||||
|
||||
speedTitleTv.setText(titleId);
|
||||
speedMinTv.setText(String.valueOf(min));
|
||||
speedMaxTv.setText(String.valueOf(max));
|
||||
speedTv.setText(String.valueOf(speedValue[0]));
|
||||
speedUnitsTv.setText(speedUnits);
|
||||
speedSeekBar.setMax(max - min);
|
||||
speedSeekBar.setProgress(Math.max(speedValue[0] - min, 0));
|
||||
speedSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
slider.setValueTo(max - min);
|
||||
slider.setValue(Math.max(speedValue[0] - min, 0));
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
public void onValueChange(@NonNull Slider slider, float val, boolean fromUser) {
|
||||
int progress = (int) val;
|
||||
int value = progress + min;
|
||||
switch (type) {
|
||||
case DEFAULT_SPEED:
|
||||
case DEFAULT_SPEED_ONLY:
|
||||
if (value > maxValue[0]) {
|
||||
value = maxValue[0];
|
||||
speedSeekBar.setProgress(Math.max(value - min, 0));
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
} else if (value < minValue[0]) {
|
||||
value = minValue[0];
|
||||
speedSeekBar.setProgress(Math.max(value - min, 0));
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
case MIN_SPEED:
|
||||
if (value > defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
speedSeekBar.setProgress(Math.max(value - min, 0));
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
case MAX_SPEED:
|
||||
if (value < defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
speedSeekBar.setProgress(Math.max(value - min, 0));
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -901,15 +902,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
speedValue[0] = value;
|
||||
speedTv.setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSeekBar(speedSeekBar, activeColor, nightMode);
|
||||
UiUtilities.setupSlider(slider, nightMode, activeColor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,20 +6,22 @@ import android.content.DialogInterface;
|
|||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.ValueHolder;
|
||||
|
@ -506,8 +508,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
final int[] minutes, final ValueHolder<Boolean> choice,
|
||||
final ValueHolder<Integer> v,
|
||||
final boolean showTrackSelection, boolean nightMode) {
|
||||
ApplicationMode appMode = app.getSettings().getApplicationMode();
|
||||
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
|
||||
int textColorSecondary = ContextCompat.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
|
||||
int selectedModeColor = ContextCompat.getColor(uiCtx, appMode.getIconColorInfo().getColor(nightMode));
|
||||
LinearLayout ll = new LinearLayout(uiCtx);
|
||||
final int dp24 = AndroidUtils.dpToPx(uiCtx, 24f);
|
||||
final int dp8 = AndroidUtils.dpToPx(uiCtx, 8f);
|
||||
|
@ -516,22 +520,20 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
tv.setText(String.format(patternMsg, uiCtx.getString(R.string.int_continuosly)));
|
||||
tv.setTextColor(textColorSecondary);
|
||||
|
||||
SeekBar sp = new SeekBar(uiCtx);
|
||||
sp.setPadding(dp24 + dp8, dp8, dp24 + dp8, dp8);
|
||||
final int secondsLength = seconds.length;
|
||||
final int minutesLength = minutes.length;
|
||||
sp.setMax(secondsLength + minutesLength - 1);
|
||||
sp.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
final int minutesLength = minutes.length;
|
||||
ViewGroup sliderContainer = UiUtilities.createSliderView(uiCtx, nightMode);
|
||||
sliderContainer.setPadding(dp24, dp8, dp24, dp8);
|
||||
Slider sp = sliderContainer.findViewById(R.id.slider);
|
||||
UiUtilities.setupSlider(sp, nightMode, selectedModeColor, true);
|
||||
sp.setValueTo(secondsLength + minutesLength - 1);
|
||||
sp.setStepSize(1);
|
||||
sp.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
String s;
|
||||
int progress = (int) value;
|
||||
if(progress == 0) {
|
||||
s = uiCtx.getString(R.string.int_continuosly);
|
||||
v.value = 0;
|
||||
|
@ -545,20 +547,18 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
tv.setText(String.format(patternMsg, s));
|
||||
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSeekBar(app, sp, nightMode, true);
|
||||
|
||||
for (int i = 0; i < secondsLength + minutesLength - 1; i++) {
|
||||
if (i < secondsLength) {
|
||||
if (v.value <= seconds[i] * 1000) {
|
||||
sp.setProgress(i);
|
||||
sp.setValue(i);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (v.value <= minutes[i - secondsLength] * 1000 * 60) {
|
||||
sp.setProgress(i);
|
||||
sp.setValue(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
|
||||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(tv);
|
||||
ll.addView(sp);
|
||||
ll.addView(sliderContainer);
|
||||
if (choice != null) {
|
||||
final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
|
||||
cb.setText(R.string.confirm_every_run);
|
||||
|
|
|
@ -9,9 +9,9 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -19,6 +19,8 @@ import androidx.preference.Preference;
|
|||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -287,8 +289,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
boolean nightMode = !app.getSettings().isLightContentForMode(mode);
|
||||
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
||||
View seekbarView = LayoutInflater.from(themedContext).inflate(R.layout.recalculation_angle_dialog, null, false);
|
||||
builder.setView(seekbarView);
|
||||
View sliderView = LayoutInflater.from(themedContext).inflate(
|
||||
R.layout.recalculation_angle_dialog, null, false);
|
||||
builder.setView(sliderView);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -303,36 +306,28 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
|
||||
setupAngleSlider(angleValue, seekbarView, nightMode, selectedModeColor);
|
||||
setupAngleSlider(angleValue, sliderView, nightMode, selectedModeColor);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private static void setupAngleSlider(final float[] angleValue,
|
||||
View seekbarView,
|
||||
View sliderView,
|
||||
final boolean nightMode,
|
||||
final int activeColor) {
|
||||
|
||||
final SeekBar angleBar = seekbarView.findViewById(R.id.angle_seekbar);
|
||||
final TextView angleTv = seekbarView.findViewById(R.id.angle_text);
|
||||
final Slider angleBar = sliderView.findViewById(R.id.angle_slider);
|
||||
final TextView angleTv = sliderView.findViewById(R.id.angle_text);
|
||||
|
||||
angleTv.setText(String.valueOf(angleValue[0]));
|
||||
angleBar.setProgress((int) angleValue[0]);
|
||||
angleBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
|
||||
angleBar.setValue((int) angleValue[0]);
|
||||
angleBar.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
int value = progress - (progress % 5);
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
angleValue[0] = value;
|
||||
angleTv.setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
});
|
||||
UiUtilities.setupSeekBar(angleBar, activeColor, nightMode);
|
||||
UiUtilities.setupSlider(angleBar, nightMode, activeColor, true);
|
||||
}
|
||||
|
||||
private void setupSelectRouteRecalcDistance(PreferenceScreen screen) {
|
||||
|
|
|
@ -71,7 +71,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
|
|||
}
|
||||
|
||||
int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||
int dialogContentMargin = app.getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
|
||||
int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
|
||||
OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
||||
if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
|
@ -80,14 +80,16 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
|
|||
entryValues = new Float[]{9.1f, 18.3f, 30.5f, 45.7f, 91.5f, 183.0f, 482.0f, 965.0f, 1609.0f};
|
||||
}
|
||||
|
||||
final int appModeColor = appMode.getIconColorInfo().getColor(nightMode);
|
||||
final int appModeColorId = appMode.getIconColorInfo().getColor(nightMode);
|
||||
final int appModeColor = ContextCompat.getColor(app, appModeColorId);
|
||||
final int activeColor = AndroidUtils.resolveAttribute(app, R.attr.active_color_basic);
|
||||
final int disabledColor = AndroidUtils.resolveAttribute(app, android.R.attr.textColorSecondary);
|
||||
|
||||
String title = getString(R.string.recalculate_route_in_deviation);
|
||||
items.add(new TitleItem(title));
|
||||
|
||||
final View sliderView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.bottom_sheet_item_slider_with_two_text, null);
|
||||
final View sliderView = UiUtilities.getInflater(getContext(), nightMode)
|
||||
.inflate(R.layout.bottom_sheet_item_slider_with_two_text, null);
|
||||
slider = sliderView.findViewById(R.id.slider);
|
||||
tvSliderTitle = sliderView.findViewById(android.R.id.title);
|
||||
tvSliderTitle.setText(getString(R.string.distance));
|
||||
|
@ -102,7 +104,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
|
|||
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
|
||||
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(enabled)
|
||||
.setCompoundButtonColorId(appModeColor)
|
||||
.setCompoundButtonColorId(appModeColorId)
|
||||
.setTitle(enabled ? on : off)
|
||||
.setTitleColorId(enabled ? activeColor : disabledColor)
|
||||
.setCustomView(getCustomButtonView(enabled))
|
||||
|
@ -129,7 +131,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
|
|||
items.add(preferenceBtn[0]);
|
||||
items.add(new DividerSpaceItem(app, contentPaddingSmall));
|
||||
items.add(new LongDescriptionItem(getString(R.string.select_distance_route_will_recalc)));
|
||||
items.add(new DividerSpaceItem(app, dialogContentMargin));
|
||||
items.add(new DividerSpaceItem(app, contentPadding));
|
||||
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
|
@ -141,6 +143,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
|
|||
}
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSlider(slider, nightMode, appModeColor, true);
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(sliderView)
|
||||
.create());
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.srtmplugin;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.net.Uri;
|
||||
|
@ -77,8 +76,8 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
|||
private boolean nightMode;
|
||||
private boolean terrainEnabled;
|
||||
|
||||
private int colorProfileRes;
|
||||
private int colorProfile;
|
||||
private ColorStateList colorProfileStateList;
|
||||
|
||||
private TextView downloadDescriptionTv;
|
||||
private TextView transparencyValueTv;
|
||||
|
@ -115,8 +114,8 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
|||
uiUtilities = app.getUIUtilities();
|
||||
nightMode = !settings.isLightContent();
|
||||
srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||
colorProfile = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
|
||||
colorProfileStateList = ColorStateList.valueOf(ContextCompat.getColor(app, colorProfile));
|
||||
colorProfileRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
|
||||
colorProfile = ContextCompat.getColor(app, colorProfileRes);
|
||||
terrainEnabled = srtmPlugin.isTerrainLayerEnabled();
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
@ -174,15 +173,8 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
|||
switchCompat.setOnClickListener(this);
|
||||
slopeBtn.setOnClickListener(this);
|
||||
|
||||
transparencySlider.setTrackColorActive(colorProfileStateList);
|
||||
transparencySlider.setThumbColor(colorProfileStateList);
|
||||
transparencySlider.setLabelBehavior(Slider.LABEL_GONE);
|
||||
zoomSlider.setTrackColorActive(colorProfileStateList);
|
||||
zoomSlider.setThumbColor(colorProfileStateList);
|
||||
zoomSlider.setLabelBehavior(Slider.LABEL_GONE);
|
||||
zoomSlider.setTickColor(nightMode
|
||||
? ColorStateList.valueOf(R.color.color_white)
|
||||
: ColorStateList.valueOf(R.color.color_black));
|
||||
UiUtilities.setupSlider(transparencySlider, nightMode, colorProfile);
|
||||
UiUtilities.setupSlider(zoomSlider, nightMode, colorProfile, true);
|
||||
|
||||
transparencySlider.addOnSliderTouchListener(this);
|
||||
zoomSlider.addOnSliderTouchListener(this);
|
||||
|
@ -264,7 +256,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
|||
String transparency = transparencyValue + "%";
|
||||
int minZoom = Math.max(srtmPlugin.getTerrainMinZoom(), TERRAIN_MIN_ZOOM);
|
||||
int maxZoom = Math.min(srtmPlugin.getTerrainMaxZoom(), TERRAIN_MAX_ZOOM);
|
||||
iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfile));
|
||||
iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfileRes));
|
||||
stateTv.setText(R.string.shared_string_enabled);
|
||||
transparencySlider.setValue(transparencyValue);
|
||||
transparencyValueTv.setText(transparency);
|
||||
|
|
|
@ -18,22 +18,25 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.ViewPropertyAnimatorCompat;
|
||||
import androidx.core.view.ViewPropertyAnimatorListener;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmAndLocationSimulation;
|
||||
|
@ -97,7 +100,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
// private RulerControl rulerControl;
|
||||
// private List<MapControls> allControls = new ArrayList<MapControls>();
|
||||
|
||||
private SeekBar transparencyBar;
|
||||
private Slider transparencySlider;
|
||||
private LinearLayout transparencyBarLayout;
|
||||
private static CommonPreference<Integer> transparencySetting;
|
||||
private boolean isTransparencyBarEnabled;
|
||||
|
@ -921,28 +924,19 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
// /////////////// Transparency bar /////////////////////////
|
||||
private void initTransparencyBar() {
|
||||
transparencyBarLayout = (LinearLayout) mapActivity.findViewById(R.id.map_transparency_layout);
|
||||
transparencyBar = (SeekBar) mapActivity.findViewById(R.id.map_transparency_seekbar);
|
||||
transparencyBar.setMax(255);
|
||||
transparencySlider = (Slider) mapActivity.findViewById(R.id.map_transparency_slider);
|
||||
transparencySlider.setValueTo(255);
|
||||
if (transparencySetting != null) {
|
||||
transparencyBar.setProgress(transparencySetting.get());
|
||||
transparencySlider.setValue(transparencySetting.get());
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
}
|
||||
transparencyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
|
||||
transparencySlider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
if (transparencySetting != null) {
|
||||
transparencySetting.set(progress);
|
||||
transparencySetting.set((int) value);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -961,18 +955,21 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
public void showTransparencyBar(CommonPreference<Integer> transparenPreference,
|
||||
boolean isTransparencyBarEnabled) {
|
||||
this.isTransparencyBarEnabled = isTransparencyBarEnabled;
|
||||
ApplicationMode appMode = app.getSettings().getApplicationMode();
|
||||
if (MapControlsLayer.transparencySetting != transparenPreference) {
|
||||
MapControlsLayer.transparencySetting = transparenPreference;
|
||||
|
||||
}
|
||||
if (transparenPreference != null && isTransparencyBarEnabled) {
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
transparencyBar.setProgress(transparenPreference.get());
|
||||
transparencySlider.setValue(transparenPreference.get());
|
||||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
}
|
||||
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
UiUtilities.setupSeekBar(app, transparencyBar, nightMode, true);
|
||||
int selectedModeColor = ContextCompat.getColor(app,
|
||||
appMode.getIconColorInfo().getColor(nightMode));
|
||||
UiUtilities.setupSlider(transparencySlider, nightMode, selectedModeColor);
|
||||
}
|
||||
|
||||
public void hideTransparencyBar() {
|
||||
|
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Jordan Frank, HumanSense Project, McGill University
|
||||
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
* See LICENSE for more information
|
||||
*/
|
||||
package net.osmand.plus.views;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import android.content.Context;
|
||||
import android.preference.DialogPreference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A preference item that uses a seek-bar, or slider to set the value.
|
||||
*
|
||||
* @author Jordan Frank <jordan.frank@cs.mcgill.ca>
|
||||
*
|
||||
*/
|
||||
public class SeekBarPreference extends DialogPreference implements
|
||||
SeekBar.OnSeekBarChangeListener {
|
||||
|
||||
private static final String MAX_VALUE_ID = "max";
|
||||
private static final String DEFAULT_VALUE_ID = "defaultValue";
|
||||
private static final String DIALOG_TEXT_ID = "text";
|
||||
private static final String DIALOG_MESSAGE_ID = "dialogMessage";
|
||||
private static final String ANDROID_NS = "http://schemas.android.com/apk/res/android";
|
||||
|
||||
private SeekBar seekBar;
|
||||
private TextView dialogTextView, valueTextView;
|
||||
private final Context context;
|
||||
|
||||
private final String dialogText, valueText;
|
||||
private final int defaultValue;
|
||||
|
||||
private int maxValue, value, valueToSave = 0;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param context
|
||||
* The application context.
|
||||
* @param attrs
|
||||
* The attribute set, containing the text, title, values, and
|
||||
* range for the slider dialog.
|
||||
*/
|
||||
public SeekBarPreference(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.context = context;
|
||||
|
||||
dialogText = context.getResources().getString(
|
||||
attrs.getAttributeResourceValue(ANDROID_NS, DIALOG_MESSAGE_ID,
|
||||
R.string.app_name));
|
||||
valueText = attrs.getAttributeValue(ANDROID_NS, DIALOG_TEXT_ID);
|
||||
defaultValue = attrs.getAttributeIntValue(ANDROID_NS, DEFAULT_VALUE_ID,
|
||||
0);
|
||||
maxValue = attrs.getAttributeIntValue(ANDROID_NS, MAX_VALUE_ID, 100);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param context
|
||||
* The application context.
|
||||
* @param attrs
|
||||
* The attribute set, containing the text, title, values, and
|
||||
* range for the slider dialog.
|
||||
*/
|
||||
public SeekBarPreference(final Context context, int dialogTextId, int defValue, int maxValue) {
|
||||
super(context, null);
|
||||
this.context = context;
|
||||
dialogText = context.getResources().getString(dialogTextId);
|
||||
valueText = null;
|
||||
this.defaultValue = defValue;
|
||||
this.maxValue = maxValue;
|
||||
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindDialogView(final View v) {
|
||||
super.onBindDialogView(v);
|
||||
seekBar.setMax(maxValue);
|
||||
seekBar.setProgress(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View onCreateDialogView() {
|
||||
LinearLayout.LayoutParams params;
|
||||
final LinearLayout layout = new LinearLayout(context);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.setPadding(6, 6, 6, 6);
|
||||
|
||||
dialogTextView = new TextView(context);
|
||||
if (dialogText != null) {
|
||||
dialogTextView.setText(dialogText);
|
||||
}
|
||||
layout.addView(dialogTextView);
|
||||
|
||||
valueTextView = new TextView(context);
|
||||
valueTextView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
valueTextView.setTextSize(32);
|
||||
params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.FILL_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
layout.addView(valueTextView, params);
|
||||
|
||||
seekBar = new SeekBar(context);
|
||||
seekBar.setOnSeekBarChangeListener(this);
|
||||
layout.addView(seekBar, new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.FILL_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
if (shouldPersist()) {
|
||||
value = getPersistedInt(defaultValue);
|
||||
}
|
||||
|
||||
seekBar.setMax(maxValue);
|
||||
seekBar.setProgress(value);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
if(positiveResult){
|
||||
if (shouldPersist()) {
|
||||
persistInt(valueToSave);
|
||||
}
|
||||
callChangeListener(Integer.valueOf(valueToSave));
|
||||
} else {
|
||||
this.valueToSave = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(final SeekBar seek, final int value,
|
||||
final boolean fromTouch) {
|
||||
final String t = String.valueOf(value);
|
||||
valueTextView.setText(valueText == null ? t : t + valueText);
|
||||
valueToSave = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(final boolean restore,
|
||||
final Object defaultValue) {
|
||||
super.onSetInitialValue(restore, defaultValue);
|
||||
if (restore) {
|
||||
value = shouldPersist() ? getPersistedInt(this.defaultValue) : 0;
|
||||
} else {
|
||||
value = (Integer) defaultValue;
|
||||
}
|
||||
valueToSave = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(final SeekBar seek) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(final SeekBar seek) {
|
||||
}
|
||||
|
||||
public void setMax(final int max) {
|
||||
maxValue = max;
|
||||
}
|
||||
|
||||
public void setValue(final int value) {
|
||||
this.value = value;
|
||||
this.valueToSave = value;
|
||||
persistInt(value);
|
||||
if (seekBar != null) {
|
||||
seekBar.setProgress(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue