mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-28 13:29:29 +00:00
Various updates to menu system
This commit is contained in:
parent
10590052f2
commit
ae27a891dd
|
@ -41,9 +41,11 @@ public class Apple2Activity extends Activity {
|
|||
|
||||
private Apple2View mView = null;
|
||||
private AlertDialog mQuitDialog = null;
|
||||
private AlertDialog mRebootDialog = null;
|
||||
private GestureDetector mDetector = null;
|
||||
private boolean mSwipeTogglesSpeed = true;
|
||||
private boolean mDoubleTapShowsKeyboard = true;
|
||||
private boolean mSingleTapShowsMainMenu = true;
|
||||
|
||||
private int mWidth = 0;
|
||||
private int mHeight = 0;
|
||||
|
@ -67,11 +69,16 @@ public class Apple2Activity extends Activity {
|
|||
public native void nativeOnResume();
|
||||
public native void nativeOnPause();
|
||||
public native void nativeOnQuit();
|
||||
|
||||
public native boolean nativeOnTouch(int action, int pointerCount, int pointerIndex, float[] xCoords, float[] yCoords);
|
||||
|
||||
public native void nativeReboot();
|
||||
public native void nativeRender();
|
||||
|
||||
public native void nativeEnableTouchJoystick(boolean visibility);
|
||||
public native void nativeSetColor(int color);
|
||||
|
||||
|
||||
// HACK NOTE 2015/02/22 : Apparently native code cannot easily access stuff in the APK ... so copy various resources
|
||||
// out of the APK and into the /data/data/... for ease of access. Because this is FOSS software we don't care about
|
||||
// security or DRM for these assets =)
|
||||
|
@ -179,7 +186,9 @@ public class Apple2Activity extends Activity {
|
|||
|
||||
boolean noMenusShowing = !(
|
||||
(mainMenu != null && mainMenu.isShowing()) ||
|
||||
(mQuitDialog != null && mQuitDialog.isShowing()) );
|
||||
(mQuitDialog != null && mQuitDialog.isShowing()) ||
|
||||
(mRebootDialog != null && mRebootDialog.isShowing())
|
||||
);
|
||||
|
||||
if (noMenusShowing) {
|
||||
nativeOnResume();
|
||||
|
@ -209,9 +218,11 @@ public class Apple2Activity extends Activity {
|
|||
settingsMenu.dismissWithoutResume();
|
||||
}
|
||||
|
||||
if (mainMenu.isShowing() || (mQuitDialog != null && mQuitDialog.isShowing())) {
|
||||
// this is a good paused state
|
||||
} else {
|
||||
boolean someMenuShowing = mainMenu.isShowing() ||
|
||||
(mQuitDialog != null && mQuitDialog.isShowing()) ||
|
||||
(mRebootDialog != null && mRebootDialog.isShowing());
|
||||
if (!someMenuShowing) {
|
||||
// show main menu on pause
|
||||
mView.showMainMenu();
|
||||
}
|
||||
}
|
||||
|
@ -226,10 +237,12 @@ public class Apple2Activity extends Activity {
|
|||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Apple2SettingsMenu settingsMenu = mView.getSettingsMenu();
|
||||
if (settingsMenu != null && settingsMenu.isShowing()) {
|
||||
settingsMenu.dismiss();
|
||||
} else {
|
||||
maybeQuitApp();
|
||||
if (settingsMenu != null) {
|
||||
if (settingsMenu.isShowing()) {
|
||||
settingsMenu.dismiss();
|
||||
} else {
|
||||
mView.showMainMenu();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
||||
|
@ -354,7 +367,7 @@ public class Apple2Activity extends Activity {
|
|||
} else if (Apple2Activity.this.isSoftKeyboardShowing()) {
|
||||
Log.d(TAG, "hiding keyboard");
|
||||
Apple2Activity.this.mView.toggleKeyboard();
|
||||
} else {
|
||||
} else if (mSingleTapShowsMainMenu) {
|
||||
Log.d(TAG, "showing main menu");
|
||||
Apple2Activity.this.mView.showMainMenu();
|
||||
}
|
||||
|
@ -398,13 +411,13 @@ public class Apple2Activity extends Activity {
|
|||
public void maybeQuitApp() {
|
||||
nativeOnPause();
|
||||
if (mQuitDialog == null) {
|
||||
mQuitDialog = new AlertDialog.Builder(this).setCancelable(true).setMessage(R.string.quit).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
mQuitDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.quit_really).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
nativeOnQuit();
|
||||
}
|
||||
}).setNegativeButton(R.string.no, null).create();
|
||||
mQuitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
/*mQuitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
nativeOnResume();
|
||||
|
@ -415,15 +428,45 @@ public class Apple2Activity extends Activity {
|
|||
public void onDismiss(DialogInterface dialog) {
|
||||
nativeOnResume();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
mQuitDialog.show();
|
||||
}
|
||||
|
||||
public void maybeReboot() {
|
||||
nativeOnPause();
|
||||
if (mRebootDialog == null) {
|
||||
mRebootDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.reboot_really).setMessage(R.string.reboot_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
nativeReboot();
|
||||
Apple2Activity.this.mView.getMainMenu().dismiss();
|
||||
}
|
||||
}).setNegativeButton(R.string.no, null).create();
|
||||
/*mRebootDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
nativeOnResume();
|
||||
}
|
||||
});
|
||||
mRebootDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
nativeOnResume();
|
||||
}
|
||||
});*/
|
||||
}
|
||||
mRebootDialog.show();
|
||||
}
|
||||
|
||||
public void setSwipeTogglesSpeed(boolean swipeTogglesSpeed) {
|
||||
mSwipeTogglesSpeed = swipeTogglesSpeed;
|
||||
}
|
||||
|
||||
public void setSingleTapShowsMainMenu(boolean singleTapShowsMainMenu) {
|
||||
mSingleTapShowsMainMenu = singleTapShowsMainMenu;
|
||||
}
|
||||
|
||||
public void setDoubleTapShowsKeyboard(boolean doubleTapShowsKeyboard) {
|
||||
mDoubleTapShowsKeyboard = doubleTapShowsKeyboard;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,13 @@ import android.util.Log;
|
|||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Apple2MainMenu {
|
||||
|
||||
|
@ -40,6 +42,66 @@ public class Apple2MainMenu {
|
|||
setup();
|
||||
}
|
||||
|
||||
enum SETTINGS {
|
||||
SHOW_SETTINGS {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.menu_settings);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.menu_settings_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2MainMenu mainMenu) {
|
||||
mainMenu.showSettings();
|
||||
}
|
||||
},
|
||||
LOAD_DISK {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.menu_disks);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.menu_disks_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2MainMenu mainMenu) {
|
||||
mainMenu.showDisksMenu();
|
||||
}
|
||||
},
|
||||
QUIT_EMULATOR {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.quit);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.quit_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2MainMenu mainMenu) {
|
||||
mainMenu.mActivity.maybeQuitApp();
|
||||
}
|
||||
},
|
||||
REBOOT_EMULATOR {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.reboot);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.reboot_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2MainMenu mainMenu) {
|
||||
mainMenu.mActivity.maybeReboot();
|
||||
}
|
||||
};
|
||||
|
||||
public abstract String getTitle(Context ctx);
|
||||
public abstract String getSummary(Context ctx);
|
||||
public abstract void handleSelection(Apple2MainMenu mainMenu);
|
||||
|
||||
public static String[] titles(Context ctx) {
|
||||
String[] titles = new String[values().length];
|
||||
int i = 0;
|
||||
for (SETTINGS setting : values()) {
|
||||
titles[i++] = setting.getTitle(ctx);
|
||||
}
|
||||
return titles;
|
||||
}
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater)mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
@ -48,44 +110,29 @@ public class Apple2MainMenu {
|
|||
mainMenuView.setEnabled(true);
|
||||
LinearLayout mainPopupContainer = (LinearLayout)listLayout.findViewById(R.id.main_popup_container);
|
||||
|
||||
String[] values = new String[] {
|
||||
mActivity.getResources().getString(R.string.menu_settings),
|
||||
mActivity.getResources().getString(R.string.menu_disks),
|
||||
mActivity.getResources().getString(R.string.spacer),
|
||||
mActivity.getResources().getString(R.string.reboot),
|
||||
};
|
||||
final String[] values = SETTINGS.titles(mActivity);
|
||||
|
||||
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1, android.R.id.text1, values) {
|
||||
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_2, android.R.id.text1, values) {
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled(int position) {
|
||||
if (position < 0 || position > 3) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return position != 2;
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
TextView tv = (TextView)view.findViewById(android.R.id.text2);
|
||||
SETTINGS setting = SETTINGS.values()[position];
|
||||
tv.setText(setting.getSummary(mActivity));
|
||||
return view;
|
||||
}
|
||||
};
|
||||
mainMenuView.setAdapter(adapter);
|
||||
mainMenuView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
Apple2MainMenu.this.showSettings();
|
||||
break;
|
||||
case 1:
|
||||
Apple2MainMenu.this.showDisksMenu();
|
||||
break;
|
||||
case 3:
|
||||
Apple2MainMenu.this.reboot();
|
||||
break;
|
||||
default:
|
||||
Apple2MainMenu.this.dismiss();
|
||||
break;
|
||||
}
|
||||
Log.d(TAG, "position:"+position+" tapped...");
|
||||
SETTINGS setting = SETTINGS.values()[position];
|
||||
setting.handleSelection(Apple2MainMenu.this);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -131,11 +178,6 @@ public class Apple2MainMenu {
|
|||
mMainMenuPopup.dismiss();
|
||||
}
|
||||
|
||||
public void reboot() {
|
||||
mActivity.nativeReboot();
|
||||
mMainMenuPopup.dismiss();
|
||||
}
|
||||
|
||||
public synchronized Apple2SettingsMenu getSettingsMenu() {
|
||||
if (mSettingsMenu == null) {
|
||||
mSettingsMenu = new Apple2SettingsMenu(mActivity, mParentView);
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
|
||||
package org.deadc0de.apple2ix;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -19,10 +22,11 @@ import android.view.ViewGroup;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Apple2SettingsMenu {
|
||||
|
||||
|
@ -38,63 +42,191 @@ public class Apple2SettingsMenu {
|
|||
setup();
|
||||
}
|
||||
|
||||
enum SETTINGS {
|
||||
SINGLE_TAP {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.keyboard_singletap);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.keyboard_singletap_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2SettingsMenu settingsMenu, boolean selected) {
|
||||
settingsMenu.mActivity.setSingleTapShowsMainMenu(selected);
|
||||
}
|
||||
},
|
||||
DOUBLE_TAP {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.keyboard_doubletap);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.keyboard_doubletap_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2SettingsMenu settingsMenu, boolean selected) {
|
||||
settingsMenu.mActivity.setDoubleTapShowsKeyboard(selected);
|
||||
}
|
||||
},
|
||||
SPEED_SWIPE {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.speed_swipe);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.speed_swipe_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2SettingsMenu settingsMenu, boolean selected) {
|
||||
settingsMenu.mActivity.setSwipeTogglesSpeed(selected);
|
||||
}
|
||||
},
|
||||
JOYSTICK_CONFIGURE {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.configure_joystick);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.configure_joystick_summary);
|
||||
}
|
||||
@Override public boolean wantsCheckbox() {
|
||||
return false;
|
||||
}
|
||||
@Override public void handleSelection(Apple2SettingsMenu settingsMenu, boolean selected) {
|
||||
}
|
||||
},
|
||||
AUDIO_ENABLE {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.audio_enabled);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.audio_enabled_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2SettingsMenu settingsMenu, boolean selected) {
|
||||
}
|
||||
},
|
||||
VIDEO_CONFIGURE {
|
||||
@Override public String getTitle(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.configure_video);
|
||||
}
|
||||
@Override public String getSummary(Context ctx) {
|
||||
return ctx.getResources().getString(R.string.configure_video_summary);
|
||||
}
|
||||
@Override public boolean wantsCheckbox() {
|
||||
return false;
|
||||
}
|
||||
@Override public boolean wantsPopup() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void handleSelection(final Apple2SettingsMenu settingsMenu, boolean selected) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(settingsMenu.mActivity).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.configure_video);
|
||||
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
String[] color_choices = new String[]{
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_bw),
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_color),
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_interpolated),
|
||||
};
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(settingsMenu.mActivity, android.R.layout.select_dialog_singlechoice, color_choices);
|
||||
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int color) {
|
||||
settingsMenu.mActivity.nativeSetColor(color);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
};
|
||||
|
||||
public abstract String getTitle(Context ctx);
|
||||
public abstract String getSummary(Context ctx);
|
||||
public abstract void handleSelection(Apple2SettingsMenu settingsMenu, boolean selected);
|
||||
public boolean wantsCheckbox() {
|
||||
return true;
|
||||
}
|
||||
public boolean wantsPopup() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String[] titles(Context ctx) {
|
||||
String[] titles = new String[values().length];
|
||||
int i = 0;
|
||||
for (SETTINGS setting : values()) {
|
||||
titles[i++] = setting.getTitle(ctx);
|
||||
}
|
||||
return titles;
|
||||
}
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater)mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mSettingsView = inflater.inflate(R.layout.activity_settings, null, false);
|
||||
|
||||
// General Settings
|
||||
ListView settingsList = (ListView)mSettingsView.findViewById(R.id.listView_settings);
|
||||
settingsList.setEnabled(true);
|
||||
|
||||
final CheckBox swipeToChangeSpeeds = (CheckBox)mSettingsView.findViewById(R.id.checkBox_speedswipe);
|
||||
swipeToChangeSpeeds.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
final String[] titles = SETTINGS.titles(mActivity);
|
||||
|
||||
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, R.layout.a2preference, R.id.a2preference_title, titles) {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Apple2SettingsMenu.this.mActivity.setSwipeTogglesSpeed(isChecked);
|
||||
public boolean areAllItemsEnabled() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final CheckBox doubleTapShowsKeyboard = (CheckBox)mSettingsView.findViewById(R.id.checkBox_doubletapkeyboard);
|
||||
doubleTapShowsKeyboard.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
/*@Override
|
||||
public boolean isEnabled(int position) {
|
||||
if (position < 0 || position > 3) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return position != 2;
|
||||
}*/
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Apple2SettingsMenu.this.mActivity.setDoubleTapShowsKeyboard(isChecked);
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
TextView tv = (TextView)view.findViewById(R.id.a2preference_summary);
|
||||
|
||||
SETTINGS setting = SETTINGS.values()[position];
|
||||
tv.setText(setting.getSummary(mActivity));
|
||||
|
||||
LinearLayout layout = (LinearLayout)view.findViewById(R.id.a2preference_widget_frame);
|
||||
if (layout.getChildCount() > 0) {
|
||||
// layout cells appear to be reused when scrolling into view ... make sure we start with clear hierarchy
|
||||
layout.removeAllViews();
|
||||
}
|
||||
|
||||
if (setting.wantsPopup()) {
|
||||
ImageView imageView = new ImageView(mActivity);
|
||||
Drawable drawable = mActivity.getResources().getDrawable(android.R.drawable.ic_menu_edit);
|
||||
imageView.setImageDrawable(drawable);
|
||||
layout.addView(imageView);
|
||||
}
|
||||
if (setting.wantsCheckbox()) {
|
||||
CheckBox checkBox = new CheckBox(mActivity);
|
||||
layout.addView(checkBox);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
});
|
||||
|
||||
// Joystick Settings
|
||||
|
||||
ListView settingsMenuView = (ListView)mSettingsView.findViewById(R.id.joystick_settings_listview);
|
||||
String[] values = new String[] {
|
||||
mActivity.getResources().getString(R.string.joystick_configure),
|
||||
};
|
||||
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1, android.R.id.text1, values);
|
||||
settingsMenuView.setAdapter(adapter);
|
||||
settingsMenuView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
settingsList.setAdapter(adapter);
|
||||
settingsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
Apple2SettingsMenu.this.showJoystickConfiguration();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
SETTINGS setting = SETTINGS.values()[position];
|
||||
|
||||
LinearLayout layout = (LinearLayout)view.findViewById(R.id.a2preference_widget_frame);
|
||||
View childView = layout.getChildAt(0);
|
||||
boolean selected = false;
|
||||
if (childView != null && childView instanceof CheckBox) {
|
||||
CheckBox checkBox = (CheckBox)childView;
|
||||
checkBox.setChecked(!checkBox.isChecked());
|
||||
selected = checkBox.isChecked();
|
||||
}
|
||||
setting.handleSelection(Apple2SettingsMenu.this, selected);
|
||||
}
|
||||
});
|
||||
|
||||
// Tab management
|
||||
|
||||
TabHost tabHost = (TabHost)mSettingsView.findViewById(R.id.tabHost_settings);
|
||||
tabHost.setup();
|
||||
TabHost.TabSpec spec = tabHost.newTabSpec("tab_general");
|
||||
spec.setIndicator(mActivity.getResources().getString(R.string.tab_general), mActivity.getResources().getDrawable(android.R.drawable.ic_menu_edit));
|
||||
spec.setContent(R.id.tab_general);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
spec = tabHost.newTabSpec("tab_joystick");
|
||||
spec.setIndicator(mActivity.getResources().getString(R.string.tab_joystick), mActivity.getResources().getDrawable(android.R.drawable.ic_menu_compass));
|
||||
spec.setContent(R.id.tab_joystick);
|
||||
tabHost.addTab(spec);
|
||||
}
|
||||
|
||||
public void showJoystickConfiguration() {
|
||||
|
|
59
Android/app/src/main/res/layout/a2preference.xml
Normal file
59
Android/app/src/main/res/layout/a2preference.xml
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2006 The Android Open Source Project
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Modified from Gingerbread android.R.layout.preference -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingRight="?android:attr/scrollbarSize">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dip"
|
||||
android:layout_marginRight="6dip"
|
||||
android:layout_marginTop="6dip"
|
||||
android:layout_marginBottom="6dip"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView android:id="@+id/a2preference_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
<TextView android:id="@+id/a2preference_summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/a2preference_title"
|
||||
android:layout_alignLeft="@id/a2preference_title"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:maxLines="4" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- Custom preference should place its actual preference widget here. -->
|
||||
<LinearLayout android:id="@+id/a2preference_widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:descendantFocusability="blocksDescendants" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,43 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:background="@color/black"
|
||||
android:orientation="vertical"
|
||||
android:baselineAligned="false"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<TabHost
|
||||
<TextView
|
||||
android:id="@+id/header_settings"
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/tabHost_settings">
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"></TabWidget>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/tab_general"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
layout="@layout/general_settings" >
|
||||
</include>
|
||||
|
||||
<include
|
||||
android:id="@+id/tab_joystick"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/joystick_settings" >
|
||||
</include>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
<ListView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/listView_settings"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tab_settings1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/keyboard_doubletap"
|
||||
android:id="@+id/checkBox_doubletapkeyboard"
|
||||
android:textSize="14sp"
|
||||
android:checked="true" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/speed_swipe"
|
||||
android:id="@+id/checkBox_speedswipe"
|
||||
android:checked="true"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1,72 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tab_settings2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/joystick_show"
|
||||
android:id="@+id/checkBox_joystick"
|
||||
android:textSize="14sp"
|
||||
android:checked="true" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
android:gravity="fill_horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/joystick"
|
||||
android:id="@+id/radioButton_joystick0"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:checked="true"
|
||||
android:layout_weight=".33" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/joystick_keyA"
|
||||
android:id="@+id/radioButton_joystickA"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_weight=".33" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/joystick_keyB"
|
||||
android:id="@+id/radioButton_joystickB"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginRight="4dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ListView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/joystick_settings_listview"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -5,24 +5,45 @@
|
|||
<color name="white">#ffffff</color>
|
||||
|
||||
<string name="app_name">Apple2ix</string>
|
||||
<string name="audio_enabled">Enable audio</string>
|
||||
<string name="audio_enabled_summary">(Unimplemented … but hopefully coming soon!)</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="color_bw">Black/white</string>
|
||||
<string name="color_color">Color</string>
|
||||
<string name="color_interpolated">Interpolated color</string>
|
||||
<string name="configure_joystick">Configure emulated joysticks…</string>
|
||||
<string name="configure_joystick_summary">TouchJoy axis and buttons, hitboxes, etc</string>
|
||||
<string name="configure_video">Configure video…</string>
|
||||
<string name="configure_video_summary">Color settings</string>
|
||||
<string name="joystick">Joystick</string>
|
||||
<string name="joystick_configure">Configure emulated joysticks…</string>
|
||||
<string name="joystick_keyA">Key Joystick 1</string>
|
||||
<string name="joystick_keyB">Key Joystick 2</string>
|
||||
<string name="joystick_show">Show emulated joystick</string>
|
||||
<string name="joystick_enable">Enable emulated joystick</string>
|
||||
<string name="keyboard">Keyboard</string>
|
||||
<string name="keyboard_doubletap">Double-tap shows keyboard</string>
|
||||
<string name="keyboard_doubletap_summary">Uncheck to disable keyboard input</string>
|
||||
<string name="keyboard_singletap">Single-tap shows main menu</string>
|
||||
<string name="keyboard_singletap_summary">(If unchecked, main menu still available from back key)</string>
|
||||
<string name="max">Max</string>
|
||||
<string name="menu_disks">Load disk image…</string>
|
||||
<string name="menu_disks_summary">Insert a Disk ][ image file</string>
|
||||
<string name="menu_settings">Emulator settings…</string>
|
||||
<string name="menu_settings_summary">General, CPU, Joystick</string>
|
||||
<string name="no">No</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="quit">Quit Apple2ix?</string>
|
||||
<string name="reboot">Reboot Apple //e…</string>
|
||||
<string name="quit">Quit emulator…</string>
|
||||
<string name="quit_summary"></string>
|
||||
<string name="quit_really">Quit emulator?</string>
|
||||
<string name="reboot">Reboot emulator…</string>
|
||||
<string name="reboot_really">Reboot emulator?</string>
|
||||
<string name="reboot_warning">You will lose unsaved progress</string>
|
||||
<string name="reboot_summary"></string>
|
||||
<string name="spacer"></string>
|
||||
<string name="speed_alt">Alternate CPU Speed</string>
|
||||
<string name="speed_cpu">CPU Speed</string>
|
||||
<string name="speed_swipe">Left/right swiping changes emulation speed</string>
|
||||
<string name="speed_swipe">Swipe changes emulation speed</string>
|
||||
<string name="speed_swipe_summary">Left/right swiping decreases/increases emulation speed</string>
|
||||
<string name="settings">Apple2ix emulator settings</string>
|
||||
<string name="tab_general">General</string>
|
||||
<string name="tab_joystick">Joystick</string>
|
||||
<string name="title_activity_second">SecondActivity</string>
|
||||
|
|
|
@ -263,3 +263,16 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeDecreaseCPUSpeed(JNIEnv *en
|
|||
pthread_mutex_unlock(&interface_mutex);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeSetColor(JNIEnv *env, jobject obj, jint color) {
|
||||
LOG("native set color : %d", color);
|
||||
if (color < COLOR_NONE || color > COLOR_INTERP) {
|
||||
return;
|
||||
}
|
||||
color_mode = color;
|
||||
|
||||
#warning HACK TODO FIXME need to refactor video resetting procedure
|
||||
video_set(0);
|
||||
video_setpage(!!(softswitches & SS_SCREEN));
|
||||
video_redraw();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user