From e440a1301f75c5b738890fbd019578cccf574626 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 6 Apr 2018 19:06:04 +0300 Subject: [PATCH 01/18] add contents for anchor links --- .../fragment_wikivoyage_article_dialog.xml | 109 +++++++- ...wikivoyage_contents_expandablelistview.xml | 15 ++ .../wikivoyage_contents_group_list_item.xml | 25 ++ OsmAnd/res/values/strings.xml | 1 + .../WikivoyageArticleDialogFragment.java | 56 +++- ...icleContentsBottomSheetDialogFragment.java | 248 ++++++++++++++++++ 6 files changed, 443 insertions(+), 11 deletions(-) create mode 100644 OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml create mode 100644 OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index 5874c973f8..3af14ad36f 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -1,12 +1,16 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml b/OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml new file mode 100644 index 0000000000..3bf81ee2e5 --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml b/OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml new file mode 100644 index 0000000000..98a4b4f794 --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f919413655..f4b6b44aa0 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ Read Saved articles Explore + Contents Result Use two digits longitude Travel diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index b8a6f168f7..783154f996 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -1,5 +1,6 @@ package net.osmand.plus.wikivoyage; +import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.Build; @@ -21,9 +22,11 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.R; +import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; import net.osmand.util.Algorithms; +import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsBottomSheetDialogFragment; import java.io.File; import java.util.ArrayList; @@ -42,15 +45,18 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen "\n" + "\n" + "\n" + - "\n"; + "\n" + ""; private static final String FOOTER_INNER = ""; private long cityId = NO_VALUE; private ArrayList langs; private String selectedLang; + private String contentsJson; private TextView selectedLangTv; private WebView contentWebView; + private WikivoyageArticleDialogFragment thiss; @Nullable @Override @@ -58,7 +64,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen if (savedInstanceState != null) { selectedLang = savedInstanceState.getString(SELECTED_LANG_KEY); } - + thiss = this; final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); @@ -81,6 +87,36 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } }); + final View buttomBar = mainView.findViewById(R.id.bottom_bar); + + buttomBar.setBackgroundColor(getResolvedColor(isNightMode(false) ? R.color.status_bar_wikivoyage_article_dark : R.color.ctx_menu_card_btn_light)); + + TextViewEx contentsButton = mainView.findViewById(R.id.contents_button); + TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_text_button); + + saveButton.setCompoundDrawablesWithIntrinsicBounds(null, + null, getMyApplication().getIconsCache() + .getIcon(R.drawable.ic_action_read_later, isNightMode(false) ? + R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null); + + contentsButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_header, + isNightMode(false) ? R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), + null, null, null); + + contentsButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentManager fm = getActivity().getSupportFragmentManager(); + Bundle args = new Bundle(); + args.putString("CONTENTS_JSON", contentsJson); + WikivoyageArticleContentsBottomSheetDialogFragment fragment = new WikivoyageArticleContentsBottomSheetDialogFragment(); + fragment.setUsedOnMap(false); + fragment.setArguments(args); + fragment.setTargetFragment(thiss, 0); + fragment.show(fm, WikivoyageArticleContentsBottomSheetDialogFragment.TAG); + } + }); + contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); return mainView; @@ -97,6 +133,15 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen outState.putString(SELECTED_LANG_KEY, selectedLang); } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 0) { + String link = data.getStringExtra("test"); + moveAnchor(link); + } + } + @Override protected int getStatusBarColor() { return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light; @@ -147,12 +192,17 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen if (article == null) { return; } - + contentsJson = article.getContentsJson(); WikivoyageLocalDataHelper.getInstance(getMyApplication()).addToHistory(article); + contentWebView.getSettings().setJavaScriptEnabled(true); contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); } + public void moveAnchor(String id) { + contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\")"); + } + @NonNull private String createHtmlContent(@NonNull WikivoyageArticle article) { StringBuilder sb = new StringBuilder(HEADER_INNER); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java new file mode 100644 index 0000000000..7f49760403 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java @@ -0,0 +1,248 @@ +package net.osmand.plus.wikivoyage.data; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseExpandableListAdapter; +import android.widget.ExpandableListView; +import android.widget.ExpandableListView.OnGroupClickListener; +import android.widget.TextView; +import android.widget.Toast; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + + public final static String TAG = "WikivoyageArticleContentsBottomSheetDialogFragment"; + private LinkedHashMap map; + private String link; + private OsmandApplication app; + + @Override + public void createMenuItems(Bundle savedInstanceState) { + Bundle args = getArguments(); + String contentsJson; + if (args != null) { + contentsJson = args.getString("CONTENTS_JSON"); + } else { + return; + } + app = getMyApplication(); + final ArrayList listDataHeader = new ArrayList(); + final LinkedHashMap> listDataChild = new LinkedHashMap>(); + + map = new LinkedHashMap<>(); + JSONObject reader = null; + try { + reader = new JSONObject(contentsJson); + } catch (JSONException e) { + e.printStackTrace(); + return; + } + List secondLevel = null; + JSONArray jArray = reader.names(); + for (int i = 0; i < jArray.length(); i++) { + try { + JSONArray contacts = reader.getJSONArray(reader.names().getString(i)); + String link = contacts.getString(1); + + map.put(reader.names().getString(i), link); + + int level = contacts.getInt(0); + + if (level == 2) { + listDataHeader.add(reader.names().getString(i)); + secondLevel = new ArrayList(); + } + if (level == 3) { + if (secondLevel == null) { + secondLevel = new ArrayList(); + } + secondLevel.add(reader.names().getString(i)); + listDataChild.put(listDataHeader.get(listDataHeader.size() - 1), secondLevel); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + items.add(new TitleItem(getString(R.string.article_contents_title))); + LayoutInflater li = LayoutInflater.from(getContext()); + View view = li.inflate(R.layout.wikivoyage_contents_expandablelistview, null); + ExpandableListView expListView = view.findViewById(R.id.expandableListView); + + ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild); + expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { + + @Override + public boolean onChildClick(ExpandableListView parent, View v, + int groupPosition, int childPosition, long id) { + link = map.get(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition)); + sendResult(0); + dismiss(); + return false; + } + }); + DisplayMetrics diaplayMetrics; + int width; + diaplayMetrics = new DisplayMetrics(); + getActivity().getWindowManager().getDefaultDisplay().getMetrics(diaplayMetrics); + width = diaplayMetrics.widthPixels; + if (android.os.Build.VERSION.SDK_INT < 18) { + expListView.setIndicatorBounds(width - ((int) (50 * getResources().getDisplayMetrics().density + 0.5f)), width - ((int) (10 * getResources().getDisplayMetrics().density + 0.5f))); + } else { + expListView.setIndicatorBoundsRelative(width - ((int) (50 * getResources().getDisplayMetrics().density + 0.5f)), width - ((int) (10 * getResources().getDisplayMetrics().density + 0.5f))); + } + expListView.setIndicatorBounds(200, 50); + expListView.setOnGroupClickListener(new OnGroupClickListener() { + @Override + public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { + link = map.get(listDataHeader.get(groupPosition)); + sendResult(0); + if (listDataChild.get(listDataHeader.get(groupPosition)) == null) { + dismiss(); + } + return false; + } + }); + expListView.setAdapter(listAdapter); + BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder() + .setCustomView(view) + .create(); + items.add(favoritesItem); + + } + + private void sendResult(int REQUEST_CODE) { + Intent intent = new Intent(); + intent.putExtra("test", link); + getTargetFragment().onActivityResult( + getTargetRequestCode(), REQUEST_CODE, intent); + } + + @Override + protected boolean useScrollableItemsContainer() { + return false; + } + + class ExpandableListAdapter extends BaseExpandableListAdapter { + + private Context _context; + private List _listDataHeader; + private LinkedHashMap> _listDataChild; + + public ExpandableListAdapter(Context context, List listDataHeader, + LinkedHashMap> listChildData) { + this._context = context; + this._listDataHeader = listDataHeader; + this._listDataChild = listChildData; + } + + @Override + public Object getChild(int groupPosition, int childPosititon) { + return this._listDataChild.get(this._listDataHeader.get(groupPosition)) + .get(childPosititon); + } + + @Override + public long getChildId(int groupPosition, int childPosition) { + return childPosition; + } + + @Override + public View getChildView(int groupPosition, final int childPosition, + boolean isLastChild, View convertView, ViewGroup parent) { + + final String childText = (String) getChild(groupPosition, childPosition); + + if (convertView == null) { + LayoutInflater infalInflater = (LayoutInflater) this._context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = infalInflater.inflate(R.layout.wikivoyage_contents_group_list_item, null); + } + + TextView txtListChild = (TextView) convertView.findViewById(R.id.group_label); + + txtListChild.setText(childText); + txtListChild.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light)); + txtListChild.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() + .getIcon(R.drawable.ic_action_list_bullet, isNightMode() ? + R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark), + null, null, null); + + return convertView; + } + + @Override + public int getChildrenCount(int groupPosition) { + if (this._listDataChild.get(this._listDataHeader.get(groupPosition)) != null) { + return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size(); + } else { + return 0; + } + } + + @Override + public Object getGroup(int groupPosition) { + return this._listDataHeader.get(groupPosition); + } + + @Override + public int getGroupCount() { + return this._listDataHeader.size(); + } + + @Override + public long getGroupId(int groupPosition) { + return groupPosition; + } + + @Override + public View getGroupView(int groupPosition, boolean isExpanded, + View convertView, ViewGroup parent) { + String headerTitle = (String) getGroup(groupPosition); + if (convertView == null) { + LayoutInflater infalInflater = (LayoutInflater) this._context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = infalInflater.inflate(R.layout.wikivoyage_contents_group_list_item, null); + } + + TextView lblListHeader = (TextView) convertView.findViewById(R.id.group_label); + lblListHeader.setText(headerTitle); + lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light)); + lblListHeader.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() + .getIcon(R.drawable.ic_action_list_sort, isNightMode() ? + R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light), + null, null, null); + + return convertView; + } + + @Override + public boolean hasStableIds() { + return false; + } + + @Override + public boolean isChildSelectable(int groupPosition, int childPosition) { + return true; + } + } +} \ No newline at end of file From 5cdf9726157084c728694b09f816fd03bcacf448 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 12:21:18 +0300 Subject: [PATCH 02/18] Rename "wikivoyage_saved_articles_list_item" with "wikivoyage_article_card"; make buttons more general --- ...les_list_item.xml => wikivoyage_article_card.xml} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename OsmAnd/res/layout/{wikivoyage_saved_articles_list_item.xml => wikivoyage_article_card.xml} (95%) diff --git a/OsmAnd/res/layout/wikivoyage_saved_articles_list_item.xml b/OsmAnd/res/layout/wikivoyage_article_card.xml similarity index 95% rename from OsmAnd/res/layout/wikivoyage_saved_articles_list_item.xml rename to OsmAnd/res/layout/wikivoyage_article_card.xml index 2d5b466e0c..1f96e9c12b 100644 --- a/OsmAnd/res/layout/wikivoyage_saved_articles_list_item.xml +++ b/OsmAnd/res/layout/wikivoyage_article_card.xml @@ -84,7 +84,7 @@ android:layout_height="wrap_content"> + tools:ignore="UnusedAttribute" + tools:text="Read"/> + tools:ignore="UnusedAttribute" + tools:text="Delete"/> From 18e231135326110f628ff3509dcb5196bad0458d Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 12:49:56 +0300 Subject: [PATCH 03/18] Add nonnull annotation --- .../osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java index aab19d481e..c77f1aafc7 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java @@ -83,6 +83,7 @@ public class WikivoyageLocalDataHelper { } } + @NonNull public List getSavedArticles() { return new ArrayList<>(savedArticles); } From b96fed3d0e99bad2552285f0cc1fdbe311b52bf2 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 14:04:39 +0300 Subject: [PATCH 04/18] Fix top divider in wikivoyage_search_list_header --- OsmAnd/res/layout/wikivoyage_search_list_header.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/wikivoyage_search_list_header.xml b/OsmAnd/res/layout/wikivoyage_search_list_header.xml index 849b7b545e..0ad109475f 100644 --- a/OsmAnd/res/layout/wikivoyage_search_list_header.xml +++ b/OsmAnd/res/layout/wikivoyage_search_list_header.xml @@ -6,7 +6,11 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + + + Date: Tue, 10 Apr 2018 14:05:23 +0300 Subject: [PATCH 05/18] Create wikivoyage_list_header --- OsmAnd/res/layout/wikivoyage_list_header.xml | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 OsmAnd/res/layout/wikivoyage_list_header.xml diff --git a/OsmAnd/res/layout/wikivoyage_list_header.xml b/OsmAnd/res/layout/wikivoyage_list_header.xml new file mode 100644 index 0000000000..d197edbc90 --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_list_header.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + From fa64c070b1fbe6687d21af58e6bcc959445d5e22 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 14:15:51 +0300 Subject: [PATCH 06/18] Add RecyclerView to SavedArticlesTabFragment --- .../layout/fragment_saved_articles_tab.xml | 13 +- .../explore/SavedArticlesRvAdapter.java | 168 ++++++++++++++++++ .../explore/SavedArticlesTabFragment.java | 10 +- 3 files changed, 185 insertions(+), 6 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java diff --git a/OsmAnd/res/layout/fragment_saved_articles_tab.xml b/OsmAnd/res/layout/fragment_saved_articles_tab.xml index 0bd472a5a8..60532f4188 100644 --- a/OsmAnd/res/layout/fragment_saved_articles_tab.xml +++ b/OsmAnd/res/layout/fragment_saved_articles_tab.xml @@ -1,14 +1,17 @@ - + diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java new file mode 100644 index 0000000000..6e552b2a5a --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -0,0 +1,168 @@ +package net.osmand.plus.wikivoyage.explore; + +import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; + +import java.util.ArrayList; +import java.util.List; + +public class SavedArticlesRvAdapter extends RecyclerView.Adapter { + + private static final int HEADER_TYPE = 0; + private static final int ITEM_TYPE = 1; + + private final OsmandApplication app; + + private final List items = new ArrayList<>(); + + private final Drawable readIcon; + private final Drawable deleteIcon; + + public SavedArticlesRvAdapter(OsmandApplication app) { + this.app = app; + List savedArticles = WikivoyageLocalDataHelper.getInstance(app).getSavedArticles(); + if (!savedArticles.isEmpty()) { + items.add(app.getString(R.string.saved_articles)); + items.addAll(savedArticles); + } + int colorId = app.getSettings().isLightContent() + ? R.color.wikivoyage_active_light : R.color.wikivoyage_active_dark; + IconsCache ic = app.getIconsCache(); + readIcon = ic.getIcon(R.drawable.ic_action_read_article, colorId); + deleteIcon = ic.getIcon(R.drawable.ic_action_read_later_fill, colorId); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + boolean header = viewType == HEADER_TYPE; + int layoutId = header ? R.layout.wikivoyage_list_header : R.layout.wikivoyage_article_card; + View itemView = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false); + return header ? new HeaderVH(itemView) : new ItemVH(itemView); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { + if (viewHolder instanceof HeaderVH) { + final HeaderVH holder = (HeaderVH) viewHolder; + holder.title.setText((String) getItem(position)); + holder.description.setText(String.valueOf(items.size() - 1)); + } else { + final ItemVH holder = (ItemVH) viewHolder; + WikivoyageArticle article = (WikivoyageArticle) getItem(position); + boolean lastItem = position == getItemCount() - 1; + + holder.title.setText(article.getTitle()); + holder.content.setText(article.getContent()); + holder.partOf.setText(article.getAggregatedPartOf()); // todo + holder.icon.setVisibility(View.GONE); // todo + holder.leftButton.setText(app.getString(R.string.shared_string_read)); + holder.leftButton.setCompoundDrawablesWithIntrinsicBounds(readIcon, null, null, null); + holder.rightButton.setText(app.getString(R.string.shared_string_delete)); + holder.rightButton.setCompoundDrawablesWithIntrinsicBounds(null, null, deleteIcon, null); + holder.divider.setVisibility(lastItem ? View.GONE : View.VISIBLE); + holder.shadow.setVisibility(lastItem ? View.VISIBLE : View.GONE); + } + } + + @Override + public int getItemViewType(int position) { + if (getItem(position) instanceof String) { + return HEADER_TYPE; + } + return ITEM_TYPE; + } + + @Override + public int getItemCount() { + return items.size(); + } + + private Object getItem(int position) { + return items.get(position); + } + + static class HeaderVH extends RecyclerView.ViewHolder { + + final TextView title; + final TextView description; + + HeaderVH(View itemView) { + super(itemView); + title = (TextView) itemView.findViewById(R.id.title); + description = (TextView) itemView.findViewById(R.id.description); + } + } + + class ItemVH extends RecyclerView.ViewHolder { + + final TextView title; + final TextView content; + final TextView partOf; + final ImageView icon; + final TextView leftButton; + final TextView rightButton; + final View divider; + final View shadow; + + ItemVH(View itemView) { + super(itemView); + title = (TextView) itemView.findViewById(R.id.title); + content = (TextView) itemView.findViewById(R.id.content); + partOf = (TextView) itemView.findViewById(R.id.part_of); + icon = (ImageView) itemView.findViewById(R.id.icon); + leftButton = (TextView) itemView.findViewById(R.id.left_button); + rightButton = (TextView) itemView.findViewById(R.id.right_button); + divider = itemView.findViewById(R.id.divider); + shadow = itemView.findViewById(R.id.shadow); + + View.OnClickListener readClickListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + Object item = getItemByPosition(); + if (item != null && item instanceof WikivoyageArticle) { + WikivoyageArticle article = (WikivoyageArticle) item; + Toast.makeText(app, "read: " + article.getTitle(), Toast.LENGTH_SHORT).show(); + } + } + }; + + itemView.setOnClickListener(readClickListener); + leftButton.setOnClickListener(readClickListener); + + rightButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Object item = getItemByPosition(); + if (item != null && item instanceof WikivoyageArticle) { + WikivoyageArticle article = (WikivoyageArticle) item; + Toast.makeText(app, "delete: " + article.getTitle(), Toast.LENGTH_SHORT).show(); + } + } + }); + } + + @Nullable + private Object getItemByPosition() { + int pos = getAdapterPosition(); + if (pos != RecyclerView.NO_POSITION) { + return getItem(pos); + } + return null; + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesTabFragment.java index ad705a4219..554790f560 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesTabFragment.java @@ -3,6 +3,8 @@ package net.osmand.plus.wikivoyage.explore; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,6 +17,12 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_saved_articles_tab, container, false); + final View mainView = inflater.inflate(R.layout.fragment_saved_articles_tab, container, false); + + final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view); + rv.setLayoutManager(new LinearLayoutManager(getContext())); + rv.setAdapter(new SavedArticlesRvAdapter(getMyApplication())); + + return mainView; } } From 0e3894f11b57e92f5446ab134ee24cb8320022a4 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 10 Apr 2018 14:33:08 +0300 Subject: [PATCH 07/18] add new class for parser and refactored contents --- .../fragment_wikivoyage_article_dialog.xml | 64 +++----- ...wikivoyage_contents_expandablelistview.xml | 15 -- ....xml => wikivoyage_contents_list_item.xml} | 12 +- OsmAnd/res/values/strings.xml | 2 +- OsmAnd/src/net/osmand/AndroidUtils.java | 6 + .../WikivoyageArticleDialogFragment.java | 24 ++- .../wikivoyage/data/ContentsJsonParser.java | 71 ++++++++ ...icleContentsBottomSheetDialogFragment.java | 154 +++++++----------- 8 files changed, 181 insertions(+), 167 deletions(-) delete mode 100644 OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml rename OsmAnd/res/layout/{wikivoyage_contents_group_list_item.xml => wikivoyage_contents_list_item.xml} (87%) create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index 3af14ad36f..5388576d21 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -3,8 +3,7 @@ xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?attr/wikivoyage_bg_color"> + android:layout_height="match_parent"> - + - - - - - + android:layout_gravity="center_vertical|end" + android:layout_weight="1" + android:background="?attr/selectableItemBackground" + android:drawablePadding="@dimen/bottom_sheet_content_padding_small" + android:ellipsize="end" + android:gravity="center_vertical|end" + android:letterSpacing="@dimen/text_button_letter_spacing" + android:maxLines="1" + android:paddingBottom="@dimen/context_menu_padding_margin_tiny" + android:paddingLeft="@dimen/bottom_sheet_content_padding_small" + android:paddingRight="@dimen/bottom_sheet_content_padding_small" + android:paddingTop="@dimen/context_menu_padding_margin_tiny" + android:text="@string/shared_string_save" + android:textColor="?attr/wikivoyage_active_color" + android:textSize="@dimen/default_desc_text_size" + osmand:typeface="@string/font_roboto_medium" + tools:drawableRight="@drawable/ic_action_read_later_fill" + tools:drawableTint="?attr/wikivoyage_active_color" + tools:ignore="UnusedAttribute" /> diff --git a/OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml b/OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml deleted file mode 100644 index 3bf81ee2e5..0000000000 --- a/OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml b/OsmAnd/res/layout/wikivoyage_contents_list_item.xml similarity index 87% rename from OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml rename to OsmAnd/res/layout/wikivoyage_contents_list_item.xml index 98a4b4f794..040a075af4 100644 --- a/OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml +++ b/OsmAnd/res/layout/wikivoyage_contents_list_item.xml @@ -1,25 +1,23 @@ - - \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index de38525bc8..93caea7dd7 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -13,7 +13,7 @@ Read Saved articles Explore - Contents + Contents Result Use two digits longitude Travel diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 8b36fac988..1d72eba831 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -311,6 +311,12 @@ public class AndroidUtils { return dm.heightPixels; } + public static int getScreenWidth(Activity activity) { + DisplayMetrics dm = new DisplayMetrics(); + activity.getWindowManager().getDefaultDisplay().getMetrics(dm); + return dm.widthPixels; + } + public static boolean isValidEmail(CharSequence target) { return !TextUtils.isEmpty(target) && android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index c3b8ba2661..f446371023 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -17,6 +17,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; +import android.widget.FrameLayout; import android.widget.TextView; import net.osmand.AndroidUtils; @@ -56,7 +57,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private TextView selectedLangTv; private WebView contentWebView; - private WikivoyageArticleDialogFragment thiss; @Nullable @Override @@ -69,7 +69,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen selectedLang = args.getString(SELECTED_LANG_KEY); } } - thiss = this; final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); @@ -92,20 +91,19 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } }); - final View buttomBar = mainView.findViewById(R.id.bottom_bar); + final View buttonBar = mainView.findViewById(R.id.bottom_bar); - buttomBar.setBackgroundColor(getResolvedColor(isNightMode(false) ? R.color.status_bar_wikivoyage_article_dark : R.color.ctx_menu_card_btn_light)); + buttonBar.setBackgroundColor(getResolvedColor(nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.ctx_menu_card_btn_light)); - TextViewEx contentsButton = mainView.findViewById(R.id.contents_button); - TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_text_button); + TextViewEx contentsButton = (TextViewEx) mainView.findViewById(R.id.contents_button); + TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_button); saveButton.setCompoundDrawablesWithIntrinsicBounds(null, - null, getMyApplication().getIconsCache() - .getIcon(R.drawable.ic_action_read_later, isNightMode(false) ? - R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null); + null, getIcon(R.drawable.ic_action_read_later, nightMode ? + R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null); contentsButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_header, - isNightMode(false) ? R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), + nightMode ? R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null, null, null); contentsButton.setOnClickListener(new View.OnClickListener() { @@ -113,11 +111,11 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen public void onClick(View v) { FragmentManager fm = getActivity().getSupportFragmentManager(); Bundle args = new Bundle(); - args.putString("CONTENTS_JSON", contentsJson); + args.putString(WikivoyageArticleContentsBottomSheetDialogFragment.CONTENTS_JSON, contentsJson); WikivoyageArticleContentsBottomSheetDialogFragment fragment = new WikivoyageArticleContentsBottomSheetDialogFragment(); fragment.setUsedOnMap(false); fragment.setArguments(args); - fragment.setTargetFragment(thiss, 0); + fragment.setTargetFragment(WikivoyageArticleDialogFragment.this, 0); fragment.show(fm, WikivoyageArticleContentsBottomSheetDialogFragment.TAG); } }); @@ -142,7 +140,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0) { - String link = data.getStringExtra("test"); + String link = data.getStringExtra(WikivoyageArticleContentsBottomSheetDialogFragment.CONTENTS_LINK); moveAnchor(link); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java new file mode 100644 index 0000000000..8852c3a5a3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java @@ -0,0 +1,71 @@ +package net.osmand.plus.wikivoyage.data; + +import android.content.Context; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + + +class ContentsJsonParser { + + static ContentsContainer parseJsonContents(String contentsJson, Context context) { + LinkedHashMap map = new LinkedHashMap(); + ArrayList listDataHeader = new ArrayList(); + LinkedHashMap> listDataChild = new LinkedHashMap>(); + + JSONObject reader = null; + try { + reader = new JSONObject(contentsJson); + } catch (JSONException e) { + e.printStackTrace(); + return null; + } + List secondLevel = null; + JSONArray jArray = reader.names(); + for (int i = 0; i < jArray.length(); i++) { + try { + JSONArray contacts = reader.getJSONArray(reader.names().getString(i)); + String link = contacts.getString(1); + + map.put(reader.names().getString(i), link); + + int level = contacts.getInt(0); + + if (level == 2) { + listDataHeader.add(reader.names().getString(i)); + secondLevel = new ArrayList(); + } + if (level == 3) { + if (secondLevel == null) { + secondLevel = new ArrayList(); + } + secondLevel.add(reader.names().getString(i)); + listDataChild.put(listDataHeader.get(listDataHeader.size() - 1), secondLevel); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + return new ContentsContainer(map, listDataHeader, listDataChild); + } + + static class ContentsContainer { + + public LinkedHashMap map; + public ArrayList listDataHeader; + public LinkedHashMap> listDataChild; + + public ContentsContainer(LinkedHashMap map, ArrayList listDataHeader, + LinkedHashMap> listChildData) { + this.map = map; + this.listDataHeader = listDataHeader; + this.listDataChild = listChildData; + } + + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java index 7f49760403..06fd24391d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java @@ -3,27 +3,23 @@ package net.osmand.plus.wikivoyage.data; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.util.DisplayMetrics; +import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnGroupClickListener; +import android.widget.LinearLayout; import android.widget.TextView; -import android.widget.Toast; -import net.osmand.plus.OsmandApplication; +import net.osmand.AndroidUtils; import net.osmand.plus.R; +import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -31,64 +27,43 @@ import java.util.List; public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public final static String TAG = "WikivoyageArticleContentsBottomSheetDialogFragment"; + public final static String CONTENTS_JSON = "contents_json"; + public final static String CONTENTS_LINK = "contents_link"; + + private LinkedHashMap map; private String link; - private OsmandApplication app; @Override public void createMenuItems(Bundle savedInstanceState) { Bundle args = getArguments(); String contentsJson; if (args != null) { - contentsJson = args.getString("CONTENTS_JSON"); + contentsJson = args.getString(CONTENTS_JSON); } else { return; } - app = getMyApplication(); - final ArrayList listDataHeader = new ArrayList(); - final LinkedHashMap> listDataChild = new LinkedHashMap>(); - - map = new LinkedHashMap<>(); - JSONObject reader = null; - try { - reader = new JSONObject(contentsJson); - } catch (JSONException e) { - e.printStackTrace(); + ContentsJsonParser.ContentsContainer contentsContainer = ContentsJsonParser.parseJsonContents(contentsJson, getContext()); + if (contentsContainer == null) { return; } - List secondLevel = null; - JSONArray jArray = reader.names(); - for (int i = 0; i < jArray.length(); i++) { - try { - JSONArray contacts = reader.getJSONArray(reader.names().getString(i)); - String link = contacts.getString(1); + final ArrayList listDataHeader = contentsContainer.listDataHeader; + final LinkedHashMap> listDataChild = contentsContainer.listDataChild; - map.put(reader.names().getString(i), link); + map = contentsContainer.map; - int level = contacts.getInt(0); - - if (level == 2) { - listDataHeader.add(reader.names().getString(i)); - secondLevel = new ArrayList(); - } - if (level == 3) { - if (secondLevel == null) { - secondLevel = new ArrayList(); - } - secondLevel.add(reader.names().getString(i)); - listDataChild.put(listDataHeader.get(listDataHeader.size() - 1), secondLevel); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } - - items.add(new TitleItem(getString(R.string.article_contents_title))); - LayoutInflater li = LayoutInflater.from(getContext()); - View view = li.inflate(R.layout.wikivoyage_contents_expandablelistview, null); - ExpandableListView expListView = view.findViewById(R.id.expandableListView); + items.add(new TitleItem(getString(R.string.shared_string_contents))); + ExpandableListView expListView = new ExpandableListView(getContext()); ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild); + + expListView.setAdapter(listAdapter); + expListView.setChildDivider(getResources().getDrawable(R.color.color_transparent)); + + expListView.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT)); + expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override @@ -100,17 +75,13 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott return false; } }); - DisplayMetrics diaplayMetrics; - int width; - diaplayMetrics = new DisplayMetrics(); - getActivity().getWindowManager().getDefaultDisplay().getMetrics(diaplayMetrics); - width = diaplayMetrics.widthPixels; + + int width = AndroidUtils.getScreenWidth(getActivity()); if (android.os.Build.VERSION.SDK_INT < 18) { - expListView.setIndicatorBounds(width - ((int) (50 * getResources().getDisplayMetrics().density + 0.5f)), width - ((int) (10 * getResources().getDisplayMetrics().density + 0.5f))); + expListView.setIndicatorBounds(width - (AndroidUtils.dpToPx(getContext(), 50)), width - (AndroidUtils.dpToPx(getContext(), 10))); } else { - expListView.setIndicatorBoundsRelative(width - ((int) (50 * getResources().getDisplayMetrics().density + 0.5f)), width - ((int) (10 * getResources().getDisplayMetrics().density + 0.5f))); + expListView.setIndicatorBoundsRelative(width - (AndroidUtils.dpToPx(getContext(), 50)), width - (AndroidUtils.dpToPx(getContext(), 10))); } - expListView.setIndicatorBounds(200, 50); expListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { @@ -122,19 +93,22 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott return false; } }); - expListView.setAdapter(listAdapter); + LinearLayout container = new LinearLayout(getContext()); + container.addView(expListView); BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder() - .setCustomView(view) + .setCustomView(container) .create(); items.add(favoritesItem); - } private void sendResult(int REQUEST_CODE) { Intent intent = new Intent(); - intent.putExtra("test", link); - getTargetFragment().onActivityResult( - getTargetRequestCode(), REQUEST_CODE, intent); + intent.putExtra(CONTENTS_LINK, link); + Fragment fragment = getTargetFragment(); + if (fragment != null) { + fragment.onActivityResult( + getTargetRequestCode(), REQUEST_CODE, intent); + } } @Override @@ -142,23 +116,22 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott return false; } - class ExpandableListAdapter extends BaseExpandableListAdapter { + class ExpandableListAdapter extends OsmandBaseExpandableListAdapter { - private Context _context; - private List _listDataHeader; - private LinkedHashMap> _listDataChild; + private Context context; + private List listDataHeader; + private LinkedHashMap> listDataChild; public ExpandableListAdapter(Context context, List listDataHeader, LinkedHashMap> listChildData) { - this._context = context; - this._listDataHeader = listDataHeader; - this._listDataChild = listChildData; + this.context = context; + this.listDataHeader = listDataHeader; + this.listDataChild = listChildData; } @Override public Object getChild(int groupPosition, int childPosititon) { - return this._listDataChild.get(this._listDataHeader.get(groupPosition)) - .get(childPosititon); + return this.listDataChild.get(this.listDataHeader.get(groupPosition)).get(childPosititon); } @Override @@ -169,22 +142,17 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott @Override public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { - - final String childText = (String) getChild(groupPosition, childPosition); - + String childText = (String) getChild(groupPosition, childPosition); if (convertView == null) { - LayoutInflater infalInflater = (LayoutInflater) this._context + LayoutInflater infalInflater = (LayoutInflater) this.context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = infalInflater.inflate(R.layout.wikivoyage_contents_group_list_item, null); + convertView = infalInflater.inflate(R.layout.wikivoyage_contents_list_item, null); } - - TextView txtListChild = (TextView) convertView.findViewById(R.id.group_label); - + TextView txtListChild = (TextView) convertView.findViewById(R.id.item_label); txtListChild.setText(childText); txtListChild.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light)); - txtListChild.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() - .getIcon(R.drawable.ic_action_list_bullet, isNightMode() ? - R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark), + txtListChild.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_bullet, + isNightMode() ? R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark), null, null, null); return convertView; @@ -192,8 +160,8 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott @Override public int getChildrenCount(int groupPosition) { - if (this._listDataChild.get(this._listDataHeader.get(groupPosition)) != null) { - return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size(); + if (this.listDataChild.get(this.listDataHeader.get(groupPosition)) != null) { + return this.listDataChild.get(this.listDataHeader.get(groupPosition)).size(); } else { return 0; } @@ -201,12 +169,12 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott @Override public Object getGroup(int groupPosition) { - return this._listDataHeader.get(groupPosition); + return this.listDataHeader.get(groupPosition); } @Override public int getGroupCount() { - return this._listDataHeader.size(); + return this.listDataHeader.size(); } @Override @@ -219,17 +187,15 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott View convertView, ViewGroup parent) { String headerTitle = (String) getGroup(groupPosition); if (convertView == null) { - LayoutInflater infalInflater = (LayoutInflater) this._context + LayoutInflater infalInflater = (LayoutInflater) this.context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = infalInflater.inflate(R.layout.wikivoyage_contents_group_list_item, null); + convertView = infalInflater.inflate(R.layout.wikivoyage_contents_list_item, null); } - - TextView lblListHeader = (TextView) convertView.findViewById(R.id.group_label); + TextView lblListHeader = (TextView) convertView.findViewById(R.id.item_label); lblListHeader.setText(headerTitle); lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light)); - lblListHeader.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() - .getIcon(R.drawable.ic_action_list_sort, isNightMode() ? - R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light), + lblListHeader.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_contents, + isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light), null, null, null); return convertView; From baa5bee92edbd84ebac55943eab82bf7330b286d Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 14:39:47 +0300 Subject: [PATCH 08/18] Fix WikivoyageArticle#getPartialContent --- .../net/osmand/plus/wikivoyage/data/WikivoyageArticle.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java index 7e00ba73fd..60c5cf823b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java @@ -98,15 +98,15 @@ public class WikivoyageArticle { // 4 is the length of

tag String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + 4); - String firstParagraphText = Html.fromHtml(firstParagraphHtml).toString(); + String firstParagraphText = Html.fromHtml(firstParagraphHtml).toString().trim(); String[] phrases = firstParagraphText.split("\\. "); StringBuilder res = new StringBuilder(); int limit = Math.min(phrases.length, PARTIAL_CONTENT_PHRASES); for (int i = 0; i < limit; i++) { - res.append(phrases[i]).append("."); + res.append(phrases[i]); if (i < limit - 1) { - res.append(" "); + res.append(". "); } } From d63198e2d559576c2d1f3f265068229d29c98e87 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 10 Apr 2018 14:48:07 +0300 Subject: [PATCH 09/18] add color --- OsmAnd/res/values/colors.xml | 1 + .../plus/wikivoyage/WikivoyageArticleDialogFragment.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 8316c39fd3..c2417de5f8 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -146,6 +146,7 @@ #101112 #f2f2f2 #222526 + #f5f5f5 #0000 diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index f446371023..94d5a4d286 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -17,7 +17,6 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; -import android.widget.FrameLayout; import android.widget.TextView; import net.osmand.AndroidUtils; @@ -93,7 +92,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen final View buttonBar = mainView.findViewById(R.id.bottom_bar); - buttonBar.setBackgroundColor(getResolvedColor(nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.ctx_menu_card_btn_light)); + buttonBar.setBackgroundColor(getResolvedColor(nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.bottom_bar_wikivoyage_article_light)); TextViewEx contentsButton = (TextViewEx) mainView.findViewById(R.id.contents_button); TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_button); From c19ba6b9bb60fe8772637e529bd712fc7c481659 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 15:08:09 +0300 Subject: [PATCH 10/18] Format wikivoyage article geographical description --- .../wikivoyage/data/WikivoyageArticle.java | 20 +++++++++++++++++++ .../explore/SavedArticlesRvAdapter.java | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java index 60c5cf823b..492021bfe7 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java @@ -4,6 +4,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.Size; import android.text.Html; +import android.text.TextUtils; import net.osmand.plus.GPXUtilities.GPXFile; @@ -113,6 +114,25 @@ public class WikivoyageArticle { return res.toString(); } + @Nullable + public String getGeoDescription() { + if (TextUtils.isEmpty(aggregatedPartOf)) { + return null; + } + + String[] parts = aggregatedPartOf.split(","); + if (parts.length > 0) { + StringBuilder res = new StringBuilder(); + res.append(parts[parts.length - 1]); + if (parts.length > 1) { + res.append(" \u2022 ").append(parts[0]); + } + return res.toString(); + } + + return null; + } + @NonNull public static String getImageUrl(@NonNull String imageTitle, boolean thumbnail) { String[] hash = getHash(imageTitle); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 6e552b2a5a..2972d7249d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -68,7 +68,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Tue, 10 Apr 2018 16:13:41 +0300 Subject: [PATCH 11/18] add colors and refactored some code --- .../fragment_wikivoyage_article_dialog.xml | 6 +-- OsmAnd/res/values/attrs.xml | 2 + OsmAnd/res/values/colors.xml | 4 +- OsmAnd/res/values/styles.xml | 4 ++ .../WikivoyageArticleDialogFragment.java | 30 ++++++--------- ...=> WikivoyageArticleContentsFragment.java} | 38 ++++++++++--------- 6 files changed, 45 insertions(+), 39 deletions(-) rename OsmAnd/src/net/osmand/plus/wikivoyage/data/{WikivoyageArticleContentsBottomSheetDialogFragment.java => WikivoyageArticleContentsFragment.java} (85%) diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index 5388576d21..321a00a158 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -71,12 +71,12 @@ android:id="@+id/bottom_row_divider" android:layout_width="match_parent" android:layout_height="1dp" - android:background="?attr/dashboard_divider" /> + android:background="?attr/wikivoyage_bottom_bar_divider_color" /> + + diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index c2417de5f8..57f49aa04b 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -146,7 +146,7 @@ #101112 #f2f2f2 #222526 - #f5f5f5 + #f5f5f5 #0000 @@ -394,7 +394,9 @@ #ffffff #222526 #f0f0f0 + #e3e3e3 #2d3133 + #2d3133 #237bff #d28521 #f2f2f2 diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index 9e4e5d219f..ea1cf14f4f 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -201,6 +201,8 @@ @color/wikivoyage_card_bg_light @color/wikivoyage_card_divider_light @color/wikivoyage_app_bar_light + @color/bottom_bar_wikivoyage_light + @color/wikivoyage_bottom_bar_divider_light @color/wikivoyage_app_bar_text_light @color/wikivoyage_active_light @@ -392,6 +394,8 @@ @color/wikivoyage_card_bg_dark @color/wikivoyage_card_divider_dark @color/wikivoyage_app_bar_dark + @color/status_bar_wikivoyage_article_dark + @color/wikivoyage_bottom_bar_divider_dark @color/wikivoyage_app_bar_text_dark @color/wikivoyage_active_dark diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 94d5a4d286..ba2dee1646 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -24,9 +24,9 @@ import net.osmand.IndexConstants; import net.osmand.plus.R; import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsFragment; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; import net.osmand.util.Algorithms; -import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsBottomSheetDialogFragment; import java.io.File; import java.util.ArrayList; @@ -90,32 +90,26 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } }); - final View buttonBar = mainView.findViewById(R.id.bottom_bar); - - buttonBar.setBackgroundColor(getResolvedColor(nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.bottom_bar_wikivoyage_article_light)); - TextViewEx contentsButton = (TextViewEx) mainView.findViewById(R.id.contents_button); TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_button); - saveButton.setCompoundDrawablesWithIntrinsicBounds(null, - null, getIcon(R.drawable.ic_action_read_later, nightMode ? - R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null); + saveButton.setCompoundDrawablesWithIntrinsicBounds( + null, null, getActiveIcon(R.drawable.ic_action_read_later), null); - contentsButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_header, - nightMode ? R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), - null, null, null); + contentsButton.setCompoundDrawablesWithIntrinsicBounds( + getActiveIcon(R.drawable.ic_action_list_header), null, null, null); contentsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getActivity().getSupportFragmentManager(); Bundle args = new Bundle(); - args.putString(WikivoyageArticleContentsBottomSheetDialogFragment.CONTENTS_JSON, contentsJson); - WikivoyageArticleContentsBottomSheetDialogFragment fragment = new WikivoyageArticleContentsBottomSheetDialogFragment(); + args.putString(WikivoyageArticleContentsFragment.CONTENTS_JSON_KEY, contentsJson); + WikivoyageArticleContentsFragment fragment = new WikivoyageArticleContentsFragment(); fragment.setUsedOnMap(false); fragment.setArguments(args); fragment.setTargetFragment(WikivoyageArticleDialogFragment.this, 0); - fragment.show(fm, WikivoyageArticleContentsBottomSheetDialogFragment.TAG); + fragment.show(fm, WikivoyageArticleContentsFragment.TAG); } }); @@ -138,9 +132,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - if (requestCode == 0) { - String link = data.getStringExtra(WikivoyageArticleContentsBottomSheetDialogFragment.CONTENTS_LINK); - moveAnchor(link); + if (requestCode == WikivoyageArticleContentsFragment.REQUEST_LINK_CODE) { + String link = data.getStringExtra(WikivoyageArticleContentsFragment.CONTENTS_LINK_KEY); + moveToAnchor(link); } } @@ -201,7 +195,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); } - public void moveAnchor(String id) { + public void moveToAnchor(String id) { contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\")"); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsFragment.java similarity index 85% rename from OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsFragment.java index 06fd24391d..3c5e414008 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsFragment.java @@ -2,8 +2,10 @@ package net.osmand.plus.wikivoyage.data; import android.content.Context; import android.content.Intent; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -24,12 +26,12 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { - - public final static String TAG = "WikivoyageArticleContentsBottomSheetDialogFragment"; - public final static String CONTENTS_JSON = "contents_json"; - public final static String CONTENTS_LINK = "contents_link"; +public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFragment { + public final static String TAG = "WikivoyageArticleContentsFragment"; + public final static String CONTENTS_JSON_KEY = "contents_json"; + public final static String CONTENTS_LINK_KEY = "contents_link"; + public final static int REQUEST_LINK_CODE = 0; private LinkedHashMap map; private String link; @@ -39,7 +41,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott Bundle args = getArguments(); String contentsJson; if (args != null) { - contentsJson = args.getString(CONTENTS_JSON); + contentsJson = args.getString(CONTENTS_JSON_KEY); } else { return; } @@ -58,8 +60,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild); expListView.setAdapter(listAdapter); - expListView.setChildDivider(getResources().getDrawable(R.color.color_transparent)); - + expListView.setChildDivider(ContextCompat.getDrawable(getContext(), R.color.color_transparent)); expListView.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); @@ -101,13 +102,13 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott items.add(favoritesItem); } - private void sendResult(int REQUEST_CODE) { + private void sendResult(int requestLinkCode) { Intent intent = new Intent(); - intent.putExtra(CONTENTS_LINK, link); + intent.putExtra(CONTENTS_LINK_KEY, link); Fragment fragment = getTargetFragment(); if (fragment != null) { fragment.onActivityResult( - getTargetRequestCode(), REQUEST_CODE, intent); + getTargetRequestCode(), requestLinkCode, intent); } } @@ -121,12 +122,19 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott private Context context; private List listDataHeader; private LinkedHashMap> listDataChild; + private Drawable itemGroupIcon; + private Drawable itemChildIcon; public ExpandableListAdapter(Context context, List listDataHeader, LinkedHashMap> listChildData) { this.context = context; this.listDataHeader = listDataHeader; this.listDataChild = listChildData; + + itemGroupIcon = getIcon(R.drawable.ic_action_contents, + isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light); + itemChildIcon = getIcon(R.drawable.ic_action_list_bullet, + isNightMode() ? R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark); } @Override @@ -151,9 +159,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott TextView txtListChild = (TextView) convertView.findViewById(R.id.item_label); txtListChild.setText(childText); txtListChild.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light)); - txtListChild.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_bullet, - isNightMode() ? R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark), - null, null, null); + txtListChild.setCompoundDrawablesWithIntrinsicBounds(itemChildIcon, null, null, null); return convertView; } @@ -194,9 +200,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott TextView lblListHeader = (TextView) convertView.findViewById(R.id.item_label); lblListHeader.setText(headerTitle); lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light)); - lblListHeader.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_contents, - isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light), - null, null, null); + lblListHeader.setCompoundDrawablesWithIntrinsicBounds(itemGroupIcon, null, null, null); return convertView; } From 292a9e182ceafdb4ae6e270ba797d5d034c52d84 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 10 Apr 2018 16:37:20 +0300 Subject: [PATCH 12/18] add colors --- OsmAnd/res/values/attrs.xml | 4 ++-- OsmAnd/res/values/colors.xml | 9 ++++++--- OsmAnd/res/values/styles.xml | 8 ++++---- .../data/WikivoyageArticleContentsFragment.java | 4 ++-- OsmAndCore-sample/src/net/osmand/AndroidUtils.java | 6 ++++++ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml index 92ddf76932..8abb38242a 100644 --- a/OsmAnd/res/values/attrs.xml +++ b/OsmAnd/res/values/attrs.xml @@ -69,10 +69,10 @@ - - + + diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 57f49aa04b..52acb1ffdf 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -146,7 +146,8 @@ #101112 #f2f2f2 #222526 - #f5f5f5 + #f5f5f5 + #222526 #0000 @@ -394,14 +395,16 @@ #ffffff #222526 #f0f0f0 - #e3e3e3 #2d3133 - #2d3133 #237bff #d28521 #f2f2f2 #222526 #454545 #ababab + #d28521 + #536dfe + #e3e3e3 + #2d3133 \ No newline at end of file diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index ea1cf14f4f..52bfa62a04 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -201,10 +201,10 @@ @color/wikivoyage_card_bg_light @color/wikivoyage_card_divider_light @color/wikivoyage_app_bar_light - @color/bottom_bar_wikivoyage_light - @color/wikivoyage_bottom_bar_divider_light @color/wikivoyage_app_bar_text_light @color/wikivoyage_active_light + @color/bottom_bar_wikivoyage_bg_light + @color/wikivoyage_bottom_bar_divider_light @@ -396,7 +396,7 @@ @color/wikivoyage_app_bar_dark @color/wikivoyage_app_bar_text_dark @color/wikivoyage_active_dark - @color/bottom_bar_wikivoyage_bg_dark + @color/wikivoyage_bottom_bar_bg_dark @color/wikivoyage_bottom_bar_divider_dark From 0d7b5ffc2f1c768dda058caea35060b345a37e86 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 17:08:56 +0300 Subject: [PATCH 15/18] Format and refactor WikivoyageArticleDialogFragment --- .../WikivoyageArticleDialogFragment.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index ba2dee1646..413d3ef7db 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -1,5 +1,6 @@ package net.osmand.plus.wikivoyage; +import android.annotation.SuppressLint; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; @@ -22,7 +23,6 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.R; -import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsFragment; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; @@ -57,6 +57,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private TextView selectedLangTv; private WebView contentWebView; + @SuppressLint("SetJavaScriptEnabled") @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -68,6 +69,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen selectedLang = args.getString(SELECTED_LANG_KEY); } } + final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); @@ -90,30 +92,30 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } }); - TextViewEx contentsButton = (TextViewEx) mainView.findViewById(R.id.contents_button); - TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_button); - - saveButton.setCompoundDrawablesWithIntrinsicBounds( - null, null, getActiveIcon(R.drawable.ic_action_read_later), null); - - contentsButton.setCompoundDrawablesWithIntrinsicBounds( - getActiveIcon(R.drawable.ic_action_list_header), null, null, null); - - contentsButton.setOnClickListener(new View.OnClickListener() { + TextView contentsBtn = (TextView) mainView.findViewById(R.id.contents_button); + contentsBtn.setCompoundDrawablesWithIntrinsicBounds( + getActiveIcon(R.drawable.ic_action_list_header), null, null, null + ); + contentsBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - FragmentManager fm = getActivity().getSupportFragmentManager(); Bundle args = new Bundle(); args.putString(WikivoyageArticleContentsFragment.CONTENTS_JSON_KEY, contentsJson); WikivoyageArticleContentsFragment fragment = new WikivoyageArticleContentsFragment(); fragment.setUsedOnMap(false); fragment.setArguments(args); fragment.setTargetFragment(WikivoyageArticleDialogFragment.this, 0); - fragment.show(fm, WikivoyageArticleContentsFragment.TAG); + fragment.show(getChildFragmentManager(), WikivoyageArticleContentsFragment.TAG); } }); + TextView saveBtn = (TextView) mainView.findViewById(R.id.save_button); + saveBtn.setCompoundDrawablesWithIntrinsicBounds( + null, null, getActiveIcon(R.drawable.ic_action_read_later), null + ); + contentWebView = (WebView) mainView.findViewById(R.id.content_web_view); + contentWebView.getSettings().setJavaScriptEnabled(true); return mainView; } @@ -188,14 +190,14 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen if (article == null) { return; } + contentsJson = article.getContentsJson(); WikivoyageLocalDataHelper.getInstance(getMyApplication()).addToHistory(article); - contentWebView.getSettings().setJavaScriptEnabled(true); contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); } - public void moveToAnchor(String id) { + private void moveToAnchor(String id) { contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\")"); } From eb134344716a82751b24fcb8da498a5df32994d9 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 17:10:27 +0300 Subject: [PATCH 16/18] Format and refactor ContentsJsonParser --- .../wikivoyage/data/ContentsJsonParser.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java index 8852c3a5a3..a6686934cd 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java @@ -1,6 +1,6 @@ package net.osmand.plus.wikivoyage.data; -import android.content.Context; +import android.support.annotation.Nullable; import org.json.JSONArray; import org.json.JSONException; @@ -10,15 +10,15 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; - class ContentsJsonParser { - static ContentsContainer parseJsonContents(String contentsJson, Context context) { - LinkedHashMap map = new LinkedHashMap(); - ArrayList listDataHeader = new ArrayList(); - LinkedHashMap> listDataChild = new LinkedHashMap>(); + @Nullable + static ContentsContainer parseJsonContents(String contentsJson) { + LinkedHashMap map = new LinkedHashMap<>(); + ArrayList listDataHeader = new ArrayList<>(); + LinkedHashMap> listDataChild = new LinkedHashMap<>(); - JSONObject reader = null; + JSONObject reader; try { reader = new JSONObject(contentsJson); } catch (JSONException e) { @@ -38,11 +38,11 @@ class ContentsJsonParser { if (level == 2) { listDataHeader.add(reader.names().getString(i)); - secondLevel = new ArrayList(); + secondLevel = new ArrayList<>(); } if (level == 3) { if (secondLevel == null) { - secondLevel = new ArrayList(); + secondLevel = new ArrayList<>(); } secondLevel.add(reader.names().getString(i)); listDataChild.put(listDataHeader.get(listDataHeader.size() - 1), secondLevel); @@ -60,12 +60,12 @@ class ContentsJsonParser { public ArrayList listDataHeader; public LinkedHashMap> listDataChild; - public ContentsContainer(LinkedHashMap map, ArrayList listDataHeader, - LinkedHashMap> listChildData) { + ContentsContainer(LinkedHashMap map, + ArrayList listDataHeader, + LinkedHashMap> listChildData) { this.map = map; this.listDataHeader = listDataHeader; this.listDataChild = listChildData; } - } } From e09d9ec8e4932ea92fdc0ed2e07edfcdaa2dac17 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 17:15:05 +0300 Subject: [PATCH 17/18] Move WikivoyageArticleContentsFragment from package data to package wikivoyage --- .../WikivoyageArticleContentsFragment.java | 13 +++++++------ .../wikivoyage/WikivoyageArticleDialogFragment.java | 1 - .../plus/wikivoyage/data/ContentsJsonParser.java | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) rename OsmAnd/src/net/osmand/plus/wikivoyage/{data => }/WikivoyageArticleContentsFragment.java (94%) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java similarity index 94% rename from OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsFragment.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java index 3f30d4deaa..34d54f6a00 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticleContentsFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java @@ -1,4 +1,4 @@ -package net.osmand.plus.wikivoyage.data; +package net.osmand.plus.wikivoyage; import android.content.Context; import android.content.Intent; @@ -21,6 +21,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.wikivoyage.data.ContentsJsonParser; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -45,7 +46,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag } else { return; } - ContentsJsonParser.ContentsContainer contentsContainer = ContentsJsonParser.parseJsonContents(contentsJson, getContext()); + ContentsJsonParser.ContentsContainer contentsContainer = ContentsJsonParser.parseJsonContents(contentsJson); if (contentsContainer == null) { return; } @@ -69,7 +70,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag @Override public boolean onChildClick(ExpandableListView parent, View v, - int groupPosition, int childPosition, long id) { + int groupPosition, int childPosition, long id) { link = map.get(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition)); sendResult(0); dismiss(); @@ -126,7 +127,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag private Drawable itemChildIcon; public ExpandableListAdapter(Context context, List listDataHeader, - LinkedHashMap> listChildData) { + LinkedHashMap> listChildData) { this.context = context; this.listDataHeader = listDataHeader; this.listDataChild = listChildData; @@ -149,7 +150,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag @Override public View getChildView(int groupPosition, final int childPosition, - boolean isLastChild, View convertView, ViewGroup parent) { + boolean isLastChild, View convertView, ViewGroup parent) { String childText = (String) getChild(groupPosition, childPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this.context @@ -190,7 +191,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag @Override public View getGroupView(int groupPosition, boolean isExpanded, - View convertView, ViewGroup parent) { + View convertView, ViewGroup parent) { String headerTitle = (String) getGroup(groupPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this.context diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 413d3ef7db..a0c5de8a64 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -24,7 +24,6 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; -import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsFragment; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java index a6686934cd..76773c7507 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java @@ -10,10 +10,10 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -class ContentsJsonParser { +public class ContentsJsonParser { @Nullable - static ContentsContainer parseJsonContents(String contentsJson) { + public static ContentsContainer parseJsonContents(String contentsJson) { LinkedHashMap map = new LinkedHashMap<>(); ArrayList listDataHeader = new ArrayList<>(); LinkedHashMap> listDataChild = new LinkedHashMap<>(); @@ -54,7 +54,7 @@ class ContentsJsonParser { return new ContentsContainer(map, listDataHeader, listDataChild); } - static class ContentsContainer { + public static class ContentsContainer { public LinkedHashMap map; public ArrayList listDataHeader; From 8ccfa46a293313098fd5fc2bb3ce8194a4bcaa28 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 17:28:59 +0300 Subject: [PATCH 18/18] Refactor and format WikivoyageContentsFragment --- .../WikivoyageArticleContentsFragment.java | 79 ++++++++++--------- .../WikivoyageArticleDialogFragment.java | 2 +- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java index 34d54f6a00..f6c2924897 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleContentsFragment.java @@ -18,10 +18,10 @@ import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.base.MenuBottomSheetDialogFragment; -import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.wikivoyage.data.ContentsJsonParser; +import net.osmand.plus.wikivoyage.data.ContentsJsonParser.ContentsContainer; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -29,10 +29,12 @@ import java.util.List; public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFragment { - public final static String TAG = "WikivoyageArticleContentsFragment"; - public final static String CONTENTS_JSON_KEY = "contents_json"; - public final static String CONTENTS_LINK_KEY = "contents_link"; - public final static int REQUEST_LINK_CODE = 0; + public static final String TAG = "WikivoyageArticleContentsFragment"; + + public static final String CONTENTS_JSON_KEY = "contents_json"; + public static final String CONTENTS_LINK_KEY = "contents_link"; + + public static final int REQUEST_LINK_CODE = 0; private LinkedHashMap map; private String link; @@ -40,16 +42,16 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag @Override public void createMenuItems(Bundle savedInstanceState) { Bundle args = getArguments(); - String contentsJson; - if (args != null) { - contentsJson = args.getString(CONTENTS_JSON_KEY); - } else { + if (args == null) { return; } - ContentsJsonParser.ContentsContainer contentsContainer = ContentsJsonParser.parseJsonContents(contentsJson); + + String contentsJson = args.getString(CONTENTS_JSON_KEY); + ContentsContainer contentsContainer = ContentsJsonParser.parseJsonContents(contentsJson); if (contentsContainer == null) { return; } + final ArrayList listDataHeader = contentsContainer.listDataHeader; final LinkedHashMap> listDataChild = contentsContainer.listDataChild; @@ -64,15 +66,15 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag expListView.setChildDivider(ContextCompat.getDrawable(getContext(), R.color.color_transparent)); expListView.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT)); + LinearLayout.LayoutParams.MATCH_PARENT) + ); expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { - @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { link = map.get(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition)); - sendResult(0); + sendResult(); dismiss(); return false; } @@ -80,15 +82,17 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag int width = AndroidUtils.getScreenWidth(getActivity()); if (android.os.Build.VERSION.SDK_INT < 18) { - expListView.setIndicatorBounds(width - (AndroidUtils.dpToPx(getContext(), 50)), width - (AndroidUtils.dpToPx(getContext(), 10))); + expListView.setIndicatorBounds(width - (AndroidUtils.dpToPx(getContext(), 50)), + width - (AndroidUtils.dpToPx(getContext(), 10))); } else { - expListView.setIndicatorBoundsRelative(width - (AndroidUtils.dpToPx(getContext(), 50)), width - (AndroidUtils.dpToPx(getContext(), 10))); + expListView.setIndicatorBoundsRelative(width - (AndroidUtils.dpToPx(getContext(), 50)), + width - (AndroidUtils.dpToPx(getContext(), 10))); } expListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { link = map.get(listDataHeader.get(groupPosition)); - sendResult(0); + sendResult(); if (listDataChild.get(listDataHeader.get(groupPosition)) == null) { dismiss(); } @@ -97,19 +101,16 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag }); LinearLayout container = new LinearLayout(getContext()); container.addView(expListView); - BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder() - .setCustomView(container) - .create(); - items.add(favoritesItem); + + items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create()); } - private void sendResult(int requestLinkCode) { + private void sendResult() { Intent intent = new Intent(); intent.putExtra(CONTENTS_LINK_KEY, link); Fragment fragment = getTargetFragment(); if (fragment != null) { - fragment.onActivityResult( - getTargetRequestCode(), requestLinkCode, intent); + fragment.onActivityResult(getTargetRequestCode(), REQUEST_LINK_CODE, intent); } } @@ -121,21 +122,24 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag class ExpandableListAdapter extends OsmandBaseExpandableListAdapter { private Context context; + private List listDataHeader; private LinkedHashMap> listDataChild; + private Drawable itemGroupIcon; private Drawable itemChildIcon; - public ExpandableListAdapter(Context context, List listDataHeader, - LinkedHashMap> listChildData) { + ExpandableListAdapter(Context context, List listDataHeader, + LinkedHashMap> listChildData) { this.context = context; this.listDataHeader = listDataHeader; this.listDataChild = listChildData; - itemGroupIcon = getIcon(R.drawable.ic_action_contents, - isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light); - itemChildIcon = getIcon(R.drawable.ic_action_list_bullet, - isNightMode() ? R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark); + itemGroupIcon = getIcon(R.drawable.ic_action_contents, nightMode + ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light); + itemChildIcon = getIcon(R.drawable.ic_action_list_bullet, nightMode + ? R.color.route_info_unchecked_mode_icon_color + : R.color.ctx_menu_nearby_routes_text_color_dark); } @Override @@ -155,11 +159,13 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this.context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = infalInflater.inflate(R.layout.wikivoyage_contents_list_item, null); + convertView = infalInflater.inflate(R.layout.wikivoyage_contents_list_item, parent, false); } TextView txtListChild = (TextView) convertView.findViewById(R.id.item_label); txtListChild.setText(childText); - txtListChild.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_contents_icon_dark : R.color.wikivoyage_contents_icon_light)); + txtListChild.setTextColor(getResolvedColor(nightMode + ? R.color.wikivoyage_contents_icon_dark + : R.color.wikivoyage_contents_icon_light)); txtListChild.setCompoundDrawablesWithIntrinsicBounds(itemChildIcon, null, null, null); return convertView; @@ -167,11 +173,8 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag @Override public int getChildrenCount(int groupPosition) { - if (this.listDataChild.get(this.listDataHeader.get(groupPosition)) != null) { - return this.listDataChild.get(this.listDataHeader.get(groupPosition)).size(); - } else { - return 0; - } + List list = listDataChild.get(listDataHeader.get(groupPosition)); + return list == null ? 0 : list.size(); } @Override @@ -196,7 +199,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this.context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = infalInflater.inflate(R.layout.wikivoyage_contents_list_item, null); + convertView = infalInflater.inflate(R.layout.wikivoyage_contents_list_item, parent, false); } TextView lblListHeader = (TextView) convertView.findViewById(R.id.item_label); lblListHeader.setText(headerTitle); @@ -216,4 +219,4 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag return true; } } -} \ No newline at end of file +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index a0c5de8a64..f11f48b14f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -104,7 +104,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen fragment.setUsedOnMap(false); fragment.setArguments(args); fragment.setTargetFragment(WikivoyageArticleDialogFragment.this, 0); - fragment.show(getChildFragmentManager(), WikivoyageArticleContentsFragment.TAG); + fragment.show(getFragmentManager(), WikivoyageArticleContentsFragment.TAG); } });