Show track on the map: all lines should be tappable.

Slider color = profile color
This commit is contained in:
androiddevkotlin 2021-01-26 19:41:49 +02:00
parent 569493f32b
commit 878208deee
4 changed files with 48 additions and 17 deletions

View file

@ -7,15 +7,16 @@
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding">
>
<LinearLayout
android:id="@+id/basic_item_body"
android:layout_width="0dp"
android:layout_height="match_parent"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
@ -46,8 +47,9 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
tools:checked="true" />
</LinearLayout>
@ -73,6 +75,8 @@
android:layout_gravity="center"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
app:srcCompat="@drawable/ic_action_track_line_bold_color" />
</LinearLayout>

View file

@ -32,6 +32,8 @@
android:background="?attr/dashboard_divider" />
<LinearLayout
android:id="@+id/interval_view_container"
android:background="?attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
@ -40,6 +42,7 @@
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_content_margin"
android:paddingBottom="@dimen/bottom_sheet_content_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
@ -106,8 +109,6 @@
android:id="@+id/second_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginBottom="@dimen/bottom_sheet_content_margin_small"
android:background="?attr/dashboard_divider" />
</LinearLayout>

View file

@ -636,7 +636,7 @@ public class UiUtilities {
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});
ColorStateList inactiveCsl = new ColorStateList(states, new int[] {activeDisableColor, inactiveColor});
slider.setTrackActiveTintList(activeCsl);
slider.setTrackInactiveTintList(inactiveCsl);
slider.setHaloTintList(activeCsl);

View file

@ -9,6 +9,7 @@ import android.os.Bundle;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
@ -18,10 +19,12 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.RangeSlider;
import net.osmand.AndroidUtils;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication;
@ -49,9 +52,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
private ImageView upDownBtn;
private SwitchCompat confirmEveryRun;
private RangeSlider intervalSlider;
private TextView intervalValueView;
private LinearLayout container;
private LinearLayout expandHideIntervalContainer;
private View divider;
private boolean infoExpanded;
@Override
@ -92,8 +96,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
}
});
divider = itemView.findViewById(R.id.second_divider);
expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container);
upDownBtn = itemView.findViewById(R.id.up_down_button);
upDownBtn.setOnClickListener(new View.OnClickListener() {
expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -108,8 +114,11 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
updateIntervalLegend();
container = itemView.findViewById(R.id.always_ask_and_range_slider_container);
intervalSlider = itemView.findViewById(R.id.interval_slider);
RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider);
intervalSlider.setValueTo(secondsLength + minutesLength - 1);
int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
int currentModeColor = ContextCompat.getColor(app, currentModeColorRes);
UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true);
container.setVisibility(View.GONE);
intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() {
@ -126,6 +135,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
updateIntervalLegend();
}
});
for (int i = 0; i < secondsLength + minutesLength; i++) {
if (i < secondsLength) {
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) {
@ -151,13 +161,19 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
}
});
SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button);
final SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button);
showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
showTrackOnMapButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
View basicItem = itemView.findViewById(R.id.basic_item_body);
basicItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), isChecked, false);
public void onClick(View v) {
if (showTrackOnMapButton.isChecked()) {
showTrackOnMapButton.setChecked(false);
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), false, false);
} else {
showTrackOnMapButton.setChecked(true);
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), true, false);
}
}
});
UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT);
@ -217,6 +233,16 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
private void toggleInfoView() {
infoExpanded = !infoExpanded;
ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) divider.getLayoutParams();
if (getMapActivity() != null) {
final int dp8 = AndroidUtils.dpToPx(getMapActivity(), 8f);
final int dp16 = AndroidUtils.dpToPx(getMapActivity(), 16f);
if (infoExpanded) {
AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8);
} else {
AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8);
}
}
AndroidUiHelper.updateVisibility(container, infoExpanded);
updateUpDownBtn();
}