mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-10 20:15:54 +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);
|
mOptions.listenAddresses = Iterables.toArray(splitter.split((String) o), String.class);
|
||||||
break;
|
break;
|
||||||
case "maxRecvKbps":
|
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;
|
break;
|
||||||
case "maxSendKbps":
|
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;
|
break;
|
||||||
case "natEnabled":
|
case "natEnabled":
|
||||||
mOptions.natEnabled = (boolean) o;
|
mOptions.natEnabled = (boolean) o;
|
||||||
|
|
|
@ -353,6 +353,9 @@ Please report any problems you encounter via Github.</string>
|
||||||
|
|
||||||
<string name="export_config">Export Configuration</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 -->
|
<!-- Experimental options -->
|
||||||
<string name="use_proxy">Connect through a proxy</string>
|
<string name="use_proxy">Connect through a proxy</string>
|
||||||
<string name="do_not_use_proxy">No proxy configured.</string>
|
<string name="do_not_use_proxy">No proxy configured.</string>
|
||||||
|
|
Loading…
Reference in a new issue