List of commits:
Subject Hash Author Date (UTC)
Handle device back button. Added Exit button on the first page. 3c92ca40f3138d14947fc69afebf4a26fc1f9eef DiAngelo 2015-12-18 13:43:49
Fixed wrong story displayed. 3cd77c19e80f7033031b23326a60ca53741915f7 DiAngelo 2015-12-17 16:28:35
Removed jQuery dependency 2d545dbb9dd48d98d9c10aa9775d4de3af081a3a DiAngelo 2015-12-17 14:12:30
Initial commit bd284e3f3dfaa733e7bae04258cad9173712569b DiAngelo 2015-12-17 12:44:38
Commit 3c92ca40f3138d14947fc69afebf4a26fc1f9eef - Handle device back button. Added Exit button on the first page.
Author: DiAngelo
Author date (UTC): 2015-12-18 13:43
Committer name: DiAngelo
Committer date (UTC): 2015-12-18 13:43
Parent(s): 3cd77c19e80f7033031b23326a60ca53741915f7
Signing key:
Tree: 55f73fc181bf8ed6ce8864105df3b75c8274721a
File Lines added Lines deleted
app/src/main/assets/index.html 1 0
app/src/main/assets/js/com/mobile/authors.rkr.js 11 3
app/src/main/assets/js/com/mobile/books.rkr.js 2 2
app/src/main/assets/js/com/mobile/content.rkr.js 2 2
app/src/main/assets/js/com/mobile/webapp.rkr.js 6 2
app/src/main/assets/js/index.js 3 0
app/src/main/assets/js/rucker/app.js 25 0
app/src/main/java/ro/bitvice/cufarulcupovestiapk/FullscreenActivity.java 17 1
app/src/main/java/ro/bitvice/cufarulcupovestiapk/WebAppInterface.java 6 0
File app/src/main/assets/index.html changed (mode: 100644) (index a7c165e..4eba13f)
27 27 <script src="js/rucker/lodash.js"></script> <script src="js/rucker/lodash.js"></script>
28 28 <script src="js/rucker/mithril.js"></script> <script src="js/rucker/mithril.js"></script>
29 29 <script src="js/rucker/webfont.js"></script> <script src="js/rucker/webfont.js"></script>
30 <script src="js/rucker/app.js"></script>
30 31 <script src="js/rucker/rkr.js"></script> <script src="js/rucker/rkr.js"></script>
31 32 <script type='text/javascript'>var require = {"baseUrl":"js/","deps":["js/index.js"]};</script> <script type='text/javascript'>var require = {"baseUrl":"js/","deps":["js/index.js"]};</script>
32 33 <script src="js/rucker/require.js"></script> <script src="js/rucker/require.js"></script>
File app/src/main/assets/js/com/mobile/authors.rkr.js changed (mode: 100644) (index 899a383..19b29c1)
... ... define(["data/authors"], function(authorsData) {
5 5 var self = this; var self = this;
6 6
7 7 this.authors = authorsData.authors; this.authors = authorsData.authors;
8 this.webApp = args.webApp;
9 8
10 9 this.onSelection = function (author) { this.onSelection = function (author) {
11 10 m.startComputation(); m.startComputation();
 
... ... define(["data/authors"], function(authorsData) {
17 16 require([booksPath], function (books) { require([booksPath], function (books) {
18 17 var pageArguments = books; var pageArguments = books;
19 18 pageArguments.author = author; pageArguments.author = author;
20 self.webApp.addPage({type: "books", active: true, arguments: pageArguments});
19 iApp.newPage({
20 type: "books",
21 active: true,
22 arguments: pageArguments
23 });
21 24 m.endComputation(); m.endComputation();
22 25 }); });
23 26 }, 200); }, 200);
24 }
27 };
28
29 this.onClose = function () {
30 iApp.exit();
31 };
25 32 }; };
26 33
27 34
28 35
29 36 comAuthors.view = function(ctrl) { comAuthors.view = function(ctrl) {
30 37 return m('div', [ return m('div', [
38 m('span', {onclick: ctrl.onClose.bind(this)}, 'Exit'),
31 39 m('h1', "Autori"), m('h1', "Autori"),
32 40 m('ul.mAuthors', [ m('ul.mAuthors', [
33 41 ctrl.authors.map(function (author, index) { ctrl.authors.map(function (author, index) {
File app/src/main/assets/js/com/mobile/books.rkr.js changed (mode: 100644) (index a810001..4be29be)
... ... define([], function() {
38 38 }; };
39 39
40 40 this.onContentLoaded = function (data, book) { this.onContentLoaded = function (data, book) {
41 self.webApp.addPage({
41 iApp.newPage({
42 42 type: "content", type: "content",
43 43 active: true, arguments: { active: true, arguments: {
44 44 content: data, content: data,
 
... ... define([], function() {
50 50 }; };
51 51
52 52 this.onBack = function () { this.onBack = function () {
53 self.webApp.back();
53 iApp.goBack();
54 54 }; };
55 55 }; };
56 56
File app/src/main/assets/js/com/mobile/content.rkr.js changed (mode: 100644) (index 7c7f605..f011ee7)
... ... define([], function() {
31 31 comContent.vm.init(); comContent.vm.init();
32 32 comContent.vm.set(args); comContent.vm.set(args);
33 33
34 this.webApp = args.webApp;
34 // this.webApp = args.webApp;
35 35
36 36 this.onBack = function () { this.onBack = function () {
37 self.webApp.back();
37 iApp.goBack();
38 38 }; };
39 39 }; };
40 40
File app/src/main/assets/js/com/mobile/webapp.rkr.js changed (mode: 100644) (index a524907..d8f8ded)
... ... define([
29 29 var newPage = new comWebApp.page(pageData, vm.activePage); var newPage = new comWebApp.page(pageData, vm.activePage);
30 30
31 31 vm.vacuum(); vm.vacuum();
32
33 32 vm.list.push(newPage); vm.list.push(newPage);
34 33
35 34 if (pageData.active) { if (pageData.active) {
 
... ... define([
84 83 comWebApp.vm.addPage(data); comWebApp.vm.addPage(data);
85 84 }; };
86 85
86 comWebApp.canGoBack = function () {
87 comWebApp.vm.vacuum();
88 return comWebApp.vm.list.length > 2;
89 };
90
87 91 comWebApp.back = function () { comWebApp.back = function () {
88 92 comWebApp.vm.removePage(); comWebApp.vm.removePage();
89 93 }; };
 
... ... define([
139 143
140 144 if (_.isUndefined(pageArguments)) { pageArguments = {}; } if (_.isUndefined(pageArguments)) { pageArguments = {}; }
141 145
142 pageArguments.webApp = comWebApp;
146 // pageArguments.webApp = comWebApp;
143 147 pageContent.push(m.component(pageComponent, pageArguments)); pageContent.push(m.component(pageComponent, pageArguments));
144 148 } }
145 149
File app/src/main/assets/js/index.js changed (mode: 100644) (index a91db4e..9229abe)
5 5 log.enableAll(); log.enableAll();
6 6
7 7 var appConf = {}; var appConf = {};
8 var iApp = new AppInterface();
8 9
9 10 function pageReady (conf) { function pageReady (conf) {
10 11 require(["app.conf", "com/mobile/webapp.rkr"], function (config, rkrWebApp) { require(["app.conf", "com/mobile/webapp.rkr"], function (config, rkrWebApp) {
11 12 appConf = config; appConf = config;
12 13
14 iApp.setWebApp(rkrWebApp);
15
13 16 var rkrContainer = document.getElementsByClassName(appConf.classContainer)[0]; var rkrContainer = document.getElementsByClassName(appConf.classContainer)[0];
14 17
15 18 // m.route(rkrContainer, rkrRoute, rkrRoutes); // m.route(rkrContainer, rkrRoute, rkrRoutes);
File app/src/main/assets/js/rucker/app.js added (mode: 100644) (index 0000000..20ec060)
1 var AppInterface = function () {
2 this._webApp = null;
3 };
4
5 AppInterface.prototype.setWebApp = function (comWebApp) {
6 this._webApp = comWebApp;
7 };
8
9 AppInterface.prototype.canGoBack = function () {
10 return this._webApp.canGoBack();
11 };
12
13 AppInterface.prototype.newPage = function (data) {
14 this._webApp.addPage(data);
15 };
16
17 AppInterface.prototype.goBack = function () {
18 m.startComputation();
19 this._webApp.back();
20 m.endComputation();
21 };
22
23 AppInterface.prototype.exit = function () {
24 Android.exit();
25 };
File app/src/main/java/ro/bitvice/cufarulcupovestiapk/FullscreenActivity.java changed (mode: 100644) (index a20a4ea..84073d7)
... ... import ro.bitvice.cufarulcupovestiapk.WebAppInterface;
5 5
6 6 import android.annotation.SuppressLint; import android.annotation.SuppressLint;
7 7 import android.app.Activity; import android.app.Activity;
8 import android.content.Context;
8 9 import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
9 10 import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
10 11 import android.os.Bundle; import android.os.Bundle;
11 12 import android.os.Handler; import android.os.Handler;
13 import android.util.Log;
12 14 import android.view.MotionEvent; import android.view.MotionEvent;
13 15 import android.view.View; import android.view.View;
14 16 import android.view.KeyEvent; import android.view.KeyEvent;
17 import android.webkit.ValueCallback;
15 18 import android.webkit.WebView; import android.webkit.WebView;
16 19 import android.webkit.WebSettings; import android.webkit.WebSettings;
17 20 import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
21 import android.widget.Toast;
18 22
19 23
20 24 /** /**
 
... ... public class FullscreenActivity extends Activity {
92 96
93 97 @Override @Override
94 98 public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
99 final Context c = this.getApplicationContext();
95 100 // Check if the key event was the Back button and if there's history // Check if the key event was the Back button and if there's history
96 101 if ((keyCode == KeyEvent.KEYCODE_BACK)) { if ((keyCode == KeyEvent.KEYCODE_BACK)) {
97 mWebView.loadUrl("javascript:prevPage()");
102 mWebView.evaluateJavascript("(function(){ return iApp.canGoBack();})();", new ValueCallback<String>() {
103 @Override
104 public void onReceiveValue(String s) {
105 Toast.makeText(c, s, Toast.LENGTH_SHORT).show();
106 if (s.equals("true")) {
107 mWebView.loadUrl("javascript:iApp.goBack()");
108 } else {
109 Toast.makeText(c, "Close APP", Toast.LENGTH_SHORT).show();
110 // System.exit(0);
111 }
112 }
113 });
98 114 return true; return true;
99 115 } }
100 116 // If it wasn't the Back key or there's no web page history, bubble up to the default // If it wasn't the Back key or there's no web page history, bubble up to the default
File app/src/main/java/ro/bitvice/cufarulcupovestiapk/WebAppInterface.java changed (mode: 100644) (index 98424cd..75d857a)
... ... public class WebAppInterface {
20 20 public void showToast(String toast) { public void showToast(String toast) {
21 21 Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
22 22 } }
23
24 /** Show a toast from the web page */
25 @JavascriptInterface
26 public void exit() {
27 System.exit(0);
28 }
23 29 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/bitvice/CufarulCuPovesti.apk

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/bitvice/CufarulCuPovesti.apk

Clone this repository using git:
git clone git://git.rocketgit.com/user/bitvice/CufarulCuPovesti.apk

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main