X-Git-Url: https://git.mdrn.pl/wl-mobile.git/blobdiff_plain/4aa83d4ec5f1b6d86b922e022df16de4fe373ea8..91d4143f8e07f469843b2265ce3120bbd64e1fde:/src/pl/org/nowoczesnapolska/wloffline/MenuInterface.java diff --git a/src/pl/org/nowoczesnapolska/wloffline/MenuInterface.java b/src/pl/org/nowoczesnapolska/wloffline/MenuInterface.java new file mode 100644 index 0000000..43417f9 --- /dev/null +++ b/src/pl/org/nowoczesnapolska/wloffline/MenuInterface.java @@ -0,0 +1,63 @@ +/* + * This file is part of WolneLektury-Mobile, licensed under GNU Affero GPLv3 or later. + * Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. + */ + +package pl.org.nowoczesnapolska.wloffline; + +import org.json.JSONArray; +import org.json.JSONException; + +import android.graphics.Color; +import android.webkit.WebView; + +import com.phonegap.api.Plugin; +import com.phonegap.api.PluginResult; + +public class MenuInterface extends Plugin{ + + public static String infoLabel = "Proszę czekać..."; + public static Boolean infoEnabled = false; + public static Boolean nightEnabled = false; + public static WebView view; + + @Override + public PluginResult execute(String action, JSONArray args, String callbackId) { + if (action.equals("setInfoButton")) { + try { + return this.setInfoButton(args.getString(0), args.getString(1)); + } catch (JSONException e) { + return new PluginResult(PluginResult.Status.ERROR, "Param errrors"); + } + } + else if (action.equals("setNightMode")) { + try { + return this.setNightMode(args.getString(0)); + } catch (JSONException e) { + return new PluginResult(PluginResult.Status.ERROR, "Param errrors"); + } + } + else { + return new PluginResult(PluginResult.Status.INVALID_ACTION); + } + } + + private PluginResult setInfoButton(String label, String enabled) { + infoLabel = label; + infoEnabled = enabled.equals("true"); + + return new PluginResult(PluginResult.Status.OK); + } + + private PluginResult setNightMode(String enabled) { + nightEnabled = enabled.equals("true"); + if (nightEnabled) { + view.setBackgroundColor(0x222222ff); + } + else { + view.setBackgroundColor(Color.WHITE); + } + + return new PluginResult(PluginResult.Status.OK); + } +}