diff --git a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml index a10a9eef42..e7b84c5305 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml @@ -66,25 +66,23 @@ + app:cardElevation="0dp" + tools:cardBackgroundColor="?attr/switch_button_active"> - + android:background="?android:attr/selectableItemBackground"> - + diff --git a/OsmAnd/res/layout/preference_button_with_icon_triple.xml b/OsmAnd/res/layout/preference_button_with_icon_triple.xml index 22d68ff090..c8905bbd61 100644 --- a/OsmAnd/res/layout/preference_button_with_icon_triple.xml +++ b/OsmAnd/res/layout/preference_button_with_icon_triple.xml @@ -1,7 +1,5 @@ @@ -28,7 +26,7 @@ android:layout_height="match_parent" android:layout_marginStart="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half" - android:layout_weight="0.5" + android:layout_weight="0.8" android:minWidth="@dimen/button_triple_center_width" android:minHeight="@dimen/setting_list_item_large_height" /> @@ -39,7 +37,7 @@ android:layout_height="match_parent" android:layout_marginStart="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half" - android:layout_weight="0.25" + android:layout_weight="0.1" android:minWidth="@dimen/context_menu_top_right_button_min_width" android:minHeight="@dimen/setting_list_item_large_height" /> diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java index 27295899da..7aaa832dd1 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java @@ -6,7 +6,6 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.text.format.DateUtils; @@ -29,6 +28,7 @@ import androidx.cardview.widget.CardView; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; @@ -81,7 +81,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen private SelectedGpxFile selectedGpxFile; private View statusContainer; - private LinearLayout buttonAppearance; + private LinearLayout showTrackContainer; private AppCompatImageView trackAppearanceIcon; private View buttonSave; private GpxBlockStatisticsBuilder blockStatisticsBuilder; @@ -161,49 +161,15 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen blockStatisticsBuilder.setBlocksClickable(false); blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode); - LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); - - final CardView buttonShow = showTrackContainer.findViewById(R.id.compound_container); - TextView showTrackTitle = buttonShow.findViewById(R.id.title); - Integer showTitle = ItemType.SHOW_TRACK.getTitleId(); - if (showTitle != null) { - showTrackTitle.setText(showTitle); - } - final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button); - showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); - - buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); + showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); - updateTrackIcon(app, trackAppearanceIcon); - buttonAppearance.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (showTrackCompound.isChecked()) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { + createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, + ItemType.SHOW_TRACK.getTitleId(), TripRecordingActiveBottomSheet.this, new Runnable() { + @Override + public void run() { hide(); - SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingActiveBottomSheet.this); } - } - } - }); - createItem(buttonAppearance, ItemType.APPEARANCE, showTrackCompound.isChecked()); - setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - buttonShow.setBackgroundTintList(null); - } - buttonShow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean checked = !showTrackCompound.isChecked(); - showTrackCompound.setChecked(checked); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); - createItem(buttonAppearance, ItemType.APPEARANCE, checked); - setShowOnMapBackground(buttonShow, checked, nightMode); - } - }); + }); buttonClear.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { @Override @@ -309,6 +275,49 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } + public static void createShowTrackItem(final OsmandApplication app, final MapActivity mapActivity, + final boolean nightMode, LinearLayout showTrackContainer, + AppCompatImageView trackAppearanceIcon, Integer showTrackId, + final Fragment target, final Runnable hideOnClickButtonAppearance) { + final CardView buttonShowTrack = showTrackContainer.findViewById(R.id.compound_container); + final CardView buttonAppearance = showTrackContainer.findViewById(R.id.additional_button_container); + + TextView showTrackTextView = buttonShowTrack.findViewById(R.id.title); + if (showTrackId != null) { + showTrackTextView.setText(showTrackId); + } + final CompoundButton showTrackCompound = buttonShowTrack.findViewById(R.id.compound_button); + showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); + UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); + + setShowOnMapBackground(buttonShowTrack, showTrackCompound.isChecked(), nightMode); + buttonShowTrack.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !showTrackCompound.isChecked(); + showTrackCompound.setChecked(checked); + app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); + setShowOnMapBackground(buttonShowTrack, checked, nightMode); + createItem(app, nightMode, buttonAppearance, ItemType.APPEARANCE, checked, null); + } + }); + + updateTrackIcon(app, trackAppearanceIcon); + createItem(app, nightMode, buttonAppearance, ItemType.APPEARANCE, showTrackCompound.isChecked(), null); + buttonAppearance.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (showTrackCompound.isChecked()) { + if (mapActivity != null) { + hideOnClickButtonAppearance.run(); + SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, target); + } + } + } + }); + } + private void createItem(View view, ItemType type, boolean enabled) { createItem(app, nightMode, view, type, enabled, null); } @@ -558,11 +567,11 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( context, normalColorId, getActiveTextColorId(nightMode) ); - DrawableCompat.setTintList(background, iconColorStateList); if (view instanceof CardView) { ((CardView) view).setCardBackgroundColor(iconColorStateList); return; } + DrawableCompat.setTintList(background, iconColorStateList); } else { UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java index 7f19ea13fb..c03a568137 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -4,12 +4,10 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.graphics.Typeface; -import android.os.Build; import android.os.Bundle; import android.text.SpannableString; import android.view.LayoutInflater; import android.view.View; -import android.widget.CompoundButton; import android.widget.LinearLayout; import android.widget.TextView; @@ -22,7 +20,6 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.slider.RangeSlider; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -37,13 +34,13 @@ import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; -import net.osmand.plus.track.TrackAppearanceFragment; import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createShowTrackItem; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.setShowOnMapBackground; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon; @@ -60,6 +57,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm private CardView confirmContainer; private SwitchCompat confirmCompound; private TextView intervalValueView; + private LinearLayout showTrackContainer; private LinearLayout intervalContainer; private RangeSlider intervalSlider; @@ -100,6 +98,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm confirmContainer = itemView.findViewById(R.id.confirm_container); confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button); + UiUtilities.setupCompoundButton(confirmCompound, nightMode, GLOBAL); updateGlobalRemember(); confirmContainer.setOnClickListener(new View.OnClickListener() { @Override @@ -111,42 +110,15 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm } }); - LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); - - final CardView buttonShow = itemView.findViewById(R.id.compound_container); - TextView showTrackTitle = buttonShow.findViewById(R.id.title); - showTrackTitle.setText(R.string.show_track_on_map); - final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button); - showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); - - LinearLayout buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); + showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); - updateTrackIcon(app, trackAppearanceIcon); - buttonAppearance.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - hide(); - SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingStartingBottomSheet.this); - } - } - }); - setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - buttonShow.setBackgroundTintList(null); - } - buttonShow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean checked = !showTrackCompound.isChecked(); - showTrackCompound.setChecked(checked); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); - setShowOnMapBackground(buttonShow, checked, nightMode); - } - }); + createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, + R.string.show_track_on_map, TripRecordingStartingBottomSheet.this, new Runnable() { + @Override + public void run() { + hide(); + } + }); updateUpDownBtn();