forked from organicmaps/organicmaps
[android] new bookmarks description screen is added
This commit is contained in:
parent
233b06a351
commit
2013859c2d
8 changed files with 245 additions and 57 deletions
|
@ -381,6 +381,9 @@
|
|||
<activity
|
||||
android:name="com.mapswithme.maps.widget.placepage.PlaceDescriptionActivity"
|
||||
android:label="@string/place_description_title"/>
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.bookmarks.description.BookmarksDescriptionActivity"
|
||||
android:label="@string/description_guide"/>
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.ugc.routes.EditCategoryNameActivity"
|
||||
android:label="@string/name"/>
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
<include
|
||||
<com.mapswithme.maps.bookmarks.BookmarkHeaderView
|
||||
android:id="@+id/guide_info"
|
||||
layout="@layout/item_guide_info" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/collections_recycler"
|
||||
android:layout_width="match_parent"
|
||||
|
|
22
android/res/layout/fragment_bookmarks_description.xml
Normal file
22
android/res/layout/fragment_bookmarks_description.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:background="?cardBackground">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<com.mapswithme.maps.bookmarks.BookmarkHeaderView
|
||||
android:id="@+id/guide_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<WebView
|
||||
android:id="@+id/webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin_base" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -1,11 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?cardBackground"
|
||||
android:orientation="vertical">
|
||||
android:background="?cardBackground">
|
||||
<ImageView
|
||||
android:id="@+id/guide_image"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -70,4 +69,4 @@
|
|||
tools:text="@string/about_menu_title" />
|
||||
</LinearLayout>
|
||||
<include layout="@layout/divider_horizontal" />
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
public class BookmarkHeaderView extends LinearLayout
|
||||
{
|
||||
|
||||
private static final String AUTHOR_LONELY_PLANET_ID = "28035594-6457-466d-8f6f-8499607df570";
|
||||
|
||||
@NonNull
|
||||
private ImageView mImageView;
|
||||
@NonNull
|
||||
private TextView mTitle;
|
||||
@NonNull
|
||||
private TextView mDescriptionBtn;
|
||||
@NonNull
|
||||
private ImageView mImageViewLogo;
|
||||
@NonNull
|
||||
private TextView mAuthorTextView;
|
||||
|
||||
public BookmarkHeaderView(@NonNull Context context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
|
||||
public BookmarkHeaderView(@NonNull Context context, @Nullable AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public BookmarkHeaderView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr)
|
||||
{
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public BookmarkHeaderView(@NonNull Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
|
||||
{
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
View.inflate(getContext(), R.layout.item_guide_info, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate()
|
||||
{
|
||||
super.onFinishInflate();
|
||||
mImageView = findViewById(R.id.guide_image);
|
||||
mTitle = findViewById(R.id.guide_title);
|
||||
mDescriptionBtn = findViewById(R.id.btn_description);
|
||||
mAuthorTextView = findViewById(R.id.content_by);
|
||||
mImageViewLogo = findViewById(R.id.logo);
|
||||
}
|
||||
|
||||
public void setCategory(@NonNull BookmarkCategory category) {
|
||||
Context context = getContext();
|
||||
if (!category.isMyCategory())
|
||||
{
|
||||
String imageUrl = category.getImageUrl();
|
||||
if (TextUtils.isEmpty(imageUrl) || !ConnectionState.isConnected())
|
||||
{
|
||||
UiUtils.hide(mImageView);
|
||||
}
|
||||
else
|
||||
{
|
||||
Glide.with(context)
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.ic_placeholder)
|
||||
.centerCrop()
|
||||
.into(mImageView);
|
||||
}
|
||||
mTitle.setText(category.getName());
|
||||
boolean isHideDescriptionBtn = TextUtils.isEmpty(category.getDescription())
|
||||
|| TextUtils.isEmpty(category.getAnnotation());
|
||||
UiUtils.hideIf(isHideDescriptionBtn, mDescriptionBtn);
|
||||
BookmarkCategory.Author author = category.getAuthor();
|
||||
if (author != null)
|
||||
{
|
||||
if (author.getId().equals(AUTHOR_LONELY_PLANET_ID))
|
||||
mImageViewLogo.setImageDrawable(context.getDrawable(R.drawable.ic_lp_logo));
|
||||
else
|
||||
UiUtils.hide(mImageViewLogo);
|
||||
|
||||
//TODO: (@velichkomarija) : Replace with "Content by ".
|
||||
CharSequence authorName = BookmarkCategory.Author.getRepresentation(context, author);
|
||||
mAuthorTextView.setText(authorName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(findViewById(R.id.guide_info));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -12,7 +11,6 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
|
@ -20,10 +18,8 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.cocosw.bottomsheet.BottomSheet;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
|
@ -37,6 +33,7 @@ import com.mapswithme.maps.bookmarks.data.BookmarkSharingResult;
|
|||
import com.mapswithme.maps.bookmarks.data.CategoryDataSource;
|
||||
import com.mapswithme.maps.bookmarks.data.SortedBlock;
|
||||
import com.mapswithme.maps.bookmarks.data.Track;
|
||||
import com.mapswithme.maps.bookmarks.description.BookmarksDescriptionActivity;
|
||||
import com.mapswithme.maps.intent.Factory;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.search.NativeBookmarkSearchListener;
|
||||
|
@ -49,7 +46,6 @@ import com.mapswithme.maps.widget.placepage.EditBookmarkFragment;
|
|||
import com.mapswithme.maps.widget.placepage.Sponsored;
|
||||
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
|
||||
import com.mapswithme.util.BottomSheetHelper;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.CrashlyticsUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.sharing.ShareOption;
|
||||
|
@ -66,7 +62,6 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
{
|
||||
public static final String TAG = BookmarksListFragment.class.getSimpleName();
|
||||
public static final String EXTRA_CATEGORY = "bookmark_category";
|
||||
public static final String AUTHOR_LONELY_PLANET_ID = "28035594-6457-466d-8f6f-8499607df570";
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
|
@ -95,7 +90,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
private FloatingActionButton mFabViewOnMap;
|
||||
@SuppressWarnings("NotNullFieldNotInitialized")
|
||||
@NonNull
|
||||
private ViewGroup mDescriptionView;
|
||||
private BookmarkHeaderView mDescriptionView;
|
||||
@NonNull
|
||||
private RecyclerView mCollectionRecyclerView;
|
||||
@NonNull
|
||||
|
@ -190,6 +185,11 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
mToolbarController = new BookmarksToolbarController(toolbar, requireActivity(), this);
|
||||
mToolbarController.setHint(R.string.search_in_the_list);
|
||||
configureRecyclerDividers(getRecyclerView());
|
||||
|
||||
TextView description = requireActivity().findViewById(R.id.btn_description);
|
||||
description.setOnClickListener((btnView) -> {
|
||||
openDescriptionScreen();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -236,50 +236,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
private void configureGuidesInfoLayout()
|
||||
{
|
||||
BookmarkCategory category = mCategoryDataSource.getData();
|
||||
if (!category.isMyCategory())
|
||||
{
|
||||
ImageView imageView = mDescriptionView.findViewById(R.id.guide_image);
|
||||
String imageUrl = category.getImageUrl();
|
||||
if (TextUtils.isEmpty(imageUrl) || !ConnectionState.isConnected())
|
||||
{
|
||||
UiUtils.hide(imageView);
|
||||
}
|
||||
else
|
||||
{
|
||||
Glide.with(mDescriptionView.getContext())
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.ic_placeholder)
|
||||
.centerCrop()
|
||||
.into(imageView);
|
||||
}
|
||||
TextView title = mDescriptionView.findViewById(R.id.guide_title);
|
||||
title.setText(category.getName());
|
||||
|
||||
TextView descriptionBtn = mDescriptionView.findViewById(R.id.btn_description);
|
||||
boolean isHideDescriptionBtn = TextUtils.isEmpty(category.getDescription())
|
||||
|| TextUtils.isEmpty(category.getAnnotation());
|
||||
UiUtils.hideIf(isHideDescriptionBtn, descriptionBtn);
|
||||
|
||||
BookmarkCategory.Author author = category.getAuthor();
|
||||
ImageView imageViewLogo = mDescriptionView.findViewById(R.id.logo);
|
||||
TextView authorTextView = mDescriptionView.findViewById(R.id.content_by);
|
||||
|
||||
if (author != null)
|
||||
{
|
||||
if (author.getId().equals(AUTHOR_LONELY_PLANET_ID))
|
||||
imageViewLogo.setImageDrawable(requireContext().getDrawable(R.drawable.ic_lp_logo));
|
||||
else
|
||||
UiUtils.hide(imageViewLogo);
|
||||
|
||||
//TODO: (@velichkomarija) : Replace with "Content by ".
|
||||
CharSequence authorName = BookmarkCategory.Author.getRepresentation(requireContext(), author);
|
||||
authorTextView.setText(authorName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(mDescriptionView);
|
||||
}
|
||||
mDescriptionView.setCategory(category);
|
||||
}
|
||||
|
||||
private void configureAdapter()
|
||||
|
@ -852,6 +809,11 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
UgcRouteSharingOptionsActivity.startForResult(requireActivity(), mCategoryDataSource.getData());
|
||||
}
|
||||
|
||||
private void openDescriptionScreen()
|
||||
{
|
||||
BookmarksDescriptionActivity.start(requireContext(), mCategoryDataSource.getData());
|
||||
}
|
||||
|
||||
private static void trackBookmarkListSharingOptions()
|
||||
{
|
||||
Statistics.INSTANCE.trackBookmarkListSharingOptions();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.mapswithme.maps.bookmarks.description;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.mapswithme.maps.base.BaseToolbarActivity;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
|
||||
public class BookmarksDescriptionActivity extends BaseToolbarActivity
|
||||
{
|
||||
|
||||
static final String EXTRA_CATEGORY = "BookmarksDescriptionActivity.bookmark_category_extra_data";
|
||||
|
||||
@Override
|
||||
protected Class<? extends Fragment> getFragmentClass()
|
||||
{
|
||||
return BookmarksDescriptionFragment.class;
|
||||
}
|
||||
|
||||
public static void start(@NonNull Context context, @NonNull BookmarkCategory data)
|
||||
{
|
||||
Intent intent = new Intent(context, BookmarksDescriptionActivity.class)
|
||||
.putExtra(EXTRA_CATEGORY, data);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.mapswithme.maps.bookmarks.description;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.bookmarks.BookmarkHeaderView;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.mapswithme.maps.bookmarks.description.BookmarksDescriptionActivity.EXTRA_CATEGORY;
|
||||
|
||||
public class BookmarksDescriptionFragment extends BaseMwmFragment
|
||||
{
|
||||
@NonNull
|
||||
private BookmarkCategory mBookmarkCategory;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle argument = getArguments();
|
||||
if (argument != null && argument.containsKey(EXTRA_CATEGORY))
|
||||
mBookmarkCategory = Objects.requireNonNull(argument.getParcelable(EXTRA_CATEGORY), "No argument provided!");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_bookmarks_description, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
ActionBar bar = ((AppCompatActivity) requireActivity()).getSupportActionBar();
|
||||
if (bar != null)
|
||||
bar.setTitle(R.string.description_guide);
|
||||
|
||||
BookmarkHeaderView headerView = view.findViewById(R.id.guide_info);
|
||||
headerView.setCategory(mBookmarkCategory);
|
||||
TextView btnDescription = view.findViewById(R.id.btn_description);
|
||||
UiUtils.hide(btnDescription);
|
||||
WebView webView = view.findViewById(R.id.webview);
|
||||
webView.loadData(mBookmarkCategory.getDescription(), Utils.TEXT_HTML, Utils.UTF_8);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue