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

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

Issue 29449609: Issue 5242 - Adjust setIcon() methods in UrlInputOpenerPreference (Closed)
Left Patch Set: Created May 26, 2017, 9:37 p.m.
Right Patch Set: Theres actually no need at all for overriding setIcon Created May 31, 2017, 2:53 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
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.sbrowser.contentblocker; 18 package org.adblockplus.sbrowser.contentblocker;
19 19
20 import android.app.AlertDialog; 20 import android.app.AlertDialog;
21 import android.content.Context; 21 import android.content.Context;
22 import android.graphics.drawable.Drawable;
23 import android.os.Build;
24 import android.os.Bundle; 22 import android.os.Bundle;
25 import android.preference.EditTextPreference; 23 import android.preference.EditTextPreference;
26 import android.support.annotation.DrawableRes;
27 import android.support.v4.content.ContextCompat;
28 import android.text.Editable; 24 import android.text.Editable;
29 import android.text.InputType; 25 import android.text.InputType;
30 import android.text.TextWatcher; 26 import android.text.TextWatcher;
31 import android.util.AttributeSet; 27 import android.util.AttributeSet;
32 import android.util.Patterns; 28 import android.util.Patterns;
33 import android.view.KeyEvent; 29 import android.view.KeyEvent;
34 import android.view.inputmethod.EditorInfo; 30 import android.view.inputmethod.EditorInfo;
35 import android.widget.EditText; 31 import android.widget.EditText;
36 import android.widget.TextView; 32 import android.widget.TextView;
37 import android.widget.Toast; 33 import android.widget.Toast;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 111 }
116 else 112 else
117 { 113 {
118 Toast.makeText(getContext(), R.string.whitelist_website_invalid_url_erro r, Toast.LENGTH_SHORT).show(); 114 Toast.makeText(getContext(), R.string.whitelist_website_invalid_url_erro r, Toast.LENGTH_SHORT).show();
119 } 115 }
120 return true; 116 return true;
121 } 117 }
122 return false; 118 return false;
123 } 119 }
124 120
125 public void setIcon(@DrawableRes int iconResId)
126 {
127 final Drawable drawable = this.getContext().getDrawable(iconResId);
128 setIcon(drawable);
129 }
130
131 public void setOnUrlReadyListener(OnUrlReadyListener listener) 121 public void setOnUrlReadyListener(OnUrlReadyListener listener)
132 { 122 {
133 this.onUrlReadyListener = listener; 123 this.onUrlReadyListener = listener;
134 } 124 }
135 125
136 private boolean isValidUrl() 126 private boolean isValidUrl()
137 { 127 {
138 return Patterns.WEB_URL.matcher(getUrl()).matches(); 128 return Patterns.WEB_URL.matcher(getUrl()).matches();
139 } 129 }
140 130
141 private String getUrl() 131 private String getUrl()
142 { 132 {
143 return getEditText().getText().toString(); 133 return getEditText().getText().toString();
144 } 134 }
145 135
146 private void setPositiveButtonEnabled(boolean enabled) 136 private void setPositiveButtonEnabled(boolean enabled)
147 { 137 {
148 if (mAlertDialog != null) 138 if (mAlertDialog != null)
149 { 139 {
150 mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled); 140 mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled);
151 } 141 }
152 } 142 }
153 143
154 public interface OnUrlReadyListener 144 public interface OnUrlReadyListener
155 { 145 {
156 void onUrlReady(String url); 146 void onUrlReady(String url);
157 } 147 }
158 } 148 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld