fix bottom buttons width;

some fixes;
This commit is contained in:
Skalii 2021-03-18 02:41:01 +02:00
parent c90a74956a
commit a8e1d60af1
4 changed files with 73 additions and 96 deletions

View file

@ -66,25 +66,23 @@
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/additional_button_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
app:cardBackgroundColor="?attr/switch_button_active"
app:cardCornerRadius="4dp" app:cardCornerRadius="4dp"
app:cardElevation="0dp"> app:cardElevation="0dp"
tools:cardBackgroundColor="?attr/switch_button_active">
<LinearLayout <FrameLayout
android:id="@+id/additional_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground">
android:clickable="true"
android:focusable="true"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/additional_button_icon" android:id="@+id/additional_button_icon"
android:layout_width="@dimen/favorites_icon_right_margin" android:layout_width="@dimen/favorites_icon_right_margin"
android:layout_height="@dimen/favorites_icon_right_margin" android:layout_height="@dimen/favorites_icon_right_margin"
android:layout_gravity="center"
android:layout_marginStart="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding" android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding"
@ -92,7 +90,7 @@
app:srcCompat="@drawable/ic_action_track_line_bold_color" app:srcCompat="@drawable/ic_action_track_line_bold_color"
tools:tint="?attr/active_color_basic" /> tools:tint="?attr/active_color_basic" />
</LinearLayout> </FrameLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding"
@ -17,7 +15,7 @@
layout="@layout/preference_button_with_icon" layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.25" android:layout_weight="0.1"
android:minWidth="@dimen/context_menu_top_right_button_min_width" android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" /> android:minHeight="@dimen/setting_list_item_large_height" />
@ -28,7 +26,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding_half" android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@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:minWidth="@dimen/button_triple_center_width"
android:minHeight="@dimen/setting_list_item_large_height" /> android:minHeight="@dimen/setting_list_item_large_height" />
@ -39,7 +37,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding_half" android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@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:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" /> android:minHeight="@dimen/setting_list_item_large_height" />

View file

@ -6,7 +6,6 @@ import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.format.DateUtils; import android.text.format.DateUtils;
@ -29,6 +28,7 @@ import androidx.cardview.widget.CardView;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -81,7 +81,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
private SelectedGpxFile selectedGpxFile; private SelectedGpxFile selectedGpxFile;
private View statusContainer; private View statusContainer;
private LinearLayout buttonAppearance; private LinearLayout showTrackContainer;
private AppCompatImageView trackAppearanceIcon; private AppCompatImageView trackAppearanceIcon;
private View buttonSave; private View buttonSave;
private GpxBlockStatisticsBuilder blockStatisticsBuilder; private GpxBlockStatisticsBuilder blockStatisticsBuilder;
@ -161,49 +161,15 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
blockStatisticsBuilder.setBlocksClickable(false); blockStatisticsBuilder.setBlocksClickable(false);
blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode); blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode);
LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); 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);
trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon);
updateTrackIcon(app, trackAppearanceIcon); createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon,
buttonAppearance.setOnClickListener(new View.OnClickListener() { ItemType.SHOW_TRACK.getTitleId(), TripRecordingActiveBottomSheet.this, new Runnable() {
@Override @Override
public void onClick(View v) { public void run() {
if (showTrackCompound.isChecked()) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
hide(); 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() { buttonClear.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
@Override @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) { private void createItem(View view, ItemType type, boolean enabled) {
createItem(app, nightMode, view, type, enabled, null); createItem(app, nightMode, view, type, enabled, null);
} }
@ -558,11 +567,11 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
context, normalColorId, getActiveTextColorId(nightMode) context, normalColorId, getActiveTextColorId(nightMode)
); );
DrawableCompat.setTintList(background, iconColorStateList);
if (view instanceof CardView) { if (view instanceof CardView) {
((CardView) view).setCardBackgroundColor(iconColorStateList); ((CardView) view).setCardBackgroundColor(iconColorStateList);
return; return;
} }
DrawableCompat.setTintList(background, iconColorStateList);
} else { } else {
UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode)));
} }

View file

@ -4,12 +4,10 @@ import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableString; import android.text.SpannableString;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.CompoundButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -22,7 +20,6 @@ import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.RangeSlider; import com.google.android.material.slider.RangeSlider;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; 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.backend.OsmandSettings;
import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; 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.UiUtilities.CompoundButtonType.GLOBAL;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; 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.UPDATE_TRACK_ICON;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem; 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.setShowOnMapBackground;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon;
@ -60,6 +57,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm
private CardView confirmContainer; private CardView confirmContainer;
private SwitchCompat confirmCompound; private SwitchCompat confirmCompound;
private TextView intervalValueView; private TextView intervalValueView;
private LinearLayout showTrackContainer;
private LinearLayout intervalContainer; private LinearLayout intervalContainer;
private RangeSlider intervalSlider; private RangeSlider intervalSlider;
@ -100,6 +98,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm
confirmContainer = itemView.findViewById(R.id.confirm_container); confirmContainer = itemView.findViewById(R.id.confirm_container);
confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button); confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button);
UiUtilities.setupCompoundButton(confirmCompound, nightMode, GLOBAL);
updateGlobalRemember(); updateGlobalRemember();
confirmContainer.setOnClickListener(new View.OnClickListener() { confirmContainer.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -111,42 +110,15 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm
} }
}); });
LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); 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);
trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon);
updateTrackIcon(app, trackAppearanceIcon); createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon,
buttonAppearance.setOnClickListener(new View.OnClickListener() { R.string.show_track_on_map, TripRecordingStartingBottomSheet.this, new Runnable() {
@Override @Override
public void onClick(View v) { public void run() {
MapActivity mapActivity = getMapActivity(); hide();
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);
}
});
updateUpDownBtn(); updateUpDownBtn();