moved rtlLanguages to super class

This commit is contained in:
Chumva 2018-05-08 10:54:40 +03:00
parent f1ec563dbb
commit cbe7d9a73a
3 changed files with 6 additions and 11 deletions

View file

@ -20,6 +20,9 @@ import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragment { public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragment {
@ -82,6 +85,7 @@ public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragme
" }" + " }" +
"}</script>" "}</script>"
+ "</body></html>"; + "</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 WebView contentWebView;
protected TextView selectedLangTv; protected TextView selectedLangTv;

View file

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

View file

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