From 855b7c22af72e81b2ee57721abb89987c97e2490 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 14 Jun 2013 11:21:44 +0200 Subject: [PATCH 1/4] fixed portal long tab issue --- code/smartphone.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/smartphone.js b/code/smartphone.js index 59acb7af..3c38940f 100644 --- a/code/smartphone.js +++ b/code/smartphone.js @@ -92,10 +92,9 @@ window.runOnSmartphonesAfterBoot = function() { $(this._container).on('taphold', function() { if (typeof android !== 'undefined' && android && android.portalLongPressed) { android.portalLongPressed(); - } else { - window.renderPortalDetails(guid); - window.smartphone.sideButton.click(); } + window.renderPortalDetails(guid); + window.smartphone.sideButton.click(); }); }); }); From cc44392d03d164c8fc6236c50cd7aa40d370bf2d Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 14 Jun 2013 12:02:03 +0200 Subject: [PATCH 2/4] reload page after login --- code/smartphone.js | 5 +++-- .../com/cradle/iitc_mobile/IITC_WebViewClient.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/code/smartphone.js b/code/smartphone.js index 3c38940f..cde15ab1 100644 --- a/code/smartphone.js +++ b/code/smartphone.js @@ -90,11 +90,12 @@ window.runOnSmartphonesAfterBoot = function() { // this is a hack, accessing Leaflet’s private _container is evil $(this._container).on('taphold', function() { + window.renderPortalDetails(guid); if (typeof android !== 'undefined' && android && android.portalLongPressed) { android.portalLongPressed(); + } else { + window.smartphone.sideButton.click(); } - window.renderPortalDetails(guid); - window.smartphone.sideButton.click(); }); }); }); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 39dfcd54..94d948fa 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -140,9 +140,21 @@ public class IITC_WebViewClient extends WebViewClient { */ @Override public void onReceivedLoginRequest(WebView view, String realm, String account, String args) { + Log.d("iitcm", "Login requested: " + realm + " " + account + " " + args); ((IITC_Mobile) context).onReceivedLoginRequest(this, view, realm, account, args); } + @Override + public void onPageFinished(WebView view, String url) { + if (url.contains("accounts.google.com")) { + Log.d("iitcm", "reload after login"); + IITC_Mobile main_activity = ((IITC_Mobile) context); + main_activity.loadUrl(main_activity.intel_url); + return; + } + super.onPageFinished(view, url); + } + // parse all enabled iitc plugins // returns a string containing all plugins without their wrappers public String parsePlugins() { From d21fdc01766fd44ae299aa39e1ebbb00e0d55858 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 14 Jun 2013 16:49:54 +0200 Subject: [PATCH 3/4] overhauled button pressed backStack behaviour...use a JS callback to let it work with JS calls --- code/panes.js | 3 + code/smartphone.js | 6 +- mobile/AndroidManifest.xml | 4 +- .../cradle/iitc_mobile/IITC_JSInterface.java | 44 ++++++++++++++- .../com/cradle/iitc_mobile/IITC_Mobile.java | 55 ++++++++----------- 5 files changed, 72 insertions(+), 40 deletions(-) diff --git a/code/panes.js b/code/panes.js index 99ffdc59..cea82b51 100644 --- a/code/panes.js +++ b/code/panes.js @@ -2,6 +2,9 @@ // window.show = function(id) { window.hideall(); + if (typeof android !== 'undefined' && android && android.switchToPane) { + android.switchToPane(id); + } switch(id) { case 'full': window.chat.show('full'); diff --git a/code/smartphone.js b/code/smartphone.js index cde15ab1..f02aa395 100644 --- a/code/smartphone.js +++ b/code/smartphone.js @@ -91,11 +91,7 @@ window.runOnSmartphonesAfterBoot = function() { // this is a hack, accessing Leaflet’s private _container is evil $(this._container).on('taphold', function() { window.renderPortalDetails(guid); - if (typeof android !== 'undefined' && android && android.portalLongPressed) { - android.portalLongPressed(); - } else { - window.smartphone.sideButton.click(); - } + window.show('info'); }); }); }); diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index 5a40f525..d7457937 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="28" + android:versionName="0.4.7"> backStack = new ArrayList(); + private boolean backStack_push = true; private int currentPane = android.R.id.home; @Override @@ -292,6 +293,7 @@ public class IITC_Mobile extends Activity { actionBar.setDisplayHomeAsUpEnabled(enabled); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) actionBar.setHomeButtonEnabled(enabled); + invalidateOptionsMenu(); } public void backStackPop() { @@ -306,20 +308,31 @@ public class IITC_Mobile extends Activity { } int index = backStack.size() - 1; int itemId = backStack.remove(index); - currentPane = itemId; - handleMenuItemSelected(itemId, false); - // if we popped our last item from stack...illustrate it on home button - if (backStack.isEmpty()) { - // Empty back stack means we should be at home (ie map) screen - setActionBarHomeEnabledWithUp(false); - } + backStack_push = false; + handleMenuItemSelected(itemId); } public void backStackUpdate(int itemId) { + // ensure no double adds if (itemId == currentPane) return; - backStack.add(currentPane); + if (itemId == android.R.id.home) { + backStack.clear(); + backStack_push = true; + } else { + if (backStack_push) + backStack.add(currentPane); + else + backStack_push = true; + } + currentPane = itemId; - if (backStack.size() == 1) setActionBarHomeEnabledWithUp(true); + if (backStack.size() >= 1) { + setActionBarHomeEnabledWithUp(true); + } else { + // if we popped our last item from stack...illustrate it on home button + // Empty back stack means we should be at home (ie map) screen + setActionBarHomeEnabledWithUp(false); + } } @Override @@ -343,19 +356,15 @@ public class IITC_Mobile extends Activity { public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection final int itemId = item.getItemId(); - boolean result = handleMenuItemSelected(itemId, true); + boolean result = handleMenuItemSelected(itemId); if (!result) return super.onOptionsItemSelected(item); return true; } - public boolean handleMenuItemSelected(int itemId, boolean addToBackStack) { + public boolean handleMenuItemSelected(int itemId) { switch (itemId) { case android.R.id.home: iitc_view.loadUrl("javascript: window.show('map');"); - actionBar.setTitle(getString(R.string.app_name)); - this.backStack.clear(); - setActionBarHomeEnabledWithUp(false); - currentPane = android.R.id.home; return true; case R.id.reload_button: actionBar.setTitle(getString(R.string.app_name)); @@ -372,8 +381,6 @@ public class IITC_Mobile extends Activity { iitc_view.loadUrl("javascript: window.show('map');"); // the getLayers function calls the setLayers method of IITC_JSInterface iitc_view.loadUrl("javascript: window.layerChooser.getLayers()"); - actionBar.setTitle(getString(R.string.app_name)); - backStackUpdate(android.R.id.home); return true; // get the users current location and focus it on map case R.id.locate: @@ -388,8 +395,6 @@ public class IITC_Mobile extends Activity { last_location.getLatitude() + "," + last_location.getLongitude() + "), 15);"); } - actionBar.setTitle(getString(R.string.app_name)); - backStackUpdate(android.R.id.home); return true; // start settings activity case R.id.action_settings: @@ -400,33 +405,21 @@ public class IITC_Mobile extends Activity { return true; case R.id.menu_info: iitc_view.loadUrl("javascript: window.show('info');"); - actionBar.setTitle(getString(R.string.menu_info)); - if (addToBackStack) backStackUpdate(itemId); return true; case R.id.menu_full: iitc_view.loadUrl("javascript: window.show('full');"); - actionBar.setTitle(getString(R.string.menu_full)); - if (addToBackStack) backStackUpdate(itemId); return true; case R.id.menu_compact: iitc_view.loadUrl("javascript: window.show('compact');"); - actionBar.setTitle(getString(R.string.menu_compact)); - if (addToBackStack) backStackUpdate(itemId); return true; case R.id.menu_public: iitc_view.loadUrl("javascript: window.show('public');"); - actionBar.setTitle(getString(R.string.menu_public)); - if (addToBackStack) backStackUpdate(itemId); return true; case R.id.menu_faction: iitc_view.loadUrl("javascript: window.show('faction');"); - actionBar.setTitle(getString(R.string.menu_faction)); - if (addToBackStack) backStackUpdate(itemId); return true; case R.id.menu_debug: iitc_view.loadUrl("javascript: window.show('debug')"); - actionBar.setTitle(getString(R.string.menu_debug)); - if (addToBackStack) backStackUpdate(itemId); return true; default: return false; From b7ede72ee94c3aeb8dd74dcd86e1270f7a1e8d92 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 14 Jun 2013 17:14:33 +0200 Subject: [PATCH 4/4] removed not needed line of code --- mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 1 - 1 file changed, 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index eca4d99b..34305218 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -293,7 +293,6 @@ public class IITC_Mobile extends Activity { actionBar.setDisplayHomeAsUpEnabled(enabled); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) actionBar.setHomeButtonEnabled(enabled); - invalidateOptionsMenu(); } public void backStackPop() {