small fixes in quick list
This commit is contained in:
parent
8f6e25dda5
commit
e7cf2a78bc
5 changed files with 63 additions and 43 deletions
|
@ -3,7 +3,7 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="16dp"
|
android:layout_height="wrap_content"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -11,8 +11,7 @@
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="12dp"/>
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
<include layout="@layout/card_top_divider"/>
|
<include layout="@layout/card_top_divider"/>
|
||||||
|
|
||||||
|
@ -46,7 +45,8 @@
|
||||||
<View
|
<View
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="0dp"
|
||||||
|
android:visibility="gone"
|
||||||
android:background="?attr/dashboard_divider"/>
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -26,7 +26,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
tools:text="Some title text"/>
|
android:text="@string/quick_favorites_show_favorites_dialog"/>
|
||||||
|
|
||||||
<android.support.v7.widget.SwitchCompat
|
<android.support.v7.widget.SwitchCompat
|
||||||
android:id="@+id/toggle_item"
|
android:id="@+id/toggle_item"
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="2dp"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/ic_action_building_number"/>
|
android:src="@drawable/ic_action_fav_dark"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -89,11 +89,11 @@
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:text="@string/favourites_edit_dialog_name"
|
android:text="@string/favourites_edit_dialog_name"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="@dimen/default_list_text_size"/>
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/name_edit"
|
android:id="@+id/name_edit"
|
||||||
tools:text="Name"
|
android:hint="@string/quick_favorites_name_preset"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
|
@ -104,6 +104,16 @@
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textColorHint="?android:textColorSecondary"/>
|
android:textColorHint="?android:textColorSecondary"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:text="@string/quick_favorites_name_description"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,23 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:background="?attr/bg_color"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/searchListItemLayout"
|
android:id="@+id/searchListItemLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:selectableItemBackground"
|
||||||
android:minHeight="60dp"
|
android:minHeight="60dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/handle_view"
|
android:id="@+id/handle_view"
|
||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="56dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginRight="4dp"
|
android:layout_marginRight="4dp"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
@ -29,47 +31,46 @@
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:src="@drawable/ic_action_flag_dark"
|
android:scaleType="centerInside"
|
||||||
android:scaleType="centerInside"/>
|
android:src="@drawable/ic_action_flag_dark"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:orientation="vertical">
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:paddingTop="8dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="Add marker"/>
|
tools:text="Add marker"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/subtitle"
|
android:id="@+id/subtitle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="@dimen/default_sub_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
tools:text="Action 1"/>
|
tools:text="Action 1"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/closeImageButton"
|
android:id="@+id/closeImageButton"
|
||||||
android:layout_width="24dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="8dp"
|
android:background="?android:selectableItemBackground"
|
||||||
android:layout_marginRight="16dp"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/ic_action_remove_dark"
|
android:src="@drawable/ic_action_remove_dark"/>
|
||||||
android:scaleType="centerInside"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -2472,4 +2472,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
||||||
<string name="dialog_add_action_title">Add Action</string>
|
<string name="dialog_add_action_title">Add Action</string>
|
||||||
<string name="dialog_add_action_subhead">Create item</string>
|
<string name="dialog_add_action_subhead">Create item</string>
|
||||||
<string name="btn_dismiss">Dismiss</string>
|
<string name="btn_dismiss">Dismiss</string>
|
||||||
|
<string name="quick_favorites_show_favorites_dialog">Show favorites dialog</string>
|
||||||
|
<string name="quick_favorites_name_preset">Name preset</string>
|
||||||
|
<string name="quick_favorites_name_description">Leave field blank and OsmAnd will use the address or name of a place for the favorite point</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -59,7 +60,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
AddQuickActionDialog dialog = new AddQuickActionDialog();
|
AddQuickActionDialog dialog = new AddQuickActionDialog();
|
||||||
dialog.show(getFragmentManager(), AddQuickActionDialog.TAG);
|
dialog.show(getFragmentManager(), AddQuickActionDialog.TAG);
|
||||||
dialog.selectionListener = QuickActionListFragment.this;
|
dialog.selectionListener = QuickActionListFragment.this;
|
||||||
|
@ -86,6 +86,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
quickActionRV.setAdapter(adapter);
|
quickActionRV.setAdapter(adapter);
|
||||||
quickActionRV.setLayoutManager(new LinearLayoutManager(getContext()));
|
quickActionRV.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
|
||||||
ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter);
|
ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter);
|
||||||
touchHelper = new ItemTouchHelper(touchHelperCallback);
|
touchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||||
touchHelper.attachToRecyclerView(quickActionRV);
|
touchHelper.attachToRecyclerView(quickActionRV);
|
||||||
|
@ -207,7 +208,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
LinearLayout.LayoutParams dividerParams = (LinearLayout.LayoutParams) itemVH.divider.getLayoutParams();
|
LinearLayout.LayoutParams dividerParams = (LinearLayout.LayoutParams) itemVH.divider.getLayoutParams();
|
||||||
//noinspection ResourceType
|
//noinspection ResourceType
|
||||||
dividerParams.setMargins(!isLongDivider(position) ? dpToPx(56f) : 0, 0, 0, 0);
|
dividerParams.setMargins(!isLongDivider(position) ? dpToPx(56f) : 0, 0, 0, 0);
|
||||||
|
@ -254,6 +254,11 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyItemRangeChanged(position, itemsList.size() - position);
|
notifyItemRangeChanged(position, itemsList.size() - position);
|
||||||
|
|
||||||
|
if (itemsList.size() == 1){
|
||||||
|
itemsList.remove(0);
|
||||||
|
notifyItemRemoved(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFABIfNotScrollable() {
|
private void showFABIfNotScrollable() {
|
||||||
|
@ -309,10 +314,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
return getActionPosition(globalPosition) == ITEMS_IN_GROUP || globalPosition == getItemCount() - 1;
|
return getActionPosition(globalPosition) == ITEMS_IN_GROUP || globalPosition == getItemCount() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRecyclerScrollable(RecyclerView recyclerView) {
|
|
||||||
return recyclerView.computeHorizontalScrollRange() > recyclerView.getWidth() || recyclerView.computeVerticalScrollRange() > recyclerView.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int dpToPx(float dp) {
|
private int dpToPx(float dp) {
|
||||||
Resources r = getActivity().getResources();
|
Resources r = getActivity().getResources();
|
||||||
return (int) TypedValue.applyDimension(
|
return (int) TypedValue.applyDimension(
|
||||||
|
@ -329,6 +330,10 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
else {
|
else {
|
||||||
int selectedPosition = viewHolder.getAdapterPosition();
|
int selectedPosition = viewHolder.getAdapterPosition();
|
||||||
int targetPosition = target.getAdapterPosition();
|
int targetPosition = target.getAdapterPosition();
|
||||||
|
Log.v(TAG, "selected: " + selectedPosition + ", target: " + targetPosition);
|
||||||
|
|
||||||
|
if (selectedPosition < 0 || targetPosition < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
Collections.swap(itemsList, selectedPosition, targetPosition);
|
Collections.swap(itemsList, selectedPosition, targetPosition);
|
||||||
if (selectedPosition - targetPosition < -1) {
|
if (selectedPosition - targetPosition < -1) {
|
||||||
|
@ -361,6 +366,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
||||||
|
|
||||||
public QuickActionItemVH(View itemView) {
|
public QuickActionItemVH(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
// AndroidUtils.setListItemBackground(itemView.getContext(), itemView, getMyApplication().getDaynightHelper().isNightMode());
|
||||||
title = (TextView) itemView.findViewById(R.id.title);
|
title = (TextView) itemView.findViewById(R.id.title);
|
||||||
subTitle = (TextView) itemView.findViewById(R.id.subtitle);
|
subTitle = (TextView) itemView.findViewById(R.id.subtitle);
|
||||||
icon = (ImageView) itemView.findViewById(R.id.imageView);
|
icon = (ImageView) itemView.findViewById(R.id.imageView);
|
||||||
|
|
Loading…
Reference in a new issue