mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-29 04:29:31 +00:00
Moar Android configuration menus
This commit is contained in:
parent
9ac6448593
commit
fcd367bd9e
|
@ -41,13 +41,18 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
|
|
||||||
enum SETTINGS {
|
enum SETTINGS {
|
||||||
SPEAKER_ENABLED {
|
SPEAKER_ENABLED {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.speaker_enable);
|
return activity.getResources().getString(R.string.speaker_enable);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.speaker_enable_summary);
|
return activity.getResources().getString(R.string.speaker_enable_summary);
|
||||||
}
|
}
|
||||||
@Override public View getView(final Apple2Activity activity, View convertView) {
|
|
||||||
|
@Override
|
||||||
|
public View getView(final Apple2Activity activity, View convertView) {
|
||||||
convertView = _basicView(activity, this, convertView);
|
convertView = _basicView(activity, this, convertView);
|
||||||
CheckBox cb = _addCheckbox(activity, this, convertView, true);
|
CheckBox cb = _addCheckbox(activity, this, convertView, true);
|
||||||
cb.setEnabled(false);
|
cb.setEnabled(false);
|
||||||
|
@ -55,22 +60,27 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SPEAKER_VOLUME {
|
SPEAKER_VOLUME {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.speaker_volume);
|
return activity.getResources().getString(R.string.speaker_volume);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.speaker_volume_summary);
|
return activity.getResources().getString(R.string.speaker_volume_summary);
|
||||||
}
|
}
|
||||||
@Override public View getView(final Apple2Activity activity, View convertView) {
|
|
||||||
LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
@Override
|
||||||
|
public View getView(final Apple2Activity activity, View convertView) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
||||||
|
|
||||||
TextView tv = (TextView)convertView.findViewById(R.id.a2preference_slider_summary);
|
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_slider_summary);
|
||||||
tv.setText(getSummary(activity));
|
tv.setText(getSummary(activity));
|
||||||
|
|
||||||
final TextView seekBarValue = (TextView)convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
final TextView seekBarValue = (TextView) convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
||||||
|
|
||||||
SeekBar sb = (SeekBar)convertView.findViewById(R.id.a2preference_slider_seekBar);
|
SeekBar sb = (SeekBar) convertView.findViewById(R.id.a2preference_slider_seekBar);
|
||||||
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
@ -123,22 +133,27 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MOCKINGBOARD_VOLUME {
|
MOCKINGBOARD_VOLUME {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.mockingboard_volume);
|
return activity.getResources().getString(R.string.mockingboard_volume);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.mockingboard_volume_summary);
|
return activity.getResources().getString(R.string.mockingboard_volume_summary);
|
||||||
}
|
}
|
||||||
@Override public View getView(final Apple2Activity activity, View convertView) {
|
|
||||||
LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
@Override
|
||||||
|
public View getView(final Apple2Activity activity, View convertView) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
||||||
|
|
||||||
TextView tv = (TextView)convertView.findViewById(R.id.a2preference_slider_summary);
|
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_slider_summary);
|
||||||
tv.setText(getSummary(activity));
|
tv.setText(getSummary(activity));
|
||||||
|
|
||||||
final TextView seekBarValue = (TextView)convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
final TextView seekBarValue = (TextView) convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
||||||
|
|
||||||
SeekBar sb = (SeekBar)convertView.findViewById(R.id.a2preference_slider_seekBar);
|
SeekBar sb = (SeekBar) convertView.findViewById(R.id.a2preference_slider_seekBar);
|
||||||
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
@ -167,30 +182,38 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ADVANCED_SEPARATOR {
|
ADVANCED_SEPARATOR {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.settings_advanced);
|
return activity.getResources().getString(R.string.settings_advanced);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.settings_advanced_summary);
|
return activity.getResources().getString(R.string.settings_advanced_summary);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AUDIO_LATENCY {
|
AUDIO_LATENCY {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.audio_latency);
|
return activity.getResources().getString(R.string.audio_latency);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.audio_latency_summary);
|
return activity.getResources().getString(R.string.audio_latency_summary);
|
||||||
}
|
}
|
||||||
@Override public View getView(final Apple2Activity activity, View convertView) {
|
|
||||||
LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
@Override
|
||||||
|
public View getView(final Apple2Activity activity, View convertView) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
||||||
|
|
||||||
TextView tv = (TextView)convertView.findViewById(R.id.a2preference_slider_summary);
|
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_slider_summary);
|
||||||
tv.setText(getSummary(activity));
|
tv.setText(getSummary(activity));
|
||||||
|
|
||||||
final TextView seekBarValue = (TextView)convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
final TextView seekBarValue = (TextView) convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
||||||
|
|
||||||
final SeekBar sb = (SeekBar)convertView.findViewById(R.id.a2preference_slider_seekBar);
|
final SeekBar sb = (SeekBar) convertView.findViewById(R.id.a2preference_slider_seekBar);
|
||||||
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
@ -202,7 +225,7 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
progress = 1;
|
progress = 1;
|
||||||
sb.setProgress(progress);
|
sb.setProgress(progress);
|
||||||
}
|
}
|
||||||
float latencySecs = (float)progress / Apple2Preferences.AUDIO_LATENCY_NUM_CHOICES;
|
float latencySecs = (float) progress / Apple2Preferences.AUDIO_LATENCY_NUM_CHOICES;
|
||||||
seekBarValue.setText("" + latencySecs);
|
seekBarValue.setText("" + latencySecs);
|
||||||
Apple2Preferences.AUDIO_LATENCY.saveFloat(activity, latencySecs);
|
Apple2Preferences.AUDIO_LATENCY.saveFloat(activity, latencySecs);
|
||||||
}
|
}
|
||||||
|
@ -226,14 +249,14 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static View _basicView(Apple2Activity activity, SETTINGS setting, View convertView) {
|
private static View _basicView(Apple2Activity activity, SETTINGS setting, View convertView) {
|
||||||
TextView tv = (TextView)convertView.findViewById(R.id.a2preference_title);
|
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_title);
|
||||||
tv.setText(setting.getTitle(activity));
|
tv.setText(setting.getTitle(activity));
|
||||||
|
|
||||||
tv = (TextView)convertView.findViewById(R.id.a2preference_summary);
|
tv = (TextView) convertView.findViewById(R.id.a2preference_summary);
|
||||||
tv.setText(setting.getSummary(activity));
|
tv.setText(setting.getSummary(activity));
|
||||||
|
|
||||||
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.a2preference_widget_frame);
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
if (layout.getChildCount() > 0) {
|
if (layout.getChildCount() > 0) {
|
||||||
// layout cells appear to be reused when scrolling into view ... make sure we start with clear hierarchy
|
// layout cells appear to be reused when scrolling into view ... make sure we start with clear hierarchy
|
||||||
layout.removeAllViews();
|
layout.removeAllViews();
|
||||||
|
@ -241,18 +264,20 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImageView _addPopupIcon(Apple2Activity activity, SETTINGS setting, View convertView) {
|
private static ImageView _addPopupIcon(Apple2Activity activity, SETTINGS setting, View convertView) {
|
||||||
ImageView imageView = new ImageView(activity);
|
ImageView imageView = new ImageView(activity);
|
||||||
Drawable drawable = activity.getResources().getDrawable(android.R.drawable.ic_menu_edit);
|
Drawable drawable = activity.getResources().getDrawable(android.R.drawable.ic_menu_edit);
|
||||||
imageView.setImageDrawable(drawable);
|
imageView.setImageDrawable(drawable);
|
||||||
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.a2preference_widget_frame);
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
layout.addView(imageView);
|
layout.addView(imageView);
|
||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CheckBox _addCheckbox(Apple2Activity activity, SETTINGS setting, View convertView, boolean isChecked) {
|
private static CheckBox _addCheckbox(Apple2Activity activity, SETTINGS setting, View convertView, boolean isChecked) {
|
||||||
CheckBox checkBox = new CheckBox(activity);
|
CheckBox checkBox = new CheckBox(activity);
|
||||||
checkBox.setChecked(isChecked);
|
checkBox.setChecked(isChecked);
|
||||||
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.a2preference_widget_frame);
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
layout.addView(checkBox);
|
layout.addView(checkBox);
|
||||||
return checkBox;
|
return checkBox;
|
||||||
}
|
}
|
||||||
|
@ -260,6 +285,7 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
public static final int size = SETTINGS.values().length;
|
public static final int size = SETTINGS.values().length;
|
||||||
|
|
||||||
public abstract String getTitle(Apple2Activity activity);
|
public abstract String getTitle(Apple2Activity activity);
|
||||||
|
|
||||||
public abstract String getSummary(Apple2Activity activity);
|
public abstract String getSummary(Apple2Activity activity);
|
||||||
|
|
||||||
public void handleSelection(Apple2AudioSettingsMenu settingsMenu, boolean isChecked) {
|
public void handleSelection(Apple2AudioSettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
@ -281,13 +307,13 @@ public class Apple2AudioSettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
LayoutInflater inflater = (LayoutInflater)mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mSettingsView = inflater.inflate(R.layout.activity_settings, null, false);
|
mSettingsView = inflater.inflate(R.layout.activity_settings, null, false);
|
||||||
|
|
||||||
TextView title = (TextView)mSettingsView.findViewById(R.id.header_settings);
|
TextView title = (TextView) mSettingsView.findViewById(R.id.header_settings);
|
||||||
title.setText(R.string.settings_audio);
|
title.setText(R.string.settings_audio);
|
||||||
|
|
||||||
ListView settingsList = (ListView)mSettingsView.findViewById(R.id.listView_settings);
|
ListView settingsList = (ListView) mSettingsView.findViewById(R.id.listView_settings);
|
||||||
settingsList.setEnabled(true);
|
settingsList.setEnabled(true);
|
||||||
|
|
||||||
// This is a bit of a hack ... we're not using the ArrayAdapter as intended here, simply piggy-backing off its call to getView() to supply a completely custom view. The arguably better way would be to create a custom Apple2SettingsAdapter or something akin to that...
|
// This is a bit of a hack ... we're not using the ArrayAdapter as intended here, simply piggy-backing off its call to getView() to supply a completely custom view. The arguably better way would be to create a custom Apple2SettingsAdapter or something akin to that...
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
/*
|
||||||
|
* Apple // emulator for *nix
|
||||||
|
*
|
||||||
|
* This software package is subject to the GNU General Public License
|
||||||
|
* version 2 or later (your choice) as published by the Free Software
|
||||||
|
* Foundation.
|
||||||
|
*
|
||||||
|
* THERE ARE NO WARRANTIES WHATSOEVER.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.deadc0de.apple2ix;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class Apple2InputSettingsMenu implements Apple2MenuView {
|
||||||
|
|
||||||
|
private final static String TAG = "Apple2InputSettingsMenu";
|
||||||
|
|
||||||
|
private Apple2Activity mActivity = null;
|
||||||
|
private View mSettingsView = null;
|
||||||
|
|
||||||
|
public Apple2InputSettingsMenu(Apple2Activity activity) {
|
||||||
|
mActivity = activity;
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SETTINGS {
|
||||||
|
FIRST_INPUT {
|
||||||
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.input_configure_first_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.input_configure_first_summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(final Apple2Activity activity, View convertView) {
|
||||||
|
convertView = _basicView(activity, this, convertView);
|
||||||
|
_addPopupIcon(activity, this, convertView);
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleSelection(final Apple2Activity activity, final Apple2InputSettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.input_configure_first_title);
|
||||||
|
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
String[] touch_choices = new String[]{
|
||||||
|
activity.getResources().getString(R.string.joystick),
|
||||||
|
activity.getResources().getString(R.string.keyboard),
|
||||||
|
};
|
||||||
|
final int checkedPosition = Apple2Preferences.FIRST_TOUCH_DEVICE.intValue(activity) - 1;
|
||||||
|
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, android.R.layout.select_dialog_singlechoice, touch_choices) {
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view = super.getView(position, convertView, parent);
|
||||||
|
CheckedTextView ctv = (CheckedTextView) view.findViewById(android.R.id.text1);
|
||||||
|
ctv.setChecked(position == checkedPosition);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int color) {
|
||||||
|
Apple2Preferences.FIRST_TOUCH_DEVICE.saveTouchDevice(activity, Apple2Preferences.TouchDevice.values()[color + 1]);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
JOYSTICK_CONFIGURE {
|
||||||
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.joystick_configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.joystick_configure_summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleSelection(final Apple2Activity activity, final Apple2InputSettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
//new Apple2JoystickSettingsMenu().show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
KEYBOARD_CONFIGURE {
|
||||||
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.keyboard_configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.keyboard_configure_summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleSelection(final Apple2Activity activity, final Apple2InputSettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
//new Apple2KeyboardSettingsMenu().show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static View _basicView(Apple2Activity activity, SETTINGS setting, View convertView) {
|
||||||
|
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_title);
|
||||||
|
tv.setText(setting.getTitle(activity));
|
||||||
|
|
||||||
|
tv = (TextView) convertView.findViewById(R.id.a2preference_summary);
|
||||||
|
tv.setText(setting.getSummary(activity));
|
||||||
|
|
||||||
|
LinearLayout layout = (LinearLayout) convertView.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();
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ImageView _addPopupIcon(Apple2Activity activity, SETTINGS setting, View convertView) {
|
||||||
|
ImageView imageView = new ImageView(activity);
|
||||||
|
Drawable drawable = activity.getResources().getDrawable(android.R.drawable.ic_menu_edit);
|
||||||
|
imageView.setImageDrawable(drawable);
|
||||||
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
|
layout.addView(imageView);
|
||||||
|
return imageView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CheckBox _addCheckbox(Apple2Activity activity, SETTINGS setting, View convertView, boolean isChecked) {
|
||||||
|
CheckBox checkBox = new CheckBox(activity);
|
||||||
|
checkBox.setChecked(isChecked);
|
||||||
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
|
layout.addView(checkBox);
|
||||||
|
return checkBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int size = SETTINGS.values().length;
|
||||||
|
|
||||||
|
public abstract String getTitle(Apple2Activity activity);
|
||||||
|
|
||||||
|
public abstract String getSummary(Apple2Activity activity);
|
||||||
|
|
||||||
|
public void handleSelection(Apple2Activity activity, Apple2InputSettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView(Apple2Activity activity, View convertView) {
|
||||||
|
return _basicView(activity, this, convertView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] titles(Apple2Activity activity) {
|
||||||
|
String[] titles = new String[size];
|
||||||
|
int i = 0;
|
||||||
|
for (SETTINGS setting : values()) {
|
||||||
|
titles[i++] = setting.getTitle(activity);
|
||||||
|
}
|
||||||
|
return titles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setup() {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
mSettingsView = inflater.inflate(R.layout.activity_settings, null, false);
|
||||||
|
|
||||||
|
TextView title = (TextView) mSettingsView.findViewById(R.id.header_settings);
|
||||||
|
title.setText(R.string.settings_audio);
|
||||||
|
|
||||||
|
ListView settingsList = (ListView) mSettingsView.findViewById(R.id.listView_settings);
|
||||||
|
settingsList.setEnabled(true);
|
||||||
|
|
||||||
|
// This is a bit of a hack ... we're not using the ArrayAdapter as intended here, simply piggy-backing off its call to getView() to supply a completely custom view. The arguably better way would be to create a custom Apple2SettingsAdapter or something akin to that...
|
||||||
|
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, R.layout.a2preference, R.id.a2preference_title, SETTINGS.titles(mActivity)) {
|
||||||
|
@Override
|
||||||
|
public boolean areAllItemsEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(int position) {
|
||||||
|
if (position < 0 || position >= SETTINGS.size) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
//View view = super.getView(position, convertView, parent);
|
||||||
|
// ^^^ WHOA ... this is catching an NPE deep in AOSP code on the second time loading the audio menu, WTF?
|
||||||
|
// Methinks it is related to the hack of loading a completely different R.layout.something for certain views...
|
||||||
|
View view = convertView != null ? convertView : super.getView(position, null, parent);
|
||||||
|
SETTINGS setting = SETTINGS.values()[position];
|
||||||
|
return setting.getView(mActivity, view);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
settingsList.setAdapter(adapter);
|
||||||
|
settingsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
SETTINGS setting = SETTINGS.values()[position];
|
||||||
|
LinearLayout layout = (LinearLayout) view.findViewById(R.id.a2preference_widget_frame);
|
||||||
|
if (layout == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(mActivity, Apple2InputSettingsMenu.this, selected);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show() {
|
||||||
|
if (isShowing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mActivity.pushApple2View(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismiss() {
|
||||||
|
mActivity.popApple2View(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowing() {
|
||||||
|
return mSettingsView.isShown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView() {
|
||||||
|
return mSettingsView;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,23 +18,30 @@ import android.util.Log;
|
||||||
|
|
||||||
public enum Apple2Preferences {
|
public enum Apple2Preferences {
|
||||||
PREFS_CONFIGURED {
|
PREFS_CONFIGURED {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
@Override public void saveBoolean(Apple2Activity activity, boolean ignored) {
|
|
||||||
|
@Override
|
||||||
|
public void saveBoolean(Apple2Activity activity, boolean ignored) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(toString(), true).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(toString(), true).apply();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
HIRES_COLOR {
|
HIRES_COLOR {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
nativeSetColor(intValue(activity));
|
nativeSetColor(intValue(activity));
|
||||||
}
|
}
|
||||||
@Override public int intValue(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public int intValue(Apple2Activity activity) {
|
||||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), HiresColor.INTERPOLATED.ordinal());
|
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), HiresColor.INTERPOLATED.ordinal());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SPEAKER_ENABLED {
|
SPEAKER_ENABLED {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
boolean enabled = booleanValue(activity);
|
boolean enabled = booleanValue(activity);
|
||||||
boolean result = nativeSetSpeakerEnabled(enabled);
|
boolean result = nativeSetSpeakerEnabled(enabled);
|
||||||
if (enabled && !result) {
|
if (enabled && !result) {
|
||||||
|
@ -42,20 +49,26 @@ public enum Apple2Preferences {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(toString(), false).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(toString(), false).apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override public boolean booleanValue(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public boolean booleanValue(Apple2Activity activity) {
|
||||||
return activity.getPreferences(Context.MODE_PRIVATE).getBoolean(toString(), true);
|
return activity.getPreferences(Context.MODE_PRIVATE).getBoolean(toString(), true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SPEAKER_VOLUME {
|
SPEAKER_VOLUME {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
nativeSetSpeakerVolume(intValue(activity));
|
nativeSetSpeakerVolume(intValue(activity));
|
||||||
}
|
}
|
||||||
@Override public int intValue(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public int intValue(Apple2Activity activity) {
|
||||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), Volume.MEDIUM.ordinal());
|
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), Volume.MEDIUM.ordinal());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MOCKINGBOARD_ENABLED {
|
MOCKINGBOARD_ENABLED {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
boolean enabled = booleanValue(activity);
|
boolean enabled = booleanValue(activity);
|
||||||
boolean result = nativeSetMockingboardEnabled(enabled);
|
boolean result = nativeSetMockingboardEnabled(enabled);
|
||||||
if (enabled && !result) {
|
if (enabled && !result) {
|
||||||
|
@ -65,18 +78,24 @@ public enum Apple2Preferences {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MOCKINGBOARD_VOLUME {
|
MOCKINGBOARD_VOLUME {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
nativeSetMockingboardVolume(intValue(activity));
|
nativeSetMockingboardVolume(intValue(activity));
|
||||||
}
|
}
|
||||||
@Override public int intValue(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public int intValue(Apple2Activity activity) {
|
||||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), Volume.MEDIUM.ordinal());
|
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), Volume.MEDIUM.ordinal());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AUDIO_LATENCY {
|
AUDIO_LATENCY {
|
||||||
@Override public void load(Apple2Activity activity) {
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
nativeSetAudioLatency(floatValue(activity));
|
nativeSetAudioLatency(floatValue(activity));
|
||||||
}
|
}
|
||||||
@Override public float floatValue(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public float floatValue(Apple2Activity activity) {
|
||||||
|
|
||||||
float defaultLatency = 0.f;
|
float defaultLatency = 0.f;
|
||||||
if (defaultLatency == 0.f) {
|
if (defaultLatency == 0.f) {
|
||||||
|
@ -92,6 +111,17 @@ public enum Apple2Preferences {
|
||||||
|
|
||||||
return activity.getPreferences(Context.MODE_PRIVATE).getFloat(toString(), defaultLatency);
|
return activity.getPreferences(Context.MODE_PRIVATE).getFloat(toString(), defaultLatency);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
FIRST_TOUCH_DEVICE {
|
||||||
|
@Override
|
||||||
|
public void load(Apple2Activity activity) {
|
||||||
|
nativeSetDefaultTouchDevice(intValue(activity));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int intValue(Apple2Activity activity) {
|
||||||
|
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), TouchDevice.KEYBOARD.ordinal());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public enum HiresColor {
|
public enum HiresColor {
|
||||||
|
@ -115,11 +145,23 @@ public enum Apple2Preferences {
|
||||||
MAX(10),
|
MAX(10),
|
||||||
ELEVEN(11);
|
ELEVEN(11);
|
||||||
private int vol;
|
private int vol;
|
||||||
|
|
||||||
Volume(int vol) {
|
Volume(int vol) {
|
||||||
this.vol = vol;
|
this.vol = vol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TouchDevice {
|
||||||
|
NONE(0),
|
||||||
|
JOYSTICK(1),
|
||||||
|
KEYBOARD(2);
|
||||||
|
private int dev;
|
||||||
|
|
||||||
|
TouchDevice(int dev) {
|
||||||
|
this.dev = dev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void load(Apple2Activity activity);
|
protected abstract void load(Apple2Activity activity);
|
||||||
|
|
||||||
protected void warnError(Apple2Activity activity, int titleId, int mesgId) {
|
protected void warnError(Apple2Activity activity, int titleId, int mesgId) {
|
||||||
|
@ -141,23 +183,32 @@ public enum Apple2Preferences {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(toString(), value).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putBoolean(toString(), value).apply();
|
||||||
load(activity);
|
load(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveInt(Apple2Activity activity, int value) {
|
public void saveInt(Apple2Activity activity, int value) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value).apply();
|
||||||
load(activity);
|
load(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFloat(Apple2Activity activity, float value) {
|
public void saveFloat(Apple2Activity activity, float value) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putFloat(toString(), value).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putFloat(toString(), value).apply();
|
||||||
load(activity);
|
load(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveHiresColor(Apple2Activity activity, HiresColor value) {
|
public void saveHiresColor(Apple2Activity activity, HiresColor value) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value.ordinal()).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value.ordinal()).apply();
|
||||||
load(activity);
|
load(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveVolume(Apple2Activity activity, Volume value) {
|
public void saveVolume(Apple2Activity activity, Volume value) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value.ordinal()).apply();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value.ordinal()).apply();
|
||||||
load(activity);
|
load(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveTouchDevice(Apple2Activity activity, TouchDevice value) {
|
||||||
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putInt(toString(), value.ordinal()).apply();
|
||||||
|
load(activity);
|
||||||
|
}
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
public boolean booleanValue(Apple2Activity activity) {
|
public boolean booleanValue(Apple2Activity activity) {
|
||||||
|
@ -184,11 +235,20 @@ public enum Apple2Preferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nativeEnableTouchJoystick(boolean enabled);
|
private static native void nativeEnableTouchJoystick(boolean enabled);
|
||||||
|
|
||||||
private static native void nativeEnableTiltJoystick(boolean enabled);
|
private static native void nativeEnableTiltJoystick(boolean enabled);
|
||||||
|
|
||||||
private static native void nativeSetColor(int color);
|
private static native void nativeSetColor(int color);
|
||||||
|
|
||||||
private static native boolean nativeSetSpeakerEnabled(boolean enabled);
|
private static native boolean nativeSetSpeakerEnabled(boolean enabled);
|
||||||
|
|
||||||
private static native void nativeSetSpeakerVolume(int volume);
|
private static native void nativeSetSpeakerVolume(int volume);
|
||||||
|
|
||||||
private static native boolean nativeSetMockingboardEnabled(boolean enabled);
|
private static native boolean nativeSetMockingboardEnabled(boolean enabled);
|
||||||
|
|
||||||
private static native void nativeSetMockingboardVolume(int volume);
|
private static native void nativeSetMockingboardVolume(int volume);
|
||||||
|
|
||||||
private static native void nativeSetAudioLatency(float latencySecs);
|
private static native void nativeSetAudioLatency(float latencySecs);
|
||||||
|
|
||||||
|
private static native void nativeSetDefaultTouchDevice(int device);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
@ -42,40 +43,56 @@ public class Apple2SettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SETTINGS {
|
enum SETTINGS {
|
||||||
JOYSTICK_CONFIGURE {
|
INPUT_CONFIGURE {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
return activity.getResources().getString(R.string.joystick_configure);
|
public String getTitle(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.input_configure);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
return activity.getResources().getString(R.string.joystick_configure_summary);
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.input_configure_summary);
|
||||||
}
|
}
|
||||||
@Override public void handleSelection(Apple2Activity activity, Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
|
||||||
//settingsMenu.mJoystickSettings.show();
|
@Override
|
||||||
|
public void handleSelection(Apple2Activity activity, Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
new Apple2InputSettingsMenu(activity).show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AUDIO_CONFIGURE {
|
AUDIO_CONFIGURE {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.audio_configure);
|
return activity.getResources().getString(R.string.audio_configure);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.audio_configure_summary);
|
return activity.getResources().getString(R.string.audio_configure_summary);
|
||||||
}
|
}
|
||||||
@Override public void handleSelection(Apple2Activity activity, Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
|
||||||
|
@Override
|
||||||
|
public void handleSelection(Apple2Activity activity, Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
||||||
new Apple2AudioSettingsMenu(activity).show();
|
new Apple2AudioSettingsMenu(activity).show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
VIDEO_CONFIGURE {
|
VIDEO_CONFIGURE {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.video_configure);
|
return activity.getResources().getString(R.string.video_configure);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.video_configure_summary);
|
return activity.getResources().getString(R.string.video_configure_summary);
|
||||||
}
|
}
|
||||||
@Override public View getView(Apple2Activity activity, View convertView) {
|
|
||||||
|
@Override
|
||||||
|
public View getView(Apple2Activity activity, View convertView) {
|
||||||
convertView = _basicView(activity, this, convertView);
|
convertView = _basicView(activity, this, convertView);
|
||||||
_addPopupIcon(activity, this, convertView);
|
_addPopupIcon(activity, this, convertView);
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSelection(Apple2Activity activity, final Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
public void handleSelection(Apple2Activity activity, final Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(settingsMenu.mActivity).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.video_configure);
|
AlertDialog.Builder builder = new AlertDialog.Builder(settingsMenu.mActivity).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.video_configure);
|
||||||
|
@ -91,7 +108,16 @@ public class Apple2SettingsMenu implements Apple2MenuView {
|
||||||
settingsMenu.mActivity.getResources().getString(R.string.color_color),
|
settingsMenu.mActivity.getResources().getString(R.string.color_color),
|
||||||
settingsMenu.mActivity.getResources().getString(R.string.color_interpolated),
|
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);
|
final int checkedPosition = Apple2Preferences.HIRES_COLOR.intValue(activity);
|
||||||
|
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(settingsMenu.mActivity, android.R.layout.select_dialog_singlechoice, color_choices) {
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view = super.getView(position, convertView, parent);
|
||||||
|
CheckedTextView ctv = (CheckedTextView) view.findViewById(android.R.id.text1);
|
||||||
|
ctv.setChecked(position == checkedPosition);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,28 +130,56 @@ public class Apple2SettingsMenu implements Apple2MenuView {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ABOUT {
|
ABOUT {
|
||||||
@Override public String getTitle(Apple2Activity activity) {
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.about_title);
|
return activity.getResources().getString(R.string.about_title);
|
||||||
}
|
}
|
||||||
@Override public String getSummary(Apple2Activity activity) {
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
return activity.getResources().getString(R.string.about_summary);
|
return activity.getResources().getString(R.string.about_summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSelection(Apple2Activity activity, final Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
public void handleSelection(Apple2Activity activity, final Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
||||||
String url = "http://github.com/mauiaaron/apple2";
|
String url = "http://github.com/mauiaaron/apple2";
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||||
i.setData(Uri.parse(url));
|
i.setData(Uri.parse(url));
|
||||||
activity.startActivity(i); }
|
activity.startActivity(i);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
RESET_PREFERENCES {
|
||||||
|
@Override
|
||||||
|
public String getTitle(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.preferences_reset_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.preferences_reset_summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleSelection(final Apple2Activity activity, final Apple2SettingsMenu settingsMenu, boolean isChecked) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.preferences_reset_really).setMessage(R.string.preferences_reset_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
Apple2Preferences.resetPreferences(activity);
|
||||||
|
}
|
||||||
|
}).setNegativeButton(R.string.no, null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static View _basicView(Apple2Activity activity, SETTINGS setting, View convertView) {
|
private static View _basicView(Apple2Activity activity, SETTINGS setting, View convertView) {
|
||||||
TextView tv = (TextView)convertView.findViewById(R.id.a2preference_title);
|
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_title);
|
||||||
tv.setText(setting.getTitle(activity));
|
tv.setText(setting.getTitle(activity));
|
||||||
|
|
||||||
tv = (TextView)convertView.findViewById(R.id.a2preference_summary);
|
tv = (TextView) convertView.findViewById(R.id.a2preference_summary);
|
||||||
tv.setText(setting.getSummary(activity));
|
tv.setText(setting.getSummary(activity));
|
||||||
|
|
||||||
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.a2preference_widget_frame);
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
if (layout.getChildCount() > 0) {
|
if (layout.getChildCount() > 0) {
|
||||||
// layout cells appear to be reused when scrolling into view ... make sure we start with clear hierarchy
|
// layout cells appear to be reused when scrolling into view ... make sure we start with clear hierarchy
|
||||||
layout.removeAllViews();
|
layout.removeAllViews();
|
||||||
|
@ -133,18 +187,20 @@ public class Apple2SettingsMenu implements Apple2MenuView {
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImageView _addPopupIcon(Apple2Activity activity, SETTINGS setting, View convertView) {
|
private static ImageView _addPopupIcon(Apple2Activity activity, SETTINGS setting, View convertView) {
|
||||||
ImageView imageView = new ImageView(activity);
|
ImageView imageView = new ImageView(activity);
|
||||||
Drawable drawable = activity.getResources().getDrawable(android.R.drawable.ic_menu_edit);
|
Drawable drawable = activity.getResources().getDrawable(android.R.drawable.ic_menu_edit);
|
||||||
imageView.setImageDrawable(drawable);
|
imageView.setImageDrawable(drawable);
|
||||||
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.a2preference_widget_frame);
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
layout.addView(imageView);
|
layout.addView(imageView);
|
||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CheckBox _addCheckbox(Apple2Activity activity, SETTINGS setting, View convertView, boolean isChecked) {
|
private static CheckBox _addCheckbox(Apple2Activity activity, SETTINGS setting, View convertView, boolean isChecked) {
|
||||||
CheckBox checkBox = new CheckBox(activity);
|
CheckBox checkBox = new CheckBox(activity);
|
||||||
checkBox.setChecked(isChecked);
|
checkBox.setChecked(isChecked);
|
||||||
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.a2preference_widget_frame);
|
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.a2preference_widget_frame);
|
||||||
layout.addView(checkBox);
|
layout.addView(checkBox);
|
||||||
return checkBox;
|
return checkBox;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +208,9 @@ public class Apple2SettingsMenu implements Apple2MenuView {
|
||||||
public static final int size = SETTINGS.values().length;
|
public static final int size = SETTINGS.values().length;
|
||||||
|
|
||||||
public abstract String getTitle(Apple2Activity activity);
|
public abstract String getTitle(Apple2Activity activity);
|
||||||
|
|
||||||
public abstract String getSummary(Apple2Activity activity);
|
public abstract String getSummary(Apple2Activity activity);
|
||||||
|
|
||||||
public abstract void handleSelection(Apple2Activity activity, Apple2SettingsMenu settingsMenu, boolean isChecked);
|
public abstract void handleSelection(Apple2Activity activity, Apple2SettingsMenu settingsMenu, boolean isChecked);
|
||||||
|
|
||||||
public View getView(Apple2Activity activity, View convertView) {
|
public View getView(Apple2Activity activity, View convertView) {
|
||||||
|
@ -171,10 +229,10 @@ public class Apple2SettingsMenu implements Apple2MenuView {
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater)mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mSettingsView = inflater.inflate(R.layout.activity_settings, null, false);
|
mSettingsView = inflater.inflate(R.layout.activity_settings, null, false);
|
||||||
|
|
||||||
ListView settingsList = (ListView)mSettingsView.findViewById(R.id.listView_settings);
|
ListView settingsList = (ListView) mSettingsView.findViewById(R.id.listView_settings);
|
||||||
settingsList.setEnabled(true);
|
settingsList.setEnabled(true);
|
||||||
|
|
||||||
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, R.layout.a2preference, R.id.a2preference_title, SETTINGS.titles(mActivity)) {
|
ArrayAdapter<?> adapter = new ArrayAdapter<String>(mActivity, R.layout.a2preference, R.id.a2preference_title, SETTINGS.titles(mActivity)) {
|
||||||
|
|
|
@ -21,16 +21,20 @@
|
||||||
<string name="disk_read_write">Read/write</string>
|
<string name="disk_read_write">Read/write</string>
|
||||||
<string name="header_disks">Insert disk:</string>
|
<string name="header_disks">Insert disk:</string>
|
||||||
<string name="joystick">Joystick</string>
|
<string name="joystick">Joystick</string>
|
||||||
<string name="joystick_configure">Configure emulated joysticks…</string>
|
<string name="input_configure">Configure input devices…</string>
|
||||||
|
<string name="input_configure_summary">Keyboard, joystick, etc</string>
|
||||||
|
<string name="input_configure_first_title">First touch device</string>
|
||||||
|
<string name="input_configure_first_summary">Touch device enabled on launch</string>
|
||||||
|
<string name="input_first_joystick">Touch joystick</string>
|
||||||
|
<string name="input_first_keyboard">Touch keyboard</string>
|
||||||
|
<string name="joystick_configure">Configure joysticks…</string>
|
||||||
<string name="joystick_configure_summary">Touch/tilt, axis and buttons, etc</string>
|
<string name="joystick_configure_summary">Touch/tilt, axis and buttons, etc</string>
|
||||||
<string name="joystick_enable">Enable emulated joystick</string>
|
<string name="joystick_enable">Enable emulated joystick</string>
|
||||||
<string name="joystick_keyA">Key Joystick 1</string>
|
<string name="joystick_keyA">Key Joystick 1</string>
|
||||||
<string name="joystick_keyB">Key Joystick 2</string>
|
<string name="joystick_keyB">Key Joystick 2</string>
|
||||||
<string name="keyboard">Keyboard</string>
|
<string name="keyboard">Keyboard</string>
|
||||||
<string name="keyboard_doubletap">Double-tap shows keyboard</string>
|
<string name="keyboard_configure">Configure keyboard…</string>
|
||||||
<string name="keyboard_doubletap_summary">Uncheck to disable keyboard input</string>
|
<string name="keyboard_configure_summary">Transparency, fading, custom keys</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="max">Max</string>
|
||||||
<string name="menu_disks">Load disk image…</string>
|
<string name="menu_disks">Load disk image…</string>
|
||||||
<string name="menu_disks_summary">Insert a Disk ][ image file</string>
|
<string name="menu_disks_summary">Insert a Disk ][ image file</string>
|
||||||
|
@ -44,6 +48,10 @@
|
||||||
<string name="mockingboard_volume_summary">Set the Mockingboard(s) volume</string>
|
<string name="mockingboard_volume_summary">Set the Mockingboard(s) volume</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
|
<string name="preferences_reset_title">Reset preferences</string>
|
||||||
|
<string name="preferences_reset_summary">Reset preferences to defaults</string>
|
||||||
|
<string name="preferences_reset_really">Really reset?</string>
|
||||||
|
<string name="preferences_reset_warning">You will lose your settings</string>
|
||||||
<string name="quit">Quit emulator…</string>
|
<string name="quit">Quit emulator…</string>
|
||||||
<string name="quit_summary"></string>
|
<string name="quit_summary"></string>
|
||||||
<string name="quit_really">Quit emulator?</string>
|
<string name="quit_really">Quit emulator?</string>
|
||||||
|
|
|
@ -13,6 +13,14 @@
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
|
typedef enum AndroidTouchDevice_t {
|
||||||
|
// Maps to values in Apple2Preferences.java
|
||||||
|
ANDROID_TOUCH_NONE = 0,
|
||||||
|
ANDROID_TOUCH_JOYSTICK,
|
||||||
|
ANDROID_TOUCH_KEYBOARD,
|
||||||
|
ANDROID_TOUCH_DEVICE_MAX,
|
||||||
|
} AndroidTouchDevice_t;
|
||||||
|
|
||||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeEnableTouchJoystick(JNIEnv *env, jclass cls, jboolean enabled) {
|
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeEnableTouchJoystick(JNIEnv *env, jclass cls, jboolean enabled) {
|
||||||
LOG("native enable touch joystick : %d", enabled);
|
LOG("native enable touch joystick : %d", enabled);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +42,7 @@ void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetColor(JNIEnv *env, jc
|
||||||
}
|
}
|
||||||
|
|
||||||
jboolean Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetSpeakerEnabled(JNIEnv *env, jclass cls, jboolean enabled) {
|
jboolean Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetSpeakerEnabled(JNIEnv *env, jclass cls, jboolean enabled) {
|
||||||
|
LOG("native set speaker enabled : %d", true);
|
||||||
// NO-OP ... speaker should always be enabled (but volume could be zero)
|
// NO-OP ... speaker should always be enabled (but volume could be zero)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +56,7 @@ void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetSpeakerVolume(JNIEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetAudioLatency(JNIEnv *env, jclass cls, jfloat latencySecs) {
|
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetAudioLatency(JNIEnv *env, jclass cls, jfloat latencySecs) {
|
||||||
|
LOG("native set audio latency : %f", latencySecs);
|
||||||
//assert(cpu_isPaused());
|
//assert(cpu_isPaused());
|
||||||
audio_setLatency(latencySecs);
|
audio_setLatency(latencySecs);
|
||||||
}
|
}
|
||||||
|
@ -68,3 +78,23 @@ void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetMockingboardVolume(JN
|
||||||
MB_SetVolumeZeroToTen(goesToTen);
|
MB_SetVolumeZeroToTen(goesToTen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetDefaultTouchDevice(JNIEnv *env, jclass cls, jint touchDevice) {
|
||||||
|
LOG("native set default touch device : %d", touchDevice);
|
||||||
|
assert(touchDevice >= 0 && touchDevice < ANDROID_TOUCH_DEVICE_MAX);
|
||||||
|
switch (touchDevice) {
|
||||||
|
case ANDROID_TOUCH_JOYSTICK:
|
||||||
|
keydriver_setTouchKeyboardOwnsScreen(false);
|
||||||
|
joydriver_setTouchJoystickOwnsScreen(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ANDROID_TOUCH_KEYBOARD:
|
||||||
|
joydriver_setTouchJoystickOwnsScreen(false);
|
||||||
|
keydriver_setTouchKeyboardOwnsScreen(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ANDROID_TOUCH_NONE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user