added back desktop mode (see #304)

This commit is contained in:
Philipp Schaefer 2013-05-26 14:15:11 +02:00
parent c8dc62eafb
commit 86fe10aa9c
3 changed files with 49 additions and 16 deletions

View File

@ -40,6 +40,8 @@
<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_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_sum">Disabling may improve performance</string>
<string name="pref_developer_options">Developer options</string>

View File

@ -27,6 +27,11 @@
android:title="@string/pref_fullscreen_actionbar"
android:summary="@string/pref_fullscreen_actionbar_sum"
android:defaultValue="false" />
<CheckBoxPreference
android:key="pref_force_desktop"
android:title="@string/pref_force_desktop"
android:summary="@string/pref_force_desktop_sum"
android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory

View File

@ -45,6 +45,7 @@ public class IITC_Mobile extends Activity {
private ActionBar actionBar;
private IITC_DeviceAccountLogin mLogin;
private MenuItem searchMenuItem;
private boolean desktop = false;
// Used for custom back stack handling
private ArrayList<Integer> backStack = new ArrayList<Integer>();
@ -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,9 +407,12 @@ 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) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
if (sharedPref.getBoolean("pref_force_desktop", false))
return (url + "?vp=f");
else
return (url + "?vp=m");
}
@ -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);
}
}