mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
fix parseInt exception - fixes https://github.com/syncthing/syncthing… (#1097)
* fix parseInt exception - fixes https://github.com/syncthing/syncthing-android/issues/1090 If the user enters an invalid integer, a message is shown telling the accepted value range. * fix min value
This commit is contained in:
parent
c43ee663a2
commit
b14a1aa177
2 changed files with 21 additions and 2 deletions
|
@ -318,10 +318,26 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
mOptions.listenAddresses = Iterables.toArray(splitter.split((String) o), String.class);
|
||||
break;
|
||||
case "maxRecvKbps":
|
||||
mOptions.maxRecvKbps = Integer.parseInt((String) o);
|
||||
int maxRecvKbps = 0;
|
||||
try {
|
||||
maxRecvKbps = Integer.parseInt((String) o);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getActivity(), getResources().getString(R.string.invalid_integer_value, 0, Integer.MAX_VALUE), Toast.LENGTH_LONG)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
mOptions.maxRecvKbps = maxRecvKbps;
|
||||
break;
|
||||
case "maxSendKbps":
|
||||
mOptions.maxSendKbps = Integer.parseInt((String) o);
|
||||
int maxSendKbps = 0;
|
||||
try {
|
||||
maxSendKbps = Integer.parseInt((String) o);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getActivity(), getResources().getString(R.string.invalid_integer_value, 0, Integer.MAX_VALUE), Toast.LENGTH_LONG)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
mOptions.maxSendKbps = maxSendKbps;
|
||||
break;
|
||||
case "natEnabled":
|
||||
mOptions.natEnabled = (boolean) o;
|
||||
|
|
|
@ -353,6 +353,9 @@ Please report any problems you encounter via Github.</string>
|
|||
|
||||
<string name="export_config">Export Configuration</string>
|
||||
|
||||
<!-- Toast after entering invalid integer value -->
|
||||
<string name="invalid_integer_value">Input value not valid. Please enter value between %1$d and %2$d.</string>
|
||||
|
||||
<!-- Experimental options -->
|
||||
<string name="use_proxy">Connect through a proxy</string>
|
||||
<string name="do_not_use_proxy">No proxy configured.</string>
|
||||
|
|
Loading…
Reference in a new issue