- URL validation
This commit is contained in:
parent
0fed677e6e
commit
5073875f70
@ -10,7 +10,10 @@ import android.preference.Preference;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Patterns;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.schueller.peertube.R;
|
||||
import java.util.List;
|
||||
|
||||
@ -34,6 +37,12 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = (preference, value) -> {
|
||||
String stringValue = value.toString();
|
||||
|
||||
// check URL is valid
|
||||
if (preference.getKey().equals("pref_api_base") && !Patterns.WEB_URL.matcher(stringValue).matches()) {
|
||||
Toast.makeText(preference.getContext(), R.string.invalid_url, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
preference.setSummary(stringValue);
|
||||
|
||||
return true;
|
||||
|
@ -59,5 +59,6 @@
|
||||
<string name="descr_overflow_button">More</string>
|
||||
<string name="menu_share">Share</string>
|
||||
<string name="playback_channel_name">PeerTube</string>
|
||||
<string name="invalid_url">Invalid Url!</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user