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

Unified Diff: src/org/adblockplus/android/AboutDialog.java

Issue 8493083: ABP/Android UI (Closed)
Patch Set: ABP/Android UI Created Oct. 12, 2012, 1:24 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « res/xml/preferences_advanced.xml ('k') | src/org/adblockplus/android/AdvancedPreferences.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/AboutDialog.java
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/org/adblockplus/android/AboutDialog.java
@@ -0,0 +1,87 @@
+package org.adblockplus.android;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.view.Window;
+import android.widget.TextView;
+
+public class AboutDialog extends Dialog
+{
+ private static Context context = null;
+
+ public AboutDialog(Context context)
+ {
+ super(context);
+ AboutDialog.context = context;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.about);
+
+ // Get package version code and name
+ String versionName = "--";
+ int versionCode = -1;
+ try
+ {
+ PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
+ versionName = pi.versionName;
+ versionCode = pi.versionCode;
+ }
+ catch (NameNotFoundException ex)
+ {
+ // ignore - it can not happen because we query information about ourselves
+ }
+
+ // Construct html
+ StringBuilder info = new StringBuilder();
+ info.append("<h3>");
+ info.append(context.getString(R.string.app_name));
+ info.append("</h3>");
+ info.append("<p>");
+ info.append(context.getString(R.string.version));
+ info.append(": ");
+ info.append(versionName);
+ info.append(" ");
+ info.append(context.getString(R.string.build));
+ info.append(" ");
+ info.append(versionCode);
+ info.append("</p>");
+ appendRawTextFile(info, R.raw.info);
+ appendRawTextFile(info, R.raw.legal);
+
+ // Show text
+ TextView tv = (TextView) findViewById(R.id.about_text);
+ tv.setText(Html.fromHtml(info.toString()));
+ tv.setMovementMethod(LinkMovementMethod.getInstance());
+ }
+
+ public static void appendRawTextFile(StringBuilder text, int id)
+ {
+ InputStream inputStream = context.getResources().openRawResource(id);
+ InputStreamReader in = new InputStreamReader(inputStream);
+ BufferedReader buf = new BufferedReader(in);
+ String line;
+ try
+ {
+ while ((line = buf.readLine()) != null)
+ text.append(line);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
« no previous file with comments | « res/xml/preferences_advanced.xml ('k') | src/org/adblockplus/android/AdvancedPreferences.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld