diff --git a/README.md b/README.md index a00b2e9..fc0295c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ By adding this Cordova plugin the Cordova app becomes the the homescreen (also k To add plugin into existing Cordova / Phonegap application: - cordova plugin add https://github.com/honza889/cordova-plugin-kiosk.git + cordova plugin add https://github.com/honza889/cordova-plugin-kiosk.git --variable KIOSK_LABEL='My Kiosk Laucher Label' + +If no `KIOSK_LABEL` value is defined, the default `Cordova Kiosk Mode` is used. The `AndroidManifest.xml` should be updated immediately. If not, you can force it by removing and re-adding Android platform: diff --git a/android/KioskActivity.java b/android/KioskActivity.java index e0d3520..4e76c9b 100644 --- a/android/KioskActivity.java +++ b/android/KioskActivity.java @@ -39,7 +39,9 @@ protected void onStart() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()); if(Build.VERSION.SDK_INT >= 23) { sp.edit().putBoolean(PREF_KIOSK_MODE, false).commit(); - checkDrawOverlayPermission(); + if(checkDrawOverlayPermission()){ + addOverlay(); + } } else { sp.edit().putBoolean(PREF_KIOSK_MODE, true).commit(); addOverlay(); @@ -48,11 +50,15 @@ protected void onStart() { } //http://stackoverflow.com/questions/7569937/unable-to-add-window-android-view-viewrootw44da9bc0-permission-denied-for-t @TargetApi(Build.VERSION_CODES.M) - public void checkDrawOverlayPermission() { + public boolean checkDrawOverlayPermission() { if (!Settings.canDrawOverlays(this.getApplicationContext())) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, REQUEST_CODE); + return false; + } + else{ + return true; } } diff --git a/plugin.xml b/plugin.xml index 65eadb3..f36dd26 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ + id="cordova-plugin-kiosk" version="0.2.0"> Cordova Kiosk Mode Jan Kalina @@ -28,6 +28,8 @@ + + @@ -56,7 +58,7 @@ - +