From 6e087a91530a9731db6dd4b41bf69eda3409c0e9 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 8 Sep 2011 14:49:31 +0200 Subject: [PATCH] night mode, new spinner --- assets/www/css/style.css | 25 +++++++++++++ assets/www/img/spinner.gif | Bin 2608 -> 0 bytes assets/www/img/spinner.png | Bin 0 -> 1439 bytes assets/www/js/main.js | 6 ++-- assets/www/js/menu.js | 9 +++++ assets/www/js/menuinterface.js | 11 ++++++ assets/www/js/view.js | 34 ++++++++++++++++-- .../nowoczesnapolska/wlmobi/Catalogue.java | 14 ++++++-- .../wlmobi/MenuInterface.java | 24 +++++++++++++ 9 files changed, 116 insertions(+), 7 deletions(-) delete mode 100644 assets/www/img/spinner.gif create mode 100644 assets/www/img/spinner.png diff --git a/assets/www/css/style.css b/assets/www/css/style.css index 8b17fb2..83271f0 100644 --- a/assets/www/css/style.css +++ b/assets/www/css/style.css @@ -6,13 +6,38 @@ body { padding: 0; margin: 0; + background: white; font-family: verdana, arial, helvetica, sans-serif; } +.night-mode { + color: #ddd; + background: #222; +} +.night-mode #search { + color: #ddd; + background: #222; +} + .spinner { margin-top: 4em; text-align: center; } +@-webkit-keyframes rotate { + from { + -webkit-transform: rotate(0deg); + } + to { + -webkit-transform: rotate(360deg); + } +} +.spinner img { + -webkit-animation-name: rotate; + -webkit-animation-duration: 4s; + -webkit-animation-iteration-count: 10; + -webkit-animation-direction: right; + -webkit-animation-timing-function:linear; +} #spinnertext { margin-top: 2em; font-size: .7em; diff --git a/assets/www/img/spinner.gif b/assets/www/img/spinner.gif deleted file mode 100644 index c69e937232b24ea30f01c68bbd2ebc798dcecfcb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2608 zcmdVcdr(tX9tZGC9yiG~=H_*Q-0%n(kWqP*D#hw{AQu8;1%gl-Hrf&{2?48KX;hHy z3Ze*zEz4t3XdUFyLbNPUYlA`|B}P=N1fqtL1*}S;87#|-W9v<#G;ul(e%d3)N(^9c$d2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KcGR-*Gl} zx3oG)bzf|65dBxD-;2ZCp??K;+TuQ9onnK?==5hzbkb^r_g>z4#D8mcv8(+XdoszA zCx-qhdgxMNMotj}SiL_6V(tLcsK7(M(r(%u<}QrVfOvyK6_;~NOTlPGfX@M7S5YQF z&*$(ylJMHJt^_aQeu{C6NaTE$G3HNN@_SnN8YcaKn%`)F@~L1x+ah7-gEJPpc6w%3 zyX}r+Qk$4RHZzfH){e~F*qJ{d*L8a6n4;U?+{de0-t)mal#TVxe)3F}^UBh+zd T)6_**#cgp_+?JL9(ew3BlNF>u diff --git a/assets/www/img/spinner.png b/assets/www/img/spinner.png new file mode 100644 index 0000000000000000000000000000000000000000..bad5a12904df26c1a7106b7a015a2290a1c58e42 GIT binary patch literal 1439 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabRA=0U}gyL32_B-@qqmdk}xE-p8*Yl zqz<4XgqrOPvYQy?4>5}^U{ycDA{mnYCMc z_8ur&wMS;z9{B}(ROatdo3}@OE(mGN-J>}NgtUNYHV7fq!`M2r_vp;t4M)0jc7xE| zJq8E%@^0BHGHkUk6`fr{rh)d@CE`1c?9m5m-`v+?`H%$e(heV`Fqr1VTBob2od{~T>KFY zm&Hi2h{Oq(DtRp+49ozVN`m}?5g8#mGq19~qkqP{(77weS4n(Oq`oJ zBc}2Q_!qB6~_ zCyyN5wROYtc~d&;%L}qo5)vQZyY=Vy&u^dKzkTua#-SrePoBMW>*4DUzkYRYuWkgo znyth&q9i1VVA(zzRHd>ASgU*>0EU{v#T zaSX9IoqAE1uh~JM?cv7zTs%!}(hCeYSkhcs+1R^UQe@Yap70W3YFzo)Cv>kH|AoAt zoYsfapBv`4$t~NxJ+$-ktSYJYf1c0wo{`DhduDyAZE1dan2CNl^Igdm4YL|2MzKXD zBqc2BYP2>m3J5;wz|O;C!t$7j`OCZ7W0Gg|Ug!$UU395Q`n||hu@1k$%*Gc`2IHw! zdrQ;mZ-rTYKWuT8_g}*8S90h7ZhFfwF=(EA%sMOY$x3Aht2p?cJX@ zkH_XTCLQpW)bMjqYhyKk;~mypO&3@h7sO6zc2QNZ@(f{G z6wJWd;rB^JV6KW5<3-QtREZz+f-e5AFPyk!=DjS_*go$2uh!Ym&Rr;AS`cCl3_%7@ LS3j3^P6"; + self._content.innerHTML = ""; + self._content.innerHTML = "
" + text +"
"; setOffset(0); }; @@ -444,6 +448,32 @@ var View = new function() { return false; } - + self.getNightMode = function() { + night_mode = window.localStorage.getItem('View.night_mode'); + if (night_mode === undefined) + return false; + else + return !!night_mode; + }; + + self.checkNightMode = function() { + night_mode = self.getNightMode(); + if (night_mode) { + document.body.setAttribute("class", "night-mode"); + } + else { + document.body.setAttribute("class", ""); + } + }; + + self.setNightMode = function(night_mode) { + night_mode = night_mode ? "1" : ""; + window.localStorage.setItem('View.night_mode', night_mode); + self.checkNightMode(); + }; + + self.toggleNightMode = function(night_mode) { + self.setNightMode(!self.getNightMode()); + }; } diff --git a/src/pl/org/nowoczesnapolska/wlmobi/Catalogue.java b/src/pl/org/nowoczesnapolska/wlmobi/Catalogue.java index 2cf726e..d296270 100644 --- a/src/pl/org/nowoczesnapolska/wlmobi/Catalogue.java +++ b/src/pl/org/nowoczesnapolska/wlmobi/Catalogue.java @@ -5,6 +5,7 @@ package pl.org.nowoczesnapolska.wlmobi; +import android.graphics.Color; import android.os.Bundle; import android.view.KeyEvent; import android.view.Menu; @@ -23,18 +24,22 @@ public class Catalogue extends DroidGap { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + super.loadUrl("file:///android_asset/www/index.html"); + MenuInterface.view = appView; + WebSettings settings = this.appView.getSettings(); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); } - @Override + @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, 1, 1, "Początek"); - menu.add(Menu.NONE, 2, 2, MenuInterface.infoLabel); - menu.add(Menu.NONE, 3, 3, "Dodaj zakładkę"); + menu.add(Menu.NONE, 3, 2, "Dodaj zakładkę"); + menu.add(Menu.NONE, 2, 3, MenuInterface.infoLabel); + menu.add(Menu.NONE, 4, 4, "Tryb nocny"); //MenuInflater inflater = getMenuInflater(); //inflater.inflate(R.menu.game_menu, menu); return super.onCreateOptionsMenu(menu); @@ -69,6 +74,9 @@ public class Catalogue extends DroidGap { case 3: this.appView.loadUrl("javascript:Menu.bookmark();"); break; + case 4: + this.appView.loadUrl("javascript:Menu.toggleNightMode();"); + break; default: return super.onOptionsItemSelected(item); } diff --git a/src/pl/org/nowoczesnapolska/wlmobi/MenuInterface.java b/src/pl/org/nowoczesnapolska/wlmobi/MenuInterface.java index 28f3f2e..064d4de 100644 --- a/src/pl/org/nowoczesnapolska/wlmobi/MenuInterface.java +++ b/src/pl/org/nowoczesnapolska/wlmobi/MenuInterface.java @@ -8,6 +8,9 @@ package pl.org.nowoczesnapolska.wlmobi; 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; @@ -15,6 +18,8 @@ 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) { @@ -25,6 +30,13 @@ public class MenuInterface extends Plugin{ 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); } @@ -36,4 +48,16 @@ public class MenuInterface extends Plugin{ 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); + } } -- 2.20.1