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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -11,8 +11,7 @@
|
|||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_height="12dp"/>
|
||||
|
||||
<include layout="@layout/card_top_divider"/>
|
||||
|
||||
|
@ -46,7 +45,8 @@
|
|||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -26,7 +26,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Some title text"/>
|
||||
android:text="@string/quick_favorites_show_favorites_dialog"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
|
@ -70,7 +70,7 @@
|
|||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_action_building_number"/>
|
||||
android:src="@drawable/ic_action_fav_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -89,11 +89,11 @@
|
|||
android:layout_marginRight="12dp"
|
||||
android:text="@string/favourites_edit_dialog_name"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name_edit"
|
||||
tools:text="Name"
|
||||
android:hint="@string/quick_favorites_name_preset"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
|
@ -104,6 +104,16 @@
|
|||
android:textColor="?android:textColorPrimary"
|
||||
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>
|
||||
|
||||
|
|
|
@ -2,21 +2,23 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:background="?attr/bg_color"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/searchListItemLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:clickable="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:minHeight="60dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/handle_view"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="4dp"
|
||||
android:focusable="false"
|
||||
|
@ -29,47 +31,46 @@
|
|||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
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
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:orientation="vertical">
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="16dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Add marker"/>
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="16dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Add marker"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Action 1"/>
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Action 1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/closeImageButton"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@drawable/ic_action_remove_dark"
|
||||
android:scaleType="centerInside"/>
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</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_subhead">Create item</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>
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.support.v7.widget.LinearLayoutManager;
|
|||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -59,7 +60,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
AddQuickActionDialog dialog = new AddQuickActionDialog();
|
||||
dialog.show(getFragmentManager(), AddQuickActionDialog.TAG);
|
||||
dialog.selectionListener = QuickActionListFragment.this;
|
||||
|
@ -86,6 +86,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
quickActionRV.setAdapter(adapter);
|
||||
quickActionRV.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
|
||||
ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter);
|
||||
touchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||
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();
|
||||
//noinspection ResourceType
|
||||
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);
|
||||
|
||||
if (itemsList.size() == 1){
|
||||
itemsList.remove(0);
|
||||
notifyItemRemoved(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void showFABIfNotScrollable() {
|
||||
|
@ -309,10 +314,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
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) {
|
||||
Resources r = getActivity().getResources();
|
||||
return (int) TypedValue.applyDimension(
|
||||
|
@ -329,6 +330,10 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
else {
|
||||
int selectedPosition = viewHolder.getAdapterPosition();
|
||||
int targetPosition = target.getAdapterPosition();
|
||||
Log.v(TAG, "selected: " + selectedPosition + ", target: " + targetPosition);
|
||||
|
||||
if (selectedPosition < 0 || targetPosition < 0)
|
||||
return false;
|
||||
|
||||
Collections.swap(itemsList, selectedPosition, targetPosition);
|
||||
if (selectedPosition - targetPosition < -1) {
|
||||
|
@ -361,6 +366,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
|
||||
public QuickActionItemVH(View itemView) {
|
||||
super(itemView);
|
||||
// AndroidUtils.setListItemBackground(itemView.getContext(), itemView, getMyApplication().getDaynightHelper().isNightMode());
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
subTitle = (TextView) itemView.findViewById(R.id.subtitle);
|
||||
icon = (ImageView) itemView.findViewById(R.id.imageView);
|
||||
|
|
Loading…
Reference in a new issue