Asynchronus preferences, where appropriate
Most UI settings should be saved asynchronously with immediate results few from runtime memory, but storing the keys for cloud saves should probably remain direct to disk with error checking.
This commit is contained in:
parent
81d2389c42
commit
858d617673
|
@ -404,7 +404,7 @@ public class FileBrowser extends Fragment {
|
|||
getActivity().getString(R.string.config_data, home_directory),
|
||||
R.drawable.ic_notification, Toast.LENGTH_LONG);
|
||||
}
|
||||
mPrefs.edit().putString("home_directory", home_directory).commit();
|
||||
mPrefs.edit().putString("home_directory", home_directory).apply();
|
||||
mCallback.onFolderSelected(Uri.fromFile(new File(home_directory)));
|
||||
JNIdc.config(home_directory);
|
||||
}
|
||||
|
@ -490,11 +490,11 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
if (games) {
|
||||
game_directory = heading;
|
||||
mPrefs.edit().putString(Config.pref_games, heading).commit();
|
||||
mPrefs.edit().putString(Config.pref_games, heading).apply();
|
||||
mCallback.onFolderSelected(Uri.fromFile(new File(game_directory)));
|
||||
} else {
|
||||
home_directory = heading.replace("/data", "");
|
||||
mPrefs.edit().putString(Config.pref_home, home_directory).commit();
|
||||
mPrefs.edit().putString(Config.pref_home, home_directory).apply();
|
||||
if (!DataDirectoryBIOS()) {
|
||||
MainActivity.showToastMessage(getActivity(),
|
||||
getActivity().getString(R.string.config_data, home_directory),
|
||||
|
|
|
@ -220,7 +220,7 @@ public class GL2JNIActivity extends Activity {
|
|||
if(prefs.getBoolean(Config.pref_vmu, false)){
|
||||
//kind of a hack - if the user last had the vmu on screen
|
||||
//inverse it and then "toggle"
|
||||
prefs.edit().putBoolean(Config.pref_vmu, false).commit();
|
||||
prefs.edit().putBoolean(Config.pref_vmu, false).apply();
|
||||
//can only display a popup after onCreate
|
||||
mView.post(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -462,7 +462,7 @@ public class GL2JNIActivity extends Activity {
|
|||
//add back to popup menu
|
||||
popUp.showVmu();
|
||||
}
|
||||
prefs.edit().putBoolean(Config.pref_vmu, showFloating).commit();
|
||||
prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply();
|
||||
}
|
||||
|
||||
public void displayConfig(PopupWindow popUpConfig) {
|
||||
|
|
|
@ -237,7 +237,7 @@ public class GL2JNINative extends NativeActivity {
|
|||
if(prefs.getBoolean(Config.pref_vmu, false)){
|
||||
//kind of a hack - if the user last had the vmu on screen
|
||||
//inverse it and then "toggle"
|
||||
prefs.edit().putBoolean(Config.pref_vmu, false).commit();
|
||||
prefs.edit().putBoolean(Config.pref_vmu, false).apply();
|
||||
//can only display a popup after onCreate
|
||||
mView.post(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -308,7 +308,7 @@ public class GL2JNINative extends NativeActivity {
|
|||
//add back to popup menu
|
||||
popUp.showVmu();
|
||||
}
|
||||
prefs.edit().putBoolean(Config.pref_vmu, showFloating).commit();
|
||||
prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply();
|
||||
}
|
||||
|
||||
public void displayConfig(PopupWindow popUpConfig) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class MainActivity extends AppCompatActivity implements
|
|||
String prior_error = mPrefs.getString("prior_error", null);
|
||||
if (prior_error != null) {
|
||||
displayLogOutput(prior_error);
|
||||
mPrefs.edit().remove("prior_error").commit();
|
||||
mPrefs.edit().remove("prior_error").apply();
|
||||
} else {
|
||||
mUEHandler = new Thread.UncaughtExceptionHandler() {
|
||||
public void uncaughtException(Thread t, Throwable error) {
|
||||
|
@ -100,7 +100,7 @@ public class MainActivity extends AppCompatActivity implements
|
|||
for (StackTraceElement trace : error.getStackTrace()) {
|
||||
output.append(trace.toString() + "\n");
|
||||
}
|
||||
mPrefs.edit().putString("prior_error", output.toString()).commit();
|
||||
mPrefs.edit().putString("prior_error", output.toString()).apply();
|
||||
error.printStackTrace();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
|
@ -168,8 +168,8 @@ public class MainActivity extends AppCompatActivity implements
|
|||
// firstFragment.setArguments(getIntent().getExtras());
|
||||
|
||||
// Add the fragment to the 'fragment_container' FrameLayout
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER").commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(
|
||||
R.id.fragment_container, firstFragment, "MAIN_BROWSER").commit();
|
||||
}
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
|
@ -319,9 +319,8 @@ public class MainActivity extends AppCompatActivity implements
|
|||
}
|
||||
|
||||
OptionsFragment optsFrag = new OptionsFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, optsFrag, "OPTIONS_FRAG")
|
||||
.commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(
|
||||
R.id.fragment_container, optsFrag, "OPTIONS_FRAG").commit();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ public class InputFragment extends Fragment {
|
|||
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
int progress = seekBar.getProgress() + 5;
|
||||
sharedPreferences.edit().putInt(Config.pref_vibrationDuration, progress).commit();
|
||||
sharedPreferences.edit().putInt(Config.pref_vibrationDuration, progress).apply();
|
||||
Config.vibrationDuration = progress;
|
||||
vib.vibrate(progress);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class InputFragment extends Fragment {
|
|||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
sharedPreferences.edit()
|
||||
.putBoolean(Config.pref_touchvibe, isChecked).commit();
|
||||
.putBoolean(Config.pref_touchvibe, isChecked).apply();
|
||||
vibLay.setVisibility( isChecked ? View.VISIBLE : View.GONE );
|
||||
}
|
||||
};
|
||||
|
@ -164,9 +164,7 @@ public class InputFragment extends Fragment {
|
|||
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
sharedPreferences.edit()
|
||||
.putBoolean(Config.pref_mic, isChecked)
|
||||
.commit();
|
||||
sharedPreferences.edit().putBoolean(Config.pref_mic, isChecked).apply();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -477,20 +475,16 @@ public class InputFragment extends Fragment {
|
|||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
sharedPreferences.edit()
|
||||
.putString(Gamepad.pref_player1, descriptor).commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player1, descriptor).apply();
|
||||
break;
|
||||
case 2:
|
||||
sharedPreferences.edit()
|
||||
.putString(Gamepad.pref_player2, descriptor).commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player2, descriptor).apply();
|
||||
break;
|
||||
case 3:
|
||||
sharedPreferences.edit()
|
||||
.putString(Gamepad.pref_player3, descriptor).commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player3, descriptor).apply();
|
||||
break;
|
||||
case 4:
|
||||
sharedPreferences.edit()
|
||||
.putString(Gamepad.pref_player4, descriptor).commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player4, descriptor).apply();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -506,20 +500,16 @@ public class InputFragment extends Fragment {
|
|||
private void removeController(int playerNum) {
|
||||
switch (playerNum) {
|
||||
case 1:
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player1, null)
|
||||
.commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player1, null).apply();
|
||||
break;
|
||||
case 2:
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player2, null)
|
||||
.commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player2, null).apply();
|
||||
break;
|
||||
case 3:
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player3, null)
|
||||
.commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player3, null).apply();
|
||||
break;
|
||||
case 4:
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player4, null)
|
||||
.commit();
|
||||
sharedPreferences.edit().putString(Gamepad.pref_player4, null).apply();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,9 +107,7 @@ public class InputModFragment extends Fragment {
|
|||
OnCheckedChangeListener joystick_mode = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putBoolean(Gamepad.pref_js_merged + player,
|
||||
isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Gamepad.pref_js_merged + player, isChecked).apply();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -118,9 +116,7 @@ public class InputModFragment extends Fragment {
|
|||
OnCheckedChangeListener rstick_mode = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putBoolean(Gamepad.pref_js_rbuttons + player,
|
||||
isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Gamepad.pref_js_rbuttons + player, isChecked).apply();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -129,9 +125,7 @@ public class InputModFragment extends Fragment {
|
|||
OnCheckedChangeListener modified_layout = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putBoolean(Gamepad.pref_js_modified + player,
|
||||
isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Gamepad.pref_js_modified + player, isChecked).apply();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -140,9 +134,7 @@ public class InputModFragment extends Fragment {
|
|||
OnCheckedChangeListener compat_mode = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putBoolean(Gamepad.pref_js_compat + player, isChecked)
|
||||
.commit();
|
||||
mPrefs.edit().putBoolean(Gamepad.pref_js_compat + player, isChecked).apply();
|
||||
if (isChecked) {
|
||||
selectController();
|
||||
}
|
||||
|
@ -469,9 +461,7 @@ public class InputModFragment extends Fragment {
|
|||
});
|
||||
builder.setOnKeyListener(new Dialog.OnKeyListener() {
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
mPrefs.edit()
|
||||
.putInt("controller" + player, event.getDeviceId())
|
||||
.commit();
|
||||
mPrefs.edit().putInt("controller" + player, event.getDeviceId()).apply();
|
||||
dialog.dismiss();
|
||||
return true;
|
||||
}
|
||||
|
@ -540,7 +530,7 @@ public class InputModFragment extends Fragment {
|
|||
return -1;
|
||||
}
|
||||
|
||||
mPrefs.edit().putInt(button + player, keyCode).commit();
|
||||
mPrefs.edit().putInt(button + player, keyCode).apply();
|
||||
|
||||
return keyCode;
|
||||
}
|
||||
|
@ -627,7 +617,7 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void remKeyCode(final String button, TextView output) {
|
||||
mPrefs.edit().remove(button + player).commit();
|
||||
mPrefs.edit().remove(button + player).apply();
|
||||
getKeyCode(button, output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
mainBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
mPrefs.edit().remove(Config.pref_home).commit();
|
||||
mPrefs.edit().remove(Config.pref_home).apply();
|
||||
hideSoftKeyBoard();
|
||||
mCallback.onMainBrowseSelected(home_directory, false);
|
||||
}
|
||||
|
@ -134,8 +134,7 @@ public class OptionsFragment extends Fragment {
|
|||
Toast.makeText(getActivity(), R.string.data_folder,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
mPrefs.edit().putString(Config.pref_home, home_directory)
|
||||
.commit();
|
||||
mPrefs.edit().putString(Config.pref_home, home_directory).apply();
|
||||
JNIdc.config(home_directory);
|
||||
new LocateThemes().execute(home_directory + "/themes");
|
||||
}
|
||||
|
@ -152,7 +151,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_usereios, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_usereios, isChecked).apply();
|
||||
}
|
||||
};
|
||||
CompoundButton reios_opt = (CompoundButton) getView().findViewById(
|
||||
|
@ -164,7 +163,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Config.pref_gamedetails, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Config.pref_gamedetails, isChecked).apply();
|
||||
if (!isChecked) {
|
||||
File dir = new File(getActivity().getExternalFilesDir(null), "images");
|
||||
for (File file : dir.listFiles()) {
|
||||
|
@ -189,10 +188,9 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
gameBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
mPrefs.edit().remove(Config.pref_games).commit();
|
||||
mPrefs.edit().remove(Config.pref_games).apply();
|
||||
if (editBrowse.getText() != null) {
|
||||
game_directory = editGames.getText().toString();
|
||||
//mPrefs.edit().putString("game_directory", game_directory).commit();
|
||||
}
|
||||
hideSoftKeyBoard();
|
||||
mCallback.onMainBrowseSelected(game_directory, true);
|
||||
|
@ -203,8 +201,7 @@ public class OptionsFragment extends Fragment {
|
|||
public void afterTextChanged(Editable s) {
|
||||
if (editBrowse.getText() != null) {
|
||||
game_directory = editGames.getText().toString();
|
||||
mPrefs.edit().putString(Config.pref_games, game_directory)
|
||||
.commit();
|
||||
mPrefs.edit().putString(Config.pref_games, game_directory).apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +240,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_nativeact, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_nativeact, isChecked).apply();
|
||||
Emulator.nativeact = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -256,7 +253,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_dynarecopt, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_dynarecopt, isChecked).apply();
|
||||
Emulator.dynarecopt = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -269,7 +266,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_unstable, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_unstable, isChecked).apply();
|
||||
Emulator.unstableopt = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -298,7 +295,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onItemSelected(AdapterView<?> parent, View view,
|
||||
int pos, long id) {
|
||||
mPrefs.edit().putInt(Emulator.pref_cable, pos + 1).commit();
|
||||
mPrefs.edit().putInt(Emulator.pref_cable, pos + 1).apply();
|
||||
Emulator.cable = pos + 1;
|
||||
}
|
||||
|
||||
|
@ -321,7 +318,7 @@ public class OptionsFragment extends Fragment {
|
|||
region_spnr.setSelection(Emulator.dcregion, true);
|
||||
region_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
mPrefs.edit().putInt(Emulator.pref_dcregion, pos).commit();
|
||||
mPrefs.edit().putInt(Emulator.pref_dcregion, pos).apply();
|
||||
Emulator.dcregion = pos;
|
||||
|
||||
}
|
||||
|
@ -351,9 +348,7 @@ public class OptionsFragment extends Fragment {
|
|||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
String item = parent.getItemAtPosition(pos).toString();
|
||||
String selection = item.substring(0, item.indexOf(" - "));
|
||||
mPrefs.edit()
|
||||
.putInt(Emulator.pref_broadcast, Integer.parseInt(selection))
|
||||
.commit();
|
||||
mPrefs.edit().putInt(Emulator.pref_broadcast, Integer.parseInt(selection)).apply();
|
||||
Emulator.broadcast = Integer.parseInt(selection);
|
||||
|
||||
}
|
||||
|
@ -366,7 +361,7 @@ public class OptionsFragment extends Fragment {
|
|||
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_limitfps, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_limitfps, isChecked).apply();
|
||||
Emulator.limitfps = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -377,7 +372,7 @@ public class OptionsFragment extends Fragment {
|
|||
OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() {
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_mipmaps, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_mipmaps, isChecked).apply();
|
||||
Emulator.mipmaps = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -388,7 +383,7 @@ public class OptionsFragment extends Fragment {
|
|||
OnCheckedChangeListener full_screen = new OnCheckedChangeListener() {
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_widescreen, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_widescreen, isChecked).apply();
|
||||
Emulator.widescreen = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -413,7 +408,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
int progress = seekBar.getProgress();
|
||||
mPrefs.edit().putInt(Emulator.pref_frameskip, progress).commit();
|
||||
mPrefs.edit().putInt(Emulator.pref_frameskip, progress).apply();
|
||||
Emulator.frameskip = progress;
|
||||
}
|
||||
});
|
||||
|
@ -423,7 +418,7 @@ public class OptionsFragment extends Fragment {
|
|||
if (frameText != null) {
|
||||
int frames = Integer.parseInt(frameText);
|
||||
frameSeek.setProgress(frames);
|
||||
mPrefs.edit().putInt(Emulator.pref_frameskip, frames).commit();
|
||||
mPrefs.edit().putInt(Emulator.pref_frameskip, frames).apply();
|
||||
Emulator.frameskip = frames;
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +433,7 @@ public class OptionsFragment extends Fragment {
|
|||
OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() {
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_pvrrender, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_pvrrender, isChecked).apply();
|
||||
Emulator.pvrrender = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -448,7 +443,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
OnCheckedChangeListener synchronous = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_syncedrender, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_syncedrender, isChecked).apply();
|
||||
Emulator.syncedrender = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -475,7 +470,7 @@ public class OptionsFragment extends Fragment {
|
|||
} else {
|
||||
cheatEdit.setText(disk);
|
||||
}
|
||||
mPrefs.edit().putString(Emulator.pref_cheatdisk, disk).commit();
|
||||
mPrefs.edit().putString(Emulator.pref_cheatdisk, disk).apply();
|
||||
Emulator.cheatdisk = disk;
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +487,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Config.pref_showfps, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Config.pref_showfps, isChecked).apply();
|
||||
}
|
||||
};
|
||||
boolean counter = mPrefs.getBoolean(Config.pref_showfps, false);
|
||||
|
@ -504,7 +499,7 @@ public class OptionsFragment extends Fragment {
|
|||
OnCheckedChangeListener force_gpu_options = new OnCheckedChangeListener() {
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Config.pref_forcegpu, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Config.pref_forcegpu, isChecked).apply();
|
||||
}
|
||||
};
|
||||
boolean enhanced = mPrefs.getBoolean(Config.pref_forcegpu, true);
|
||||
|
@ -520,14 +515,13 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putInt(Config.pref_rendertype,
|
||||
isChecked ? GL2JNIView.LAYER_TYPE_SOFTWARE
|
||||
: GL2JNIView.LAYER_TYPE_HARDWARE)
|
||||
.commit();
|
||||
.putInt(Config.pref_rendertype, isChecked
|
||||
? GL2JNIView.LAYER_TYPE_SOFTWARE : GL2JNIView.LAYER_TYPE_HARDWARE
|
||||
).apply();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
if (isChecked) {
|
||||
force_gpu_opt.setEnabled(false);
|
||||
mPrefs.edit().putBoolean(Config.pref_forcegpu, false).commit();
|
||||
mPrefs.edit().putBoolean(Config.pref_forcegpu, false).apply();
|
||||
} else {
|
||||
force_gpu_opt.setEnabled(true);
|
||||
}
|
||||
|
@ -542,7 +536,7 @@ public class OptionsFragment extends Fragment {
|
|||
OnCheckedChangeListener emu_sound = new OnCheckedChangeListener() {
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mPrefs.edit().putBoolean(Emulator.pref_nosound, isChecked).commit();
|
||||
mPrefs.edit().putBoolean(Emulator.pref_nosound, isChecked).apply();
|
||||
Emulator.nosound = isChecked;
|
||||
}
|
||||
};
|
||||
|
@ -565,7 +559,7 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
int render = Integer.parseInt(parent.getItemAtPosition(pos).toString());
|
||||
mPrefs.edit().putInt(Config.pref_renderdepth, render).commit();
|
||||
mPrefs.edit().putInt(Config.pref_renderdepth, render).apply();
|
||||
}
|
||||
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
|
@ -617,10 +611,10 @@ public class OptionsFragment extends Fragment {
|
|||
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
|
||||
String theme = String.valueOf(parentView.getItemAtPosition(position));
|
||||
if (theme.equals("None")) {
|
||||
mPrefs.edit().remove(Config.pref_theme).commit();
|
||||
mPrefs.edit().remove(Config.pref_theme).apply();
|
||||
} else {
|
||||
String theme_path = home_directory + "/themes/" + theme;
|
||||
mPrefs.edit().putString(Config.pref_theme, theme_path).commit();
|
||||
mPrefs.edit().putString(Config.pref_theme, theme_path).apply();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
@ -654,6 +648,6 @@ public class OptionsFragment extends Fragment {
|
|||
}
|
||||
local.renameTo(flash);
|
||||
}
|
||||
mPrefs.edit().putString("localized", localized).commit();
|
||||
mPrefs.edit().putString("localized", localized).apply();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,12 +52,30 @@ public class VJoy {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return new float[][] {
|
||||
// x-shift, y-shift, sizing-factor
|
||||
new float[] { prefs.getFloat("touch_x_shift_dpad", 0), prefs.getFloat("touch_y_shift_dpad", 0), prefs.getFloat("touch_scale_dpad", 1) }, // DPAD
|
||||
new float[] { prefs.getFloat("touch_x_shift_buttons", 0), prefs.getFloat("touch_y_shift_buttons", 0), prefs.getFloat("touch_scale_buttons", 1) }, // X, Y, B, A Buttons
|
||||
new float[] { prefs.getFloat("touch_x_shift_start", 0), prefs.getFloat("touch_y_shift_start", 0), prefs.getFloat("touch_scale_start", 1) }, // Start
|
||||
new float[] { prefs.getFloat("touch_x_shift_left_trigger", 0), prefs.getFloat("touch_y_shift_left_trigger", 0), prefs.getFloat("touch_scale_left_trigger", 1) }, // Left Trigger
|
||||
new float[] { prefs.getFloat("touch_x_shift_right_trigger", 0), prefs.getFloat("touch_y_shift_right_trigger", 0), prefs.getFloat("touch_scale_right_trigger", 1) }, // Right Trigger
|
||||
new float[] { prefs.getFloat("touch_x_shift_analog", 0), prefs.getFloat("touch_y_shift_analog", 0), prefs.getFloat("touch_scale_analog", 1) } // Analog Stick
|
||||
new float[] { prefs.getFloat("touch_x_shift_dpad", 0),
|
||||
prefs.getFloat("touch_y_shift_dpad", 0),
|
||||
prefs.getFloat("touch_scale_dpad", 1)
|
||||
}, // DPAD
|
||||
new float[] { prefs.getFloat("touch_x_shift_buttons", 0),
|
||||
prefs.getFloat("touch_y_shift_buttons", 0),
|
||||
prefs.getFloat("touch_scale_buttons", 1)
|
||||
}, // X, Y, B, A Buttons
|
||||
new float[] { prefs.getFloat("touch_x_shift_start", 0),
|
||||
prefs.getFloat("touch_y_shift_start", 0),
|
||||
prefs.getFloat("touch_scale_start", 1)
|
||||
}, // Start
|
||||
new float[] { prefs.getFloat("touch_x_shift_left_trigger", 0),
|
||||
prefs.getFloat("touch_y_shift_left_trigger", 0),
|
||||
prefs.getFloat("touch_scale_left_trigger", 1)
|
||||
}, // Left Trigger
|
||||
new float[] { prefs.getFloat("touch_x_shift_right_trigger", 0),
|
||||
prefs.getFloat("touch_y_shift_right_trigger", 0),
|
||||
prefs.getFloat("touch_scale_right_trigger", 1)
|
||||
}, // Right Trigger
|
||||
new float[] { prefs.getFloat("touch_x_shift_analog", 0),
|
||||
prefs.getFloat("touch_y_shift_analog", 0),
|
||||
prefs.getFloat("touch_scale_analog", 1)
|
||||
} // Analog Stick
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -91,56 +109,56 @@ public class VJoy {
|
|||
public static void writeCustomVjoyValues(float[][] vjoy_d_custom, Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
prefs.edit().putFloat("touch_x_shift_dpad", vjoy_d_custom[0][0]).commit();
|
||||
prefs.edit().putFloat("touch_y_shift_dpad", vjoy_d_custom[0][1]).commit();
|
||||
prefs.edit().putFloat("touch_scale_dpad", vjoy_d_custom[0][2]).commit();
|
||||
prefs.edit().putFloat("touch_x_shift_dpad", vjoy_d_custom[0][0]).apply();
|
||||
prefs.edit().putFloat("touch_y_shift_dpad", vjoy_d_custom[0][1]).apply();
|
||||
prefs.edit().putFloat("touch_scale_dpad", vjoy_d_custom[0][2]).apply();
|
||||
|
||||
prefs.edit().putFloat("touch_x_shift_buttons", vjoy_d_custom[1][0]).commit();
|
||||
prefs.edit().putFloat("touch_y_shift_buttons", vjoy_d_custom[1][1]).commit();
|
||||
prefs.edit().putFloat("touch_scale_buttons", vjoy_d_custom[1][2]).commit();
|
||||
prefs.edit().putFloat("touch_x_shift_buttons", vjoy_d_custom[1][0]).apply();
|
||||
prefs.edit().putFloat("touch_y_shift_buttons", vjoy_d_custom[1][1]).apply();
|
||||
prefs.edit().putFloat("touch_scale_buttons", vjoy_d_custom[1][2]).apply();
|
||||
|
||||
prefs.edit().putFloat("touch_x_shift_start", vjoy_d_custom[2][0]).commit();
|
||||
prefs.edit().putFloat("touch_y_shift_start", vjoy_d_custom[2][1]).commit();
|
||||
prefs.edit().putFloat("touch_scale_start", vjoy_d_custom[2][2]).commit();
|
||||
prefs.edit().putFloat("touch_x_shift_start", vjoy_d_custom[2][0]).apply();
|
||||
prefs.edit().putFloat("touch_y_shift_start", vjoy_d_custom[2][1]).apply();
|
||||
prefs.edit().putFloat("touch_scale_start", vjoy_d_custom[2][2]).apply();
|
||||
|
||||
prefs.edit().putFloat("touch_x_shift_left_trigger", vjoy_d_custom[3][0]).commit();
|
||||
prefs.edit().putFloat("touch_y_shift_left_trigger", vjoy_d_custom[3][1]).commit();
|
||||
prefs.edit().putFloat("touch_scale_left_trigger", vjoy_d_custom[3][2]).commit();
|
||||
prefs.edit().putFloat("touch_x_shift_left_trigger", vjoy_d_custom[3][0]).apply();
|
||||
prefs.edit().putFloat("touch_y_shift_left_trigger", vjoy_d_custom[3][1]).apply();
|
||||
prefs.edit().putFloat("touch_scale_left_trigger", vjoy_d_custom[3][2]).apply();
|
||||
|
||||
prefs.edit().putFloat("touch_x_shift_right_trigger", vjoy_d_custom[4][0]).commit();
|
||||
prefs.edit().putFloat("touch_y_shift_right_trigger", vjoy_d_custom[4][1]).commit();
|
||||
prefs.edit().putFloat("touch_scale_right_trigger", vjoy_d_custom[4][2]).commit();
|
||||
prefs.edit().putFloat("touch_x_shift_right_trigger", vjoy_d_custom[4][0]).apply();
|
||||
prefs.edit().putFloat("touch_y_shift_right_trigger", vjoy_d_custom[4][1]).apply();
|
||||
prefs.edit().putFloat("touch_scale_right_trigger", vjoy_d_custom[4][2]).apply();
|
||||
|
||||
prefs.edit().putFloat("touch_x_shift_analog", vjoy_d_custom[5][0]).commit();
|
||||
prefs.edit().putFloat("touch_y_shift_analog", vjoy_d_custom[5][1]).commit();
|
||||
prefs.edit().putFloat("touch_scale_analog", vjoy_d_custom[5][2]).commit();
|
||||
prefs.edit().putFloat("touch_x_shift_analog", vjoy_d_custom[5][0]).apply();
|
||||
prefs.edit().putFloat("touch_y_shift_analog", vjoy_d_custom[5][1]).apply();
|
||||
prefs.edit().putFloat("touch_scale_analog", vjoy_d_custom[5][2]).apply();
|
||||
}
|
||||
|
||||
public static void resetCustomVjoyValues(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
prefs.edit().remove("touch_x_shift_dpad").commit();
|
||||
prefs.edit().remove("touch_y_shift_dpad").commit();
|
||||
prefs.edit().remove("touch_scale_dpad").commit();
|
||||
prefs.edit().remove("touch_x_shift_dpad").apply();
|
||||
prefs.edit().remove("touch_y_shift_dpad").apply();
|
||||
prefs.edit().remove("touch_scale_dpad").apply();
|
||||
|
||||
prefs.edit().remove("touch_x_shift_buttons").commit();
|
||||
prefs.edit().remove("touch_y_shift_buttons").commit();
|
||||
prefs.edit().remove("touch_scale_buttons").commit();
|
||||
prefs.edit().remove("touch_x_shift_buttons").apply();
|
||||
prefs.edit().remove("touch_y_shift_buttons").apply();
|
||||
prefs.edit().remove("touch_scale_buttons").apply();
|
||||
|
||||
prefs.edit().remove("touch_x_shift_start").commit();
|
||||
prefs.edit().remove("touch_y_shift_start").commit();
|
||||
prefs.edit().remove("touch_scale_start").commit();
|
||||
prefs.edit().remove("touch_x_shift_start").apply();
|
||||
prefs.edit().remove("touch_y_shift_start").apply();
|
||||
prefs.edit().remove("touch_scale_start").apply();
|
||||
|
||||
prefs.edit().remove("touch_x_shift_left_trigger").commit();
|
||||
prefs.edit().remove("touch_y_shift_left_trigger").commit();
|
||||
prefs.edit().remove("touch_scale_left_trigger").commit();
|
||||
prefs.edit().remove("touch_x_shift_left_trigger").apply();
|
||||
prefs.edit().remove("touch_y_shift_left_trigger").apply();
|
||||
prefs.edit().remove("touch_scale_left_trigger").apply();
|
||||
|
||||
prefs.edit().remove("touch_x_shift_right_trigger").commit();
|
||||
prefs.edit().remove("touch_y_shift_right_trigger").commit();
|
||||
prefs.edit().remove("touch_scale_right_trigger").commit();
|
||||
prefs.edit().remove("touch_x_shift_right_trigger").apply();
|
||||
prefs.edit().remove("touch_y_shift_right_trigger").apply();
|
||||
prefs.edit().remove("touch_scale_right_trigger").apply();
|
||||
|
||||
prefs.edit().remove("touch_x_shift_analog").commit();
|
||||
prefs.edit().remove("touch_y_shift_analog").commit();
|
||||
prefs.edit().remove("touch_scale_analog").commit();
|
||||
prefs.edit().remove("touch_x_shift_analog").apply();
|
||||
prefs.edit().remove("touch_y_shift_analog").apply();
|
||||
prefs.edit().remove("touch_scale_analog").apply();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue