Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
24f6219cfe
4 changed files with 32 additions and 2 deletions
|
@ -407,6 +407,7 @@ dependencies {
|
|||
compile fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
|
||||
|
||||
compile 'commons-logging:commons-logging-api:1.1'
|
||||
compile 'commons-codec:commons-codec:1.11'
|
||||
compile 'it.unibo.alice.tuprolog:tuprolog:3.2.1'
|
||||
compile 'org.beanshell:bsh-core:2.0b4'
|
||||
compile 'fr.univ-valenciennes:bzip2:1.0'
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/action_bar_image_container"
|
||||
android:layout_width="@dimen/action_bar_image_width_land"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/actionModeBackground"
|
||||
|
|
|
@ -140,8 +140,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
if (article == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = HEADER_INNER + article.getContent() + FOOTER_INNER;
|
||||
String articleTitle = "<h1>" + article.getTitle() + "</h1>";
|
||||
String content = HEADER_INNER + articleTitle + article.getContent() + FOOTER_INNER;
|
||||
contentWebView.loadDataWithBaseURL(getBaseUrl(), content, "text/html", "UTF-8", null);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
package net.osmand.plus.wikivoyage.data;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
public class WikivoyageArticle {
|
||||
|
||||
private static final String IMAGE_ROOT_URL = "https://upload.wikimedia.org/wikipedia/commons/";
|
||||
private static final String THUMB_PREFIX = "320px-";
|
||||
|
||||
String id;
|
||||
String title;
|
||||
String content;
|
||||
|
@ -59,4 +68,23 @@ public class WikivoyageArticle {
|
|||
public String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getThumbImageUrl(@NonNull String imageTitle) {
|
||||
String[] hash = getHash(imageTitle);
|
||||
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + THUMB_PREFIX + imageTitle;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getImageUrl(@NonNull String imageTitle) {
|
||||
String[] hash = getHash(imageTitle);
|
||||
return IMAGE_ROOT_URL + hash[0] + "/" + hash[1] + "/" + imageTitle;
|
||||
}
|
||||
|
||||
@Size(2)
|
||||
@NonNull
|
||||
private static String[] getHash(@NonNull String s) {
|
||||
String md5 = new String(Hex.encodeHex(DigestUtils.md5(s.replace(" ", "_"))));
|
||||
return new String[]{md5.substring(0, 1), md5.substring(0, 2)};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue