From 86fe10aa9c2fb0cb5d4b6a41564b2d2bdc1acda4 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Sun, 26 May 2013 14:15:11 +0200 Subject: [PATCH] added back desktop mode (see #304) --- mobile/res/values/strings.xml | 2 ++ mobile/res/xml/preferences.xml | 31 ++++++++++-------- .../com/cradle/iitc_mobile/IITC_Mobile.java | 32 +++++++++++++++++-- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index 756daa84..82119080 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -40,6 +40,8 @@ Shows +/- buttons even on multitouch capable devices. Hide Action Bar in fullscreen mode Nice for screenshots. Note: IITCM cannot be controlled without Action Bar. + Force desktop mode + Nice for tablets, looks awful on smartphones Force https Disabling may improve performance Developer options diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index f986bc1e..57f2c2b7 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -12,22 +12,27 @@ - - - - + android:defaultValue="false" /> + + + + backStack = new ArrayList(); @@ -79,6 +80,10 @@ public class IITC_Mobile extends Activity { @Override public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key) { + if (key.equals("pref_force_desktop")) { + desktop = sharedPreferences.getBoolean("pref_force_desktop", false); + invalidateOptionsMenu(); + } if (key.equals("pref_user_loc")) user_loc = sharedPreferences.getBoolean("pref_user_loc", false); @@ -93,6 +98,9 @@ public class IITC_Mobile extends Activity { }; 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 loc_mngr = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); @@ -299,6 +307,8 @@ public class IITC_Mobile extends Activity { // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default + // enable/disable desktop menu + enableDesktopUI(menu, desktop); return true; } @@ -397,10 +407,13 @@ public class IITC_Mobile extends Activity { } } - // Force mobile view. - // New actions are not compatible with desktop mode + // vp=f enables desktop mode...vp=m is the defaul mobile view private String addUrlParam(String url) { - return (url + "?vp=m"); + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + if (sharedPref.getBoolean("pref_force_desktop", false)) + return (url + "?vp=f"); + else + return (url + "?vp=m"); } // inject the iitc-script and load the intel url @@ -486,4 +499,17 @@ public class IITC_Mobile extends Activity { // garbage collection 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); + } }