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; @@ -528,6 +553,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 +581,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) { @@ -649,6 +691,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; 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()); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index ac42775bd2..994b3034d9 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,17 +172,12 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme .create()); items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small))); - } @Override public void onResume() { super.onResume(); runUpdatingTimeTrackSaved(); - Fragment target = getTargetFragment(); - if (target instanceof TripRecordingBottomSheet) { - ((TripRecordingBottomSheet) target).hide(); - } } @Override @@ -243,6 +229,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); } 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) { 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) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java index ac45fc1294..91f67afd22 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; diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java index f79ac0c6b5..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); @@ -485,7 +482,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); } } } @@ -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();