Small code changes

This commit is contained in:
emanuele-f 2022-07-20 15:31:49 +02:00
parent 8c4edce1be
commit fa8bd28615
2 changed files with 12 additions and 15 deletions

View File

@ -193,18 +193,20 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
}
}
private boolean validateIp(String value) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
return (InetAddresses.isNumericAddress(value));
else {
Matcher matcher = Patterns.IP_ADDRESS.matcher(value);
return(matcher.matches());
}
}
@SuppressWarnings("deprecation")
private void setupUdpExporterPrefs() {
/* Collector IP validation */
EditTextPreference mRemoteCollectorIp = requirePreference(Prefs.PREF_COLLECTOR_IP_KEY);
mRemoteCollectorIp.setOnPreferenceChangeListener((preference, newValue) -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
return (InetAddresses.isNumericAddress(newValue.toString()));
else {
Matcher matcher = Patterns.IP_ADDRESS.matcher(newValue.toString());
return(matcher.matches());
}
});
mRemoteCollectorIp.setOnPreferenceChangeListener((preference, newValue) -> validateIp(newValue.toString()));
/* Collector port validation */
EditTextPreference mRemoteCollectorPort = requirePreference(Prefs.PREF_COLLECTOR_PORT_KEY);
@ -404,4 +406,4 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
mVpnExceptions.setVisible(!enabled);
}
}
}
}

View File

@ -8,9 +8,4 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/adContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>