diff options
author | Dmitry Donskoy <donskdmitry@mail.ru> | 2018-10-25 18:07:24 +0300 |
---|---|---|
committer | Aleksandr Zatsepin <alexzatsepin@users.noreply.github.com> | 2018-11-06 19:30:44 +0300 |
commit | b5ed2caf0685bd6a52faf1496279e14215879632 (patch) | |
tree | d0f293f0f22b6032d36bc0a903c7bb6594a02856 | |
parent | 4b6b4b4ebfd79be4e06beb343731fc2eb0b70625 (diff) |
[android] Added transition scheme for sharing options screen, supported my categories flag
22 files changed, 231 insertions, 74 deletions
diff --git a/android/res/drawable-hdpi/ic_add_members.png b/android/res/drawable-hdpi/ic_add_members.png Binary files differnew file mode 100755 index 0000000000..3ea68b3b44 --- /dev/null +++ b/android/res/drawable-hdpi/ic_add_members.png diff --git a/android/res/drawable-mdpi/ic_add_members.png b/android/res/drawable-mdpi/ic_add_members.png Binary files differnew file mode 100755 index 0000000000..a4270689d0 --- /dev/null +++ b/android/res/drawable-mdpi/ic_add_members.png diff --git a/android/res/drawable-xhdpi/ic_add_members.png b/android/res/drawable-xhdpi/ic_add_members.png Binary files differnew file mode 100755 index 0000000000..5d1fc41c19 --- /dev/null +++ b/android/res/drawable-xhdpi/ic_add_members.png diff --git a/android/res/drawable-xxhdpi/ic_add_members.png b/android/res/drawable-xxhdpi/ic_add_members.png Binary files differnew file mode 100755 index 0000000000..dffcaab1fc --- /dev/null +++ b/android/res/drawable-xxhdpi/ic_add_members.png diff --git a/android/res/drawable-xxxhdpi/ic_add_members.png b/android/res/drawable-xxxhdpi/ic_add_members.png Binary files differnew file mode 100755 index 0000000000..91f98de8c5 --- /dev/null +++ b/android/res/drawable-xxxhdpi/ic_add_members.png diff --git a/android/res/layout/item_bookmark_category.xml b/android/res/layout/item_bookmark_category.xml index 12edc32c73..98d559dfc0 100644 --- a/android/res/layout/item_bookmark_category.xml +++ b/android/res/layout/item_bookmark_category.xml @@ -29,35 +29,55 @@ android:singleLine="true" android:textAppearance="@style/MwmTextAppearance.Body1" tools:text="Bookmark name looooooooooooooooooongasdasdasd"/> - <TextView - android:id="@+id/size" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + <LinearLayout + android:id="@+id/bottom_line_container" + android:orientation="horizontal" android:layout_below="@id/name" android:layout_alignLeft="@id/name" android:layout_alignStart="@id/name" - android:layout_marginBottom="@dimen/margin_half_plus" - android:ellipsize="end" - android:singleLine="true" - android:textAppearance="@style/MwmTextAppearance.Body3" - tools:text="42000000"/> - - <TextView - android:id="@+id/author_name" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/name" - android:layout_toRightOf="@id/size" - android:layout_toEndOf="@id/size" - android:layout_marginBottom="@dimen/margin_half_plus" - android:layout_alignEnd="@id/name" - android:layout_alignRight="@id/name" android:layout_toStartOf="@id/more" android:layout_toLeftOf="@id/more" - android:ellipsize="end" - android:singleLine="true" - android:textAppearance="@style/MwmTextAppearance.Body3" - tools:text="42000000"/> + android:layout_marginBottom="@dimen/margin_half_plus" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <ImageView + android:id="@+id/access_rule_img" + android:layout_gravity="center_vertical" + android:tint="?iconTint" + android:layout_width="@dimen/margin_half_plus_eight" + android:layout_height="@dimen/margin_half_plus_eight"/> + <TextView + android:id="@+id/access_rule" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:ellipsize="end" + android:singleLine="true" + android:textAppearance="@style/MwmTextAppearance.Body3" + tools:text="42000000" + android:layout_marginLeft="@dimen/margin_half" + android:layout_marginStart="@dimen/margin_half"/> + <TextView + android:id="@+id/size" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:ellipsize="end" + android:singleLine="true" + android:textAppearance="@style/MwmTextAppearance.Body3" + tools:text="42000000"/> + + <TextView + android:id="@+id/author_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:ellipsize="end" + android:singleLine="true" + android:textAppearance="@style/MwmTextAppearance.Body3" + tools:text="42000000"/> + </LinearLayout> + <ImageView android:id="@id/more" android:layout_width="wrap_content" diff --git a/android/res/menu/menu_bookmark_categories.xml b/android/res/menu/menu_bookmark_categories.xml index d1b804d23b..baafcf88b7 100644 --- a/android/res/menu/menu_bookmark_categories.xml +++ b/android/res/menu/menu_bookmark_categories.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/set_show"/> <item android:id="@+id/set_share" @@ -9,8 +10,13 @@ <item android:id="@+id/set_edit" android:title="@string/rename" android:icon="@drawable/ic_edit"/> - + <item android:id="@+id/list_settings" + android:title="@string/list_settings" + android:icon="@drawable/ic_menu_settings"/> + <item android:id="@+id/sharing_options" + android:title="@string/sharing_options" + android:icon="@drawable/ic_menu_settings"/> <item android:id="@+id/set_delete" android:title="@string/delete" android:icon="@drawable/ic_delete"/> -</menu>
\ No newline at end of file +</menu> diff --git a/android/res/menu/option_menu_bookmarks.xml b/android/res/menu/option_menu_bookmarks.xml index 54d7077f1a..9272cbaf1b 100644 --- a/android/res/menu/option_menu_bookmarks.xml +++ b/android/res/menu/option_menu_bookmarks.xml @@ -2,8 +2,8 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/set_share" - android:icon="@drawable/ic_share_bookmark" + android:icon="@drawable/ic_add_members" android:title="@string/share" app:showAsAction="ifRoom"/> -</menu>
\ No newline at end of file +</menu> diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 14ec4c26d5..d3801c3220 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -1699,7 +1699,7 @@ public class MwmActivity extends BaseMwmFragmentActivity try { BookmarksDownloadManager.from(target).enqueueRequest(mUrl); - BookmarkCategoriesActivity.startForResult(target, BookmarksPageFactory.CATALOG.ordinal()); + BookmarkCategoriesActivity.startForResult(target, BookmarksPageFactory.DOWNLOADED.ordinal()); } catch (MalformedURLException e) { diff --git a/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java b/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java index 51cf99f073..b0fda2f2c2 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java @@ -20,6 +20,8 @@ import com.mapswithme.maps.bookmarks.data.BookmarkCategory; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.bookmarks.data.BookmarkSharingResult; import com.mapswithme.maps.dialog.EditTextDialogFragment; +import com.mapswithme.maps.ugc.routes.UgcRouteEditSettingsActivity; +import com.mapswithme.maps.ugc.routes.UgcRouteSharingOptionsActivity; import com.mapswithme.maps.widget.PlaceholderView; import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory; import com.mapswithme.util.BottomSheetHelper; @@ -312,6 +314,12 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag return new BookmarkManager.DefaultBookmarksCatalogListener(); } + @NonNull + protected BookmarkCategory getSelectedCategory() + { + return mSelectedCategory; + } + interface CategoryEditor { void commit(@NonNull String newName); @@ -340,9 +348,23 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag SET_EDIT(R.id.set_edit, editAction()), SHOW_ON_MAP(R.id.show_on_map, showAction()), SHARE_LIST(R.id.share_list, shareAction()), + SHARING_OPTIONS(R.id.sharing_options, showSharingOptions()), + LIST_SETTINGS(R.id.list_settings, showListSettings()), DELETE_LIST(R.id.delete_list, deleteAction()); @NonNull + private static MenuClickProcessorBase showSharingOptions() + { + return new MenuClickProcessorBase.OpenSharingOptions(); + } + + @NonNull + private static MenuClickProcessorBase showListSettings() + { + return new MenuClickProcessorBase.OpenListSettings(); + } + + @NonNull private static MenuClickProcessorBase.ShowAction showAction() { return new MenuClickProcessorBase.ShowAction(); @@ -414,6 +436,9 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag @NonNull BookmarkCategory category) { frag.onShareActionSelected(category); + Intent intent = new Intent(frag.getContext(), UgcRouteEditSettingsActivity.class); + intent.putExtra(UgcRouteEditSettingsActivity.EXTRA_BOOKMARK_CATEGORY, frag.mSelectedCategory); + frag.startActivity(intent); } } @@ -445,5 +470,25 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag frag); } } + + protected static class OpenSharingOptions extends MenuClickProcessorBase + { + @Override + public void process(@NonNull BaseBookmarkCategoriesFragment frag, + @NonNull BookmarkCategory category) + { + UgcRouteSharingOptionsActivity.start(frag.getContext(), category); + } + } + + protected static class OpenListSettings extends MenuClickProcessorBase + { + @Override + public void process(@NonNull BaseBookmarkCategoriesFragment frag, + @NonNull BookmarkCategory category) + { + + } + } } } diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesAdapter.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesAdapter.java index eaec6defa0..d3e470b3ec 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesAdapter.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesAdapter.java @@ -12,6 +12,7 @@ import com.mapswithme.maps.R; import com.mapswithme.maps.adapter.OnItemClickListener; import com.mapswithme.maps.bookmarks.data.BookmarkCategory; import com.mapswithme.maps.bookmarks.data.BookmarkManager; +import com.mapswithme.util.UiUtils; import static com.mapswithme.maps.bookmarks.Holders.CategoryViewHolder; import static com.mapswithme.maps.bookmarks.Holders.HeaderViewHolder; @@ -131,13 +132,27 @@ public class BookmarkCategoriesAdapter extends BaseBookmarkCategoryAdapter<Recyc categoryHolder.setName(category.getName()); bindSize(categoryHolder, category); bindAuthor(categoryHolder, category); + bindAccessRules(category, categoryHolder); categoryHolder.setVisibilityState(category.isVisible()); ToggleVisibilityClickListener listener = new ToggleVisibilityClickListener(categoryHolder); categoryHolder.setVisibilityListener(listener); - categoryHolder.setMoreListener(v -> { - if (mCategoryListCallback != null) - mCategoryListCallback.onMoreOperationClick(category); - }); + categoryHolder.setMoreListener(v -> onMoreOperationClicked(category)); + } + + private void bindAccessRules(@NonNull BookmarkCategory category, + @NonNull CategoryViewHolder categoryHolder) + { + BookmarkCategory.AccessRules rules = category.getAccessRules(); + categoryHolder.mAccessRuleImage.setImageResource(rules.getDrawableResId()); + String representation = categoryHolder.itemView.getResources().getString(rules.getNameResId()) + + UiUtils.PHRASE_SEPARATOR; + categoryHolder.mAccessRule.setText(representation); + } + + private void onMoreOperationClicked(BookmarkCategory category) + { + if (mCategoryListCallback != null) + mCategoryListCallback.onMoreOperationClick(category); } private void bindSize(@NonNull CategoryViewHolder categoryHolder, diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java index 970fecd4b2..be20298cbe 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java @@ -9,6 +9,7 @@ import com.cocosw.bottomsheet.BottomSheet; import com.mapswithme.maps.R; import com.mapswithme.maps.auth.Authorizer; import com.mapswithme.maps.auth.TargetFragmentCallback; +import com.mapswithme.maps.bookmarks.data.BookmarkCategory; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.widget.BookmarkBackupView; import com.mapswithme.util.UiUtils; @@ -70,5 +71,8 @@ public class BookmarkCategoriesFragment extends BaseBookmarkCategoriesFragment { boolean isMultipleItems = getAdapter().getBookmarkCategories().size() > 1; setEnableForMenuItem(R.id.set_delete, bottomSheet, isMultipleItems); + boolean isLocal = getSelectedCategory() + .getAccessRules() == BookmarkCategory.AccessRules.ACCESS_RULES_LOCAL; + setEnableForMenuItem(R.id.set_share, bottomSheet, isLocal); } } diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksListFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksListFragment.java index 34752df491..4eb71218ba 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksListFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksListFragment.java @@ -27,6 +27,7 @@ import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.bookmarks.data.BookmarkSharingResult; import com.mapswithme.maps.bookmarks.data.CategoryDataSource; import com.mapswithme.maps.bookmarks.data.Track; +import com.mapswithme.maps.ugc.routes.UgcRouteSharingOptionsActivity; import com.mapswithme.maps.widget.placepage.EditBookmarkFragment; import com.mapswithme.maps.widget.placepage.Sponsored; import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory; @@ -152,7 +153,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA BookmarkListAdapter adapter = getAdapter(); adapter.registerAdapterDataObserver(mCategoryDataSource); adapter.setOnClickListener(this); - adapter.setOnLongClickListener(isCatalogCategory() ? null : this); + adapter.setOnLongClickListener(isCategorySharingRestricted() ? null : this); } @Override @@ -200,7 +201,8 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA case BookmarkListAdapter.TYPE_BOOKMARK: final Bookmark bookmark = (Bookmark) adapter.getItem(mSelectedPosition); - int menuResId = isCatalogCategory() ? R.menu.menu_bookmarks_catalog : R.menu.menu_bookmarks; + int menuResId = isCategorySharingRestricted() ? R.menu.menu_bookmarks_catalog + : R.menu.menu_bookmarks; BottomSheet bs = BottomSheetHelper.create(getActivity(), bookmark.getTitle()) .sheet(menuResId) .listener(this) @@ -272,14 +274,16 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - if (isCatalogCategory()) + if (isCategorySharingRestricted()) return; inflater.inflate(R.menu.option_menu_bookmarks, menu); } - private boolean isCatalogCategory() + private boolean isCategorySharingRestricted() { - return mCategoryDataSource.getData().getType() == BookmarkCategory.Type.CATALOG; + BookmarkCategory category = mCategoryDataSource.getData(); + return category.getType() == BookmarkCategory.Type.DOWNLOADED + || category.getAccessRules() != BookmarkCategory.AccessRules.ACCESS_RULES_LOCAL; } @Override @@ -287,11 +291,15 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA { if (item.getItemId() == R.id.set_share) { - SharingHelper.INSTANCE.prepareBookmarkCategoryForSharing(getActivity(), - mCategoryDataSource.getData().getId()); + openSharingOptionsScreen(); return true; } return super.onOptionsItemSelected(item); } + + private void openSharingOptionsScreen() + { + UgcRouteSharingOptionsActivity.start(getContext(), getCategoryOrThrow()); + } } diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksPageFactory.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksPageFactory.java index 3b1daad627..52c74181e9 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksPageFactory.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksPageFactory.java @@ -10,7 +10,8 @@ import com.mapswithme.util.statistics.Statistics; public enum BookmarksPageFactory { - PRIVATE(new Analytics(Statistics.ParamValue.MY), true) + PRIVATE(new Analytics(Statistics.ParamValue.MY), + true) { @NonNull @Override @@ -22,10 +23,13 @@ public enum BookmarksPageFactory @Override public int getTitle() { - return R.string.bookmarks; + return R.string.bookmarks_page_my; } }, - CATALOG(new Analytics(Statistics.ParamValue.DOWNLOADED), new BookmarkCategoriesPageResProvider.Catalog(), false) + + DOWNLOADED(new Analytics(Statistics.ParamValue.DOWNLOADED), + new BookmarkCategoriesPageResProvider.Catalog(), + false) { @NonNull @Override @@ -37,7 +41,7 @@ public enum BookmarksPageFactory @Override public int getTitle() { - return R.string.guides; + return R.string.downloader_downloaded_subtitle; } }; diff --git a/android/src/com/mapswithme/maps/bookmarks/CatalogBookmarkCategoriesAdapter.java b/android/src/com/mapswithme/maps/bookmarks/CatalogBookmarkCategoriesAdapter.java index 8bafac5824..d3debac9b2 100644 --- a/android/src/com/mapswithme/maps/bookmarks/CatalogBookmarkCategoriesAdapter.java +++ b/android/src/com/mapswithme/maps/bookmarks/CatalogBookmarkCategoriesAdapter.java @@ -12,13 +12,13 @@ public class CatalogBookmarkCategoriesAdapter extends BookmarkCategoriesAdapter { CatalogBookmarkCategoriesAdapter(@NonNull Context context) { - super(context, BookmarkCategory.Type.CATALOG); + super(context, BookmarkCategory.Type.DOWNLOADED); } @Override @NonNull public List<BookmarkCategory> getBookmarkCategories() { - return BookmarkManager.INSTANCE.getCatalogCategoriesSnapshot().getItems(); + return BookmarkManager.INSTANCE.getDownloadedCategoriesSnapshot().getItems(); } } diff --git a/android/src/com/mapswithme/maps/bookmarks/Holders.java b/android/src/com/mapswithme/maps/bookmarks/Holders.java index 3b29fb30f2..159e458ed9 100644 --- a/android/src/com/mapswithme/maps/bookmarks/Holders.java +++ b/android/src/com/mapswithme/maps/bookmarks/Holders.java @@ -138,6 +138,10 @@ public class Holders View mMore; @NonNull TextView mAuthorName; + @NonNull + TextView mAccessRule; + @NonNull + ImageView mAccessRuleImage; @Nullable private BookmarkCategory mEntity; @@ -152,6 +156,8 @@ public class Holders mSize = root.findViewById(R.id.size); mMore = root.findViewById(R.id.more); mAuthorName = root.findViewById(R.id.author_name); + mAccessRule = root.findViewById(R.id.access_rule); + mAccessRuleImage = root.findViewById(R.id.access_rule_img); } void setVisibilityState(boolean visible) diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java index 5eb0d2c324..2c5a8a1e18 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.res.Resources; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.PluralsRes; @@ -46,7 +47,7 @@ public class BookmarkCategory implements Parcelable mDescription = description; mTracksCount = tracksCount; mBookmarksCount = bookmarksCount; - mTypeIndex = fromCatalog ? Type.CATALOG.ordinal() : Type.PRIVATE.ordinal(); + mTypeIndex = fromCatalog ? Type.DOWNLOADED.ordinal() : Type.PRIVATE.ordinal(); mIsMyCategory = isMyCategory; mIsVisible = isVisible; mAuthor = TextUtils.isEmpty(authorId) || TextUtils.isEmpty(authorName) @@ -111,7 +112,7 @@ public class BookmarkCategory implements Parcelable public boolean isFromCatalog() { - return Type.values()[mTypeIndex] == Type.CATALOG; + return Type.values()[mTypeIndex] == Type.DOWNLOADED; } public boolean isVisible() @@ -288,19 +289,19 @@ public class BookmarkCategory implements Parcelable return sb.toString(); } - public static class IsFromCatalog implements TypeConverter<BookmarkCategory, Boolean> + public static class Downloaded implements TypeConverter<BookmarkCategory, Boolean> { @Override public Boolean convert(@NonNull BookmarkCategory data) { - return data.isFromCatalog(); + return data.isFromCatalog() && !data.isMyCategory(); } } public enum Type { PRIVATE(BookmarksPageFactory.PRIVATE, FilterStrategy.PredicativeStrategy.makePrivateInstance()), - CATALOG(BookmarksPageFactory.CATALOG, FilterStrategy.PredicativeStrategy.makeCatalogInstance()); + DOWNLOADED(BookmarksPageFactory.DOWNLOADED, FilterStrategy.PredicativeStrategy.makeDownloadedInstance()); @NonNull private BookmarksPageFactory mFactory; @@ -380,35 +381,43 @@ public class BookmarkCategory implements Parcelable public enum AccessRules { - ACCESS_RULES_LOCAL(R.string.not_shared), - ACCESS_RULES_PUBLIC(R.string.public_access), - ACCESS_RULES_DIRECT_LINK(R.string.limited_access), - ACCESS_RULES_P2P(UiUtils.NO_ID) + ACCESS_RULES_LOCAL(R.string.not_shared, R.drawable.ic_globe), + ACCESS_RULES_PUBLIC(R.string.public_access, R.drawable.ic_globe), + ACCESS_RULES_DIRECT_LINK(R.string.limited_access, R.drawable.ic_globe), + ACCESS_RULES_P2P(UiUtils.NO_ID, R.drawable.ic_globe) { @Override - public int getResId() + public int getNameResId() { throw new IllegalStateException("Unsupported here"); } }, - ACCESS_RULES_PAID(UiUtils.NO_ID) + ACCESS_RULES_PAID(UiUtils.NO_ID, R.drawable.ic_globe) { @Override - public int getResId() + public int getNameResId() { throw new IllegalStateException("Unsupported here"); } }; private final int mResId; + private final int mDrawableResId; - AccessRules(int resId) + AccessRules(int resId, int drawableResId) { mResId = resId; + mDrawableResId = drawableResId; + } + + @DrawableRes + public int getDrawableResId() + { + return mDrawableResId; } @StringRes - public int getResId() + public int getNameResId() { return mResId; } diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 44c046fcf7..bf912e107a 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -461,10 +461,10 @@ public enum BookmarkManager } @NonNull - public AbstractCategoriesSnapshot.Default getCatalogCategoriesSnapshot() + public AbstractCategoriesSnapshot.Default getDownloadedCategoriesSnapshot() { BookmarkCategory[] items = nativeGetBookmarkCategories(); - return new AbstractCategoriesSnapshot.Default(items, new FilterStrategy.Catalog()); + return new AbstractCategoriesSnapshot.Default(items, new FilterStrategy.Downloaded()); } @NonNull @@ -500,7 +500,7 @@ public enum BookmarkManager public boolean areAllCatalogCategoriesVisible() { - return areAllCategoriesVisible(BookmarkCategory.Type.CATALOG); + return areAllCategoriesVisible(BookmarkCategory.Type.DOWNLOADED); } public boolean areAllOwnedCategoriesVisible() @@ -520,7 +520,7 @@ public enum BookmarkManager public boolean areAllCatalogCategoriesInvisible() { - return areAllCategoriesInvisible(BookmarkCategory.Type.CATALOG); + return areAllCategoriesInvisible(BookmarkCategory.Type.DOWNLOADED); } public boolean areAllOwnedCategoriesInvisible() diff --git a/android/src/com/mapswithme/maps/bookmarks/data/FilterStrategy.java b/android/src/com/mapswithme/maps/bookmarks/data/FilterStrategy.java index 515284f838..cd254717aa 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/FilterStrategy.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/FilterStrategy.java @@ -27,15 +27,15 @@ public interface FilterStrategy { public Private() { - super(new Predicate.Equals<>(new BookmarkCategory.IsFromCatalog(), false)); + super(new Predicate.Equals<>(new BookmarkCategory.Downloaded(), false)); } } - class Catalog extends PredicativeStrategy<Boolean> + class Downloaded extends PredicativeStrategy<Boolean> { - Catalog() + Downloaded() { - super(new Predicate.Equals<>(new BookmarkCategory.IsFromCatalog(), true)); + super(new Predicate.Equals<>(new BookmarkCategory.Downloaded(), true)); } } @@ -63,9 +63,9 @@ public interface FilterStrategy } @NonNull - public static FilterStrategy makeCatalogInstance() + public static FilterStrategy makeDownloadedInstance() { - return new Catalog(); + return new Downloaded(); } @NonNull diff --git a/android/src/com/mapswithme/maps/ugc/routes/BaseEditUgcRouteActivity.java b/android/src/com/mapswithme/maps/ugc/routes/BaseEditUgcRouteActivity.java new file mode 100644 index 0000000000..85df94546a --- /dev/null +++ b/android/src/com/mapswithme/maps/ugc/routes/BaseEditUgcRouteActivity.java @@ -0,0 +1,30 @@ +package com.mapswithme.maps.ugc.routes; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.mapswithme.maps.base.BaseMwmFragmentActivity; +import com.mapswithme.maps.base.DataObservable; +import com.mapswithme.maps.base.ObservableHost; + +public abstract class BaseEditUgcRouteActivity extends BaseMwmFragmentActivity implements ObservableHost<DataObservable> +{ + @SuppressWarnings("NullableProblems") + @NonNull + private DataObservable mObservable; + + @Override + protected void safeOnCreate(@Nullable Bundle savedInstanceState) + { + super.safeOnCreate(savedInstanceState); + mObservable = new DataObservable(); + } + + @NonNull + @Override + public DataObservable getObservable() + { + return mObservable; + } +} diff --git a/android/src/com/mapswithme/maps/ugc/routes/UgcRouteEditSettingsFragment.java b/android/src/com/mapswithme/maps/ugc/routes/UgcRouteEditSettingsFragment.java index 579e1d0e07..5c7b513f03 100644 --- a/android/src/com/mapswithme/maps/ugc/routes/UgcRouteEditSettingsFragment.java +++ b/android/src/com/mapswithme/maps/ugc/routes/UgcRouteEditSettingsFragment.java @@ -67,7 +67,7 @@ public class UgcRouteEditSettingsFragment extends BaseMwmToolbarFragment mEditCategoryNameView.setText(mCategory.getName()); mEditCategoryNameView.requestFocus(); mAccessRulesView = root.findViewById(R.id.sharing_options_desc); - mAccessRulesView.setText(mCategory.getAccessRules().getResId()); + mAccessRulesView.setText(mCategory.getAccessRules().getNameResId()); mEditDescView = root.findViewById(R.id.edit_description); mEditDescView.setText(mCategory.getDescription()); View clearNameBtn = root.findViewById(R.id.edit_text_clear_btn); @@ -81,7 +81,7 @@ public class UgcRouteEditSettingsFragment extends BaseMwmToolbarFragment { super.onActivityResult(requestCode, resultCode, data); mCategory = BookmarkManager.INSTANCE.getAllCategoriesSnapshot().refresh(mCategory); - mAccessRulesView.setText(mCategory.getAccessRules().getResId()); + mAccessRulesView.setText(mCategory.getAccessRules().getNameResId()); } private void onSharingOptionsClicked() @@ -126,11 +126,10 @@ public class UgcRouteEditSettingsFragment extends BaseMwmToolbarFragment String categoryName = mEditCategoryNameView.getEditableText().toString().trim(); if (!TextUtils.equals(categoryName, mCategory.getName())) - BookmarkManager.INSTANCE.setCategoryName(mCategory.getId(), categoryName); + BookmarkManager.INSTANCE.setCategoryName(mCategory.getId(), categoryName); String categoryDesc = mEditDescView.getEditableText().toString().trim(); if (!TextUtils.equals(mCategory.getDescription(), categoryDesc)) BookmarkManager.INSTANCE.setCategoryDescription(mCategory.getId(), categoryDesc); - } } diff --git a/android/src/com/mapswithme/maps/ugc/routes/UgcRouteSharingOptionsActivity.java b/android/src/com/mapswithme/maps/ugc/routes/UgcRouteSharingOptionsActivity.java index 735e2e9fc6..ab87eaa0bf 100644 --- a/android/src/com/mapswithme/maps/ugc/routes/UgcRouteSharingOptionsActivity.java +++ b/android/src/com/mapswithme/maps/ugc/routes/UgcRouteSharingOptionsActivity.java @@ -1,11 +1,15 @@ package com.mapswithme.maps.ugc.routes; +import android.content.Context; +import android.content.Intent; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmFragmentActivity; +import com.mapswithme.maps.bookmarks.data.BookmarkCategory; public class UgcRouteSharingOptionsActivity extends BaseMwmFragmentActivity { @@ -35,4 +39,11 @@ public class UgcRouteSharingOptionsActivity extends BaseMwmFragmentActivity { return R.layout.fragment_container_layout; } + + public static void start(@NonNull Context context, @NonNull BookmarkCategory category) + { + Intent intent = new Intent(context, UgcRouteSharingOptionsActivity.class) + .putExtra(UgcSharingOptionsFragment.EXTRA_BOOKMARK_CATEGORY, category); + context.startActivity(intent); + } } |