diff --git a/android/res/layout/fragment_ugc_routes_sharing_options.xml b/android/res/layout/fragment_ugc_routes_sharing_options.xml
index e763bec5a2..36f0a28bb5 100644
--- a/android/res/layout/fragment_ugc_routes_sharing_options.xml
+++ b/android/res/layout/fragment_ugc_routes_sharing_options.xml
@@ -132,48 +132,6 @@
android:layout_marginRight="@dimen/margin_base"
android:layout_marginEnd="@dimen/margin_base"/>
-
-
-
-
-
-
-
@@ -280,6 +238,44 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/android/src/com/mapswithme/maps/adapter/TagsAdapter.java b/android/src/com/mapswithme/maps/adapter/TagsAdapter.java
index e93ca98d66..d248249311 100644
--- a/android/src/com/mapswithme/maps/adapter/TagsAdapter.java
+++ b/android/src/com/mapswithme/maps/adapter/TagsAdapter.java
@@ -34,12 +34,17 @@ public class TagsAdapter extends RecyclerView.Adapter
@NonNull
private final List mTags;
+ @NonNull
+ private final TagsCompositeAdapter.SelectionPolicy mSelectionPolicy;
+
TagsAdapter(@NonNull OnItemClickListener listener, @NonNull SelectionState state,
- @NonNull List tags)
+ @NonNull List tags,
+ @NonNull TagsCompositeAdapter.SelectionPolicy selectionPolicy)
{
mListener = new ClickListenerWrapper(listener);
mState = state;
mTags = tags;
+ mSelectionPolicy = selectionPolicy;
setHasStableIds(true);
}
@@ -61,14 +66,24 @@ public class TagsAdapter extends RecyclerView.Adapter
public void onBindViewHolder(TagViewHolder holder, int position)
{
CatalogTag tag = mTags.get(position);
- holder.itemView.setSelected(mState.contains(tag));
+ boolean isTagSelected = mState.contains(tag);
+ holder.itemView.setSelected(isTagSelected);
holder.mTag = tag;
Context context = holder.itemView.getContext();
+ holder.mText.setText(tag.getLocalizedName());
+ boolean isEnabled = hasTagsFreeSpace() || isTagSelected;
+ holder.itemView.setEnabled(isEnabled);
StateListDrawable selector = TagsResFactory.makeSelector(context, tag.getColor());
holder.itemView.setBackgroundDrawable(selector);
ColorStateList color = TagsResFactory.makeColor(context, tag.getColor());
holder.mText.setTextColor(color);
- holder.mText.setText(tag.getLocalizedName());
+ holder.mText.setSelected(isTagSelected);
+ holder.mText.setEnabled(isEnabled);
+ }
+
+ private boolean hasTagsFreeSpace()
+ {
+ return mSelectionPolicy.isTagsSelectionAllowed();
}
@Override
diff --git a/android/src/com/mapswithme/maps/adapter/TagsCompositeAdapter.java b/android/src/com/mapswithme/maps/adapter/TagsCompositeAdapter.java
index 2e72cab0c0..81d3de6be6 100644
--- a/android/src/com/mapswithme/maps/adapter/TagsCompositeAdapter.java
+++ b/android/src/com/mapswithme/maps/adapter/TagsCompositeAdapter.java
@@ -34,11 +34,14 @@ public class TagsCompositeAdapter extends RecyclerView.Adapter groups,
@NonNull List savedState,
- @NonNull OnItemClickListener> clickListener)
+ @NonNull OnItemClickListener> clickListener,
+ int selectedTagsLimit)
{
mContext = context;
mCatalogTagsGroups = groups;
- mComponentHolders = makeRecyclerComponents(context, groups, savedState, clickListener);
+
+ mComponentHolders = makeRecyclerComponents(context, groups, savedState, clickListener,
+ selectedTagsLimit);
setHasStableIds(true);
}
@@ -46,16 +49,18 @@ public class TagsCompositeAdapter extends RecyclerView.Adapter makeRecyclerComponents(@NonNull Context context,
@NonNull List groups,
@NonNull List savedState,
- @NonNull OnItemClickListener> externalListener)
+ @NonNull OnItemClickListener> externalListener,
+ int selectedTagsLimit)
{
List result = new ArrayList<>();
-
+ SelectionPolicy selectionPolicy = () -> getSelectedTags().size() < selectedTagsLimit;
for (int i = 0; i < groups.size(); i++)
{
CatalogTagsGroup each = groups.get(i);
TagsAdapter.SelectionState state = TagsAdapter.SelectionState.from(savedState, each);
OnItemClickListener listener = new TagsListClickListener(externalListener, i);
- TagsAdapter adapter = new TagsAdapter(listener, state, each.getTags());
+
+ TagsAdapter adapter = new TagsAdapter(listener, state, each.getTags(), selectionPolicy);
Resources res = context.getResources();
Drawable divider = res.getDrawable(R.drawable.divider_transparent_base);
TagItemDecoration decor = new UgcRouteTagItemDecorator(divider);
@@ -129,6 +134,12 @@ public class TagsCompositeAdapter extends RecyclerView.Adapter>,
@@ -200,7 +201,7 @@ public class UgcRouteTagsFragment extends BaseMwmFragment implements BookmarkMan
showErrorLoadingDialog();
return;
}
- installTags(tagsGroups);
+ installTags(tagsGroups, 1);
}
@Override
@@ -210,11 +211,12 @@ public class UgcRouteTagsFragment extends BaseMwmFragment implements BookmarkMan
/* Not ready yet */
}
- private void installTags(@NonNull List tagsGroups)
+ private void installTags(@NonNull List tagsGroups, int tagsLimit)
{
List savedStateTags = validateSavedState(mSavedInstanceState);
TagGroupNameAdapter categoryAdapter = new TagGroupNameAdapter(tagsGroups);
- mTagsAdapter = new TagsCompositeAdapter(getContext(), tagsGroups, savedStateTags, this);
+ mTagsAdapter = new TagsCompositeAdapter(getContext(), tagsGroups, savedStateTags, this,
+ tagsLimit);
RecyclerCompositeAdapter compositeAdapter = makeCompositeAdapter(categoryAdapter, mTagsAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.VERTICAL,
@@ -262,9 +264,11 @@ public class UgcRouteTagsFragment extends BaseMwmFragment implements BookmarkMan
@NonNull Pair item)
{
ActivityCompat.invalidateOptionsMenu(getActivity());
- TagsAdapter adapter = item.first;
- int position = item.second.getAdapterPosition();
- adapter.notifyItemChanged(position);
+ Objects.requireNonNull(mTagsAdapter);
+ for (int i = 0; i < mTagsAdapter.getItemCount(); i++)
+ {
+ mTagsAdapter.getItem(i).notifyDataSetChanged();
+ }
}
@Override
diff --git a/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java b/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java
index c2d94d7f35..8a4c5ab94c 100644
--- a/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java
+++ b/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java
@@ -50,9 +50,11 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl
private static final int REQ_CODE_ERROR_BROKEN_FILE_DIALOG = 104;
private static final int REQ_CODE_ERROR_EDITED_ON_WEB_DIALOG = 105;
private static final int REQ_CODE_ERROR_COMMON = 106;
+ private static final int REQ_CODE_ERROR_NOT_ENOUGH_BOOKMARKS = 107;
private static final String BUNDLE_CURRENT_MODE = "current_mode";
private static final String UPLOADING_PROGRESS_DIALOG_TAG = "uploading_progress_dialog";
private static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog";
+ private static final String NOT_ENOUGH_BOOKMARKS_DIALOG_TAG = "not_enough_bookmarks_dialog";
private static final String ERROR_BROKEN_FILE_DIALOG_TAG = "error_broken_file_dialog";
private static final String ERROR_EDITED_ON_WEB_DIALOG_REQ_TAG = "error_edited_on_web_dialog";
private static final String ERROR_COMMON_DIALOG_TAG = "error_common_dialog";
@@ -143,7 +145,7 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl
{
boolean isPublished = mCategory.getAccessRules() == BookmarkCategory.AccessRules.ACCESS_RULES_PUBLIC;
UiUtils.hideIf(isPublished, mUploadAndPublishText, mGetDirectLinkContainer);
- UiUtils.showIf(isPublished, mPublishingCompletedStatusContainer, mEditOnWebBtn);
+ UiUtils.showIf(isPublished, mPublishingCompletedStatusContainer);
mPublishCategoryImage.setSelected(!isPublished);
boolean isLinkSuccessFormed = mCategory.getAccessRules() == BookmarkCategory.AccessRules.ACCESS_RULES_DIRECT_LINK;
@@ -447,9 +449,9 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl
private void showCommonErrorDialog()
{
- showErrorDialog(R.string.upload_error_toast,
- REQ_CODE_ERROR_COMMON,
- ERROR_COMMON_DIALOG_TAG);
+ showUploadErrorDialog(R.string.upload_error_toast,
+ REQ_CODE_ERROR_COMMON,
+ ERROR_COMMON_DIALOG_TAG);
}
private void onUploadSuccess()
@@ -477,23 +479,36 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl
private void showErrorEditedOnWebDialog()
{
- showErrorDialog(R.string.unable_upload_error_subtitle_edited,
- REQ_CODE_ERROR_EDITED_ON_WEB_DIALOG,
- ERROR_EDITED_ON_WEB_DIALOG_REQ_TAG);
+ showUploadErrorDialog(R.string.unable_upload_error_subtitle_edited,
+ REQ_CODE_ERROR_EDITED_ON_WEB_DIALOG,
+ ERROR_EDITED_ON_WEB_DIALOG_REQ_TAG);
}
private void showErrorBrokenFileDialog()
{
- showErrorDialog(R.string.unable_upload_error_subtitle_broken,
- REQ_CODE_ERROR_BROKEN_FILE_DIALOG,
- ERROR_BROKEN_FILE_DIALOG_TAG);
+ showUploadErrorDialog(R.string.unable_upload_error_subtitle_broken,
+ REQ_CODE_ERROR_BROKEN_FILE_DIALOG,
+ ERROR_BROKEN_FILE_DIALOG_TAG);
}
- private void showErrorDialog(@StringRes int subtitle, int reqCode, @NonNull String tag)
+ private void showUploadErrorDialog(@StringRes int subtitle, int reqCode, @NonNull String tag)
+ {
+ showErrorDialog(R.string.unable_upload_errorr_title, subtitle, reqCode, tag);
+ }
+
+ private void showNotEnoughBookmarksDialog()
+ {
+ /* FIXME */
+ showErrorDialog(R.string.not_enough_memory, R.string.not_enough_memory,
+ REQ_CODE_ERROR_NOT_ENOUGH_BOOKMARKS, NOT_ENOUGH_BOOKMARKS_DIALOG_TAG);
+ }
+
+ private void showErrorDialog(@StringRes int title, @StringRes int subtitle, int reqCode,
+ @NonNull String tag)
{
AlertDialog dialog = new AlertDialog.Builder()
- .setTitleId(R.string.unable_upload_errorr_title)
+ .setTitleId(title)
.setMessageId(subtitle)
.setPositiveBtnId(R.string.ok)
.setReqCode(reqCode)