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

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

Issue 29370727: Issue 4505 - Add translations (Closed)
Patch Set: Removing now unused readTextFile Created Jan. 6, 2017, 4:07 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 | « res/values/strings.xml ('k') | 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
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 this.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this) ; 100 this.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this) ;
101 } 101 }
102 102
103 private void checkForCompatibleSBrowserAndProceed() 103 private void checkForCompatibleSBrowserAndProceed()
104 { 104 {
105 if (!Engine.hasCompatibleSBrowserInstalled(this.getApplicationContext())) 105 if (!Engine.hasCompatibleSBrowserInstalled(this.getApplicationContext()))
106 { 106 {
107 final AlertDialog d = new AlertDialog.Builder(this) 107 final AlertDialog d = new AlertDialog.Builder(this)
108 .setCancelable(false) 108 .setCancelable(false)
109 .setTitle(R.string.sbrowser_dialog_title) 109 .setTitle(R.string.sbrowser_dialog_title)
110 .setMessage(Html.fromHtml(this.readTextFile(R.raw.sbrowser_dialog))) 110 .setMessage(Html.fromHtml(getString(R.string.sbrowser_dialog_message)) )
111 .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener () 111 .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener ()
112 { 112 {
113 @Override 113 @Override
114 public void onClick(DialogInterface dialog, int which) 114 public void onClick(DialogInterface dialog, int which)
115 { 115 {
116 try 116 try
117 { 117 {
118 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market:/ /details?id=" 118 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market:/ /details?id="
119 + SBROWSER_APP_ID))); 119 + SBROWSER_APP_ID)));
120 } 120 }
(...skipping 15 matching lines...) Expand all
136 private void checkAAStatusAndProceed() 136 private void checkAAStatusAndProceed()
137 { 137 {
138 final SharedPreferences prefs = this.getSharedPreferences(); 138 final SharedPreferences prefs = this.getSharedPreferences();
139 final String keyAaInfoShown = this.getString(R.string.key_aa_info_shown); 139 final String keyAaInfoShown = this.getString(R.string.key_aa_info_shown);
140 final boolean aaInfoShown = prefs.getBoolean(keyAaInfoShown, false); 140 final boolean aaInfoShown = prefs.getBoolean(keyAaInfoShown, false);
141 if (!aaInfoShown) 141 if (!aaInfoShown)
142 { 142 {
143 final AlertDialog d = new AlertDialog.Builder(this) 143 final AlertDialog d = new AlertDialog.Builder(this)
144 .setCancelable(false) 144 .setCancelable(false)
145 .setTitle(R.string.aa_dialog_title) 145 .setTitle(R.string.aa_dialog_title)
146 .setMessage(Html.fromHtml(this.readTextFile(R.raw.aa_dialog))) 146 .setMessage(Html.fromHtml(getString(R.string.aa_dialog_message)))
147 .setNeutralButton(R.string.aa_dialog_button, new OnClickListener() 147 .setNeutralButton(R.string.aa_dialog_button, new OnClickListener()
148 { 148 {
149 @Override 149 @Override
150 public void onClick(DialogInterface dialog, int which) 150 public void onClick(DialogInterface dialog, int which)
151 { 151 {
152 prefs.edit() 152 prefs.edit()
153 .putBoolean(keyAaInfoShown, true) 153 .putBoolean(keyAaInfoShown, true)
154 .commit(); 154 .commit();
155 MainPreferences.this.checkSetupStatus(); 155 MainPreferences.this.checkSetupStatus();
156 } 156 }
(...skipping 10 matching lines...) Expand all
167 { 167 {
168 final boolean applicationActivated = this.getSharedPreferences() 168 final boolean applicationActivated = this.getSharedPreferences()
169 .getBoolean(this.getString(R.string.key_application_activated), false); 169 .getBoolean(this.getString(R.string.key_application_activated), false);
170 170
171 if (!applicationActivated) 171 if (!applicationActivated)
172 { 172 {
173 Log.d(TAG, "Showing setup dialog"); 173 Log.d(TAG, "Showing setup dialog");
174 this.setupDialog = new AlertDialog.Builder(this) 174 this.setupDialog = new AlertDialog.Builder(this)
175 .setCancelable(false) 175 .setCancelable(false)
176 .setTitle(R.string.setup_dialog_title) 176 .setTitle(R.string.setup_dialog_title)
177 .setMessage(Html.fromHtml(this.readTextFile(R.raw.setup_dialog))) 177 .setMessage(Html.fromHtml(getString(R.string.setup_dialog_message)))
178 .setNeutralButton(R.string.setup_dialog_button, new OnClickListener() 178 .setNeutralButton(R.string.setup_dialog_button, new OnClickListener()
179 { 179 {
180 @Override 180 @Override
181 public void onClick(DialogInterface dialog, int which) 181 public void onClick(DialogInterface dialog, int which)
182 { 182 {
183 Engine.openSBrowserSettings(MainPreferences.this); 183 Engine.openSBrowserSettings(MainPreferences.this);
184 } 184 }
185 }) 185 })
186 .create(); 186 .create();
187 this.setupDialog.show(); 187 this.setupDialog.show();
(...skipping 30 matching lines...) Expand all
218 } 218 }
219 else if (this.getString(R.string.key_application_activated).equals(key)) 219 else if (this.getString(R.string.key_application_activated).equals(key))
220 { 220 {
221 if (this.setupDialog != null) 221 if (this.setupDialog != null)
222 { 222 {
223 this.setupDialog.dismiss(); 223 this.setupDialog.dismiss();
224 this.setupDialog = null; 224 this.setupDialog = null;
225 } 225 }
226 } 226 }
227 } 227 }
228
229 private String readTextFile(int id)
230 {
231 try
232 {
233 final BufferedReader r = new BufferedReader(new InputStreamReader(this.get Resources()
234 .openRawResource(id), "UTF-8"));
235 try
236 {
237 final StringBuilder sb = new StringBuilder();
238 for (String line = r.readLine(); line != null; line = r.readLine())
239 {
240 sb.append(line);
241 sb.append('\n');
242 }
243 return sb.toString();
244 }
245 finally
246 {
247 r.close();
248 }
249 }
250 catch (IOException e)
251 {
252 Log.e(TAG, "Resource reading failed for: " + id, e);
253 return "...";
254 }
255 }
256 } 228 }
OLDNEW
« no previous file with comments | « res/values/strings.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld