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

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

Issue 29572644: Noissue - Lint adjustments
Patch Set: Removing shared prefs editor commit() to apply() change Created Oct. 12, 2017, 9:14 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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-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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 import android.view.ViewGroup.LayoutParams; 44 import android.view.ViewGroup.LayoutParams;
45 import android.view.Window; 45 import android.view.Window;
46 import android.widget.Button; 46 import android.widget.Button;
47 import android.widget.LinearLayout; 47 import android.widget.LinearLayout;
48 import android.widget.TextView; 48 import android.widget.TextView;
49 49
50 public class StartPane extends DialogFragment implements OnClickListener, OnKeyL istener 50 public class StartPane extends DialogFragment implements OnClickListener, OnKeyL istener
51 { 51 {
52 private static final String TAG = "AdblockBrowser.StartPane"; 52 private static final String TAG = "AdblockBrowser.StartPane";
53 private int currentStep = 0; 53 private int currentStep = 0;
54 private static final HashMap<String, Integer> FONTS = new HashMap<String, Inte ger>(); 54 private static final HashMap<String, Integer> FONTS = new HashMap<>();
55 private HashMap<String, Typeface> loadedFonts = new HashMap<String, Typeface>( ); 55 private final HashMap<String, Typeface> loadedFonts = new HashMap<>();
56 56
57 private static final int[] BETA_RESOURCE_LIST = 57 private static final int[] BETA_RESOURCE_LIST =
58 { 58 {
59 R.layout.abb_start_pane_step_1, R.string.abb_frp_button_1, 59 R.layout.abb_start_pane_step_1, R.string.abb_frp_button_1,
60 R.layout.abb_start_pane_step_2, R.string.abb_frp_button_2, 60 R.layout.abb_start_pane_step_2, R.string.abb_frp_button_2,
61 R.layout.abb_start_pane_step_3, R.string.abb_frp_button_3 61 R.layout.abb_start_pane_step_3, R.string.abb_frp_button_3
62 }; 62 };
63 63
64 private static final int[] RELEASE_RESOURCE_LIST = 64 private static final int[] RELEASE_RESOURCE_LIST =
65 { 65 {
66 R.layout.abb_start_pane_step_1, R.string.abb_frp_button_2, 66 R.layout.abb_start_pane_step_1, R.string.abb_frp_button_2,
67 R.layout.abb_start_pane_step_2, R.string.abb_frp_button_3 67 R.layout.abb_start_pane_step_2, R.string.abb_frp_button_3
68 }; 68 };
69 69
70 private int[] pagesResourceList; 70 private int[] pagesResourceList;
71 71
72 static 72 static
73 { 73 {
74 FONTS.put("ttf_opensans_light", R.raw.opensans_light); 74 FONTS.put("ttf_opensans_light", R.raw.opensans_light);
75 FONTS.put("ttf_opensans_semibold", R.raw.opensans_semibold); 75 FONTS.put("ttf_opensans_semibold", R.raw.opensans_semibold);
76 } 76 }
77 77
78 static Typeface typefaceFromResource(final Context context, final int resId) 78 private static Typeface typefaceFromResource(final Context context, final int resId)
79 { 79 {
80 Typeface ret = null; 80 Typeface ret = null;
81 try 81 try
82 { 82 {
83 context.getCacheDir().mkdir(); 83 context.getCacheDir().mkdir();
84 final File output = File.createTempFile("abb_font", ".ttf"); 84 final File output = File.createTempFile("abb_font", ".ttf");
85 final byte[] buffer = new byte[4096]; 85 final byte[] buffer = new byte[4096];
86 final InputStream in = context.getResources().openRawResource(resId); 86 final InputStream in = context.getResources().openRawResource(resId);
87 final FileOutputStream out = new FileOutputStream(output); 87 final FileOutputStream out = new FileOutputStream(output);
88 for (;;) 88 for (;;)
(...skipping 16 matching lines...) Expand all
105 } 105 }
106 return ret; 106 return ret;
107 } 107 }
108 108
109 private void loadTypefaces() 109 private void loadTypefaces()
110 { 110 {
111 final Context context = this.getActivity(); 111 final Context context = this.getActivity();
112 this.loadedFonts.clear(); 112 this.loadedFonts.clear();
113 for (Map.Entry<String, Integer> e : FONTS.entrySet()) 113 for (Map.Entry<String, Integer> e : FONTS.entrySet())
114 { 114 {
115 final Typeface t = typefaceFromResource(context, e.getValue().intValue()); 115 final Typeface t = typefaceFromResource(context, e.getValue());
116 if (t != null) 116 if (t != null)
117 { 117 {
118 this.loadedFonts.put(e.getKey(), t); 118 this.loadedFonts.put(e.getKey(), t);
119 } 119 }
120 } 120 }
121 } 121 }
122 122
123 private void loadPagesResources() 123 private void loadPagesResources()
124 { 124 {
125 final boolean useBetaResourceList = !AppConstants.ABB_RELEASE_BUILD && Brows erAppUtils.wasInstalledFromPlayStore(getContext()); 125 final boolean useBetaResourceList = !AppConstants.ABB_RELEASE_BUILD && Brows erAppUtils.wasInstalledFromPlayStore(getContext());
(...skipping 11 matching lines...) Expand all
137 } 137 }
138 138
139 @Override 139 @Override
140 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) 140 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle)
141 { 141 {
142 final View view = inflater.inflate(R.layout.abb_start_pane, container, false ); 142 final View view = inflater.inflate(R.layout.abb_start_pane, container, false );
143 143
144 this.updateContents(view); 144 this.updateContents(view);
145 145
146 this.getDialog().setOnKeyListener(this); 146 this.getDialog().setOnKeyListener(this);
147 ((Button) view.findViewById(R.id.abb_frp_button)).setOnClickListener(this); 147 view.findViewById(R.id.abb_frp_button).setOnClickListener(this);
148 148
149 return view; 149 return view;
150 } 150 }
151 151
152 @Override 152 @Override
153 public void onActivityCreated(Bundle savedInstanceState) 153 public void onActivityCreated(Bundle savedInstanceState)
154 { 154 {
155 super.onActivityCreated(savedInstanceState); 155 super.onActivityCreated(savedInstanceState);
156 final Window window = getDialog().getWindow(); 156 final Window window = getDialog().getWindow();
157 window.setBackgroundDrawable(null); 157 window.setBackgroundDrawable(null);
(...skipping 25 matching lines...) Expand all
183 this.currentStep--; 183 this.currentStep--;
184 this.updateContents(this.getView()); 184 this.updateContents(this.getView());
185 } 185 }
186 return true; 186 return true;
187 } 187 }
188 return false; 188 return false;
189 } 189 }
190 190
191 private static List<View> listViews(final View parent) 191 private static List<View> listViews(final View parent)
192 { 192 {
193 final List<View> views = new ArrayList<View>(); 193 final List<View> views = new ArrayList<>();
194 listViews(parent, views); 194 listViews(parent, views);
195 return views; 195 return views;
196 } 196 }
197 197
198 private static void listViews(final View parent, final List<View> views) 198 private static void listViews(final View parent, final List<View> views)
199 { 199 {
200 views.add(parent); 200 views.add(parent);
201 if (parent instanceof ViewGroup) 201 if (parent instanceof ViewGroup)
202 { 202 {
203 final ViewGroup vg = (ViewGroup) parent; 203 final ViewGroup vg = (ViewGroup) parent;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 } 241 }
242 } 242 }
243 243
244 private void setButtonText(final View view, final int viewId, final int resId) 244 private void setButtonText(final View view, final int viewId, final int resId)
245 { 245 {
246 final Button button = (Button) view.findViewById(viewId); 246 final Button button = (Button) view.findViewById(viewId);
247 button.setText(this.getString(resId)); 247 button.setText(this.getString(resId));
248 } 248 }
249 } 249 }
OLDNEW

Powered by Google App Engine
This is Rietveld