Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/InputValidatorDialogPreference.java

Issue 29524668: Issue 3916 - Supporting Adding filter lists via URL (Closed)
Left Patch Set: fixes Created Oct. 4, 2017, 3:14 p.m.
Right Patch Set: Use TAG constant for log, fix in MoreBlockingPreferenceCategory Created Oct. 10, 2017, 1:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 18 matching lines...) Expand all
29 import android.util.Log; 29 import android.util.Log;
30 import android.util.Patterns; 30 import android.util.Patterns;
31 import android.view.KeyEvent; 31 import android.view.KeyEvent;
32 import android.view.View; 32 import android.view.View;
33 import android.view.inputmethod.EditorInfo; 33 import android.view.inputmethod.EditorInfo;
34 import android.widget.EditText; 34 import android.widget.EditText;
35 import android.widget.TextView; 35 import android.widget.TextView;
36 import android.widget.Toast; 36 import android.widget.Toast;
37 37
38 import org.adblockplus.adblockplussbrowser.R; 38 import org.adblockplus.adblockplussbrowser.R;
39 import org.adblockplus.sbrowser.contentblocker.engine.Engine;
39 import org.adblockplus.sbrowser.contentblocker.util.PreferenceUtils; 40 import org.adblockplus.sbrowser.contentblocker.util.PreferenceUtils;
40 import org.apache.commons.validator.routines.DomainValidator; 41 import org.apache.commons.validator.routines.DomainValidator;
41 42
42 public class InputValidatorDialogPreference extends EditTextPreference implement s TextWatcher, 43 public class InputValidatorDialogPreference extends EditTextPreference implement s TextWatcher,
43 TextView.OnEditorActionListener 44 TextView.OnEditorActionListener
44 { 45 {
45 46
46 public enum ValidationType 47 public enum ValidationType
47 { 48 {
48 DOMAIN, 49 DOMAIN,
49 URL 50 URL
50 } 51 }
51 52
53 private static final String TAG = InputValidatorDialogPreference.class.getSimp leName();
52 private OnInputReadyListener onInputReadyListener; 54 private OnInputReadyListener onInputReadyListener;
53 private AlertDialog alertDialog; 55 private AlertDialog alertDialog;
54 private ValidationType validationType; 56 private ValidationType validationType;
55 57
56 public InputValidatorDialogPreference(Context context) 58 public InputValidatorDialogPreference(Context context)
57 { 59 {
58 this(context, null); 60 this(context, null);
59 } 61 }
60 62
61 public InputValidatorDialogPreference(Context context, AttributeSet attrs) 63 public InputValidatorDialogPreference(Context context, AttributeSet attrs)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 156
155 private boolean isValidUrl() 157 private boolean isValidUrl()
156 { 158 {
157 return Patterns.WEB_URL.matcher(getInput()).matches(); 159 return Patterns.WEB_URL.matcher(getInput()).matches();
158 } 160 }
159 161
160 private boolean isValidInput() 162 private boolean isValidInput()
161 { 163 {
162 if (validationType == null) 164 if (validationType == null)
163 { 165 {
164 Log.i(getClass().getSimpleName(), "ValidationType was not defined and is t herefore set to" + 166 Log.i(TAG, "ValidationType was not defined and is therefore set to" +
diegocarloslima 2017/10/10 13:08:28 I know that the log tag is currently only used her
jens 2017/10/10 13:56:40 I was not sure if it's mandatory, as there are als
165 " ValidationType.URL per default. Please consider to set in manually." ); 167 " ValidationType.URL per default. Please consider to set in manually." );
166 validationType = ValidationType.URL; 168 validationType = ValidationType.URL;
167 } 169 }
168 170
169 switch (validationType) 171 switch (validationType)
170 { 172 {
171 case DOMAIN: 173 case DOMAIN:
172 return isValidDomain(); 174 return isValidDomain();
173 default: 175 default:
174 return isValidUrl(); 176 return isValidUrl();
(...skipping 11 matching lines...) Expand all
186 { 188 {
187 alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled); 189 alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled);
188 } 190 }
189 } 191 }
190 192
191 public interface OnInputReadyListener 193 public interface OnInputReadyListener
192 { 194 {
193 void onInputReady(String input); 195 void onInputReady(String input);
194 } 196 }
195 } 197 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld