From f31fb31670dba3795c15510f4292678e13f5fbe6 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 14 Jun 2013 11:51:11 +0200 Subject: [PATCH 1/5] added switch to map trigger --- plugins/bookmarks-by-zaso.user.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index 75dc8fc8..75ef21e4 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -305,12 +305,18 @@ if(typeof window.plugin !== 'function') window.plugin = function(){}; // If it's a map if(typeList == 'bkmrk_maps'){ if(bkmrk['label']==''){ label = bkmrk['latlng']+' ['+bkmrk['z']+']'; } - btn_link = ''+label+''; + if (!window.isSmartphone()) + btn_link = ''+label+''; + else + btn_link = ''+label+''; } // If it's a portal else if(typeList == 'bkmrk_portals'){ var guid = bkmrk['guid']; - var btn_link = ''+label+''; + if (!window.isSmartphone()) + var btn_link = ''+label+''; + else + var btn_link = ''+label+''; } // Create the bookmark elementTemp += '
  • '+btn_remove+btn_link+'
  • '; From ebfa030c3dc4b2b288f7af51b8aedb18098833ea Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Sat, 15 Jun 2013 11:12:40 +0200 Subject: [PATCH 2/5] code formatting --- plugins/bookmarks-by-zaso.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index ba3fb048..56c06303 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -311,10 +311,10 @@ // If it's a portal else if(typeList == 'bkmrk_portals'){ var guid = bkmrk['guid']; - if (!window.isSmartphone()) - var btn_link = ''+label+''; - else - var btn_link = ''+label+''; + if (!window.isSmartphone()) + var btn_link = ''+label+''; + else + var btn_link = ''+label+''; } // Create the bookmark elementTemp += '
  • '+btn_remove+btn_link+'
  • '; From f8cd22f16261d209766ef9f19443b0a6ef559da5 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Sat, 15 Jun 2013 12:49:26 +0200 Subject: [PATCH 3/5] reload after plugin with the reload-method to stay consistent with the action bar --- mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 2 ++ mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 34305218..0f72fbe6 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -369,6 +369,8 @@ public class IITC_Mobile extends Activity { actionBar.setTitle(getString(R.string.app_name)); backStack.clear(); setActionBarHomeEnabledWithUp(false); + // iitc starts on map after reload + currentPane = android.R.id.home; this.loadUrl(intel_url); return true; case R.id.toggle_fullscreen: diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 94d948fa..5912002d 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -147,9 +147,9 @@ public class IITC_WebViewClient extends WebViewClient { @Override public void onPageFinished(WebView view, String url) { if (url.contains("accounts.google.com")) { - Log.d("iitcm", "reload after login"); + Log.d("iitcm", "reload after login/logout"); IITC_Mobile main_activity = ((IITC_Mobile) context); - main_activity.loadUrl(main_activity.intel_url); + main_activity.handleMenuItemSelected(R.id.reload_button); return; } super.onPageFinished(view, url); From 899d59d38fa1020f1c44be2ac5667db2974683db Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Sat, 15 Jun 2013 13:06:53 +0200 Subject: [PATCH 4/5] added back "press twice to exit" (fixes #356) - there is no reason why we shouldn't do it this way --- .../src/com/cradle/iitc_mobile/IITC_Mobile.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 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 0f72fbe6..ada5ac09 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -19,6 +19,7 @@ import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Handler; import android.os.StrictMode; import android.preference.PreferenceManager; import android.util.Log; @@ -54,6 +55,7 @@ public class IITC_Mobile extends Activity { private ArrayList backStack = new ArrayList(); private boolean backStack_push = true; private int currentPane = android.R.id.home; + private boolean back_button_pressed = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -285,7 +287,19 @@ public class IITC_Mobile extends Activity { // Pop last item from backStack and pretend the relevant menu item was clicked backStackPop(); } else { - super.onBackPressed(); + if (back_button_pressed) + super.onBackPressed(); + else { + back_button_pressed = true; + Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show(); + // reset back button after 2 seconds + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + back_button_pressed=false; + } + }, 2000); + } } } From ba24a79c341b38498af045eac832b1131209a1cc Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Sat, 15 Jun 2013 13:31:23 +0200 Subject: [PATCH 5/5] made press twice to exit an option (see #356) --- mobile/res/values/strings.xml | 2 ++ mobile/res/xml/preferences.xml | 5 +++++ mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index 0dbabb95..d486e60e 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -44,6 +44,8 @@ Nice for tablets, looks awful on smartphones Force https Disabling may improve performance + Press back button twice to exit + Avoids accidental exits Developer options Enable developer mode If enabled, all IITC sources will be loaded from external storage of the Android device. diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index 3d96a98e..a4b14c02 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -50,6 +50,11 @@ android:title="@string/pref_force_https" android:summary="@string/pref_force_https_sum" android:defaultValue="true" /> + dialogStack = new ArrayList(); + private SharedPreferences sharedPref; // Used for custom back stack handling private ArrayList backStack = new ArrayList(); @@ -80,7 +81,7 @@ public class IITC_Mobile extends Activity { actionBar.setHomeButtonEnabled(true); // do something if user changed something in the settings - SharedPreferences sharedPref = PreferenceManager + sharedPref = PreferenceManager .getDefaultSharedPreferences(this); listener = new OnSharedPreferenceChangeListener() { @Override @@ -106,6 +107,10 @@ public class IITC_Mobile extends Activity { // no iitc reload needed here return; } + // no reload needed + if (key.equals("pref_press_twice_to_exit")) + return; + reload_needed = true; } }; @@ -287,7 +292,7 @@ public class IITC_Mobile extends Activity { // Pop last item from backStack and pretend the relevant menu item was clicked backStackPop(); } else { - if (back_button_pressed) + if (back_button_pressed || !sharedPref.getBoolean("pref_press_twice_to_exit", false)) super.onBackPressed(); else { back_button_pressed = true;