mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-12 17:08:59 -04:00
Implement getLanguage() to get the ZIM file language code
This commit is contained in:
parent
3e93bff32a
commit
105f730b11
17
kiwix.c
17
kiwix.c
@ -99,6 +99,23 @@ JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getId(JNIEnv *env,
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getLanguage(JNIEnv *env, jobject obj) {
|
||||||
|
jstring language;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&readerLock);
|
||||||
|
if (reader != NULL) {
|
||||||
|
try {
|
||||||
|
std::string cLanguage = reader->getLanguage();
|
||||||
|
language = c2jni(cLanguage, env);
|
||||||
|
} catch (exception &e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&readerLock);
|
||||||
|
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getMimeType(JNIEnv *env, jobject obj, jstring url) {
|
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getMimeType(JNIEnv *env, jobject obj, jstring url) {
|
||||||
jstring mimeType;
|
jstring mimeType;
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,6 +22,7 @@ package org.kiwix.kiwixmobile;
|
|||||||
public class JNIKiwix {
|
public class JNIKiwix {
|
||||||
public native String getMainPage();
|
public native String getMainPage();
|
||||||
public native String getId();
|
public native String getId();
|
||||||
|
public native String getLanguage();
|
||||||
public native String getMimeType(String url);
|
public native String getMimeType(String url);
|
||||||
public native boolean loadZIM(String path);
|
public native boolean loadZIM(String path);
|
||||||
public native byte[] getContent(String url, JNIKiwixString mimeType, JNIKiwixInt size);
|
public native byte[] getContent(String url, JNIKiwixString mimeType, JNIKiwixInt size);
|
||||||
@ -30,7 +31,6 @@ public class JNIKiwix {
|
|||||||
public native boolean getPageUrlFromTitle(String title, JNIKiwixString url);
|
public native boolean getPageUrlFromTitle(String title, JNIKiwixString url);
|
||||||
public native boolean getTitle(JNIKiwixString title);
|
public native boolean getTitle(JNIKiwixString title);
|
||||||
public native boolean getDescription(JNIKiwixString title);
|
public native boolean getDescription(JNIKiwixString title);
|
||||||
public native boolean getLanguage(JNIKiwixString language);
|
|
||||||
public native boolean getDate(JNIKiwixString language);
|
public native boolean getDate(JNIKiwixString language);
|
||||||
public native boolean getFavicon(JNIKiwixString content, JNIKiwixString mimeType);
|
public native boolean getFavicon(JNIKiwixString content, JNIKiwixString mimeType);
|
||||||
public native boolean getCreator(JNIKiwixString creator);
|
public native boolean getCreator(JNIKiwixString creator);
|
||||||
|
@ -92,6 +92,14 @@ public class ZimContentProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLanguage() {
|
||||||
|
if (jniKiwix == null || zimFileName == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return jniKiwix.getLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean searchSuggestions(String prefix, int count) {
|
public static boolean searchSuggestions(String prefix, int count) {
|
||||||
if (jniKiwix == null || zimFileName == null) {
|
if (jniKiwix == null || zimFileName == null) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user