Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-05-08 13:05:16 +02:00
commit bee593c204
14 changed files with 287 additions and 33 deletions

View file

@ -164,6 +164,7 @@ h2 {
line-height: 1.6em;
line-height: var(--main-text-line-height);
letter-spacing: 0.015em;
border-bottom: #eaecf0;
border-bottom: 1px solid var(--divider-color-day);
padding-top: 0%;
padding-bottom: 5%;
@ -174,6 +175,7 @@ h2 {
.nightmode h2 {
color: #999999;
color: var(--headline-text-color-night);
border-bottom: #2d3133;
border-bottom: 1px solid var(--divider-color-night);
font-weight: 100;
}

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:paddingLeft="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
tools:src="@drawable/list_destination" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingBottom="@dimen/wikilink_bottom_sheet_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start"
android:paddingTop="@dimen/content_padding_small">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="@dimen/text_margin_small"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Some title" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:lineSpacingMultiplier="@dimen/text_button_line_spacing_multiplier"
android:textSize="@dimen/default_sub_text_size"
tools:text="Some description" />
</LinearLayout>
</FrameLayout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingBottom="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingTop="@dimen/wikilink_bottom_sheet_padding"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Some title" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Some description" />
</LinearLayout>

View file

@ -73,6 +73,22 @@
android:layout_marginStart="@dimen/content_padding"
tools:src="@drawable/ic_action_import"/>
<Button
android:id="@+id/button_action"
android:layout_width="wrap_content"
android:layout_height="33dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:background="@drawable/buy_btn_background_light"
android:minWidth="40dp"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:text="@string/get_plugin"
android:textColor="@color/buy_button_color"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>
<View

View file

@ -212,4 +212,6 @@
<dimen name="wikivoyage_start_editing_card_text_image_padding">60dp</dimen>
<dimen name="wikivoyage_show_images_dialog_buttons_height">66dp</dimen>
<dimen name="wikilink_bottom_sheet_padding">21dp</dimen>
</resources>

View file

@ -299,6 +299,8 @@
<dimen name="wikivoyage_explore_card_image_height">144dp</dimen>
<dimen name="wikilink_bottom_sheet_padding">14dp</dimen>
<dimen name="text_button_letter_spacing" format="float">0.01</dimen>
<dimen name="text_button_line_spacing_multiplier" format="float">1.2</dimen>
</resources>

View file

@ -9,6 +9,11 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="open_wikipedia_link_online">Open wikipedia link online</string>
<string name="open_wikipedia_link_online_description">OsmAnd will redirect you to the browser and open the link online.</string>
<string name="read_wikipedia_offline_description">Get OsmAnd Live subscription to read Wikipedia and Wikivoyage articles offline.</string>
<string name="how_to_open_link">How to open link?</string>
<string name="read_wikipedia_offline">Read Wikipedia offline</string>
<string name="download_all">Download all</string>
<string name="shared_string_restart">Restart</string>
<string name="show_images">Show images</string>

View file

@ -20,6 +20,9 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragment {
@ -82,6 +85,7 @@ public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragme
" }" +
"}</script>"
+ "</body></html>";
protected static final Set<String> rtlLanguages = new HashSet<>(Arrays.asList("ar","dv","he","iw","fa","nqo","ps","sd","ug","ur","yi"));
protected WebView contentWebView;
protected TextView selectedLangTv;

View file

@ -0,0 +1,113 @@
package net.osmand.plus.wikipedia;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.view.View;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
import net.osmand.plus.wikivoyage.article.WikivoyageArticleWikiLinkFragment;
public class WikipediaArticleWikiLinkFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = WikivoyageArticleWikiLinkFragment.class.getSimpleName();
public static final String ARTICLE_URL_KEY = "article_url";
private String articleUrl;
@Override
public void createMenuItems(Bundle savedInstanceState) {
final Context ctx = getContext();
if (ctx == null) {
return;
}
Bundle args = getArguments();
if (args != null) {
articleUrl = args.getString(ARTICLE_URL_KEY);
}
BaseBottomSheetItem wikiLinkitem = new BottomSheetItemWithDescription.Builder()
.setDescription(articleUrl)
.setTitle(getString(R.string.how_to_open_link))
.setLayoutId(R.layout.bottom_sheet_item_title_with_descr)
.create();
items.add(wikiLinkitem);
items.add(new TitleDividerItem(ctx));
Drawable osmandLiveIcon = getIcon(R.drawable.ic_action_subscription_osmand_live, 0);
Drawable viewOnlineIcon = getIcon(R.drawable.ic_world_globe_dark, nightMode
? R.color.wikivoyage_contents_parent_icon_dark : R.color.wikivoyage_contents_parent_icon_light);
BaseBottomSheetItem wikiArticleOnlineItem = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.open_wikipedia_link_online_description))
.setIcon(viewOnlineIcon)
.setTitle(getString(R.string.open_wikipedia_link_online))
.setLayoutId(R.layout.bottom_sheet_item_in_frame_with_descr_and_icon)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WikipediaDialogFragment.showFullArticle(ctx, Uri.parse(articleUrl), nightMode);
dismiss();
}
})
.create();
items.add(wikiArticleOnlineItem);
items.add(new DividerHalfItem(ctx));
BaseBottomSheetItem wikiArticleOfflineItem = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.read_wikipedia_offline_description))
.setIcon(osmandLiveIcon)
.setTitle(getString(R.string.read_wikipedia_offline))
.setLayoutId(R.layout.bottom_sheet_item_in_frame_with_descr_and_icon)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager fm = getFragmentManager();
if (fm != null) {
ChoosePlanDialogFragment.showWikivoyageInstance(fm);
}
dismiss();
}
})
.create();
items.add(wikiArticleOfflineItem);
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}
@Override
protected int getBgColorId() {
return nightMode ? R.color.wikivoyage_bottom_bar_bg_dark : R.color.bg_color_light;
}
public static boolean showInstance(@NonNull FragmentManager fm,
@NonNull String articleUrl) {
try {
Bundle args = new Bundle();
args.putString(ARTICLE_URL_KEY, articleUrl);
WikipediaArticleWikiLinkFragment fragment = new WikipediaArticleWikiLinkFragment();
fragment.setArguments(args);
fragment.show(fm, TAG);
return true;
} catch (RuntimeException e) {
return false;
}
}
}

View file

@ -38,9 +38,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.util.Algorithms;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@ -134,9 +132,7 @@ public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment {
@NonNull
protected String createHtmlContent() {
StringBuilder sb = new StringBuilder(HEADER_INNER);
String[] rtlLanguages = new String[]{"ar", "dv", "he", "iw", "fa", "nqo", "ps", "sd", "ug", "ur", "yi"};
Set<String> rtls = new HashSet<>(Arrays.asList(rtlLanguages));
String bodyTag = rtls.contains(langSelected) ? "<body dir=\"rtl\">\n" : "<body>\n";
String bodyTag = rtlLanguages.contains(langSelected) ? "<body dir=\"rtl\">\n" : "<body>\n";
sb.append(bodyTag);
String nightModeClass = nightMode ? " nightmode" : "";
sb.append("<div class=\"main");

View file

@ -42,11 +42,8 @@ import net.osmand.util.Algorithms;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static net.osmand.plus.OsmandSettings.WikiArticleShowImages.OFF;
@ -311,9 +308,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
@NonNull
protected String createHtmlContent() {
StringBuilder sb = new StringBuilder(HEADER_INNER);
String[] rtlLanguages = new String[]{"ar","dv","he","iw","fa","nqo","ps","sd","ug","ur","yi"};
Set<String> rtls = new HashSet<>(Arrays.asList(rtlLanguages));
String bodyTag = rtls.contains(article.getLang()) ? "<body dir=\"rtl\">\n" : "<body>\n";
String bodyTag = rtlLanguages.contains(article.getLang()) ? "<body dir=\"rtl\">\n" : "<body>\n";
sb.append(bodyTag);
String nightModeClass = nightMode ? " nightmode" : "";
String imageTitle = article.getImageTitle();

View file

@ -16,7 +16,6 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
@ -48,12 +47,13 @@ public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFrag
wikiRegion = args.getString(WIKI_REGION);
}
}
items.add(new TitleItem(getString(R.string.how_to_open_wiki_title)));
BaseBottomSheetItem wikiLinkitem = new TitleItem.Builder().setTitle(articleUrl)
.setTitleColorId(nightMode
BaseBottomSheetItem wikiLinkitem = new BottomSheetItemWithDescription.Builder()
.setDescription(articleUrl)
.setDescriptionColorId(nightMode
? R.color.wikivoyage_contents_parent_icon_dark : R.color.wikivoyage_contents_parent_icon_light)
.setLayoutId(R.layout.bottom_sheet_item_title)
.setTitle(getString(R.string.how_to_open_wiki_title))
.setLayoutId(R.layout.bottom_sheet_item_title_with_descr)
.create();
items.add(wikiLinkitem);
items.add(new TitleDividerItem(getContext()));
@ -69,7 +69,7 @@ public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFrag
getString(R.string.download_wiki_region_placeholder) : wikiRegion))
.setIcon(downloadIcon)
.setTitle(getString(R.string.download_wikipedia_label))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
.setLayoutId(R.layout.bottom_sheet_item_in_frame_with_descr_and_icon)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -92,7 +92,7 @@ public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFrag
.setDescription(getString(R.string.open_in_browser_wiki_description))
.setIcon(viewOnlineIcon)
.setTitle(getString(R.string.open_in_browser_wiki))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
.setLayoutId(R.layout.bottom_sheet_item_in_frame_with_descr_and_icon)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -111,11 +111,6 @@ public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFrag
outState.putString(WIKI_REGION, wikiRegion);
}
@Override
protected boolean useScrollableItemsContainer() {
return false;
}
@Override
protected int getBgColorId() {
return nightMode ? R.color.wikivoyage_bottom_bar_bg_dark : R.color.bg_color_light;

View file

@ -21,6 +21,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadResources;
@ -228,8 +229,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() {
@Override
public void onPrimaryButtonClick() {
IndexItem[] items = neededIndexItems.toArray(new IndexItem[neededIndexItems.size()]);
downloadManager.startDownload(getMyActivity(), items);
downloadManager.startDownload(getMyActivity(), getAllItemsForDownload());
adapter.updateNeededMapsCard();
}
@ -245,19 +245,37 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
@Override
public void onIndexItemClick(IndexItem item) {
DownloadIndexesThread downloadThread = app.getDownloadThread();
if (downloadThread.isDownloading(item)) {
downloadThread.cancelDownload(item);
if (item.getType() == DownloadActivityType.WIKIPEDIA_FILE && !Version.isPaidVersion(app)) {
FragmentManager fm = getFragmentManager();
if (fm != null) {
ChoosePlanDialogFragment.showWikipediaInstance(fm);
}
} else {
downloadManager.startDownload(getMyActivity(), item);
DownloadIndexesThread downloadThread = app.getDownloadThread();
if (downloadThread.isDownloading(item)) {
downloadThread.cancelDownload(item);
} else if (!item.isDownloaded()) {
downloadManager.startDownload(getMyActivity(), item);
}
adapter.updateNeededMapsCard();
}
adapter.updateNeededMapsCard();
}
});
adapter.setNeededMapsCard(neededMapsCard);
}
}
private IndexItem[] getAllItemsForDownload() {
boolean paidVersion = Version.isPaidVersion(getMyApplication());
ArrayList<IndexItem> res = new ArrayList<>();
for (IndexItem item : neededIndexItems) {
if (!item.isDownloaded() && (paidVersion || item.getType() != DownloadActivityType.WIKIPEDIA_FILE)) {
res.add(item);
}
}
return res.toArray(new IndexItem[res.size()]);
}
@NonNull
private String getWikivoyageFileName() {
File selectedTravelBook = getMyApplication().getTravelDbHelper().getSelectedTravelBook();

View file

@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@ -12,6 +13,8 @@ import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.IndexItem;
@ -59,6 +62,8 @@ public class TravelNeededMapsCard extends BaseTravelCard {
? R.string.maps_you_need_descr : R.string.no_index_file_to_download);
adjustChildCount(holder.itemsContainer);
boolean paidVersion = Version.isPaidVersion(app);
for (int i = 0; i < items.size(); i++) {
IndexItem item = items.get(i);
boolean downloading = downloadThread.isDownloading(item);
@ -80,9 +85,17 @@ public class TravelNeededMapsCard extends BaseTravelCard {
((TextView) view.findViewById(R.id.description)).setText(getItemDescription(item));
ImageView iconAction = (ImageView) view.findViewById(R.id.icon_action);
iconAction.setVisibility(item.isDownloaded() ? View.GONE : View.VISIBLE);
if (!item.isDownloaded()) {
iconAction.setImageDrawable(downloading ? cancelIcon : downloadIcon);
Button buttonAction = (Button) view.findViewById(R.id.button_action);
if (item.isDownloaded()) {
iconAction.setVisibility(View.GONE);
buttonAction.setVisibility(View.GONE);
} else {
boolean showBtn = !paidVersion && item.getType() == DownloadActivityType.WIKIPEDIA_FILE;
iconAction.setVisibility(showBtn ? View.GONE : View.VISIBLE);
buttonAction.setVisibility(showBtn ? View.VISIBLE : View.GONE);
if (!showBtn) {
iconAction.setImageDrawable(downloading ? cancelIcon : downloadIcon);
}
}
ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);