forked from jrquak/gnucash-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace Editor.commit() to apply()
- Loading branch information
Showing
4 changed files
with
79 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
|
||
/** | ||
* Fragment for general preferences. Currently caters to the passcode and reporting preferences | ||
* | ||
* @author Oleksandr Tyshkovets <[email protected]> | ||
*/ | ||
public class GeneralPreferenceFragment extends PreferenceFragmentCompat implements | ||
|
@@ -67,6 +68,7 @@ public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | ||
|
||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); | ||
assert actionBar != null; | ||
actionBar.setHomeButtonEnabled(true); | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
actionBar.setTitle(R.string.title_general_prefs); | ||
|
@@ -78,7 +80,8 @@ public void onResume() { | |
|
||
final Intent intent = new Intent(getActivity(), PasscodePreferenceActivity.class); | ||
|
||
mCheckBoxPreference = (CheckBoxPreference) findPreference(getString(R.string.key_enable_passcode)); | ||
mCheckBoxPreference = findPreference(getString(R.string.key_enable_passcode)); | ||
assert mCheckBoxPreference != null; | ||
mCheckBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { | ||
@Override | ||
public boolean onPreferenceChange(Preference preference, Object newValue) { | ||
|
@@ -115,84 +118,60 @@ public boolean onPreferenceChange(Preference preference, | |
// | ||
// Preference : key_use_double_back_button_press_to_quit | ||
// | ||
|
||
if (preference.getKey() | ||
.equals(getString(R.string.key_use_double_back_button_press_to_quit))) { | ||
if (preference.getKey().equals(getString(R.string.key_use_double_back_button_press_to_quit))) { | ||
|
||
// Store the new value of the Preference | ||
getPreferenceManager().getSharedPreferences() | ||
.edit() | ||
.putBoolean(getString(R.string.key_use_double_back_button_press_to_quit), | ||
Boolean.parseBoolean(newValue.toString())) | ||
.commit(); | ||
.edit() | ||
.putBoolean(getString(R.string.key_use_double_back_button_press_to_quit), Boolean.parseBoolean(newValue.toString())) | ||
.apply(); | ||
} | ||
|
||
// | ||
// Set Preference : key_shall_open_keyboard_in_account_searchable_spinner | ||
// | ||
|
||
if (preference.getKey() | ||
.equals(getString(R.string.key_shall_open_keyboard_in_account_searchable_spinner))) { | ||
if (preference.getKey().equals(getString(R.string.key_shall_open_keyboard_in_account_searchable_spinner))) { | ||
|
||
// Store the new value of the Preference | ||
getPreferenceManager().getSharedPreferences() | ||
.edit() | ||
.putBoolean(getString(R.string.key_shall_open_keyboard_in_account_searchable_spinner), | ||
Boolean.parseBoolean(newValue.toString())) | ||
.commit(); | ||
.edit() | ||
.putBoolean(getString(R.string.key_shall_open_keyboard_in_account_searchable_spinner), Boolean.parseBoolean(newValue.toString())) | ||
.apply(); | ||
} | ||
|
||
// | ||
// Set Preference : key_use_color_in_account_list | ||
// | ||
|
||
if (preference.getKey() | ||
.equals(getString(R.string.key_use_color_in_account_list))) { | ||
if (preference.getKey().equals(getString(R.string.key_use_color_in_account_list))) { | ||
|
||
// Store the new value of the Preference | ||
getPreferenceManager().getSharedPreferences() | ||
.edit() | ||
.putBoolean(getString(R.string.key_use_color_in_account_list), | ||
Boolean.parseBoolean(newValue.toString())) | ||
.commit(); | ||
.edit() | ||
.putBoolean(getString(R.string.key_use_color_in_account_list), Boolean.parseBoolean(newValue.toString())) | ||
.apply(); | ||
} | ||
|
||
// | ||
// Set Preference : enable_passcode | ||
// | ||
|
||
if (preference.getKey() | ||
.equals(getString(R.string.key_enable_passcode))) { | ||
|
||
if (preference.getKey().equals(getString(R.string.key_enable_passcode))) { | ||
if ((Boolean) newValue) { | ||
|
||
startActivityForResult(new Intent(getActivity(), | ||
PasscodePreferenceActivity.class), | ||
GeneralPreferenceFragment.PASSCODE_REQUEST_CODE); | ||
|
||
startActivityForResult(new Intent(getActivity(), PasscodePreferenceActivity.class), GeneralPreferenceFragment.PASSCODE_REQUEST_CODE); | ||
} else { | ||
|
||
Intent passIntent = new Intent(getActivity(), | ||
PasscodeLockScreenActivity.class); | ||
passIntent.putExtra(UxArgument.DISABLE_PASSCODE, | ||
UxArgument.DISABLE_PASSCODE); | ||
startActivityForResult(passIntent, | ||
GeneralPreferenceFragment.REQUEST_DISABLE_PASSCODE); | ||
Intent passIntent = new Intent(getActivity(), PasscodeLockScreenActivity.class); | ||
passIntent.putExtra(UxArgument.DISABLE_PASSCODE, UxArgument.DISABLE_PASSCODE); | ||
startActivityForResult(passIntent, GeneralPreferenceFragment.REQUEST_DISABLE_PASSCODE); | ||
} | ||
} | ||
|
||
// | ||
// Set Preference : use_color_in_reports | ||
// | ||
|
||
if (preference.getKey() | ||
.equals(getString(R.string.key_use_account_color))) { | ||
|
||
if (preference.getKey().equals(getString(R.string.key_use_account_color))) { | ||
getPreferenceManager().getSharedPreferences() | ||
.edit() | ||
.putBoolean(getString(R.string.key_use_account_color), | ||
Boolean.parseBoolean(newValue.toString())) | ||
.commit(); | ||
.edit() | ||
.putBoolean(getString(R.string.key_use_account_color), Boolean.parseBoolean(newValue.toString())) | ||
.apply(); | ||
} | ||
|
||
return true; | ||
|
@@ -202,7 +181,7 @@ public boolean onPreferenceChange(Preference preference, | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
super.onActivityResult(requestCode, resultCode, data); | ||
|
||
if (mEditor == null){ | ||
if (mEditor == null) { | ||
mEditor = getPreferenceManager().getSharedPreferences().edit(); | ||
} | ||
|
||
|
@@ -231,7 +210,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
} | ||
break; | ||
} | ||
mEditor.commit(); | ||
mEditor.apply(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters