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

Side by Side Diff: src/org/adblockplus/android/AboutDialog.java

Issue 8363097: ABP/Android preferences UI (Closed) Base URL: https://hg.adblockplus.org/adblockplusandroid/
Patch Set: Created Sept. 14, 2012, 8:20 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
OLDNEW
(Empty)
1 package org.adblockplus.android;
2
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStream;
6 import java.io.InputStreamReader;
7
8 import android.app.Dialog;
9 import android.content.Context;
10 import android.content.pm.PackageInfo;
11 import android.content.pm.PackageManager.NameNotFoundException;
12 import android.os.Bundle;
13 import android.text.Html;
14 import android.text.method.LinkMovementMethod;
15 import android.view.Window;
16 import android.widget.TextView;
17
18 public class AboutDialog extends Dialog
19 {
20 private static Context mContext = null;
Felix Dahlke 2012/09/18 15:32:49 Shouldn't class variables be prefixed with "s" whe
21
22 public AboutDialog(Context context)
23 {
24 super(context);
25 mContext = context;
26 }
27
28 @Override
29 public void onCreate(Bundle savedInstanceState)
30 {
31 requestWindowFeature(Window.FEATURE_NO_TITLE);
32 setContentView(R.layout.about);
33 String versionName = "--";
34 int versionCode = -1;
35 try
36 {
37 PackageInfo pi = mContext.getPackageManager().getPackage Info(mContext.getPackageName(), 0);
38 versionName = pi.versionName;
39 versionCode = pi.versionCode;
40 }
41 catch (NameNotFoundException ex)
42 {
43 }
44
45 StringBuilder info = new StringBuilder();
46 info.append("<h3>");
47 info.append(mContext.getString(R.string.app_name));
48 info.append("</h3>");
49 info.append("<p>");
50 info.append(mContext.getString(R.string.version));
51 info.append(": ");
52 info.append(versionName);
53 info.append(" ");
54 info.append(mContext.getString(R.string.build));
55 info.append(" ");
56 info.append(versionCode);
57 info.append("</p>");
58 appendRawTextFile(info, R.raw.info);
59 appendRawTextFile(info, R.raw.legal);
60
61 TextView tv = (TextView) findViewById(R.id.about_text);
62 tv.setText(Html.fromHtml(info.toString()));
63 tv.setMovementMethod(LinkMovementMethod.getInstance());
64 }
65
66 public static void appendRawTextFile(StringBuilder text, int id)
67 {
68 InputStream inputStream = mContext.getResources().openRawResourc e(id);
69 InputStreamReader in = new InputStreamReader(inputStream);
70 BufferedReader buf = new BufferedReader(in);
71 String line;
72 try
73 {
74 while ((line = buf.readLine()) != null)
75 text.append(line);
76 }
77 catch (IOException e)
78 {
Felix Dahlke 2012/09/18 15:32:49 Empty catch blocks are in most cases not a good th
79 }
80 }
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld