fix min buttons width to 48dp;

fix letter spacing in text of buttons to 0.01;
fix padding below buttons to 16dp in "Clear recorded data" and "Track recording stop" dialogs;
add showing "Stop online tracking" button when needed;
fix changing track appearance icon after applying;
This commit is contained in:
Skalii 2021-02-17 19:21:27 +02:00
parent 9586caee38
commit b2834291b6
6 changed files with 62 additions and 18 deletions

View file

@ -12,6 +12,7 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="@dimen/content_padding_small" android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small" android:paddingLeft="@dimen/content_padding_small"
@ -34,7 +35,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:duplicateParentState="true" android:duplicateParentState="true"
android:letterSpacing="@dimen/description_letter_spacing" android:letterSpacing="@dimen/text_button_letter_spacing"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
tools:text="Title" tools:text="Title"
@ -45,7 +46,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:duplicateParentState="true" android:duplicateParentState="true"
android:letterSpacing="@dimen/description_letter_spacing" android:letterSpacing="@dimen/text_button_letter_spacing"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:visibility="gone" android:visibility="gone"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"

View file

@ -102,6 +102,19 @@
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding" /> android:layout_marginBottom="@dimen/content_padding" />
<include
android:id="@+id/button_online"
layout="@layout/bottom_sheet_button_with_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding_half"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding"
android:visibility="gone" />
<include <include
android:id="@+id/button_segment" android:id="@+id/button_segment"
layout="@layout/bottom_sheet_button_with_icon" layout="@layout/bottom_sheet_button_with_icon"

View file

@ -36,7 +36,7 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
app = requiredMyApplication(); app = requiredMyApplication();
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin); int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
int verticalSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small); int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding);
final View buttonClear = createItem(inflater, ItemType.CLEAR_DATA); final View buttonClear = createItem(inflater, ItemType.CLEAR_DATA);
final View buttonCancel = createItem(inflater, ItemType.CANCEL); final View buttonCancel = createItem(inflater, ItemType.CANCEL);
@ -74,7 +74,7 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
}) })
.create()); .create());
items.add(new DividerSpaceItem(app, verticalSmall)); items.add(new DividerSpaceItem(app, verticalNormal));
} }
private View createItem(LayoutInflater inflater, ItemType type) { private View createItem(LayoutInflater inflater, ItemType type) {

View file

@ -50,7 +50,7 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin); int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
int verticalSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small); int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding);
final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD);
final View buttonSave = createItem(inflater, ItemType.STOP_AND_SAVE); final View buttonSave = createItem(inflater, ItemType.STOP_AND_SAVE);
@ -99,7 +99,7 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
}) })
.create()); .create());
items.add(new DividerSpaceItem(app, verticalSmall)); items.add(new DividerSpaceItem(app, verticalNormal));
items.add(new BaseBottomSheetItem.Builder() items.add(new BaseBottomSheetItem.Builder()
.setCustomView(buttonCancel) .setCustomView(buttonCancel)
@ -112,7 +112,7 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
}) })
.create()); .create());
items.add(new DividerSpaceItem(app, verticalSmall)); items.add(new DividerSpaceItem(app, verticalNormal));
} }
private View createItem(LayoutInflater inflater, ItemType type) { private View createItem(LayoutInflater inflater, ItemType type) {

View file

@ -80,6 +80,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
private SelectedGpxFile selectedGpxFile; private SelectedGpxFile selectedGpxFile;
private View statusContainer; private View statusContainer;
private LinearLayout buttonAppearance;
private View buttonSave; private View buttonSave;
private GpxBlockStatisticsBuilder blockStatisticsBuilder; private GpxBlockStatisticsBuilder blockStatisticsBuilder;
@ -129,16 +130,20 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
.create()); .create());
View buttonClear = itemView.findViewById(R.id.button_clear); View buttonClear = itemView.findViewById(R.id.button_clear);
final View buttonOnline = itemView.findViewById(R.id.button_online);
View buttonSegment = itemView.findViewById(R.id.button_segment); View buttonSegment = itemView.findViewById(R.id.button_segment);
buttonSave = itemView.findViewById(R.id.button_save); buttonSave = itemView.findViewById(R.id.button_save);
final View buttonPause = itemView.findViewById(R.id.button_pause); final View buttonPause = itemView.findViewById(R.id.button_pause);
View buttonStop = itemView.findViewById(R.id.button_stop); View buttonStop = itemView.findViewById(R.id.button_stop);
createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave()); createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave());
createItem(buttonOnline, ItemType.STOP_ONLINE, hasDataToSave());
createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored()); createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored());
createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true); createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true);
createItem(buttonStop, ItemType.STOP, true); createItem(buttonStop, ItemType.STOP, true);
AndroidUiHelper.updateVisibility(buttonOnline, app.getLiveMonitoringHelper().isLiveMonitoringEnabled());
statusContainer = itemView.findViewById(R.id.status_container); statusContainer = itemView.findViewById(R.id.status_container);
updateStatus(); updateStatus();
@ -163,31 +168,29 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
if (showTitle != null) { if (showTitle != null) {
showTrackTitle.setText(showTitle); showTrackTitle.setText(showTitle);
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
buttonShow.setPaddingRelative(AndroidUtils.dpToPx(app, 12f), 0, buttonShow.getPaddingRight(), 0);
} else {
buttonShow.setPadding(AndroidUtils.dpToPx(app, 12f), 0, buttonShow.getPaddingRight(), 0);
}
showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode))); showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode)));
showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size)); showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size));
Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium)); Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium));
showTrackTitle.setTypeface(typeface); showTrackTitle.setTypeface(typeface);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float letterSpacing = AndroidUtils.getFloatValueFromRes(app, R.dimen.description_letter_spacing); float letterSpacing = AndroidUtils.getFloatValueFromRes(app, R.dimen.text_button_letter_spacing);
showTrackTitle.setLetterSpacing(letterSpacing); showTrackTitle.setLetterSpacing(letterSpacing);
} }
final SwitchCompat showTrackOnMapButton = buttonShow.findViewById(R.id.switch_button); final SwitchCompat showTrackOnMapButton = buttonShow.findViewById(R.id.switch_button);
showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT); UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT);
final LinearLayout buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); buttonAppearance = showTrackContainer.findViewById(R.id.additional_button);
View divider = buttonAppearance.getChildAt(0); View divider = buttonAppearance.getChildAt(0);
AndroidUiHelper.setVisibility(View.GONE, divider); AndroidUiHelper.setVisibility(View.GONE, divider);
int marginS = app.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_small); int marginS = app.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_small);
UiUtilities.setMargins(buttonAppearance, marginS, 0, 0, 0); UiUtilities.setMargins(buttonAppearance, marginS, 0, 0, 0);
String width = settings.CURRENT_TRACK_WIDTH.get(); updateTrackIcon(buttonAppearance);
boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get();
int color = settings.CURRENT_TRACK_COLOR.get();
Drawable appearanceDrawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color);
AppCompatImageView appearanceIcon = buttonAppearance.findViewById(R.id.icon_after_divider);
int marginTrackIconH = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0);
appearanceIcon.setImageDrawable(appearanceDrawable);
buttonAppearance.setOnClickListener(new View.OnClickListener() { buttonAppearance.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -226,6 +229,14 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
} }
}); });
buttonOnline.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
settings.LIVE_MONITORING.set(false);
AndroidUiHelper.updateVisibility(buttonOnline, false);
}
});
buttonSegment.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { buttonSegment.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -299,6 +310,17 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
} }
} }
private void updateTrackIcon(View buttonAppearance) {
String width = settings.CURRENT_TRACK_WIDTH.get();
boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get();
int color = settings.CURRENT_TRACK_COLOR.get();
Drawable appearanceDrawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color);
AppCompatImageView appearanceIcon = buttonAppearance.findViewById(R.id.icon_after_divider);
int marginTrackIconH = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0);
appearanceIcon.setImageDrawable(appearanceDrawable);
}
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);
} }
@ -474,6 +496,13 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
} }
} }
public void show(boolean updateTrackIcon) {
show();
if (updateTrackIcon && buttonAppearance != null) {
updateTrackIcon(buttonAppearance);
}
}
public void hide() { public void hide() {
Dialog dialog = getDialog(); Dialog dialog = getDialog();
if (dialog != null) { if (dialog != null) {
@ -495,6 +524,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
STOP(R.string.shared_string_control_stop, R.drawable.ic_action_rec_stop), 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_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_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); CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close);
@StringRes @StringRes

View file

@ -385,7 +385,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
if (target instanceof TripRecordingBottomSheet) { if (target instanceof TripRecordingBottomSheet) {
((TripRecordingBottomSheet) target).show(); ((TripRecordingBottomSheet) target).show();
} else if (target instanceof TripRecordingActiveBottomSheet) { } else if (target instanceof TripRecordingActiveBottomSheet) {
((TripRecordingActiveBottomSheet) target).show(); ((TripRecordingActiveBottomSheet) target).show(true);
} }
} }