Merge remote-tracking branch 'origin/master'
# Conflicts: # OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java
This commit is contained in:
commit
8b16be751d
6 changed files with 93 additions and 53 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>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/map_quick_action"
|
||||
android:src="@drawable/ic_action_plus"
|
||||
app:backgroundTint="@color/dashboard_blue"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -2471,5 +2471,10 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="quick_action_add_favorite">Add favorite</string>
|
||||
<string name="dialog_add_action_title">Add Action</string>
|
||||
<string name="dialog_add_action_subhead">Create item</string>
|
||||
<string name="quick_actions_delete">Delete Action</string>
|
||||
<string name="quick_actions_delete_text">Are you sure you want to delete \"%s\" Action?</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>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.quickaction;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -9,10 +10,13 @@ import android.support.design.widget.FloatingActionButton;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
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 +63,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 +89,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);
|
||||
|
@ -133,12 +137,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
String actionsJson = getMyApplication().getSettings().QUICK_ACTION_LIST.get();
|
||||
|
||||
return quickActionFactory.parseActiveActionsList(actionsJson);
|
||||
// List<QuickAction> result = new ArrayList<>();
|
||||
// for (int i = 0; i < 4; i++) {
|
||||
// result.addAll(quickActionFactory.produceTypeActionsList());
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
|
@ -150,6 +148,27 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
getMyApplication().getSettings().QUICK_ACTION_LIST.set(json);
|
||||
}
|
||||
|
||||
void createAndShowDeleteDialog(final int itemPosition, final String itemName) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getContext(), R.style.OsmandLightTheme));
|
||||
builder.setTitle(R.string.quick_actions_delete);
|
||||
builder.setMessage(getResources().getString(R.string.quick_actions_delete_text, itemName));
|
||||
builder.setIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_delete_dark));
|
||||
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
adapter.deleteItem(itemPosition);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.show();
|
||||
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.dashboard_blue));
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.dashboard_blue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionSelected(QuickAction action) {
|
||||
adapter.addItem(action);
|
||||
|
@ -180,8 +199,8 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
|
||||
int viewType = getItemViewType(position);
|
||||
QuickAction item = itemsList.get(position);
|
||||
int viewType = getItemViewType(position);
|
||||
final QuickAction item = itemsList.get(position);
|
||||
|
||||
if (viewType == SCREEN_ITEM_TYPE) {
|
||||
final QuickActionItemVH itemVH = (QuickActionItemVH) holder;
|
||||
|
@ -203,11 +222,10 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
itemVH.closeBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
QuickActionAdapter.this.deleteItem(holder.getAdapterPosition());
|
||||
createAndShowDeleteDialog(holder.getAdapterPosition(), getResources().getString(item.getNameRes()));
|
||||
}
|
||||
});
|
||||
|
||||
// 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 +272,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 +332,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 +348,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 +384,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