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

Side by Side Diff: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/UrlInputOpenerPreference.java

Issue 29449609: Issue 5242 - Adjust setIcon() methods in UrlInputOpenerPreference (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 = ContextCompat.getDrawable(getContext(), iconResId) ;
128 setIcon(drawable);
129 }
130
131 public void setIcon(Drawable icon)
132 {
133 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
134 {
135 super.setIcon(icon);
136 }
137 }
138
139 public void setOnUrlReadyListener(OnUrlReadyListener listener) 121 public void setOnUrlReadyListener(OnUrlReadyListener listener)
140 { 122 {
141 this.onUrlReadyListener = listener; 123 this.onUrlReadyListener = listener;
142 } 124 }
143 125
144 private boolean isValidUrl() 126 private boolean isValidUrl()
145 { 127 {
146 return Patterns.WEB_URL.matcher(getUrl()).matches(); 128 return Patterns.WEB_URL.matcher(getUrl()).matches();
147 } 129 }
148 130
149 private String getUrl() 131 private String getUrl()
150 { 132 {
151 return getEditText().getText().toString(); 133 return getEditText().getText().toString();
152 } 134 }
153 135
154 private void setPositiveButtonEnabled(boolean enabled) 136 private void setPositiveButtonEnabled(boolean enabled)
155 { 137 {
156 if (mAlertDialog != null) 138 if (mAlertDialog != null)
157 { 139 {
158 mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled); 140 mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled);
159 } 141 }
160 } 142 }
161 143
162 public interface OnUrlReadyListener 144 public interface OnUrlReadyListener
163 { 145 {
164 void onUrlReady(String url); 146 void onUrlReady(String url);
165 } 147 }
166 } 148 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld