From 3dd74265fe54466e83a91928def2d3ac7a801dfd Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 00:56:34 +0200 Subject: [PATCH 1/8] fix "Start" button appearance --- .../monitoring/TripRecordingBottomSheet.java | 38 +++++++++++++++++++ .../TripRecordingStartingBottomSheet.java | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 8db1508454..c7f4316848 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -453,6 +453,21 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl setItemBackground(context, nightMode, view, enabled); } + public static void createItemActive(Context context, boolean nightMode, View view, ItemType type) { + view.setTag(type); + AppCompatImageView icon = view.findViewById(R.id.icon); + if (icon != null) { + setTintedIconActive(context, icon, nightMode, type); + } + TextView title = view.findViewById(R.id.button_text); + Integer titleId = type.getTitleId(); + if (title != null && titleId != null) { + title.setText(titleId); + setTextColorActive(context, title, nightMode, type); + } + setItemBackgroundActive(context, nightMode, view); + } + public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) { if (view instanceof CardView) { int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode); @@ -472,6 +487,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl view.setBackgroundDrawable(background); } + public static void setItemBackgroundActive(Context context, boolean nightMode, View view) { + if (view instanceof CardView) { + ((CardView) view).setCardBackgroundColor(ContextCompat.getColor(context, getActiveTextColorId(nightMode))); + } + } + public enum ItemType { SHOW_TRACK(R.string.shared_string_show_on_map, null), APPEARANCE(null, null), @@ -528,6 +549,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } + protected static void setTextColorActive(Context context, TextView tv, boolean nightMode, ItemType type) { + if (tv != null) { + tv.setTextColor(ContextCompat.getColor(context, getPressedColorId(nightMode))); + } + } + protected static void setTintedIcon(Context context, AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) { Integer iconId = type.getIconId(); if (iv != null && iconId != null) { @@ -550,6 +577,17 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } + protected static void setTintedIconActive(Context context, AppCompatImageView iv, boolean nightMode, ItemType type) { + Integer iconId = type.getIconId(); + if (iv != null && iconId != null) { + Drawable icon = AppCompatResources.getDrawable(context, iconId); + if (icon != null) { + DrawableCompat.setTint(icon, ContextCompat.getColor(context, getPressedColorId(nightMode))); + } + iv.setImageDrawable(icon); + } + } + @Override public void onPointSelected(TrkSegment segment, double lat, double lon) { if (trackChartPoints == null) { diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java index e45f792514..17d472a489 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -35,6 +35,7 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenTyp import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItemActive; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItem; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createShowTrackItem; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.updateTrackIcon; @@ -123,7 +124,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm }); CardView cardCenter = itemView.findViewById(R.id.button_center); - createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null); + createItemActive(app, nightMode, cardCenter, ItemType.START_RECORDING); cardCenter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { From 5a68b91b0c823ff45b483a22441d339b36d7145a Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 03:51:02 +0200 Subject: [PATCH 2/8] fix close button in main dialog; fix divider between toggle buttons; --- .../plus/monitoring/TripRecordingBottomSheet.java | 5 +++-- .../net/osmand/plus/myplaces/SegmentGPXAdapter.java | 10 ++++++++-- OsmAnd/src/net/osmand/plus/track/SegmentsCard.java | 2 +- .../plus/views/controls/PagerSlidingTabStrip.java | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index c7f4316848..97a56b6c68 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -163,7 +163,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl ContextCompat.getColor(app, getActiveTextColorId(nightMode))); CardView cardLeft = itemView.findViewById(R.id.button_left); - createItem(cardLeft, ItemType.CANCEL); + createItem(cardLeft, ItemType.CLOSE); cardLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -296,7 +296,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl viewGroup.removeAllViews(); setupDisplayHelper(); - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode, true); AndroidUiHelper.setVisibility(View.GONE, segmentView.findViewById(R.id.list_item_divider)); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); @@ -509,6 +509,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file), STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close), + CLOSE(R.string.shared_string_close, R.drawable.ic_action_close), START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement), SETTINGS(R.string.shared_string_settings, R.drawable.ic_action_settings), FINISH(R.string.shared_string_finish, R.drawable.ic_action_point_destination), diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java index ac45fc1294..9891c6ef5f 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java @@ -6,6 +6,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; @@ -48,7 +49,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { boolean create = false; if (row == null) { create = true; - row = createGpxTabsView(displayHelper, parent, listener, nightMode); + row = createGpxTabsView(displayHelper, parent, listener, nightMode, false); } GpxDisplayItem item = getItem(position); if (item != null) { @@ -66,7 +67,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { } public static View createGpxTabsView(TrackDisplayHelper displayHelper, ViewGroup root, - SegmentActionsListener listener, boolean nightMode) { + SegmentActionsListener listener, boolean nightMode, boolean withDivider) { Context context = root.getContext(); View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false); @@ -74,6 +75,11 @@ public class SegmentGPXAdapter extends ArrayAdapter { tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive)); tabLayout.setIndicatorHeight(0); tabLayout.setShouldExpand(true); + if (withDivider) { + tabLayout.setDividerWidth(AndroidUtils.dpToPx(context, 1.0f)); + tabLayout.setDividerColor(ContextCompat.getColor(context, nightMode ? + R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light)); + } WrapContentHeightViewPager pager = row.findViewById(R.id.pager); pager.setSwipeable(false); pager.setOffscreenPageLimit(2); diff --git a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java index a3ed324543..8a49438bc6 100644 --- a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java @@ -42,7 +42,7 @@ public class SegmentsCard extends BaseCard { container.removeAllViews(); List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); for (GpxDisplayItem displayItem : items) { - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode, false); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java index f79ac0c6b5..7eade8f2ba 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java @@ -485,7 +485,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); - canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); + canvas.drawLine(tab.getRight(), tabsContainer.getTop(), tab.getRight(), tabsContainer.getBottom(), dividerPaint); } } } From eff2d35a7f9f1ddeb4be2aa1f18e34aba8332eda Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 04:14:47 +0200 Subject: [PATCH 3/8] fix header height in main dialog; fix header title and stop button title in discard dialog; --- OsmAnd/res/layout/trip_recording_fragment.xml | 1 + .../net/osmand/plus/monitoring/TripRecordingBottomSheet.java | 2 +- .../plus/monitoring/TripRecordingDiscardBottomSheet.java | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/trip_recording_fragment.xml b/OsmAnd/res/layout/trip_recording_fragment.xml index 449ae3dd5d..d3f1cd81ca 100644 --- a/OsmAnd/res/layout/trip_recording_fragment.xml +++ b/OsmAnd/res/layout/trip_recording_fragment.xml @@ -18,6 +18,7 @@ android:paddingEnd="@dimen/content_padding" android:paddingRight="@dimen/content_padding" android:paddingBottom="@dimen/content_padding" + android:minHeight="@dimen/bottom_sheet_selected_item_title_height" android:weightSum="2"> negative = Arrays.asList(CLEAR_DATA, STOP_AND_DISCARD); + private static final List negative = Arrays.asList(CLEAR_DATA, STOP, STOP_AND_DISCARD); ItemType(@Nullable @StringRes Integer titleId, @Nullable @DrawableRes Integer iconId) { this.titleId = titleId; diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java index 70414eab5e..cff99d9daa 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java @@ -42,13 +42,13 @@ public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragme LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin); int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding); - final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); + final View buttonDiscard = createItem(inflater, ItemType.STOP); final View buttonCancel = createItem(inflater, ItemType.CANCEL); items.add(new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.track_recording_description)) .setDescriptionColorId(getPrimaryTextColorId(nightMode)) - .setTitle(app.getString(R.string.track_recording_title)) + .setTitle(app.getString(R.string.track_recording_stop_without_saving)) .setLayoutId(R.layout.bottom_sheet_item_title_with_description) .create()); From 27bf5e7809655e5da4ba38e61fb1515ee7a31bb1 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 12:56:50 +0200 Subject: [PATCH 4/8] fix display of the button "Start online monitoring" --- .../monitoring/TripRecordingBottomSheet.java | 3 +- .../TripRecordingOptionsBottomSheet.java | 42 ++++++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 1389e473c5..c11c452149 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -507,7 +507,8 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl STOP(R.string.shared_string_control_stop, R.drawable.ic_action_rec_stop), STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop), STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file), - STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), + START_ONLINE(R.string.live_monitoring_start, R.drawable.ic_world_globe_dark), + STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_action_offline), CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close), CLOSE(R.string.shared_string_close, R.drawable.ic_action_close), START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement), diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index ac42775bd2..52f218190f 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java @@ -51,8 +51,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme private SelectedGpxFile selectedGpxFile; private final Handler handler = new Handler(); private Runnable updatingTimeTrackSaved; - private int indexButtonOnline = -1; - private int indexButtonOnlineDivider = -1; private GPXFile getGPXFile() { return selectedGpxFile.getGpxFile(); @@ -91,7 +89,8 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme buttonClear = createItem(inflater, ItemType.CLEAR_DATA, hasDataToSave()); final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); - final View buttonOnline = createItem(inflater, ItemType.STOP_ONLINE, hasDataToSave()); + final View buttonOnline = createItem(inflater, settings.LIVE_MONITORING.get() + ? ItemType.STOP_ONLINE : ItemType.START_ONLINE); buttonSave = createItem(inflater, ItemType.SAVE, hasDataToSave()); final View buttonSegment = createItem(inflater, ItemType.START_NEW_SEGMENT, wasTrackMonitored()); @@ -131,27 +130,19 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme items.add(new DividerSpaceItem(app, dp36)); - if (app.getLiveMonitoringHelper().isLiveMonitoringEnabled()) { - items.add(new BaseBottomSheetItem.Builder() - .setCustomView(buttonOnline) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - settings.LIVE_MONITORING.set(false); - if (indexButtonOnline != -1) { - AndroidUiHelper.updateVisibility(items.get(indexButtonOnline).getView(), false); - } - if (indexButtonOnlineDivider != -1) { - AndroidUiHelper.updateVisibility(items.get(indexButtonOnlineDivider).getView(), false); - } - } - }) - .create()); - indexButtonOnline = items.size() - 1; + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonOnline) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean wasOnlineMonitored = !settings.LIVE_MONITORING.get(); + settings.LIVE_MONITORING.set(wasOnlineMonitored); + createItem(buttonOnline, wasOnlineMonitored ? ItemType.STOP_ONLINE : ItemType.START_ONLINE); + } + }) + .create()); - items.add(new DividerSpaceItem(app, dp36)); - indexButtonOnlineDivider = items.size() - 1; - } + items.add(new DividerSpaceItem(app, dp36)); items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonSave) @@ -181,7 +172,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme .create()); items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small))); - } @Override @@ -243,6 +233,10 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme } } + private void createItem(View view, ItemType type) { + TripRecordingBottomSheet.createItem(app, nightMode, view, type, true, null); + } + private View createItem(LayoutInflater inflater, ItemType type, boolean enabled) { return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type, enabled, null); } From ffe15a976fc83b3d070d4295abe0d77aac5f1a76 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 13:23:16 +0200 Subject: [PATCH 5/8] add horizontal margins for graphs --- .../plus/monitoring/TripRecordingBottomSheet.java | 1 + .../net/osmand/plus/myplaces/GPXItemPagerAdapter.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index c11c452149..2b2e13d2c4 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -314,6 +314,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl graphsAdapter = new GPXItemPagerAdapter(app, GpxUiHelper.makeGpxDisplayItem(app, displayHelper.getGpx()), displayHelper, nightMode, this, true); + graphsAdapter.setChartHMargin(getResources().getDimensionPixelSize(R.dimen.content_padding)); pager.setAdapter(graphsAdapter); tabLayout.setViewPager(pager); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java index b8899dd9c7..34232a8c6d 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java @@ -24,6 +24,7 @@ import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture; import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener; +import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; @@ -82,6 +83,11 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid private boolean chartClicked; private boolean nightMode; private boolean onlyGraphs; + private int chartHMargin = 0; + + public void setChartHMargin(int chartHMargin) { + this.chartHMargin = chartHMargin; + } public GPXItemPagerAdapter(@NonNull OsmandApplication app, @NonNull GpxDisplayItem gpxItem, @@ -201,6 +207,8 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid if (gpxFile != null && gpxItem != null) { GPXTrackAnalysis analysis = gpxItem.analysis; LineChart chart = view.findViewById(R.id.chart); + ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chart.getLayoutParams(); + AndroidUtils.setMargins(lp, chartHMargin, lp.topMargin, chartHMargin, lp.bottomMargin); setupChart(view, chart); switch (tabType) { @@ -436,8 +444,8 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid view.findViewById(R.id.list_divider).setVisibility(View.GONE); view.findViewById(R.id.bottom_line_blocks).setVisibility(View.GONE); } - updateJoinGapsInfo(view, position); if (!onlyGraphs) { + updateJoinGapsInfo(view, position); view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { From 9d17f50f4b66358ca9aa0d1daf3eb5ddd65c0fcb Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 17:24:09 +0200 Subject: [PATCH 6/8] fix full height of main dialog in landscape --- .../monitoring/TripRecordingBottomSheet.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 2b2e13d2c4..425378b4b6 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -5,11 +5,13 @@ import android.app.Dialog; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.CompoundButton; import android.widget.FrameLayout; import android.widget.LinearLayout; @@ -690,6 +692,36 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl return nightMode ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_inactive_light; } + @Override + protected void setupHeightAndBackground(final View mainView) { + final Activity activity = getActivity(); + if (activity == null) { + return; + } + if (AndroidUiHelper.isOrientationPortrait(activity)) { + super.setupHeightAndBackground(mainView); + return; + } + + mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewTreeObserver obs = mainView.getViewTreeObserver(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + obs.removeOnGlobalLayoutListener(this); + } else { + obs.removeGlobalOnLayoutListener(this); + } + final View contentView = mainView.findViewById(R.id.scroll_view); + contentView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; + contentView.requestLayout(); + boolean showTopShadow = AndroidUtils.getScreenHeight(activity) - AndroidUtils.getStatusBarHeight(activity) + - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8); + drawTopShadow(showTopShadow); + } + }); + } + @Override protected boolean hideButtonsContainer() { return true; From ad409bc96796b1e52b718a79449e999d3fc50949 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 17:49:46 +0200 Subject: [PATCH 7/8] fix keep the main "Trip Record" dialog visible after clicking on "Options" --- .../osmand/plus/monitoring/TripRecordingBottomSheet.java | 6 +----- .../plus/monitoring/TripRecordingOptionsBottomSheet.java | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 425378b4b6..3decf5bbad 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -239,15 +239,11 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } - public void show() { + public void show(String... keys) { Dialog dialog = getDialog(); if (dialog != null) { dialog.show(); } - } - - public void show(String... keys) { - show(); for (String key : keys) { if (key.equals(UPDATE_TRACK_ICON)) { updateTrackIcon(app, trackAppearanceIcon); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index 52f218190f..994b3034d9 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java @@ -178,10 +178,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme public void onResume() { super.onResume(); runUpdatingTimeTrackSaved(); - Fragment target = getTargetFragment(); - if (target instanceof TripRecordingBottomSheet) { - ((TripRecordingBottomSheet) target).hide(); - } } @Override From 1a149c0d63b72ad2a53f62e88e1447408e0a259d Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 21:05:10 +0200 Subject: [PATCH 8/8] small fixes --- .../plus/monitoring/TripRecordingBottomSheet.java | 5 ++++- .../net/osmand/plus/myplaces/SegmentGPXAdapter.java | 9 ++------- OsmAnd/src/net/osmand/plus/track/SegmentsCard.java | 2 +- .../plus/views/controls/PagerSlidingTabStrip.java | 12 ------------ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 3decf5bbad..480e5affa8 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -294,10 +294,13 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl viewGroup.removeAllViews(); setupDisplayHelper(); - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode, true); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode); AndroidUiHelper.setVisibility(View.GONE, segmentView.findViewById(R.id.list_item_divider)); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); + tabLayout.setDividerWidth(AndroidUtils.dpToPx(app, 1)); + tabLayout.setDividerColor(ContextCompat.getColor(app, nightMode ? + R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light)); tabLayout.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() { @Override public void onTabSelected(int position) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java index 9891c6ef5f..91f67afd22 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java @@ -49,7 +49,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { boolean create = false; if (row == null) { create = true; - row = createGpxTabsView(displayHelper, parent, listener, nightMode, false); + row = createGpxTabsView(displayHelper, parent, listener, nightMode); } GpxDisplayItem item = getItem(position); if (item != null) { @@ -67,7 +67,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { } public static View createGpxTabsView(TrackDisplayHelper displayHelper, ViewGroup root, - SegmentActionsListener listener, boolean nightMode, boolean withDivider) { + SegmentActionsListener listener, boolean nightMode) { Context context = root.getContext(); View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false); @@ -75,11 +75,6 @@ public class SegmentGPXAdapter extends ArrayAdapter { tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive)); tabLayout.setIndicatorHeight(0); tabLayout.setShouldExpand(true); - if (withDivider) { - tabLayout.setDividerWidth(AndroidUtils.dpToPx(context, 1.0f)); - tabLayout.setDividerColor(ContextCompat.getColor(context, nightMode ? - R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light)); - } WrapContentHeightViewPager pager = row.findViewById(R.id.pager); pager.setSwipeable(false); pager.setOffscreenPageLimit(2); diff --git a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java index 8a49438bc6..a3ed324543 100644 --- a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java @@ -42,7 +42,7 @@ public class SegmentsCard extends BaseCard { container.removeAllViews(); List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); for (GpxDisplayItem displayItem : items) { - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode, false); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java index 7eade8f2ba..bdb936f8ba 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java @@ -129,7 +129,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { private int dividerWidth = 0; - private int dividerPadding = 0; @ColorInt private int dividerColor; @@ -183,7 +182,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); - dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); @@ -214,7 +212,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); - dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); indicatorBgColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabBackground, Color.TRANSPARENT); @@ -720,10 +717,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { return underlineHeight; } - public int getDividerPadding() { - return dividerPadding; - } - public int getScrollOffset() { return scrollOffset; } @@ -826,11 +819,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { invalidate(); } - public void setDividerPadding(int dividerPaddingPx) { - this.dividerPadding = dividerPaddingPx; - invalidate(); - } - public void setScrollOffset(int scrollOffsetPx) { this.scrollOffset = scrollOffsetPx; invalidate();