Bug 849955 - Put the quit menu item back for non-touchscreen devices on ICS and up. r=sriram

This commit is contained in:
Kartikaya Gupta 2013-03-13 11:41:56 +00:00
parent 705f3765df
commit 6b33d2a704
2 changed files with 20 additions and 1 deletions

View File

@ -1369,7 +1369,7 @@ abstract public class BrowserApp extends GeckoApp
// Only show the "Quit" menu item on pre-ICS. In ICS+, it's easy to
// kill an app through the task switcher.
aMenu.findItem(R.id.quit).setVisible(Build.VERSION.SDK_INT < 14);
aMenu.findItem(R.id.quit).setVisible(Build.VERSION.SDK_INT < 14 || !isTouchDevice());
if (tab == null || tab.getURL() == null) {
bookmark.setEnabled(false);

View File

@ -65,6 +65,7 @@ import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.Display;
import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@ -188,6 +189,7 @@ abstract public class GeckoApp
private static Boolean sIsLargeTablet = null;
private static Boolean sIsSmallTablet = null;
private static Boolean sIsTouchDevice = null;
abstract public int getLayout();
abstract public boolean hasTabsSideBar();
@ -1331,6 +1333,23 @@ abstract public class GeckoApp
return sIsSmallTablet;
}
public boolean isTouchDevice() {
if (sIsTouchDevice == null) {
if (Build.VERSION.SDK_INT >= 9) {
sIsTouchDevice = false;
for (int inputDeviceId : InputDevice.getDeviceIds()) {
if ((InputDevice.getDevice(inputDeviceId).getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
sIsTouchDevice = true;
}
}
} else {
// pre-gingerbread just assume everything is touch-enabled
sIsTouchDevice = true;
}
}
return sIsTouchDevice;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)