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;
History.init(function() {
console.log('after history.init');
View.init(function() {
- Catalogue.sync(function() {
- Catalogue.updateLocal();
+ Menu.init(function() {
+ Catalogue.sync(function() {
+ Catalogue.updateLocal();
+ }, error);
}, error);
}, error);
}, error);
var self = this;
var infoView = "ProjectInfo";
+ self.init = function() {
+ window.MenuInterface.setNightMode(View.getNightMode());
+ };
+
self.start = function() {
History.visit('');
};
History.addBookmark(name);
};
+ self.toggleNightMode = function() {
+ View.toggleNightMode();
+ window.MenuInterface.setNightMode(View.getNightMode());
+ };
+
self.setInfoButton = function(view, label, enabled) {
self.infoView = view;
window.MenuInterface.setInfoButton(label, enabled);
[label, enabled]
);
},
+ setNightMode: function(enabled, win, fail) {
+ if (enabled == false) enabled = "false";
+ else enabled = "true";
+ return PhoneGap.exec(
+ win,
+ fail,
+ "MenuInterface",
+ "setNightMode",
+ [enabled]
+ );
+ },
};
self.currentTitle = '';
document.getElementById("cover").style.display = 'none';
+
+ self.checkNightMode();
+
self.enter('');
success && success();
this.spinner = function(text) {
if (!text)
text = "Ładowanie";
- self._content.innerHTML = "<div class='spinner'><img src='img/spinner.gif' /><div id='spinnertext'>" + text +"</div></div>";
+ self._content.innerHTML = "";
+ self._content.innerHTML = "<div class='spinner'><img src='img/spinner.png' /><div id='spinnertext'>" + text +"</div></div>";
setOffset(0);
};
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());
+ };
}
package pl.org.nowoczesnapolska.wlmobi;
+import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
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);
case 3:
this.appView.loadUrl("javascript:Menu.bookmark();");
break;
+ case 4:
+ this.appView.loadUrl("javascript:Menu.toggleNightMode();");
+ break;
default:
return super.onOptionsItemSelected(item);
}
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 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) {
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);
}
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);
+ }
}