From a6df760d62144c0f7bb4c08ca40f9971f4bfd20e Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Thu, 14 Jun 2018 17:55:22 +0300 Subject: [PATCH] [android] Added bookmarks catalog UI and descriptions, removed multiple JNI calls, replaced them with BookmarkCategory model methods --- android/build.gradle | 1 + .../bookmarks/BaseBookmarkCategoriesFragment.java | 8 ++++++-- .../bookmarks/CachedBookmarkCategoriesFragment.java | 12 ++++++++++++ .../src/com/mapswithme/util/sharing/TargetUtils.java | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index f5b55e36d8..93b815a500 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -107,6 +107,7 @@ dependencies { exclude group: 'com.google.android.gms' } implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.ms-square:expandableTextView:0.1.4' } def getDate() { diff --git a/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java b/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java index 8abda6ebfa..b82525ab5e 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BaseBookmarkCategoriesFragment.java @@ -280,6 +280,11 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag .putExtra(BookmarksListFragment.EXTRA_CATEGORY, category); } + protected void onShareActionSelected(@NonNull BookmarkCategory category) + { + SharingHelper.INSTANCE.prepareBookmarkCategoryForSharing(getActivity(), category.getId()); + } + @Override public void onItemLongClick(View v, BookmarkCategory category) { @@ -394,8 +399,7 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag public void process(@NonNull BaseBookmarkCategoriesFragment frag, @NonNull BookmarkCategory category) { - SharingHelper.INSTANCE.prepareBookmarkCategoryForSharing(frag.getActivity(), - category.getId()); + frag.onShareActionSelected(category); } } diff --git a/android/src/com/mapswithme/maps/bookmarks/CachedBookmarkCategoriesFragment.java b/android/src/com/mapswithme/maps/bookmarks/CachedBookmarkCategoriesFragment.java index 8d4faa795b..f457c0a17c 100644 --- a/android/src/com/mapswithme/maps/bookmarks/CachedBookmarkCategoriesFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/CachedBookmarkCategoriesFragment.java @@ -12,6 +12,7 @@ import com.mapswithme.maps.R; import com.mapswithme.maps.bookmarks.data.BookmarkCategory; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.util.UiUtils; +import com.mapswithme.util.sharing.TargetUtils; public class CachedBookmarkCategoriesFragment extends BaseBookmarkCategoriesFragment implements BookmarkManager.BookmarksCatalogListener @@ -56,6 +57,17 @@ public class CachedBookmarkCategoriesFragment extends BaseBookmarkCategoriesFrag openBookmarksCatalogScreen(); } + @Override + protected void onShareActionSelected(@NonNull BookmarkCategory category) + { + String deepLink = BookmarkManager.INSTANCE.getCatalogDeeplink(category.getId()); + Intent intent = new Intent(Intent.ACTION_SEND) + .setType(TargetUtils.TYPE_TEXT_PLAIN) + .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)) + .putExtra(Intent.EXTRA_TEXT, deepLink); + startActivity(Intent.createChooser(intent, getString(R.string.share))); + } + @Override protected int getDeleteMenuItemResId() { diff --git a/android/src/com/mapswithme/util/sharing/TargetUtils.java b/android/src/com/mapswithme/util/sharing/TargetUtils.java index 55726e4501..7ae3b1ac97 100644 --- a/android/src/com/mapswithme/util/sharing/TargetUtils.java +++ b/android/src/com/mapswithme/util/sharing/TargetUtils.java @@ -3,10 +3,10 @@ package com.mapswithme.util.sharing; import android.content.Intent; import android.net.Uri; -final class TargetUtils +public final class TargetUtils { + public static final String TYPE_TEXT_PLAIN = "text/plain"; static final String TYPE_MESSAGE_RFC822 = "message/rfc822"; - static final String TYPE_TEXT_PLAIN = "text/plain"; static final String EXTRA_SMS_BODY = "sms_body"; static final String EXTRA_SMS_TEXT = Intent.EXTRA_TEXT; static final String URI_STRING_SMS = "sms:";