Quick Action UI fixes

This commit is contained in:
Nazar-Kutz 2020-06-09 10:20:39 +03:00
parent e1183a12d8
commit 720c12645b
10 changed files with 80 additions and 47 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<net.osmand.plus.widgets.TextViewEx 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:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:paddingBottom="@dimen/gpx_small_text_margin"
android:textAppearance="@style/TextAppearance.ListItemTitle"
app:typeface="@string/font_roboto_regular"
tools:text="@string/auto_zoom_map_descr" />

View file

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar_switch_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:orientation="vertical">
android:background="?attr/list_background_color">
<LinearLayout
android:id="@+id/selectable_item"
@ -47,4 +46,7 @@
</LinearLayout>
</LinearLayout>
<include layout="@layout/card_bottom_divider"
android:id="@+id/top_shadow_inner" />
</FrameLayout>

View file

@ -19,16 +19,18 @@
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:scaleType="centerInside"
android:tint="?attr/default_icon_color"
osmand:srcCompat="@drawable/ic_action_flag"
android:layout_marginEnd="@dimen/content_padding" />
osmand:srcCompat="@drawable/ic_action_flag" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular"

View file

@ -46,7 +46,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:background="?attr/bottom_bar_background_color"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:orientation="horizontal">
@ -74,15 +74,15 @@
android:id="@+id/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/content_padding_half"
android:layout_gravity="center_vertical|end">
android:layout_gravity="center_vertical|end"
android:layout_margin="@dimen/content_padding_half">
<FrameLayout
android:id="@+id/button_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/content_padding_half"
android:background="?attr/selectableItemBackground">
android:background="?attr/selectableItemBackground"
android:padding="@dimen/content_padding_half">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_text"

View file

@ -17,23 +17,30 @@
android:orientation="horizontal">
<FrameLayout
android:id="@+id/action_button"
android:layout_width="@dimen/acceptable_touch_radius"
android:layout_height="@dimen/acceptable_touch_radius"
android:layout_gravity="center">
android:layout_marginLeft="@dimen/dashCardMargin"
android:layout_marginRight="@dimen/dashCardMargin"
android:layout_gravity="center"
android:padding="@dimen/content_padding_small">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/action_icon"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:clickable="false"
android:focusable="false"
android:duplicateParentState="true"
tools:src="@drawable/ic_action_remove"
tools:tint="@color/icon_color_default_light" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:tint="@color/icon_color_default_light" />
@ -103,17 +110,18 @@
<FrameLayout
android:id="@+id/move_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/acceptable_touch_radius"
android:layout_height="@dimen/acceptable_touch_radius"
android:layout_marginLeft="@dimen/dashCardMargin"
android:layout_marginRight="@dimen/dashCardMargin"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:padding="@dimen/content_padding_small">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/move_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:tint="?attr/secondary_icon_color"
osmand:srcCompat="@drawable/ic_action_item_move" />

View file

@ -106,6 +106,8 @@
<attr name="purchase_dialog_shadow_btn_bg" format="reference"/>
<attr name="purchase_dialog_outline_btn_bg" format="reference"/>
<attr name="bottom_bar_background_color" format="color" />
<attr name="bottom_nav_shadow" format="reference"/>
<attr name="purchase_dialog_active_card_bg" format="reference"/>

View file

@ -417,6 +417,9 @@
<color name="text_field_box_dark">#3F474B</color>
<color name="text_field_box_light">#eeeeee</color>
<color name="bottom_bar_background_color_dark">#252727</color>
<color name="bottom_bar_background_color_light">#FFFFFF</color>
<color name="preference_category_title">#7E33FF</color>
<color name="preference_top_switch_off">#808080</color>

View file

@ -121,6 +121,7 @@
<!-- Osmand themes styles -->
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
<item name="bottom_bar_background_color">@color/bottom_bar_background_color_light</item>
<item name="android:textDirection">locale</item>
<item name="android:statusBarColor">@color/status_bar_color_light</item>
<item name="mapBackground">@color/map_background_color_light</item>
@ -411,6 +412,7 @@
</style>
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
<item name="bottom_bar_background_color">@color/bottom_bar_background_color_dark</item>
<item name="android:textDirection">locale</item>
<item name="android:statusBarColor">@color/status_bar_color_dark</item>
<item name="mapBackground">@color/map_background_color_dark</item>

View file

@ -54,7 +54,7 @@ public class ConfirmationBottomSheet extends MenuBottomSheetDialogFragment {
items.add(new TitleItem(title));
items.add(new BottomSheetItemWithDescription.Builder()
.setDescription(message)
.setLayoutId(R.layout.bottom_sheet_item_preference_descr)
.setLayoutId(R.layout.bottom_sheet_item_primary_descr)
.create());
}

View file

@ -175,12 +175,13 @@ public class QuickActionListFragment extends BaseOsmAndFragment
rv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (screenType == SCREEN_TYPE_REORDER) {
if (dy > 0 && fab.getVisibility() == View.VISIBLE)
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
fab.hide();
else if (dy < 0 && fab.getVisibility() != View.VISIBLE)
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
fab.show();
}
}
}
});
@ -505,11 +506,11 @@ public class QuickActionListFragment extends BaseOsmAndFragment
final QuickAction action = (QuickAction) item.value;
if (screenType == SCREEN_TYPE_REORDER) {
h.handleView.setVisibility(View.VISIBLE);
h.deleteBtn.setVisibility(View.VISIBLE);
h.moveButton.setVisibility(View.VISIBLE);
h.deleteIcon.setVisibility(View.VISIBLE);
h.checkbox.setVisibility(View.GONE);
h.handleView.setOnTouchListener(new View.OnTouchListener() {
h.moveButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) ==
@ -530,6 +531,8 @@ public class QuickActionListFragment extends BaseOsmAndFragment
}
});
h.deleteBtn.setClickable(true);
h.deleteBtn.setFocusable(true);
h.itemContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -543,12 +546,14 @@ public class QuickActionListFragment extends BaseOsmAndFragment
});
} else if (screenType == SCREEN_TYPE_DELETE) {
h.handleView.setVisibility(View.GONE);
h.deleteBtn.setVisibility(View.GONE);
h.moveButton.setVisibility(View.GONE);
h.deleteIcon.setVisibility(View.GONE);
h.checkbox.setVisibility(View.VISIBLE);
h.checkbox.setClickable(false);
h.deleteBtn.setClickable(false);
h.deleteBtn.setFocusable(false);
h.itemContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -655,22 +660,9 @@ public class QuickActionListFragment extends BaseOsmAndFragment
}
saveQuickActions();
updateListItems();
showFABIfNotScrollable();
}
}
private void showFABIfNotScrollable() {
LinearLayoutManager layoutManager = (LinearLayoutManager) rv.getLayoutManager();
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
if (screenType == SCREEN_TYPE_REORDER &&
(lastVisibleItemPosition == items.size() - 1
|| lastVisibleItemPosition == items.size()) &&
layoutManager.findFirstVisibleItemPosition() == 0 &&
fab.getVisibility() != View.VISIBLE ||
items.size() == 0)
fab.show();
}
public List<QuickAction> getQuickActions() {
List<QuickAction> result = new ArrayList<>();
for (ListItem item : items) {
@ -717,8 +709,10 @@ public class QuickActionListFragment extends BaseOsmAndFragment
public ImageView icon;
public View itemDivider;
public View longDivider;
public ImageView handleView;
public ImageView deleteBtn;
public View moveButton;
public ImageView moveIcon;
public View deleteBtn;
public ImageView deleteIcon;
public CompoundButton checkbox;
public View itemContainer;
@ -730,14 +724,16 @@ public class QuickActionListFragment extends BaseOsmAndFragment
icon = (ImageView) itemView.findViewById(R.id.imageView);
itemDivider = itemView.findViewById(R.id.item_divider);
longDivider = itemView.findViewById(R.id.long_divider);
deleteBtn = (ImageView) itemView.findViewById(R.id.action_icon);
handleView = (ImageView) itemView.findViewById(R.id.move_icon);
deleteBtn = itemView.findViewById(R.id.action_button);
deleteIcon = (ImageView) itemView.findViewById(R.id.action_icon);
moveButton = itemView.findViewById(R.id.move_button);
moveIcon = (ImageView) itemView.findViewById(R.id.move_icon);
checkbox = (CompoundButton) itemView.findViewById(R.id.checkbox);
itemContainer = itemView.findViewById(R.id.searchListItemLayout);
deleteBtn.setImageDrawable(app.getUIUtilities()
.getIcon(R.drawable.ic_action_remove, R.color.color_osm_edit_delete));
handleView.setImageDrawable(app.getUIUtilities()
deleteIcon.setImageDrawable(app.getUIUtilities()
.getIcon(R.drawable.ic_action_delete_item, R.color.color_osm_edit_delete));
moveIcon.setImageDrawable(app.getUIUtilities()
.getThemedIcon(R.drawable.ic_action_item_move));
UiUtilities.setupCompoundButton(checkbox, nightMode,
UiUtilities.CompoundButtonType.GLOBAL);