From 0744150577f721a79b05a50017c5579a54ebbf63 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Tue, 27 Nov 2018 19:14:35 +0100 Subject: [PATCH] turn nanodroid_nlpbackend into an array for better code --- CommonInstaller | 57 ++++++++++++++++++++++++++-------------- doc/.nanodroid-setup | 2 +- doc/AlterInstallation.md | 15 +++++------ 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/CommonInstaller b/CommonInstaller index b2b39e6..5aa9f4c 100644 --- a/CommonInstaller +++ b/CommonInstaller @@ -687,26 +687,27 @@ install_microg () { fi fi - case ${nanodroid_nlpbackend} in - 0 ) NLPBACKEND="" - ui_print " << with microG [Nominatim]" ;; - 1 ) NLPBACKEND="nlpBackendDejavu" - ui_print " << with microG [Déjà Vu, Nominatim]" ;; - 2 ) NLPBACKEND="nlpBackendIchnaea" - ui_print " << with microG [Ichnaea, Nominatim]" ;; - 3 ) NLPBACKEND="nlpBackendApple" - ui_print " << with microG [Apple, Nominatim]" ;; - 4 ) NLPBACKEND="nlpBackendDejavu nlpBackendIchnaea" - ui_print " << with microG [Déjà Vu, Ichnaea, Nominatim]" ;; - 5 ) NLPBACKEND="nlpBackendDejavu nlpBackendApple" - ui_print " << with microG [Déjà Vu, Apple, Nominatim]" ;; - 6 ) NLPBACKEND="nlpBackendIchnaea nlpBackendApple" - ui_print " << with microG [Ichnaea, Apple, Nominatim]" ;; - 7 ) NLPBACKEND="nlpBackendDejavu nlpBackendIchnaea nlpBackendApple" - ui_print " << with microG [Déjà Vu, Ichnaea, Apple, Nominatim]" ;; - esac + NLPBACKEND="nlpBackendNominatim" + NLPSTRING="Nominatim" - for app in ${NLPBACKEND} nlpBackendNominatim; do + if [ "${nanodroid_nlpbackend[0]}" -eq 1 ]; then + NLPBACKEND="${NLPBACKEND} nlpBackendDejavu" + NLPSTRING="${NLPSTRING}, Déjà Vu" + fi + + if [ "${nanodroid_nlpbackend[1]}" -eq 1 ]; then + NLPBACKEND="${NLPBACKEND} nlpBackendIchnaea" + NLPSTRING="${NLPSTRING}, Ichnaea" + fi + + if [ "${nanodroid_nlpbackend[2]}" -eq 1 ]; then + NLPBACKEND="${NLPBACKEND} nlpBackendApple" + NLPSTRING="${NLPSTRING}, Apple" + fi + + ui_print " << with microg [${NLPSTRING}]" + + for app in ${NLPBACKEND}; do nanodroid_install_apk ${app} done @@ -1375,7 +1376,23 @@ check_cfg_setup () { [ -z "${nanodroid_gsync}" ] && set_prop nanodroid_gsync 0 [ -z "${nanodroid_forcesystem}" ] && set_prop nanodroid_forcesystem 0 [ -z "${nanodroid_swipe}" ] && set_prop nanodroid_swipe 0 - [ -z "${nanodroid_nlpbackend}" ] && set_prop nanodroid_nlpbackend 1 + + [ -z "${nanodroid_nlpbackend}" ] && set_prop nanodroid_nlpbackend "(1 0 0)" + + # in NanoDroid <= 20.2 nanodroid_nlpbackend is an integer + # starting with 20.3 it's an array, migrate the value + if [ "${#nanodroid_nlpbackend[0]}" -eq 1 ]; then + case "${nanodroid_nlpbackend}" in + 0 ) tmp_prop="(0 0 0)" + 1 ) tmp_prop="(1 0 0)" + 2 ) tmp_prop="(0 1 0)" + 3 ) tmp_prop="(1 1 0)" + esac + + sed -e '/^nanodroid_nlpbackend/d' -i "${cfg_setup}" + set_prop nanodroid_nlpbackend "${tmp_prop}" + fi + [ -z "${nanodroid_bash}" ] && set_prop nanodroid_bash 1 [ -z "${nanodroid_nano}" ] && set_prop nanodroid_nano 1 [ -z "${nanodroid_utils}" ] && set_prop nanodroid_utils 1 diff --git a/doc/.nanodroid-setup b/doc/.nanodroid-setup index 2f1bd03..0c3c899 100644 --- a/doc/.nanodroid-setup +++ b/doc/.nanodroid-setup @@ -10,7 +10,7 @@ nanodroid_init=1 nanodroid_gsync=0 nanodroid_swipe=0 nanodroid_forcesystem=0 -nanodroid_nlpbackend=3 +nanodroid_nlpbackend=(1 0 0) nanodroid_nano=1 nanodroid_bash=1 nanodroid_utils=1 diff --git a/doc/AlterInstallation.md b/doc/AlterInstallation.md index a9b9b96..35823b2 100644 --- a/doc/AlterInstallation.md +++ b/doc/AlterInstallation.md @@ -28,7 +28,7 @@ nanodroid_init=1 nanodroid_gsync=0 nanodroid_swipe=0 nanodroid_forcesystem=0 -nanodroid_nlpbackend=3 +nanodroid_nlpbackend=(1 0 0) nanodroid_bash=1 nanodroid_nano=1 nanodroid_utils=1 @@ -46,7 +46,7 @@ nanodroid_mapsv1=1 nanodroid_gsync=0 nanodroid_swipe=0 nanodroid_forcesystem=0 -nanodroid_nlpbackend=1 +nanodroid_nlpbackend=(1 0 0) ``` the **F-Droid** (nanodroid_fdroid is always 1) and **Bromite WebView** pckage supports the following options @@ -130,13 +130,12 @@ whether to provide Swipe libraries whether to force system mode installation, regardless whether Magisk is installed -`nanodroid_nlpbackend=[0|1|2]` +`nanodroid_nlpbackend=([0|1] [0|1] [0|1])` -what location backend for microG to install -* 0 = no location backend -* 1 = Déjà Vu location backend -* 2 = Ichnaea (Mozilla) location backend -* 3 = Déjà Vu and Ichnaea location backends +what location backends for microG to install +* 1st element 0|1 = Déjà Vu location backend +* 2nd element 0|1 = Ichnaea (Mozilla) location backend +* 3rd element 0|1 = Apple location backend `nanodroid_bash=[0|1]`