mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-30 00:01:19 +00:00
Fixed crash when changing app preferences (fixes #125).
This commit is contained in:
parent
1733091e4b
commit
56063c577a
1 changed files with 7 additions and 3 deletions
|
@ -136,10 +136,13 @@ public class SettingsFragment extends PreferenceFragment
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
|
// Convert new value to integer if input type is number.
|
||||||
|
if (preference instanceof EditTextPreference) {
|
||||||
EditTextPreference etp = (EditTextPreference) preference;
|
EditTextPreference etp = (EditTextPreference) preference;
|
||||||
if (etp.getEditText().getInputType() == InputType.TYPE_CLASS_NUMBER) {
|
if (etp.getEditText().getInputType() == InputType.TYPE_CLASS_NUMBER) {
|
||||||
o = Integer.parseInt((String) o);
|
o = Integer.parseInt((String) o);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (preference.equals(mSyncOnlyCharging) || preference.equals(mSyncOnlyWifi)) {
|
if (preference.equals(mSyncOnlyCharging) || preference.equals(mSyncOnlyWifi)) {
|
||||||
mSyncthingService.updateState();
|
mSyncthingService.updateState();
|
||||||
|
@ -158,6 +161,7 @@ public class SettingsFragment extends PreferenceFragment
|
||||||
((SyncthingActivity) getActivity()).getApi().requireRestart(getActivity());
|
((SyncthingActivity) getActivity()).getApi().requireRestart(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the preference value as summary.
|
||||||
if (preference instanceof EditTextPreference) {
|
if (preference instanceof EditTextPreference) {
|
||||||
String value = (String) o;
|
String value = (String) o;
|
||||||
preference.setSummary(value);
|
preference.setSummary(value);
|
||||||
|
|
Loading…
Reference in a new issue