Merge branch 'master' of https://github.com/jonatkins/ingress-intel-total-conversion
This commit is contained in:
		
							
								
								
									
										22
									
								
								code/boot.js
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								code/boot.js
									
									
									
									
									
								
							| @@ -6,27 +6,6 @@ | |||||||
| // Used to disable on multitouch devices | // Used to disable on multitouch devices | ||||||
| window.showZoom = true; | window.showZoom = true; | ||||||
|  |  | ||||||
| window.setupBackButton = function() { |  | ||||||
|   var c = window.isSmartphone() |  | ||||||
|     ? window.smartphone.mapButton |  | ||||||
|     : $('#chatcontrols a.active'); |  | ||||||
|  |  | ||||||
|   window.setupBackButton._actions = [c.get(0)]; |  | ||||||
|   $('#chatcontrols a').click(function() { |  | ||||||
|     // ignore shrink button |  | ||||||
|     if($(this).hasClass('toggle')) return; |  | ||||||
|     window.setupBackButton._actions.push(this); |  | ||||||
|     window.setupBackButton._actions = window.setupBackButton._actions.slice(-2); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   window.goBack = function() { |  | ||||||
|     var a = window.setupBackButton._actions[0]; |  | ||||||
|     if(!a) return; |  | ||||||
|     $(a).click(); |  | ||||||
|     window.setupBackButton._actions = [a]; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| window.setupLargeImagePreview = function() { | window.setupLargeImagePreview = function() { | ||||||
|   $('#portaldetails').on('click', '.imgpreview', function() { |   $('#portaldetails').on('click', '.imgpreview', function() { | ||||||
|     var img = $(this).find('img')[0]; |     var img = $(this).find('img')[0]; | ||||||
| @@ -408,7 +387,6 @@ function boot() { | |||||||
|   window.setupQRLoadLib(); |   window.setupQRLoadLib(); | ||||||
|   window.setupLayerChooserSelectOne(); |   window.setupLayerChooserSelectOne(); | ||||||
|   window.setupLayerChooserStatusRecorder(); |   window.setupLayerChooserStatusRecorder(); | ||||||
|   window.setupBackButton(); |  | ||||||
|   // read here ONCE, so the URL is only evaluated one time after the |   // read here ONCE, so the URL is only evaluated one time after the | ||||||
|   // necessary data has been loaded. |   // necessary data has been loaded. | ||||||
|   urlPortalLL = getURLParam('pll'); |   urlPortalLL = getURLParam('pll'); | ||||||
|   | |||||||
| @@ -90,8 +90,12 @@ window.runOnSmartphonesAfterBoot = function() { | |||||||
|  |  | ||||||
|       // this is a hack, accessing Leaflet’s private _container is evil |       // this is a hack, accessing Leaflet’s private _container is evil | ||||||
|       $(this._container).on('taphold', function() { |       $(this._container).on('taphold', function() { | ||||||
|         window.renderPortalDetails(guid); |         if (typeof android !== 'undefined' && android && android.portalLongPressed) { | ||||||
|         window.smartphone.sideButton.click(); |           android.portalLongPressed(); | ||||||
|  |         } else { | ||||||
|  |           window.renderPortalDetails(guid); | ||||||
|  |           window.smartphone.sideButton.click(); | ||||||
|  |         } | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
|   | |||||||
| @@ -1,8 +1,8 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|           package="com.cradle.iitc_mobile" |           package="com.cradle.iitc_mobile" | ||||||
|           android:versionCode="22" |           android:versionCode="23" | ||||||
|           android:versionName="0.4.1"> |           android:versionName="0.4.2"> | ||||||
|  |  | ||||||
|     <uses-sdk |     <uses-sdk | ||||||
|         android:minSdkVersion="14" |         android:minSdkVersion="14" | ||||||
|   | |||||||
| @@ -2,15 +2,9 @@ | |||||||
|     <item android:id="@+id/menu_search" |     <item android:id="@+id/menu_search" | ||||||
|           android:title="@string/menu_search" |           android:title="@string/menu_search" | ||||||
|           android:icon="@drawable/action_search" |           android:icon="@drawable/action_search" | ||||||
|  |           android:orderInCategory="10" | ||||||
|           android:showAsAction="ifRoom|collapseActionView" |           android:showAsAction="ifRoom|collapseActionView" | ||||||
|           android:actionViewClass="android.widget.SearchView" /> |           android:actionViewClass="android.widget.SearchView" /> | ||||||
|     <item |  | ||||||
|         android:id="@+id/menu_map" |  | ||||||
|         android:icon="@drawable/location_map" |  | ||||||
|         android:orderInCategory="20" |  | ||||||
|         android:showAsAction="ifRoom" |  | ||||||
|         android:title="@string/menu_map"> |  | ||||||
|     </item> |  | ||||||
|     <item |     <item | ||||||
|         android:id="@+id/menu_info" |         android:id="@+id/menu_info" | ||||||
|         android:icon="@drawable/action_about" |         android:icon="@drawable/action_about" | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <resources> | <resources> | ||||||
|  |  | ||||||
|     <string name="app_name">IITC mobile</string> |     <string name="app_name">IITC Mobile</string> | ||||||
|     <string name="action_settings">Settings</string> |     <string name="action_settings">Settings</string> | ||||||
|     <string name="reload">Reload IITC</string> |     <string name="reload">Reload IITC</string> | ||||||
|     <string name="version">Print Version</string> |     <string name="version">Print Version</string> | ||||||
| @@ -40,6 +40,8 @@ | |||||||
|     <string name="pref_user_zoom_sum">Shows +/- buttons even on multitouch capable devices.</string> |     <string name="pref_user_zoom_sum">Shows +/- buttons even on multitouch capable devices.</string> | ||||||
|     <string name="pref_fullscreen_actionbar">Hide Action Bar in fullscreen mode</string> |     <string name="pref_fullscreen_actionbar">Hide Action Bar in fullscreen mode</string> | ||||||
|     <string name="pref_fullscreen_actionbar_sum">Nice for screenshots. Note: IITCM cannot be controlled without Action Bar.</string> |     <string name="pref_fullscreen_actionbar_sum">Nice for screenshots. Note: IITCM cannot be controlled without Action Bar.</string> | ||||||
|  |     <string name="pref_force_desktop">Force desktop mode</string> | ||||||
|  |     <string name="pref_force_desktop_sum">Nice for tablets, looks awful on smartphones</string> | ||||||
|     <string name="pref_force_https">Force https</string> |     <string name="pref_force_https">Force https</string> | ||||||
|     <string name="pref_force_https_sum">Disabling may improve performance</string> |     <string name="pref_force_https_sum">Disabling may improve performance</string> | ||||||
|     <string name="pref_developer_options">Developer options</string> |     <string name="pref_developer_options">Developer options</string> | ||||||
| @@ -49,7 +51,6 @@ | |||||||
|     <string name="pref_select_iitc">IITC source</string> |     <string name="pref_select_iitc">IITC source</string> | ||||||
|  |  | ||||||
|     <string name="menu_chat">Chat</string> |     <string name="menu_chat">Chat</string> | ||||||
|     <string name="menu_map">Map</string> |  | ||||||
|     <string name="menu_full">Full</string> |     <string name="menu_full">Full</string> | ||||||
|     <string name="menu_compact">Compact</string> |     <string name="menu_compact">Compact</string> | ||||||
|     <string name="menu_public">Public</string> |     <string name="menu_public">Public</string> | ||||||
|   | |||||||
| @@ -12,22 +12,27 @@ | |||||||
|     <PreferenceCategory |     <PreferenceCategory | ||||||
|         android:key="pref_about_cat" |         android:key="pref_about_cat" | ||||||
|         android:title="@string/pref_ui_cat"> |         android:title="@string/pref_ui_cat"> | ||||||
| 	    <CheckBoxPreference |         <CheckBoxPreference | ||||||
| 	        android:key="pref_user_loc" | 	        android:key="pref_user_loc" | ||||||
| 	        android:title="@string/pref_user_loc" | 	        android:title="@string/pref_user_loc" | ||||||
| 	        android:summary="@string/pref_user_loc_sum" | 	        android:summary="@string/pref_user_loc_sum" | ||||||
| 	        android:defaultValue="false" /> |             android:defaultValue="false" /> | ||||||
| 	    <CheckBoxPreference |         <CheckBoxPreference | ||||||
|                 android:key="pref_user_zoom" |             android:key="pref_user_zoom" | ||||||
|                 android:title="@string/pref_user_zoom" |             android:title="@string/pref_user_zoom" | ||||||
|                 android:summary="@string/pref_user_zoom_sum" |             android:summary="@string/pref_user_zoom_sum" | ||||||
| 	        android:defaultValue="false" /> |             android:defaultValue="false" /> | ||||||
| 	    <CheckBoxPreference |         <CheckBoxPreference | ||||||
|                 android:key="pref_fullscreen_actionbar" |             android:key="pref_fullscreen_actionbar" | ||||||
|                 android:title="@string/pref_fullscreen_actionbar" |             android:title="@string/pref_fullscreen_actionbar" | ||||||
|                 android:summary="@string/pref_fullscreen_actionbar_sum" |             android:summary="@string/pref_fullscreen_actionbar_sum" | ||||||
| 	        android:defaultValue="false" /> |             android:defaultValue="false" /> | ||||||
|             </PreferenceCategory> |         <CheckBoxPreference | ||||||
|  | 	        android:key="pref_force_desktop" | ||||||
|  |             android:title="@string/pref_force_desktop" | ||||||
|  |             android:summary="@string/pref_force_desktop_sum" | ||||||
|  |             android:defaultValue="false" /> | ||||||
|  |     </PreferenceCategory> | ||||||
|  |  | ||||||
|     <PreferenceCategory |     <PreferenceCategory | ||||||
|         android:key="pref_mics" |         android:key="pref_mics" | ||||||
|   | |||||||
| @@ -64,6 +64,16 @@ public class IITC_JSInterface { | |||||||
|                 .show(); |                 .show(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @JavascriptInterface | ||||||
|  |     public void portalLongPressed() { | ||||||
|  |         final IITC_Mobile iitcm = (IITC_Mobile) context; | ||||||
|  |         iitcm.runOnUiThread(new Runnable() { | ||||||
|  |             @Override | ||||||
|  |             public void run() { | ||||||
|  |                 iitcm.handleMenuItemSelected(R.id.menu_info, true); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|     // get layers and list them in a dialog |     // get layers and list them in a dialog | ||||||
|     @JavascriptInterface |     @JavascriptInterface | ||||||
|     public void setLayers(String base_layer, String overlay_layer) { |     public void setLayers(String base_layer, String overlay_layer) { | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.cradle.iitc_mobile; | package com.cradle.iitc_mobile; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.util.ArrayList; | ||||||
|  |  | ||||||
| import android.app.ActionBar; | import android.app.ActionBar; | ||||||
| import android.app.Activity; | import android.app.Activity; | ||||||
| @@ -16,8 +17,8 @@ import android.location.LocationManager; | |||||||
| import android.net.ConnectivityManager; | import android.net.ConnectivityManager; | ||||||
| import android.net.NetworkInfo; | import android.net.NetworkInfo; | ||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
|  | import android.os.Build; | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.os.Handler; |  | ||||||
| import android.os.StrictMode; | import android.os.StrictMode; | ||||||
| import android.preference.PreferenceManager; | import android.preference.PreferenceManager; | ||||||
| import android.util.Log; | import android.util.Log; | ||||||
| @@ -34,7 +35,6 @@ public class IITC_Mobile extends Activity { | |||||||
|     private static final int REQUEST_LOGIN = 1; |     private static final int REQUEST_LOGIN = 1; | ||||||
|  |  | ||||||
|     private IITC_WebView iitc_view; |     private IITC_WebView iitc_view; | ||||||
|     private boolean back_button_pressed = false; |  | ||||||
|     private OnSharedPreferenceChangeListener listener; |     private OnSharedPreferenceChangeListener listener; | ||||||
|     private String intel_url = "https://www.ingress.com/intel"; |     private String intel_url = "https://www.ingress.com/intel"; | ||||||
|     private boolean user_loc = false; |     private boolean user_loc = false; | ||||||
| @@ -45,6 +45,11 @@ public class IITC_Mobile extends Activity { | |||||||
|     private ActionBar actionBar; |     private ActionBar actionBar; | ||||||
|     private IITC_DeviceAccountLogin mLogin; |     private IITC_DeviceAccountLogin mLogin; | ||||||
|     private MenuItem searchMenuItem; |     private MenuItem searchMenuItem; | ||||||
|  |     private boolean desktop = false; | ||||||
|  |  | ||||||
|  |     // Used for custom back stack handling | ||||||
|  |     private ArrayList<Integer> backStack = new ArrayList<Integer>(); | ||||||
|  |     private int currentPane = android.R.id.home; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onCreate(Bundle savedInstanceState) { |     protected void onCreate(Bundle savedInstanceState) { | ||||||
| @@ -64,8 +69,9 @@ public class IITC_Mobile extends Activity { | |||||||
|         actionBar = this.getActionBar(); |         actionBar = this.getActionBar(); | ||||||
|         actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |         actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ||||||
|                 | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE); |                 | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE); | ||||||
|         actionBar.setTitle(getString(R.string.menu_map)); |         actionBar.setTitle(getString(R.string.app_name)); | ||||||
|         actionBar.setHomeButtonEnabled(true); |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) | ||||||
|  |             actionBar.setHomeButtonEnabled(true); | ||||||
|  |  | ||||||
|         // do something if user changed something in the settings |         // do something if user changed something in the settings | ||||||
|         SharedPreferences sharedPref = PreferenceManager |         SharedPreferences sharedPref = PreferenceManager | ||||||
| @@ -74,6 +80,10 @@ public class IITC_Mobile extends Activity { | |||||||
|             @Override |             @Override | ||||||
|             public void onSharedPreferenceChanged( |             public void onSharedPreferenceChanged( | ||||||
|                     SharedPreferences sharedPreferences, String key) { |                     SharedPreferences sharedPreferences, String key) { | ||||||
|  |                 if (key.equals("pref_force_desktop")) { | ||||||
|  |                     desktop = sharedPreferences.getBoolean("pref_force_desktop", false); | ||||||
|  |                     invalidateOptionsMenu(); | ||||||
|  |                 } | ||||||
|                 if (key.equals("pref_user_loc")) |                 if (key.equals("pref_user_loc")) | ||||||
|                     user_loc = sharedPreferences.getBoolean("pref_user_loc", |                     user_loc = sharedPreferences.getBoolean("pref_user_loc", | ||||||
|                             false); |                             false); | ||||||
| @@ -88,6 +98,9 @@ public class IITC_Mobile extends Activity { | |||||||
|         }; |         }; | ||||||
|         sharedPref.registerOnSharedPreferenceChangeListener(listener); |         sharedPref.registerOnSharedPreferenceChangeListener(listener); | ||||||
|  |  | ||||||
|  |         // enable/disable desktop mode on menu create and url load | ||||||
|  |         desktop = sharedPref.getBoolean("pref_force_desktop", false); | ||||||
|  |  | ||||||
|         // Acquire a reference to the system Location Manager |         // Acquire a reference to the system Location Manager | ||||||
|         loc_mngr = (LocationManager) this |         loc_mngr = (LocationManager) this | ||||||
|                 .getSystemService(Context.LOCATION_SERVICE); |                 .getSystemService(Context.LOCATION_SERVICE); | ||||||
| @@ -123,6 +136,10 @@ public class IITC_Mobile extends Activity { | |||||||
|  |  | ||||||
|         fullscreen_actionbar = sharedPref.getBoolean("pref_fullscreen_actionbar", false); |         fullscreen_actionbar = sharedPref.getBoolean("pref_fullscreen_actionbar", false); | ||||||
|  |  | ||||||
|  |         // Clear the back stack | ||||||
|  |         backStack.clear(); | ||||||
|  |         setActionBarHomeEnabledWithUp(false); | ||||||
|  |  | ||||||
|         handleIntent(getIntent(), true); |         handleIntent(getIntent(), true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -152,8 +169,10 @@ public class IITC_Mobile extends Activity { | |||||||
|                     (SearchView) searchMenuItem.getActionView(); |                     (SearchView) searchMenuItem.getActionView(); | ||||||
|             searchView.setQuery(query, false); |             searchView.setQuery(query, false); | ||||||
|             searchView.clearFocus(); |             searchView.clearFocus(); | ||||||
|  |             actionBar.setTitle(getString(R.string.app_name)); | ||||||
|  |             backStackUpdate(android.R.id.home); | ||||||
|             iitc_view.loadUrl("javascript:search('" + query + "');"); |             iitc_view.loadUrl("javascript:search('" + query + "');"); | ||||||
|         } else if (onCreate){ |         } else if (onCreate) { | ||||||
|             this.loadUrl(intel_url); |             this.loadUrl(intel_url); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -231,27 +250,49 @@ public class IITC_Mobile extends Activity { | |||||||
|     // we want a self defined behavior for the back button |     // we want a self defined behavior for the back button | ||||||
|     @Override |     @Override | ||||||
|     public void onBackPressed() { |     public void onBackPressed() { | ||||||
|         // exit fullscreen mode if it is enabled |         // exit fullscreen mode if it is enabled and action bar is disabled or the back stack is empty | ||||||
|         if (fullscreen_mode) { |         if (fullscreen_mode && (backStack.isEmpty() || fullscreen_actionbar)) { | ||||||
|             this.toggleFullscreen(); |             this.toggleFullscreen(); | ||||||
|             return; |         } else if (!backStack.isEmpty()) { | ||||||
|         } |             // Pop last item from backStack and pretend the relevant menu item was clicked | ||||||
|         if (this.back_button_pressed) { |             backStackPop(); | ||||||
|  |         } else { | ||||||
|             super.onBackPressed(); |             super.onBackPressed(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void setActionBarHomeEnabledWithUp(boolean enabled) { | ||||||
|  |         actionBar.setDisplayHomeAsUpEnabled(enabled); | ||||||
|  |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) | ||||||
|  |             actionBar.setHomeButtonEnabled(enabled); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void backStackPop() { | ||||||
|  |         // shouldn't be called when back stack is empty | ||||||
|  |         // catch wrong usage | ||||||
|  |         if (backStack.isEmpty()) { | ||||||
|  |             // Empty back stack means we should be at home (ie map) screen | ||||||
|  |             setActionBarHomeEnabledWithUp(false); | ||||||
|  |             actionBar.setTitle(getString(R.string.app_name)); | ||||||
|  |             iitc_view.loadUrl("javascript: window.show('map');"); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |         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); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|         iitc_view.loadUrl("javascript: window.goBack();"); |     public void backStackUpdate(int itemId) { | ||||||
|         this.back_button_pressed = true; |         if (itemId == currentPane) return; | ||||||
|         Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show(); |         backStack.add(currentPane); | ||||||
|  |         currentPane = itemId; | ||||||
|         // reset back button after 0.5 seconds |         if (backStack.size() == 1) setActionBarHomeEnabledWithUp(true); | ||||||
|         new Handler().postDelayed(new Runnable() { |  | ||||||
|             @Override |  | ||||||
|             public void run() { |  | ||||||
|                 back_button_pressed = false; |  | ||||||
|             } |  | ||||||
|         }, 500); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -266,37 +307,53 @@ public class IITC_Mobile extends Activity { | |||||||
|         // Assumes current activity is the searchable activity |         // Assumes current activity is the searchable activity | ||||||
|         searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); |         searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); | ||||||
|         searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default |         searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default | ||||||
|  |         // enable/disable desktop menu | ||||||
|  |         enableDesktopUI(menu, desktop); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onOptionsItemSelected(MenuItem item) { |     public boolean onOptionsItemSelected(MenuItem item) { | ||||||
|         // Handle item selection |         // Handle item selection | ||||||
|         switch (item.getItemId()) { |         final int itemId = item.getItemId(); | ||||||
|  |         boolean result = handleMenuItemSelected(itemId, true); | ||||||
|  |         if (!result) return super.onOptionsItemSelected(item); | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public boolean handleMenuItemSelected(int itemId, boolean addToBackStack) { | ||||||
|  |         switch (itemId) { | ||||||
|             case android.R.id.home: |             case android.R.id.home: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('map');"); |                 iitc_view.loadUrl("javascript: window.show('map');"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_map)); |                 actionBar.setTitle(getString(R.string.app_name)); | ||||||
|                 return true; |                 this.backStack.clear(); | ||||||
|             case R.id.menu_map: |                 setActionBarHomeEnabledWithUp(false); | ||||||
|                 iitc_view.loadUrl("javascript: window.show('map');"); |                 currentPane = android.R.id.home; | ||||||
|                 actionBar.setTitle(getString(R.string.menu_map)); |  | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.reload_button: |             case R.id.reload_button: | ||||||
|  |                 actionBar.setTitle(getString(R.string.app_name)); | ||||||
|  |                 backStack.clear(); | ||||||
|  |                 setActionBarHomeEnabledWithUp(false); | ||||||
|                 this.loadUrl(intel_url); |                 this.loadUrl(intel_url); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_map)); |  | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.toggle_fullscreen: |             case R.id.toggle_fullscreen: | ||||||
|                 toggleFullscreen(); |                 toggleFullscreen(); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.layer_chooser: |             case R.id.layer_chooser: | ||||||
|  |                 // Force map view to handle potential issue with back stack | ||||||
|  |                 if (!backStack.isEmpty() && currentPane != android.R.id.home) | ||||||
|  |                     iitc_view.loadUrl("javascript: window.show('map');"); | ||||||
|                 // the getLayers function calls the setLayers method of IITC_JSInterface |                 // the getLayers function calls the setLayers method of IITC_JSInterface | ||||||
|                 iitc_view.loadUrl("javascript: window.layerChooser.getLayers()"); |                 iitc_view.loadUrl("javascript: window.layerChooser.getLayers()"); | ||||||
|  |                 actionBar.setTitle(getString(R.string.app_name)); | ||||||
|  |                 backStackUpdate(android.R.id.home); | ||||||
|                 return true; |                 return true; | ||||||
|             // get the users current location and focus it on map |             // get the users current location and focus it on map | ||||||
|             case R.id.locate: |             case R.id.locate: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('map');"); |                 iitc_view.loadUrl("javascript: window.show('map');"); | ||||||
|                 iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 15});"); |                 iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 15});"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_map)); |                 actionBar.setTitle(getString(R.string.app_name)); | ||||||
|  |                 backStackUpdate(android.R.id.home); | ||||||
|                 return true; |                 return true; | ||||||
|             // start settings activity |             // start settings activity | ||||||
|             case R.id.action_settings: |             case R.id.action_settings: | ||||||
| @@ -308,29 +365,35 @@ public class IITC_Mobile extends Activity { | |||||||
|             case R.id.menu_info: |             case R.id.menu_info: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('info');"); |                 iitc_view.loadUrl("javascript: window.show('info');"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_info)); |                 actionBar.setTitle(getString(R.string.menu_info)); | ||||||
|  |                 if (addToBackStack) backStackUpdate(itemId); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_full: |             case R.id.menu_full: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('full');"); |                 iitc_view.loadUrl("javascript: window.show('full');"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_full)); |                 actionBar.setTitle(getString(R.string.menu_full)); | ||||||
|  |                 if (addToBackStack) backStackUpdate(itemId); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_compact: |             case R.id.menu_compact: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('compact');"); |                 iitc_view.loadUrl("javascript: window.show('compact');"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_compact)); |                 actionBar.setTitle(getString(R.string.menu_compact)); | ||||||
|  |                 if (addToBackStack) backStackUpdate(itemId); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_public: |             case R.id.menu_public: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('public');"); |                 iitc_view.loadUrl("javascript: window.show('public');"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_public)); |                 actionBar.setTitle(getString(R.string.menu_public)); | ||||||
|  |                 if (addToBackStack) backStackUpdate(itemId); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_faction: |             case R.id.menu_faction: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('faction');"); |                 iitc_view.loadUrl("javascript: window.show('faction');"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_faction)); |                 actionBar.setTitle(getString(R.string.menu_faction)); | ||||||
|  |                 if (addToBackStack) backStackUpdate(itemId); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_debug: |             case R.id.menu_debug: | ||||||
|                 iitc_view.loadUrl("javascript: window.show('debug')"); |                 iitc_view.loadUrl("javascript: window.show('debug')"); | ||||||
|                 actionBar.setTitle(getString(R.string.menu_debug)); |                 actionBar.setTitle(getString(R.string.menu_debug)); | ||||||
|  |                 if (addToBackStack) backStackUpdate(itemId); | ||||||
|                 return true; |                 return true; | ||||||
|             default: |             default: | ||||||
|                 return super.onOptionsItemSelected(item); |                 return false; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -344,10 +407,12 @@ public class IITC_Mobile extends Activity { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Force mobile view. |     // vp=f enables desktop mode...vp=m is the defaul mobile view | ||||||
|     // New actions are not compatible with desktop mode |  | ||||||
|     private String addUrlParam(String url) { |     private String addUrlParam(String url) { | ||||||
|         return (url + "?vp=m"); |         if (desktop) | ||||||
|  |             return (url + "?vp=f"); | ||||||
|  |         else | ||||||
|  |             return (url + "?vp=m"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // inject the iitc-script and load the intel url |     // inject the iitc-script and load the intel url | ||||||
| @@ -371,17 +436,20 @@ public class IITC_Mobile extends Activity { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void toggleFullscreen() { |     public void toggleFullscreen() { | ||||||
|  |         // TODO: Figure out how to handle this with new back stack? | ||||||
|  |  | ||||||
|         if (fullscreen_mode) { |         if (fullscreen_mode) { | ||||||
|             if (fullscreen_actionbar) |             if (fullscreen_actionbar) | ||||||
|                 this.getActionBar().show(); |                 this.getActionBar().show(); | ||||||
|             this.fullscreen_mode = false; |             this.fullscreen_mode = false; | ||||||
|         } else { |         } else { | ||||||
|             if (fullscreen_actionbar) |             if (fullscreen_actionbar) { | ||||||
|                 this.getActionBar().hide(); |                 this.getActionBar().hide(); | ||||||
|  |                 // show a toast with instructions to exit the fc mode again | ||||||
|  |                 Toast.makeText(this, "Press back button to exit fullscreen", | ||||||
|  |                         Toast.LENGTH_SHORT).show(); | ||||||
|  |             } | ||||||
|             this.fullscreen_mode = true; |             this.fullscreen_mode = true; | ||||||
|             // show a toast with instructions to exit the fc mode again |  | ||||||
|             Toast.makeText(this, "Press back button to exit fullscreen", |  | ||||||
|                     Toast.LENGTH_SHORT).show(); |  | ||||||
|         } |         } | ||||||
|         // toggle notification bar |         // toggle notification bar | ||||||
|         WindowManager.LayoutParams attrs = getWindow().getAttributes(); |         WindowManager.LayoutParams attrs = getWindow().getAttributes(); | ||||||
| @@ -430,4 +498,17 @@ public class IITC_Mobile extends Activity { | |||||||
|         // garbage collection |         // garbage collection | ||||||
|         mLogin = null; |         mLogin = null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // disable/enable some menu buttons... | ||||||
|  |     public void enableDesktopUI(Menu menu, boolean desktop) { | ||||||
|  |         MenuItem item; | ||||||
|  |         item = menu.findItem(R.id.menu_chat); | ||||||
|  |         item.setVisible(!desktop); | ||||||
|  |         item = menu.findItem(R.id.menu_info); | ||||||
|  |         item.setVisible(!desktop); | ||||||
|  |         item = menu.findItem(R.id.menu_debug); | ||||||
|  |         item.setVisible(!desktop); | ||||||
|  |         item = menu.findItem(R.id.layer_chooser); | ||||||
|  |         item.setVisible(!desktop); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user