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

Side by Side Diff: mobile/android/thirdparty/org/adblockplus/browser/SubscriptionPreferenceCategory.java

Issue 29341314: Issue 2512 - A square to mark and unmark is displayed on the side of "None". (Closed)
Patch Set: Created May 12, 2016, 12:30 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 @Override 90 @Override
91 public void run() 91 public void run()
92 { 92 {
93 SubscriptionPreferenceCategory.this.initEntries(); 93 SubscriptionPreferenceCategory.this.initEntries();
94 } 94 }
95 }); 95 });
96 } 96 }
97 }); 97 });
98 } 98 }
99 99
100 private CheckBoxPreference createDisabledCheckBox(final int titleId, final int summaryId) 100 private Preference createDisabledPreference(final int titleId, final int summa ryId)
101 { 101 {
102 final CheckBoxPreference cbp = new CheckBoxPreference(this.getContext()); 102 final Preference preference = new Preference(this.getContext());
103 cbp.setTitle(titleId); 103 preference.setTitle(titleId);
104 cbp.setSummary(summaryId); 104 preference.setSummary(summaryId);
105 cbp.setEnabled(false); 105 preference.setEnabled(false);
106 cbp.setShouldDisableView(true); 106 preference.setShouldDisableView(true);
107 cbp.setSelectable(false); 107 preference.setSelectable(false);
108 return cbp; 108 return preference;
109 } 109 }
110 110
111 private CheckBoxPreference createEnabledCheckBox( 111 private CheckBoxPreference createEnabledCheckBox(
112 final SubscriptionContainer.Subscription subscription) 112 final SubscriptionContainer.Subscription subscription)
113 { 113 {
114 final CheckBoxPreference cbp = new CheckBoxPreference(this.getContext()); 114 final CheckBoxPreference cbp = new CheckBoxPreference(this.getContext());
115 cbp.setTitle(subscription.specialization); 115 cbp.setTitle(subscription.specialization);
116 cbp.setSummary(subscription.title); 116 cbp.setSummary(subscription.title);
117 cbp.setChecked(true); 117 cbp.setChecked(true);
118 cbp.setKey(subscription.url); 118 cbp.setKey(subscription.url);
(...skipping 23 matching lines...) Expand all
142 } 142 }
143 143
144 private void initEntries(final int titleId, final int summaryId, boolean enabl ed) 144 private void initEntries(final int titleId, final int summaryId, boolean enabl ed)
145 { 145 {
146 this.removeAll(); 146 this.removeAll();
147 final List<SubscriptionContainer.Subscription> entries = 147 final List<SubscriptionContainer.Subscription> entries =
148 subscriptionContainer.getSubscriptions(enabled); 148 subscriptionContainer.getSubscriptions(enabled);
149 149
150 if (entries.isEmpty()) 150 if (entries.isEmpty())
151 { 151 {
152 this.addPreference(this.createDisabledCheckBox(titleId, summaryId)); 152 this.addPreference(this.createDisabledPreference(titleId, summaryId));
153 } 153 }
154 else 154 else
155 { 155 {
156 for (SubscriptionContainer.Subscription e : entries) 156 for (SubscriptionContainer.Subscription e : entries)
157 { 157 {
158 this.addPreference(this.createEnabledCheckBox(e)); 158 this.addPreference(this.createEnabledCheckBox(e));
159 } 159 }
160 } 160 }
161 } 161 }
162 162
163 private static class CheckBoxChangeListener implements OnPreferenceChangeListe ner 163 private static class CheckBoxChangeListener implements OnPreferenceChangeListe ner
164 { 164 {
165 @Override 165 @Override
166 public boolean onPreferenceChange(Preference preference, Object newValue) 166 public boolean onPreferenceChange(Preference preference, Object newValue)
167 { 167 {
168 if (preference instanceof CheckBoxPreference && newValue instanceof Boolea n) 168 if (preference instanceof CheckBoxPreference && newValue instanceof Boolea n)
169 { 169 {
170 final CheckBoxPreference cbp = (CheckBoxPreference) preference; 170 final CheckBoxPreference cbp = (CheckBoxPreference) preference;
171 final boolean enable = ((Boolean) newValue).booleanValue(); 171 final boolean enable = ((Boolean) newValue).booleanValue();
172 SubscriptionPreferenceCategory.subscriptionContainer.changeSubscriptionS tate( 172 SubscriptionPreferenceCategory.subscriptionContainer.changeSubscriptionS tate(
173 cbp.getKey(), 173 cbp.getKey(),
174 enable); 174 enable);
175 } 175 }
176 return true; 176 return true;
177 } 177 }
178 } 178 }
179 } 179 }
180 180
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