mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-11 14:30:08 +00:00
Remove old preference migration codepath
This commit is contained in:
parent
44e7bda8ac
commit
a25d68a1d2
@ -184,285 +184,6 @@ public class Apple2Preferences {
|
||||
}
|
||||
|
||||
Apple2Utils.migrateToExternalStorage(activity);
|
||||
if (BuildConfig.VERSION_CODE >= 17) {
|
||||
// FIXME TODO : remove this after most/all app users are on 18+
|
||||
|
||||
boolean keypadPreset = false;
|
||||
Apple2AbstractMenu.IMenuEnum menuEnum = null;
|
||||
ArrayList<String> keypadJSONChars = new ArrayList<String>();
|
||||
ArrayList<String> keypadJSONScans = new ArrayList<String>();
|
||||
for (int i = 0; i < Apple2KeypadSettingsMenu.ROSETTE_SIZE; i++) {
|
||||
keypadJSONChars.add("" + Apple2KeyboardSettingsMenu.ICONTEXT_NONACTION);
|
||||
keypadJSONScans.add("-1");
|
||||
}
|
||||
int keypadTapChar = Apple2KeyboardSettingsMenu.ICONTEXT_NONACTION;
|
||||
int keypadTapScan = -1;
|
||||
int keypadSwipeDownChar = Apple2KeyboardSettingsMenu.ICONTEXT_NONACTION;
|
||||
int keypadSwipeDownScan = -1;
|
||||
int keypadSwipeUpChar = Apple2KeyboardSettingsMenu.ICONTEXT_NONACTION;
|
||||
int keypadSwipeUpScan = -1;
|
||||
|
||||
Map<String, ?> oldPrefs = activity.getPreferences(Activity.MODE_PRIVATE).getAll();
|
||||
for (Map.Entry<String, ?> entry : oldPrefs.entrySet()) {
|
||||
|
||||
String key = entry.getKey();
|
||||
Object val = entry.getValue();
|
||||
Log.d("OLDPREFS", key + " : " + val.toString());
|
||||
|
||||
// remove olde preference ...
|
||||
activity.getPreferences(Activity.MODE_PRIVATE).edit().remove(key).commit();
|
||||
|
||||
try {
|
||||
switch (key) {
|
||||
|
||||
case "HIRES_COLOR": // long
|
||||
menuEnum = Apple2VideoSettingsMenu.SETTINGS.COLOR_MODE_CONFIGURE;
|
||||
break;
|
||||
case "LANDSCAPE_MODE": // bool
|
||||
menuEnum = Apple2VideoSettingsMenu.SETTINGS.LANDSCAPE_MODE;
|
||||
break;
|
||||
case "PORTRAIT_KEYBOARD_POSITION_SCALE": //-> float
|
||||
menuEnum = Apple2PortraitCalibration.States.CALIBRATE_KEYBOARD_POSITION_SCALE;
|
||||
val = (int) val / (float) Apple2PortraitCalibration.PORTRAIT_CALIBRATE_NUM_CHOICES;
|
||||
break;
|
||||
case "PORTRAIT_FRAMEBUFFER_POSITION_SCALE": // -> float
|
||||
menuEnum = Apple2PortraitCalibration.States.CALIBRATE_FRAMEBUFFER_POSITION_SCALE;
|
||||
val = (int) val / (float) Apple2PortraitCalibration.PORTRAIT_CALIBRATE_NUM_CHOICES;
|
||||
break;
|
||||
case "PORTRAIT_KEYBOARD_HEIGHT_SCALE": // -> float
|
||||
menuEnum = Apple2PortraitCalibration.States.CALIBRATE_KEYBOARD_HEIGHT_SCALE;
|
||||
val = (int) val / (float) Apple2PortraitCalibration.PORTRAIT_CALIBRATE_NUM_CHOICES;
|
||||
break;
|
||||
|
||||
case "SPEAKER_VOLUME": // long
|
||||
menuEnum = Apple2AudioSettingsMenu.SETTINGS.SPEAKER_VOLUME;
|
||||
break;
|
||||
case "MOCKINGBOARD_ENABLED": // bool
|
||||
menuEnum = Apple2AudioSettingsMenu.SETTINGS.MOCKINGBOARD_ENABLED;
|
||||
break;
|
||||
case "MOCKINGBOARD_VOLUME": // long
|
||||
menuEnum = Apple2AudioSettingsMenu.SETTINGS.MOCKINGBOARD_VOLUME;
|
||||
break;
|
||||
case "AUDIO_LATENCY": // -> float
|
||||
menuEnum = Apple2AudioSettingsMenu.SETTINGS.AUDIO_LATENCY;
|
||||
val = (int) val / (float) Apple2AudioSettingsMenu.AUDIO_LATENCY_NUM_CHOICES;
|
||||
break;
|
||||
|
||||
case "TOUCH_MENU_ENABLED": // bool
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.TOUCH_MENU_ENABLED;
|
||||
break;
|
||||
case "KEYBOARD_VISIBILITY_ACTIVE": // -> float
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.KEYBOARD_VISIBILITY_ACTIVE;
|
||||
val = (int) val / (float) ALPHA_SLIDER_NUM_CHOICES;
|
||||
break;
|
||||
case "KEYBOARD_VISIBILITY_INACTIVE": // -> float
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.KEYBOARD_VISIBILITY_INACTIVE;
|
||||
val = (int) val / (float) ALPHA_SLIDER_NUM_CHOICES;
|
||||
break;
|
||||
case "KEYBOARD_GLYPH_SCALE": // long
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.KEYBOARD_GLYPH_SCALE;
|
||||
break;
|
||||
case "KEYBOARD_LOWERCASE_ENABLED": // bool
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.KEYBOARD_ENABLE_LOWERCASE;
|
||||
break;
|
||||
case "KEYBOARD_CLICK_ENABLED": // bool
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.KEYBOARD_ENABLE_CLICK;
|
||||
break;
|
||||
case "KEYBOARD_ALT": // long
|
||||
menuEnum = Apple2KeyboardSettingsMenu.SETTINGS.KEYBOARD_CHOOSE_ALT;
|
||||
break;
|
||||
case "KEYBOARD_ALT_PATH": // String
|
||||
setJSONPref(Apple2Preferences.PREF_DOMAIN_KEYBOARD, "altPath", val);
|
||||
continue;
|
||||
|
||||
case "JOYSTICK_SWIPEUP_BUTTON":
|
||||
menuEnum = Apple2JoystickSettingsMenu.SETTINGS.JOYSTICK_SWIPEUP_BUTTON;
|
||||
break;
|
||||
case "JOYSTICK_TAP_BUTTON":
|
||||
menuEnum = Apple2JoystickSettingsMenu.SETTINGS.JOYSTICK_TAP_BUTTON;
|
||||
break;
|
||||
case "JOYSTICK_SWIPEDOWN_BUTTON":
|
||||
menuEnum = Apple2JoystickSettingsMenu.SETTINGS.JOYSTICK_SWIPEDOWN_BUTTON;
|
||||
break;
|
||||
case "JOYSTICK_VISIBILITY": // boolean
|
||||
menuEnum = Apple2JoystickSettingsMenu.JoystickAdvanced.SETTINGS.JOYSTICK_VISIBILITY;
|
||||
break;
|
||||
case "JOYSTICK_BUTTON_THRESHOLD": // -> float
|
||||
menuEnum = Apple2JoystickSettingsMenu.JoystickAdvanced.SETTINGS.JOYSTICK_BUTTON_THRESHOLD;
|
||||
val = (int) val * Apple2JoystickSettingsMenu.getJoystickButtonSwitchThresholdScale(activity);
|
||||
break;
|
||||
case "JOYSTICK_DIVIDER": // -> float
|
||||
Apple2Preferences.setJSONPref(Apple2Preferences.PREF_DOMAIN_JOYSTICK, Apple2JoystickCalibration.PREF_SCREEN_DIVISION, (int) val / (float) Apple2JoystickCalibration.JOYSTICK_DIVIDER_NUM_CHOICES);
|
||||
continue;
|
||||
case "JOYSTICK_AXIS_ON_LEFT": // bool
|
||||
menuEnum = Apple2JoystickSettingsMenu.JoystickAdvanced.SETTINGS.JOYSTICK_AXIS_ON_LEFT;
|
||||
break;
|
||||
case "JOYSTICK_TAPDELAY": // -> float
|
||||
menuEnum = Apple2JoystickSettingsMenu.SETTINGS.JOYSTICK_TAPDELAY;
|
||||
val = ((int) val / (float) Apple2JoystickSettingsMenu.TAPDELAY_NUM_CHOICES * Apple2JoystickSettingsMenu.TAPDELAY_SCALE);
|
||||
break;
|
||||
case "JOYSTICK_AZIMUTH_VISIBILITY": // boolean
|
||||
continue; // removed
|
||||
case "JOYSTICK_AXIS_SENSITIVIY": // -> float
|
||||
menuEnum = Apple2JoystickSettingsMenu.JoystickAdvanced.SETTINGS.JOYSTICK_AXIS_SENSITIVITY;
|
||||
final int pivot = Apple2JoystickSettingsMenu.JOYSTICK_AXIS_SENSITIVITY_DEC_NUMCHOICES;
|
||||
float sensitivity = 1.f;
|
||||
if ((int) val < pivot) {
|
||||
int decAmount = (pivot - (int) val);
|
||||
sensitivity -= (Apple2JoystickSettingsMenu.JOYSTICK_AXIS_SENSITIVITY_DEC_STEP * decAmount);
|
||||
} else if ((int) val > pivot) {
|
||||
int incAmount = ((int) val - pivot);
|
||||
sensitivity += (Apple2JoystickSettingsMenu.JOYSTICK_AXIS_SENSITIVITY_INC_STEP * incAmount);
|
||||
}
|
||||
val = sensitivity;
|
||||
break;
|
||||
|
||||
case "CURRENT_DISK_PATH": // String
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DISK_SEARCH_PATH;
|
||||
try {
|
||||
val = new JSONArray((String) val);
|
||||
} catch (JSONException e) {
|
||||
Log.v(TAG, "JSON error parsing disk path : " + e);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case "CURRENT_DRIVE_A_BUTTON": // bool
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DRIVE_A;
|
||||
break;
|
||||
case "CURRENT_DISK_A": // String
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DISK_PATH_A;
|
||||
break;
|
||||
case "CURRENT_DISK_A_RO": // bool
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DISK_PATH_A_RO;
|
||||
break;
|
||||
case "CURRENT_DISK_B": // String
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DISK_PATH_B;
|
||||
break;
|
||||
case "CURRENT_DISK_B_RO": // bool
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DISK_PATH_B_RO;
|
||||
break;
|
||||
|
||||
case "CURRENT_DISK_RO_BUTTON": // bool
|
||||
menuEnum = Apple2DisksMenu.SETTINGS.CURRENT_DISK_RO_BUTTON;
|
||||
break;
|
||||
case "CURRENT_TOUCH_DEVICE": // long
|
||||
menuEnum = Apple2SettingsMenu.SETTINGS.CURRENT_INPUT;
|
||||
break;
|
||||
|
||||
case "CRASH_CHECK": // boolean
|
||||
menuEnum = Apple2SettingsMenu.SETTINGS.CRASH;
|
||||
break;
|
||||
case "SHOW_DISK_OPERATIONS": // bool
|
||||
menuEnum = Apple2SettingsMenu.SETTINGS.SHOW_DISK_OPERATIONS;
|
||||
break;
|
||||
|
||||
case "KEYPAD_KEYS": // long
|
||||
menuEnum = Apple2KeypadSettingsMenu.SETTINGS.KEYPAD_CHOOSE_KEYS;
|
||||
if ((int) val != 0) {
|
||||
Apple2KeypadSettingsMenu.KeypadPreset preset = Apple2KeypadSettingsMenu.KeypadPreset.values()[(int) val - 1];
|
||||
preset.apply(activity);
|
||||
keypadPreset = true;
|
||||
}
|
||||
break;
|
||||
case "KEYREPEAT_THRESHOLD": // -> float
|
||||
menuEnum = Apple2KeypadSettingsMenu.KeypadAdvanced.SETTINGS.KEYREPEAT_THRESHOLD;
|
||||
val = (int) val / (float) Apple2KeypadSettingsMenu.KEYREPEAT_NUM_CHOICES;
|
||||
break;
|
||||
case "KEYPAD_TAP_KEY_SCAN":
|
||||
keypadTapScan = (int) val;
|
||||
continue;
|
||||
case "KEYPAD_TAP_KEY_ASCII":
|
||||
keypadTapChar = (int) val;
|
||||
continue;
|
||||
case "KEYPAD_SWIPEDOWN_KEY_SCAN":
|
||||
keypadSwipeDownScan = (int) val;
|
||||
continue;
|
||||
case "KEYPAD_SWIPEDOWN_KEY_ASCII":
|
||||
keypadSwipeDownChar = (int) val;
|
||||
continue;
|
||||
case "KEYPAD_SWIPEUP_KEY_SCAN":
|
||||
keypadSwipeUpScan = (int) val;
|
||||
continue;
|
||||
case "KEYPAD_SWIPEUP_KEY_ASCII":
|
||||
keypadSwipeUpChar = (int) val;
|
||||
continue;
|
||||
|
||||
case "KEYPAD_NORTHWEST_KEY_SCAN":
|
||||
keypadJSONScans.set(0, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_NORTHWEST_KEY_ASCII":
|
||||
keypadJSONChars.set(0, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_NORTH_KEY_SCAN":
|
||||
keypadJSONScans.set(1, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_NORTH_KEY_ASCII":
|
||||
keypadJSONChars.set(1, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_NORTHEAST_KEY_SCAN":
|
||||
keypadJSONScans.set(2, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_NORTHEAST_KEY_ASCII":
|
||||
keypadJSONChars.set(2, val.toString());
|
||||
continue;
|
||||
|
||||
case "KEYPAD_WEST_KEY_SCAN":
|
||||
keypadJSONScans.set(3, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_WEST_KEY_ASCII":
|
||||
keypadJSONChars.set(3, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_CENTER_KEY_SCAN":
|
||||
keypadJSONScans.set(4, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_CENTER_KEY_ASCII":
|
||||
keypadJSONChars.set(4, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_EAST_KEY_SCAN":
|
||||
keypadJSONScans.set(5, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_EAST_KEY_ASCII":
|
||||
keypadJSONChars.set(5, val.toString());
|
||||
continue;
|
||||
|
||||
case "KEYPAD_SOUTHWEST_KEY_SCAN":
|
||||
keypadJSONScans.set(6, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_SOUTHWEST_KEY_ASCII":
|
||||
keypadJSONChars.set(6, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_SOUTH_KEY_SCAN":
|
||||
keypadJSONScans.set(7, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_SOUTH_KEY_ASCII":
|
||||
keypadJSONChars.set(7, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_SOUTHEAST_KEY_SCAN":
|
||||
keypadJSONScans.set(8, val.toString());
|
||||
continue;
|
||||
case "KEYPAD_SOUTHEAST_KEY_ASCII":
|
||||
keypadJSONChars.set(8, val.toString());
|
||||
continue;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
setJSONPref(menuEnum, val);
|
||||
save(activity);
|
||||
} catch (ClassCastException cce) {
|
||||
Log.v(TAG, "" + cce);
|
||||
}
|
||||
}
|
||||
|
||||
// handle keypad arrays
|
||||
if (oldPrefs.size() > 0 && !keypadPreset) {
|
||||
Apple2KeypadSettingsMenu.KeypadPreset.saveRosettes(keypadJSONChars, keypadJSONScans);
|
||||
Apple2KeypadSettingsMenu.KeypadPreset.saveTouchDownKey(keypadTapChar, keypadTapScan);
|
||||
Apple2KeypadSettingsMenu.KeypadPreset.saveSwipeNorthKey(keypadSwipeUpChar, keypadSwipeUpScan);
|
||||
Apple2KeypadSettingsMenu.KeypadPreset.saveSwipeSouthKey(keypadSwipeDownChar, keypadSwipeDownScan);
|
||||
}
|
||||
}
|
||||
|
||||
save(activity);
|
||||
return firstTime;
|
||||
|
Loading…
x
Reference in New Issue
Block a user