ActionBar

This commit is contained in:
James Sanford 2012-10-09 20:55:27 -07:00
parent b3a3ffe648
commit b023e66caf
3 changed files with 75 additions and 0 deletions

30
res/menu/actions.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- ic_bt_keyboard_hid, ic_lockscreen_ime -->
<item android:id="@+id/action_keyboard"
android:icon="@drawable/ic_bt_keyboard_hid"
android:showAsAction="ifRoom"
android:title="Keyboard" />
<item android:id="@+id/action_joystick"
android:icon="@drawable/ic_bt_misc_hid"
android:showAsAction="ifRoom"
android:title="Use Joystick" />
<item android:id="@+id/action_speed"
android:icon="@drawable/dial"
android:showAsAction="ifRoom"
android:title="Emulation Speed" />
<item android:id="@+id/action_function"
android:icon="@drawable/ic_dialog_attach"
android:showAsAction="never"
android:title="Special Keys" />
<item android:id="@+id/action_diskimage"
android:icon="@drawable/ic_menu_save"
android:showAsAction="ifRoom"
android:title="Disk Images" />
</menu>

View File

@ -92,6 +92,9 @@ class BitmapSize {
scaleX = Math.max(1, scaleX);
scaleY = Math.min(scaleX, height / 400.0f);
// NOTE: scaleY should really never be less than '1',
// although theoretically 0.5-1 would look OK, it causes poor performance
// If Y would be compressed in a weird way, reduce the scale and use 1:1.
if ((scaleX - scaleY) > 0.5) {
scaleX = Math.max(1, scaleX - 1);

View File

@ -278,6 +278,48 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset {
// return super.dispatchGenericMotionEvent(event);
// }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// BUG: no overflow menu on devices with menu button
// BUG: when action bar is hidden, menu bar only shows overflow items
getMenuInflater().inflate(R.menu.actions, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// TODO: add code to adjust anything that might change
return super.onPrepareOptionsMenu(menu);
}
// TODO: FIXME: Seriously in progress.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Action bar was clicked.
final int item_id = item.getItemId();
if (item_id == R.id.action_keyboard) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.toggleSoftInput(0, 0);
}
return true;
} else if (item_id == R.id.action_speed) {
new SpeedFragment().show(getFragmentManager(), FRAGMENT_SPEED);
return true;
} else if (item_id == R.id.action_joystick) {
mModeMouse = !mModeMouse;
// TOAST...'now using...joystick or mouse'
return true;
} else if (item_id == R.id.action_function) {
// drop down menu for special keys...?
return true;
} else if (item_id == R.id.action_diskimage) {
// start fragment for disk images
return true;
}
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);