diff --git a/android/build.gradle b/android/build.gradle index 93b815a500..f5b55e36d8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -107,7 +107,6 @@ 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/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp index 34fdf47162..691237ae5b 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp @@ -685,7 +685,6 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetBookmarkCategor auto const bookmarksCount = manager.GetUserMarkIds(data.m_id).size(); auto const isVisible = manager.IsVisible(data.m_id); - return env->NewObject(g_bookmarkCategoryClass, g_bookmarkCategoryConstructor, static_cast(data.m_id), diff --git a/android/res/layout/fragment_bookmark_list.xml b/android/res/layout/fragment_bookmark_list.xml index 8a91a8defc..609fb154f5 100644 --- a/android/res/layout/fragment_bookmark_list.xml +++ b/android/res/layout/fragment_bookmark_list.xml @@ -1,6 +1,28 @@ - + android:layout_height="match_parent" + xmlns:mapsme="http://schemas.android.com/apk/res-auto"> + + + + + diff --git a/android/res/layout/item_category_description.xml b/android/res/layout/item_category_description.xml index 6d60935f00..f4f1378dff 100644 --- a/android/res/layout/item_category_description.xml +++ b/android/res/layout/item_category_description.xml @@ -17,30 +17,26 @@ android:textAppearance="@style/MwmTextAppearance.Body3" android:layout_width="match_parent" android:layout_height="wrap_content"/> - - + android:layout_height="wrap_content"> - + diff --git a/android/res/layout/item_category_title.xml b/android/res/layout/item_category_title.xml index 3935c20c90..8f4873302f 100644 --- a/android/res/layout/item_category_title.xml +++ b/android/res/layout/item_category_title.xml @@ -1,15 +1,14 @@ + android:fontFamily="@string/robotoMedium" + android:text="@string/bookmarks" + tools:targetApi="jelly_bean"/> diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index d33d683d35..957fef8e14 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -1398,4 +1398,5 @@ Got it This list is empty To add a bookmark, tap a place on the map and then tap the star icon + …more diff --git a/android/settings.gradle b/android/settings.gradle index 1908e4c7a3..3fdbaafdd9 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1 +1 @@ -include '3rd_party:BottomSheet' \ No newline at end of file +include '3rd_party:BottomSheet' diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java index 10218daf7e..9c406104c3 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java @@ -153,7 +153,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter= Build.VERSION_CODES.HONEYCOMB; - } - - private static boolean isPostLolipop() { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - private static void applyAlphaAnimation(View view, float alpha) { - if (isPostHoneycomb()) { - view.setAlpha(alpha); - } else { - AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha); - // make it instant - alphaAnimation.setDuration(0); - alphaAnimation.setFillAfter(true); - view.startAnimation(alphaAnimation); - } - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static Drawable getDrawable(@NonNull Context context, @DrawableRes int resId) { - Resources resources = context.getResources(); - if (isPostLolipop()) { - return resources.getDrawable(resId, context.getTheme()); - } else { - return resources.getDrawable(resId); - } - } - - private static int getRealTextViewHeight(@NonNull TextView textView) { - int textHeight = textView.getLayout().getLineTop(textView.getLineCount()); - int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom(); - return textHeight + padding; - } - - class ExpandCollapseAnimation extends Animation { - private final View mTargetView; - private final int mStartHeight; - private final int mEndHeight; - - public ExpandCollapseAnimation(View view, int startHeight, int endHeight) { - mTargetView = view; - mStartHeight = startHeight; - mEndHeight = endHeight; - setDuration(mAnimationDuration); - } - - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - final int newHeight = (int)((mEndHeight - mStartHeight) * interpolatedTime + mStartHeight); - mTv.setMaxHeight(newHeight - mMarginBetweenTxtAndBottom); - if (Float.compare(mAnimAlphaStart, 1.0f) != 0) { - applyAlphaAnimation(mTv, mAnimAlphaStart + interpolatedTime * (1.0f - mAnimAlphaStart)); - } - mTargetView.getLayoutParams().height = newHeight; - mTargetView.requestLayout(); - } - - @Override - public void initialize( int width, int height, int parentWidth, int parentHeight ) { - super.initialize(width, height, parentWidth, parentHeight); - } - - @Override - public boolean willChangeBounds( ) { - return true; - } - }; - - public interface OnExpandStateChangeListener { - /** - * Called when the expand/collapse animation has been finished - * - * @param textView - TextView being expanded/collapsed - * @param isExpanded - true if the TextView has been expanded - */ - void onExpandStateChanged(TextView textView, boolean isExpanded); - } -} diff --git a/android/src/com/mapswithme/maps/bookmarks/Holders.java b/android/src/com/mapswithme/maps/bookmarks/Holders.java index 606fc494a4..b6edb1089f 100644 --- a/android/src/com/mapswithme/maps/bookmarks/Holders.java +++ b/android/src/com/mapswithme/maps/bookmarks/Holders.java @@ -8,6 +8,8 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.PluralsRes; import android.support.v7.widget.RecyclerView; +import android.text.Layout; +import android.text.StaticLayout; import android.text.TextUtils; import android.view.View; import android.widget.CheckBox; @@ -268,9 +270,8 @@ public class Holders return -1; int beforeCurrentSectionItemsCount = getTracksSectionPosition(category); - return (beforeCurrentSectionItemsCount == -1 - ? getDescItemCount(category) - : beforeCurrentSectionItemsCount) + return (beforeCurrentSectionItemsCount == -1 ? getDescItemCount(category) + : beforeCurrentSectionItemsCount) + getTrackItemCount(category); } @@ -370,9 +371,9 @@ public class Holders @NonNull private final TextView mDistance; - TrackViewHolder(@NonNull View itemView, BookmarkCategory categoryId) + TrackViewHolder(@NonNull View itemView, @NonNull BookmarkCategory category) { - super(itemView, categoryId); + super(itemView, category); mIcon = itemView.findViewById(R.id.iv__bookmark_color); mName = itemView.findViewById(R.id.tv__bookmark_name); mDistance = itemView.findViewById(R.id.tv__bookmark_distance); @@ -401,9 +402,9 @@ public class Holders @NonNull private final TextView mView; - SectionViewHolder(@NonNull TextView itemView, BookmarkCategory categoryId) + SectionViewHolder(@NonNull TextView itemView, @NonNull BookmarkCategory category) { - super(itemView, categoryId); + super(itemView, category); mView = itemView; } @@ -412,7 +413,6 @@ public class Holders { final int sectionIndex = getSectionForPosition(mCategory, position); mView.setText(getSections().get(sectionIndex)); - mView.setText(getSections().get(sectionIndex)); } private List getSections() @@ -427,34 +427,56 @@ public class Holders static class DescriptionViewHolder extends BaseBookmarkHolder { - @NonNull - private final ExpandableTextView mContentView; + static final float SPACING_MULTIPLE = 1.0f; + static final float SPACING_ADD = 0.0f; @NonNull private final TextView mTitle; @NonNull private final TextView mAuthor; + @NonNull + private final TextView mDescText; + @NonNull + private final View mMoreBtn; DescriptionViewHolder(@NonNull View itemView, @NonNull BookmarkCategory category) { super(itemView, category); - mContentView = itemView.findViewById(R.id.description); - mContentView.setOnButtonClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - mContentView.setText(category.getDescription()); - } - }); + mDescText = itemView.findViewById(R.id.text); + mMoreBtn = itemView.findViewById(R.id.more_btn); + mMoreBtn.setOnClickListener(this::onMoreBtnClicked); mTitle = itemView.findViewById(R.id.title); mAuthor = itemView.findViewById(R.id.author); } + private void onMoreBtnClicked(View v) + { + int lineCount = calcLineCount(mDescText, mCategory.getDescription()); + mDescText.setLines(lineCount); + mDescText.setText(mCategory.getDescription()); + v.setVisibility(View.GONE); + } + @Override void bind(int position) { mTitle.setText(mCategory.getName()); - mContentView.setText(mCategory.getAnnotation()); + bindAuthor(); + bindDescriptionIfEmpty(); + } + + private void bindDescriptionIfEmpty() + { + if (TextUtils.isEmpty(mDescText.getText())) + { + String desc = TextUtils.isEmpty(mCategory.getAnnotation()) + ? mCategory.getDescription() + : mCategory.getAnnotation(); + mDescText.setText(desc); + } + } + + private void bindAuthor() + { BookmarkCategory.Author author = mCategory.getAuthor(); Context c = itemView.getContext(); CharSequence authorName = author == null @@ -462,5 +484,18 @@ public class Holders : BookmarkCategory.Author.getRepresentation(c, author); mAuthor.setText(authorName); } + + private static int calcLineCount(@NonNull TextView textView, @NonNull String src) + { + StaticLayout staticLayout = new StaticLayout(src, + textView.getPaint(), + textView.getWidth(), + Layout.Alignment.ALIGN_NORMAL, + SPACING_MULTIPLE, + SPACING_ADD, + true); + + return staticLayout.getLineCount(); + } } } diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java index 809aaa16f4..d6eb7d57d9 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkCategory.java @@ -15,92 +15,6 @@ import com.mapswithme.util.TypeConverter; public class BookmarkCategory implements Parcelable { - public static final String DESCRIPTION = "\n" + - "Владимир Семёнович Высоцкий\n" + - "Vladimir Vysotsky.jpg\n" + - "Владимир Высоцкий на концерте 23 апреля 1979 года. Фото Игоря Пальмина\n" + - "Дата рождения:\t25 января 1938\n" + - "Место рождения:\tМосква, СССР\n" + - "Дата смерти:\t25 июля 1980 (42 года)\n" + - "Место смерти:\tМосква, СССР\n" + - "Страна:\t\n" + - "Flag of the Soviet Union (1955–1980).svg СССР\n" + - "Род деятельности:\t\n" + - "поэт, поэт-песенник, автор-исполнитель, прозаик, актёр театра и кино, певец, " + - "композитор, гитарист\n" + - "Место работы:\t\n" + - "Московский драматический театр имени А. С. Пушкина\n" + - "Театр на Таганке\n" + - "Высшее образование:\t\n" + - "Школа-студия МХАТ\n" + - "Награды и премии:\tГосударственная премия СССР — 1987 Premia mvd.jpg[1][2]\n" + - "Подпись:\tПодпись\n" + - "Отец:\tСемён Владимирович Высоцкий\n" + - "Мать:\tНина Максимовна Высоцкая\n" + - "Супруг(а):\t\n" + - "• Изольда Жукова (Мешкова)[⇨], \n" + - "• Людмила Абрамова[⇨], \n" + - "• Марина Влади[⇨]\n" + - "Дети:\tАркадий Высоцкий, Никита Высоцкий[⇨]\n" + - "Похоронен\t\n" + - "Ваганьковское кладбище\n" + - "IMDb:\tID 0904584\n" + - "Логотип Викицитатника Цитаты в Викицитатнике\n" + - "Commons-logo.svg Владимир Семёнович Высоцкий на Викискладе\n" + - "Влади́мир Семёнович Высо́цкий (25 января 1938, Москва — 25 июля 1980, Москва)" + - " — советский поэт, актёр театра и кино, автор-исполнитель песен (бард); автор" + - " прозаических произведений и сценариев. Лауреат Государственной премии СССР " + - "(«за создание образа Жеглова в телевизионном художественном фильме „Место " + - "встречи изменить нельзя“ и авторское исполнение песен», 1987, посмертно).\n" + - "\n" + - "Как поэт Высоцкий реализовал себя прежде всего в жанре авторской песни. " + - "Первые из написанных им произведений относятся к началу 1960-х годов. " + - "Изначально они исполнялись в кругу друзей; позже получили широкую известность" + - " благодаря распространявшимся по стране магнитофонным записям. Поэзия " + - "Высоцкого отличалась многообразием тем (уличные, лагерные, военные, " + - "сатирические, бытовые, сказочные, «спортивные» песни), остротой смыслового " + - "подтекста и акцентированной социально-нравственной позицией автора. В его " + - "произведениях, рассказывающих о внутреннем выборе людей, поставленных в " + - "экстремальные обстоятельства, прослеживались экзистенциальные мотивы. " + - "Творческая эволюция Высоцкого ознаменовалась несколькими этапами. В его " + - "раннем творчестве преобладали уличные и дворовые песни. С середины 1960-х " + - "годов тематика произведений начала расширяться, а песенные циклы складываться" + - " в новую «энциклопедию русской жизни». В 1970-х годах значительную часть " + - "творчества Высоцкого составляли песни и стихотворения " + - "исповедально-философского характера, поэт часто обращался к вечным вопросам " + - "бытия.\n" + - "\n" + - "Театральная биография Высоцкого, окончившего в 1960 году Школу-студию МХАТ, " + - "связана главным образом с работой в Театре на Таганке. На его сцене актёр " + - "играл Галилея (спектакль «Жизнь Галилея», 1966), Хлопушу («Пугачёв», 1967), " + - "Гамлета («Гамлет», 1971), Лопахина («Вишнёвый сад», 1975), Свидригайлова " + - "(«Преступление и наказание», 1979). Дебют Высоцкого в кино состоялся в 1959 " + - "году, когда он сыграл эпизодическую роль в фильме «Сверстницы». За годы " + - "работы в кинематографе актёр снялся более чем в двадцати пяти фильмах. " + - "Кинобиография Высоцкого включает роли подпольщика Бродского («Интервенция», " + - "1968), зоолога фон Корена («Плохой хороший человек», 1973), капитана Жеглова " + - "(«Место встречи изменить нельзя», 1979), Дон Гуана («Маленькие трагедии», " + - "1979) и другие. Исследователи отмечали, что в сценических и экранных работах " + - "Высоцкого экспрессивность сочеталась с психологической достоверностью. В ряде" + - " спектаклей, а также в художественных фильмах, теле- и радиопостановках он " + - "выступал и как автор песен.\n" + - "\n" + - "При жизни Высоцкого его песни не получили в СССР официального признания. В " + - "1968 году в рамках газетной кампании, дискредитирующей его " + - "музыкально-поэтическое творчество, они были подвергнуты резкой критике. " + - "Вплоть до 1981 года ни одно советское издательство не выпустило книгу с его " + - "текстами. Цензурные ограничения частично были сняты только после смерти " + - "Высоцкого, когда вышел в свет сборник его поэтических произведений «Нерв» " + - "(составитель — Роберт Рождественский). Тем не менее цензорский контроль за " + - "публикациями стихов и песен Высоцкого, а также посвящённых ему " + - "газетно-журнальных статей продолжал действовать вплоть до перестройки. " + - "Легализация его творчества началась в Советском Союзе в 1986 году, когда при " + - "Союзе писателей СССР была создана комиссия по литературному наследию " + - "Высоцкого. Со второй половины 1980-х годов начался выпуск книг и собраний " + - "сочинений поэта, ведётся исследовательская работа, посвящённая его творчеству" + - ". По некоторым оценкам, Высоцкий, занимающий одно из центральных мест в " + - "истории русской культуры XX века, «оказал сильное влияние на формирование " + - "взглядов своих современников и последующих поколений»."; private final long mId; @NonNull private final String mName; @@ -122,8 +36,8 @@ public class BookmarkCategory implements Parcelable { mId = id; mName = name; - mAnnotation = "asdasdasdasdasdasdasdasdasdasdasdasd"; - mDescription = DESCRIPTION; + mAnnotation = annotation; + mDescription = description; mTracksCount = tracksCount; mBookmarksCount = bookmarksCount; mTypeIndex = fromCatalog ? Type.CATALOG.ordinal() : Type.PRIVATE.ordinal(); diff --git a/android/src/com/mapswithme/util/SharedPropertiesUtils.java b/android/src/com/mapswithme/util/SharedPropertiesUtils.java index 1bb7ac5ba1..85545d49c5 100644 --- a/android/src/com/mapswithme/util/SharedPropertiesUtils.java +++ b/android/src/com/mapswithme/util/SharedPropertiesUtils.java @@ -1,5 +1,6 @@ package com.mapswithme.util; +import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.NonNull; @@ -15,9 +16,16 @@ public final class SharedPropertiesUtils private static final String PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING = "ShowEmulateBadStorageSetting"; private static final String PREFS_BACKUP_WIDGET_EXPANDED = "BackupWidgetExpanded"; private static final String PREFS_WHATS_NEW_TITLE_CONCATENATION = "WhatsNewTitleConcatenation"; + private static final String PREFS_CATALOG_CATEGORIES_HEADER_CLOSED = "catalog_categories_header_closed"; private static final SharedPreferences PREFS = PreferenceManager.getDefaultSharedPreferences(MwmApplication.get()); + //Utils class + private SharedPropertiesUtils() + { + throw new IllegalStateException("Try instantiate utility class SharedPropertiesUtils"); + } + public static boolean isShowcaseSwitchedOnLocal() { return PreferenceManager.getDefaultSharedPreferences(MwmApplication.get()) @@ -71,9 +79,17 @@ public final class SharedPropertiesUtils PREFS.edit().putString(PREFS_WHATS_NEW_TITLE_CONCATENATION, concatenation).apply(); } - //Utils class - private SharedPropertiesUtils() + public static boolean isCatalogCategoriesHeaderClosed(Context context) { - throw new IllegalStateException("Try instantiate utility class SharedPropertiesUtils"); + return MwmApplication.prefs(context) + .getBoolean(PREFS_CATALOG_CATEGORIES_HEADER_CLOSED, false); + } + + public static void setCatalogCategoriesHeaderClosed(Context context, boolean value) + { + MwmApplication.prefs(context) + .edit() + .putBoolean(PREFS_CATALOG_CATEGORIES_HEADER_CLOSED, value) + .apply(); } }