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

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

Issue 29325578: Issue 2938 - Hide the beta community first run slide (Closed)
Patch Set: Mentioned follow-up issue Created Sept. 2, 2015, 3:17 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 import android.view.ViewGroup; 42 import android.view.ViewGroup;
43 import android.view.ViewGroup.LayoutParams; 43 import android.view.ViewGroup.LayoutParams;
44 import android.view.Window; 44 import android.view.Window;
45 import android.widget.Button; 45 import android.widget.Button;
46 import android.widget.LinearLayout; 46 import android.widget.LinearLayout;
47 import android.widget.TextView; 47 import android.widget.TextView;
48 48
49 public class StartPane extends DialogFragment implements OnClickListener, OnKeyL istener 49 public class StartPane extends DialogFragment implements OnClickListener, OnKeyL istener
50 { 50 {
51 private static final String TAG = "AdblockBrowser.StartPane"; 51 private static final String TAG = "AdblockBrowser.StartPane";
52 private int currentStep = 1; 52 private int currentStep = 0;
53 private static final int NUMBER_OF_STEPS = 3; 53 // For now we disable the beta community page,
54 // see https://issues.adblockplus.org/ticket/2937 for a follow-up issue
55 // for detecting whether we are on the beta channel or not
56 private static final boolean SKIP_BETA_COMMUNITY_PAGE = true;
54 private static final HashMap<String, Integer> FONTS = new HashMap<String, Inte ger>(); 57 private static final HashMap<String, Integer> FONTS = new HashMap<String, Inte ger>();
55 private HashMap<String, Typeface> loadedFonts = new HashMap<String, Typeface>( ); 58 private HashMap<String, Typeface> loadedFonts = new HashMap<String, Typeface>( );
56 59
60 private static final int[] BETA_RESOURCE_LIST =
61 {
62 R.layout.abb_start_pane_step_1, R.string.abb_frp_button_1,
63 R.layout.abb_start_pane_step_2, R.string.abb_frp_button_2,
64 R.layout.abb_start_pane_step_3, R.string.abb_frp_button_3
65 };
66
67 private static final int[] RELEASE_RESOURCE_LIST =
68 {
69 R.layout.abb_start_pane_step_1, R.string.abb_frp_button_2,
70 R.layout.abb_start_pane_step_2, R.string.abb_frp_button_3
71 };
72
73 private static final int[] PAGES_RESOURCE_LIST = SKIP_BETA_COMMUNITY_PAGE ?
74 RELEASE_RESOURCE_LIST : BETA_RESOURCE_LIST;
75
57 static 76 static
58 { 77 {
59 FONTS.put("ttf_opensans_light", R.raw.opensans_light); 78 FONTS.put("ttf_opensans_light", R.raw.opensans_light);
60 FONTS.put("ttf_opensans_semibold", R.raw.opensans_semibold); 79 FONTS.put("ttf_opensans_semibold", R.raw.opensans_semibold);
61 } 80 }
62 81
63 static Typeface typefaceFromResource(final Context context, final int resId) 82 static Typeface typefaceFromResource(final Context context, final int resId)
64 { 83 {
65 Typeface ret = null; 84 Typeface ret = null;
66 try 85 try
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { 150 {
132 super.onActivityCreated(savedInstanceState); 151 super.onActivityCreated(savedInstanceState);
133 final Window window = getDialog().getWindow(); 152 final Window window = getDialog().getWindow();
134 window.setBackgroundDrawable(null); 153 window.setBackgroundDrawable(null);
135 window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 154 window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
136 } 155 }
137 156
138 @Override 157 @Override
139 public void onClick(View v) 158 public void onClick(View v)
140 { 159 {
141 if (this.currentStep < NUMBER_OF_STEPS) 160 final int nextStep = this.currentStep + 1;
161 if (nextStep * 2 < PAGES_RESOURCE_LIST.length)
142 { 162 {
143 this.currentStep++; 163 this.currentStep = nextStep;
144 this.updateContents(this.getView()); 164 this.updateContents(this.getView());
145 } 165 }
146 else 166 else
147 { 167 {
148 this.dismissAllowingStateLoss(); 168 this.dismissAllowingStateLoss();
149 } 169 }
150 } 170 }
151 171
152 @Override 172 @Override
153 public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) 173 public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
154 { 174 {
155 if (keyCode == KeyEvent.KEYCODE_BACK) 175 if (keyCode == KeyEvent.KEYCODE_BACK)
156 { 176 {
157 if (event.getAction() == KeyEvent.ACTION_DOWN && this.currentStep > 1) 177 if (event.getAction() == KeyEvent.ACTION_DOWN && this.currentStep > 0)
158 { 178 {
159 this.currentStep--; 179 this.currentStep--;
160 this.updateContents(this.getView()); 180 this.updateContents(this.getView());
161 } 181 }
162 return true; 182 return true;
163 } 183 }
164 return false; 184 return false;
165 } 185 }
166 186
167 private static List<View> listViews(final View parent) 187 private static List<View> listViews(final View parent)
(...skipping 17 matching lines...) Expand all
185 } 205 }
186 } 206 }
187 207
188 private void updateContents(final View view) 208 private void updateContents(final View view)
189 { 209 {
190 final LinearLayout ll = (LinearLayout) view.findViewById(R.id.abb_main_conte nt); 210 final LinearLayout ll = (LinearLayout) view.findViewById(R.id.abb_main_conte nt);
191 ll.removeAllViews(); 211 ll.removeAllViews();
192 212
193 final LayoutInflater inflater = (LayoutInflater) this.getActivity() 213 final LayoutInflater inflater = (LayoutInflater) this.getActivity()
194 .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 214 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
195 inflater.inflate( 215 inflater.inflate(PAGES_RESOURCE_LIST[this.currentStep * 2], ll, true);
196 this.getResources().getIdentifier("abb_start_pane_step_" + this.currentS tep, 216 this.setButtonText(view, R.id.abb_frp_button, PAGES_RESOURCE_LIST[this.curre ntStep * 2 + 1]);
197 "layout",
198 this.getActivity().getPackageName()), ll, true);
199
200 this.setButtonText(view, R.id.abb_frp_button,
201 this.getResources().getIdentifier("abb_frp_button_" + this.currentStep,
202 "string",
203 this.getActivity().getPackageName()));
204 217
205 final List<View> views = listViews(view); 218 final List<View> views = listViews(view);
206 for (View v : views) 219 for (View v : views)
207 { 220 {
208 final Object tag = v.getTag(); 221 final Object tag = v.getTag();
209 if (tag != null) 222 if (tag != null)
210 { 223 {
211 Typeface t = this.loadedFonts.get(tag.toString()); 224 Typeface t = this.loadedFonts.get(tag.toString());
212 if (t != null) 225 if (t != null)
213 { 226 {
214 if (v instanceof TextView) 227 if (v instanceof TextView)
215 { 228 {
216 ((TextView) v).setTypeface(t); 229 ((TextView) v).setTypeface(t);
217 } 230 }
218 else if (v instanceof Button) 231 else if (v instanceof Button)
219 { 232 {
220 ((Button) v).setTypeface(t); 233 ((Button) v).setTypeface(t);
221 } 234 }
222 } 235 }
223 } 236 }
224 } 237 }
225 } 238 }
226 239
227 private void setButtonText(final View view, final int viewId, final int resId) 240 private void setButtonText(final View view, final int viewId, final int resId)
228 { 241 {
229 final Button button = (Button) view.findViewById(viewId); 242 final Button button = (Button) view.findViewById(viewId);
230 button.setText(this.getString(resId)); 243 button.setText(this.getString(resId));
231 } 244 }
232 } 245 }
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