mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-26 00:29:27 +00:00
Refactor slider views and misc
This commit is contained in:
parent
acfb60634e
commit
37bb0cc6d8
|
@ -110,7 +110,11 @@ public abstract class Apple2AbstractMenu implements Apple2MenuView {
|
|||
public void saveInt(int value);
|
||||
}
|
||||
|
||||
protected static View _sliderView(final Apple2Activity activity, final IMenuEnum setting, final int numChoices, final boolean showFloatValue, final IPreferenceLoadSave iLoadSave) {
|
||||
public interface IPreferenceSlider extends IPreferenceLoadSave {
|
||||
public void showValue(int value, final TextView seekBarValue);
|
||||
}
|
||||
|
||||
protected static View _sliderView(final Apple2Activity activity, final IMenuEnum setting, final int numChoices, final IPreferenceSlider iLoadSave) {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.a2preference_slider, null, false);
|
||||
|
@ -127,11 +131,7 @@ public abstract class Apple2AbstractMenu implements Apple2MenuView {
|
|||
if (!fromUser) {
|
||||
return;
|
||||
}
|
||||
if (showFloatValue) {
|
||||
seekBarValue.setText("" + ((float) progress / numChoices));
|
||||
} else {
|
||||
seekBarValue.setText("" + progress);
|
||||
}
|
||||
iLoadSave.showValue(progress, seekBarValue);
|
||||
iLoadSave.saveInt(progress);
|
||||
}
|
||||
|
||||
|
@ -148,11 +148,7 @@ public abstract class Apple2AbstractMenu implements Apple2MenuView {
|
|||
sb.setMax(numChoices);
|
||||
int progress = iLoadSave.intValue();
|
||||
sb.setProgress(progress);
|
||||
if (showFloatValue) {
|
||||
seekBarValue.setText("" + ((float) progress / numChoices));
|
||||
} else {
|
||||
seekBarValue.setText("" + progress);
|
||||
}
|
||||
iLoadSave.showValue(progress, seekBarValue);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.deadc0de.apple2ix;
|
|||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Apple2AudioSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
|
@ -49,12 +50,12 @@ public class Apple2AudioSettingsMenu extends Apple2AbstractMenu {
|
|||
enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
SPEAKER_ENABLED {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.speaker_enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.speaker_enable_summary);
|
||||
}
|
||||
|
||||
|
@ -68,37 +69,43 @@ public class Apple2AudioSettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
SPEAKER_VOLUME {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.speaker_volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.speaker_volume_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
return _sliderView(activity, this, Apple2Preferences.Volume.MAX.ordinal() - 1, /*showFloatValue:*/false, new IPreferenceLoadSave() {
|
||||
return _sliderView(activity, this, Apple2Preferences.Volume.MAX.ordinal() - 1, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
Apple2Preferences.SPEAKER_VOLUME.saveVolume(activity, Apple2Preferences.Volume.values()[progress]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.SPEAKER_VOLUME.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
seekBarValue.setText("" + progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
MOCKINGBOARD_ENABLED {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.mockingboard_enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.mockingboard_enable_summary);
|
||||
}
|
||||
|
||||
|
@ -117,54 +124,60 @@ public class Apple2AudioSettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
MOCKINGBOARD_VOLUME {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.mockingboard_volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.mockingboard_volume_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
return _sliderView(activity, this, Apple2Preferences.Volume.MAX.ordinal() - 1, /*showFloatValue:*/false, new IPreferenceLoadSave() {
|
||||
return _sliderView(activity, this, Apple2Preferences.Volume.MAX.ordinal() - 1, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
Apple2Preferences.MOCKINGBOARD_VOLUME.saveVolume(activity, Apple2Preferences.Volume.values()[progress]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.MOCKINGBOARD_VOLUME.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
seekBarValue.setText("" + progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
ADVANCED_SEPARATOR {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.settings_advanced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.settings_advanced_summary);
|
||||
}
|
||||
},
|
||||
AUDIO_LATENCY {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.audio_latency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.audio_latency_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
return _sliderView(activity, this, Apple2Preferences.AUDIO_LATENCY_NUM_CHOICES, /*showFloatValue:*/true, new IPreferenceLoadSave() {
|
||||
return _sliderView(activity, this, Apple2Preferences.AUDIO_LATENCY_NUM_CHOICES, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
if (progress == 0) {
|
||||
|
@ -173,10 +186,16 @@ public class Apple2AudioSettingsMenu extends Apple2AbstractMenu {
|
|||
}
|
||||
Apple2Preferences.AUDIO_LATENCY.saveInt(activity, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.AUDIO_LATENCY.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
seekBarValue.setText("" + ((float) progress / Apple2Preferences.AUDIO_LATENCY_NUM_CHOICES));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.net.Uri;
|
|||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
|
@ -53,12 +54,12 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
TOUCH_MENU_ENABLED {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_enable_summary);
|
||||
}
|
||||
|
||||
|
@ -77,18 +78,18 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
TOUCH_MENU_VISIBILITY {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_visibility_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
return _sliderView(activity, this, Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES, /*showFloatValue:*/true, new IPreferenceLoadSave() {
|
||||
return _sliderView(activity, this, Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
Apple2Preferences.TOUCH_MENU_VISIBILITY.saveInt(activity, progress);
|
||||
|
@ -97,22 +98,27 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
public int intValue() {
|
||||
return Apple2Preferences.TOUCH_MENU_VISIBILITY.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
seekBarValue.setText("" + ((float) progress / Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
CURRENT_INPUT {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.input_current);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.input_current_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
public final View getView(final Apple2Activity activity, View convertView) {
|
||||
convertView = _basicView(activity, this, convertView);
|
||||
_addPopupIcon(activity, this, convertView);
|
||||
return convertView;
|
||||
|
@ -131,19 +137,51 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
|
||||
@Override
|
||||
public void saveInt(int value) {
|
||||
Apple2Preferences.CURRENT_TOUCH_DEVICE.saveTouchDevice(activity, Apple2Preferences.TouchDevice.values()[value + 1]);
|
||||
Apple2Preferences.CURRENT_TOUCH_DEVICE.saveTouchDevice(activity, Apple2Preferences.TouchDeviceVariant.values()[value + 1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
JOYSTICK_CONFIGURE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_configure_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
//new Apple2KeyboardSettingsMenu().show();
|
||||
}
|
||||
},
|
||||
KEYPAD_CONFIGURE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keypad_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keypad_configure_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
//new Apple2JoystickSettingsMenu(activity).show();
|
||||
}
|
||||
},
|
||||
KEYBOARD_CONFIGURE {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_configure_summary);
|
||||
}
|
||||
|
||||
|
@ -152,30 +190,14 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
//new Apple2KeyboardSettingsMenu().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 Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
//new Apple2JoystickSettingsMenu(activity).show();
|
||||
}
|
||||
},
|
||||
AUDIO_CONFIGURE {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.audio_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.audio_configure_summary);
|
||||
}
|
||||
|
||||
|
@ -186,12 +208,12 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
VIDEO_CONFIGURE {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.video_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.video_configure_summary);
|
||||
}
|
||||
|
||||
|
@ -223,12 +245,12 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
ABOUT {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.about_apple2ix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.about_apple2ix_summary);
|
||||
}
|
||||
|
||||
|
@ -242,12 +264,12 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
ABOUT_APPLE2 {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.about_apple2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.about_apple2_summary);
|
||||
}
|
||||
|
||||
|
@ -261,12 +283,12 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||
},
|
||||
RESET_PREFERENCES {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.preferences_reset_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.preferences_reset_summary);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,19 +24,40 @@
|
|||
<string name="emulation_continue">Continue…</string>
|
||||
<string name="emulation_preferences">Preferences…</string>
|
||||
<string name="header_disks">Insert disk:</string>
|
||||
<string name="joystick">Joystick</string>
|
||||
<string name="input_configure">Configure input devices…</string>
|
||||
<string name="input_configure_summary">Keyboard, joystick, etc</string>
|
||||
<string name="input_current">Current touch device</string>
|
||||
<string name="input_current_summary">Choose current touch device</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_current_variant">Choose joystick type</string>
|
||||
<string name="joystick_current_variant_summary">Choose from emulated joystick or keypad devices</string>
|
||||
<string name="joystick">Joystick</string>
|
||||
<string name="joystickA">Touch Joystick</string>
|
||||
<string name="keypadA">Touch Keypad</string>
|
||||
<string name="joystick_axis_sensitivity_summary">Tune sensitivity scale</string>
|
||||
<string name="joystick_button_axis_enable">Enable button axis</string>
|
||||
<string name="joystick_button_axis_enable_summary">Enable button axis</string>
|
||||
<string name="joystick_button_button1">Button1 (Open Apple)</string>
|
||||
<string name="joystick_button_button2">Button2 (Closed Apple)</string>
|
||||
<string name="joystick_button_button_both">Both</string>
|
||||
<string name="joystick_button_button_none">None</string>
|
||||
<string name="joystick_button_tap_button">Tap fire</string>
|
||||
<string name="joystick_button_tap_button_summary">Button to fire on tap down</string>
|
||||
<string name="joystick_button_tapdelay_summary">Tap delay in secs (interval to determine if tap or swipe)</string>
|
||||
<string name="joystick_button_swipe_up_button">Swipe up fire</string>
|
||||
<string name="joystick_button_swipe_up_button_summary">Button to fire on swipe up</string>
|
||||
<string name="joystick_button_swipe_down_button">Swipe down fire</string>
|
||||
<string name="joystick_button_swipe_down_button_summary">Button to fire on swipe down</string>
|
||||
<string name="joystick_calibrate">Calibrate…</string>
|
||||
<string name="joystick_calibrate_summary">Configure and test current settings</string>
|
||||
<string name="joystick_configure">Configure joystick…</string>
|
||||
<string name="joystick_configure_summary">Axis touch/tilt, buttons, etc</string>
|
||||
<string name="joystick_current">Current joystick flavor</string>
|
||||
<string name="joystick_current_summary">Emulated physical joystick or keypad</string>
|
||||
<string name="joystick_swap">Swap axis and buttons</string>
|
||||
<string name="joystick_swap_summary">Axis target on right and button </string>
|
||||
<string name="keypad">Keypad Joystick</string>
|
||||
<string name="keypadA">Touch Keypad Joystick</string>
|
||||
<string name="keypad_configure">Configure keypad joystick…</string>
|
||||
<string name="keypad_configure_summary">Axis touch/tilt, buttons, etc</string>
|
||||
<string name="keyboard">Keyboard</string>
|
||||
<string name="keyboard_configure">Configure keyboard…</string>
|
||||
<string name="keyboard_configure_summary">Transparency, fading, custom keys</string>
|
||||
|
|
Loading…
Reference in New Issue
Block a user