diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixWebView.java b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixWebView.java index d89b090d8..d4c71ddf2 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixWebView.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixWebView.java @@ -23,6 +23,7 @@ import android.content.Context; import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; import android.net.Uri; +import android.os.Build; import android.os.Environment; import android.os.Handler; import android.os.Message; @@ -31,6 +32,7 @@ import android.util.Log; import android.view.ContextMenu; import android.view.MenuItem; import android.view.View; +import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.Toast; import java.io.File; @@ -64,10 +66,14 @@ public class KiwixWebView extends WebView { this.callback = callback; KiwixApplication.getApplicationComponent().inject(this); // Set the user agent to the current locale so it can be read with navigator.userAgent - getSettings().setUserAgentString(LanguageUtils.getCurrentLocale(context).toString()); + final WebSettings settings = getSettings(); + settings.setUserAgentString(LanguageUtils.getCurrentLocale(context).toString()); + settings.setDomStorageEnabled(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + settings.setAllowUniversalAccessFromFileURLs(true); + } setWebViewClient(new KiwixWebViewClient(callback)); setWebChromeClient(new KiwixWebChromeClient(callback)); - getSettings().setDomStorageEnabled(true); } public void loadPrefs() { diff --git a/create-signed-android-release.sh b/contrib/create-signed-android-release.sh similarity index 58% rename from create-signed-android-release.sh rename to contrib/create-signed-android-release.sh index 7b1a3b25a..acda44e7d 100755 --- a/create-signed-android-release.sh +++ b/contrib/create-signed-android-release.sh @@ -1,40 +1,38 @@ #!/bin/bash function usage { - echo "Usage: $0 kiwix-android.keystore [PACKAGE] [APP_VERSION]" - echo "You must specify the path of the certificate keystore." - exit 1 + echo "Usage: $0 kiwix-android.keystore [PACKAGE] [APP_VERSION]" + echo "You must specify the path of the certificate keystore." + exit 1 } if [ -f "$1" ]; - then - CERTIFICATE=$1 +then + CERTIFICATE=$1 else - usage + usage fi function die { - echo -n "[ERROR] " - echo -n $1 - echo -n " Aborting. -" - exit 1 + echo -n "[ERROR] " + echo -n $1 + echo -n " Aborting." + exit 1 } # default values are guessed from repo (AndroidManifest and res/values/branding) -APP_NAME=`python -c "from xml.dom.minidom import parse; d=parse('res/values/branding.xml'); print([e.childNodes[0].data.strip() for e in d.getElementsByTagName('string') if e.getAttribute('name') == 'app_name'][-1])"` -TARGET_VERSION=`grep "compileSdkVersion" build.gradle | awk '{print $2}'` -BUILD_VERSION=`grep "buildToolsVersion" build.gradle | awk '{print $2}' | sed 's/"//g'` +APP_NAME=$(python -c "from xml.dom.minidom import parse; d=parse('res/values/branding.xml'); print([e.childNodes[0].data.strip() for e in d.getElementsByTagName('string') if e.getAttribute('name') == 'app_name'][-1])") +TARGET_VERSION=$(grep "compileSdkVersion" build.gradle | awk '{print $2}') +BUILD_VERSION=$(grep "buildToolsVersion" build.gradle | awk '{print $2}' | sed 's/"//g') if [ "x$2" != "x" ]; - then - PACKAGE=$2 +then + PACKAGE=$2 fi - if [ "x$3" != "x" ]; - then - APP_VERSION=$3 +then + APP_VERSION=$3 fi ../src/dependencies/android-sdk/tools/android update project -p . -n kiwix -t android-${TARGET_VERSION} diff --git a/contrib/install-kiwix-on-device.sh b/contrib/install-kiwix-on-device.sh new file mode 100755 index 000000000..eecc4b455 --- /dev/null +++ b/contrib/install-kiwix-on-device.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# default value is guessed from repo (AndroidManifest) +PACKAGE=$(python -c "from xml.dom.minidom import parse; d=parse('../app/src/main/AndroidManifest.xml'); print([e.getAttribute('package').strip() for e in d.getElementsByTagName('manifest')][-1])") + +if [ "x$1" != "x" ]; +then + PACKAGE=$1 +fi + +if [ -f ../app/build/outputs/apk/${PACKAGE}-debug.apk ] +then + echo "Uninstalling old Kiwix APK..." + ${ANDROID_HOME}/platform-tools/adb uninstall ${PACKAGE} ; + echo "Installing new Kiwix APK..." + ${ANDROID_HOME}/platform-tools/adb install ../build/outputs/apk/${PACKAGE}-debug.apk +else + echo "No APK file available for package ${PACKAGE} !" +fi diff --git a/make-screenshot.sh b/contrib/make-screenshot.sh similarity index 93% rename from make-screenshot.sh rename to contrib/make-screenshot.sh index d943b9ba0..d2a80c458 100755 --- a/make-screenshot.sh +++ b/contrib/make-screenshot.sh @@ -2,7 +2,7 @@ if hash adb 2>/dev/null then - ADB=`which adb` + ADB=$(which adb) TMP=/data/local/tmp/ FILE=${1:-screenshot.png} PATH=$TMP$FILE diff --git a/install-kiwix-on-device.sh b/install-kiwix-on-device.sh deleted file mode 100755 index 784d27d09..000000000 --- a/install-kiwix-on-device.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# default value is guessed from repo (AndroidManifest) -PACKAGE=`python -c "from xml.dom.minidom import parse; d=parse('app/src/main/AndroidManifest.xml'); print([e.getAttribute('package').strip() for e in d.getElementsByTagName('manifest')][-1])"` - -if [ "x$1" != "x" ]; - then - PACKAGE=$1 -fi - -if [ -f app/build/outputs/apk/${PACKAGE}-debug.apk ] -then - echo "Uninstalling old Kiwix APK..." - ${ANDROID_HOME}/platform-tools/adb uninstall ${PACKAGE} ; - echo "Installing new Kiwix APK..." - ${ANDROID_HOME}/platform-tools/adb install build/outputs/apk/${PACKAGE}-debug.apk -else - echo "No APK file available for package ${PACKAGE} !" -fi