1 package org.fedorahosted.freeotp;
3 import android.app.AlertDialog;
4 import android.content.Context;
5 import android.content.DialogInterface;
6 import android.content.pm.PackageInfo;
7 import android.content.pm.PackageManager;
8 import android.content.res.Resources;
9 import android.text.Html;
10 import android.text.method.LinkMovementMethod;
11 import android.view.View;
12 import android.widget.TextView;
14 public class AboutDialog extends AlertDialog {
15 private void init(Context ctx) {
16 Resources res = ctx.getResources();
17 View v = getLayoutInflater().inflate(R.layout.about, null, false);
21 PackageManager pm = ctx.getPackageManager();
22 PackageInfo info = pm.getPackageInfo(ctx.getPackageName(), 0);
23 String version = res.getString(R.string.about_version,
26 tv = (TextView) v.findViewById(R.id.about_version);
28 } catch (PackageManager.NameNotFoundException e) {
32 String apache2 = res.getString(R.string.link_apache2);
33 String license = res.getString(R.string.about_license, apache2);
34 tv = (TextView) v.findViewById(R.id.about_license);
35 tv.setMovementMethod(LinkMovementMethod.getInstance());
36 tv.setText(Html.fromHtml(license));
38 String lwebsite = res.getString(R.string.link_website);
39 String swebsite = res.getString(R.string.about_website, lwebsite);
40 tv = (TextView) v.findViewById(R.id.about_website);
41 tv.setMovementMethod(LinkMovementMethod.getInstance());
42 tv.setText(Html.fromHtml(swebsite));
44 String problem = res.getString(R.string.link_report_a_problem);
45 String help = res.getString(R.string.link_ask_for_help);
46 String feedback = res.getString(R.string.about_feedback, problem, help);
47 tv = (TextView) v.findViewById(R.id.about_feedback);
48 tv.setMovementMethod(LinkMovementMethod.getInstance());
49 tv.setText(Html.fromHtml(feedback));
51 String title = ctx.getResources().getString(R.string.about);
52 setTitle(title + " " + ctx.getResources().getString(R.string.app_name));
55 String ok = res.getString(android.R.string.ok);
56 setButton(BUTTON_POSITIVE, ok, new OnClickListener() {
58 public void onClick(DialogInterface dialog, int which) {
63 public AboutDialog(Context context, boolean cancelable,
64 OnCancelListener cancelListener) {
65 super(context, cancelable, cancelListener);
69 public AboutDialog(Context context, int theme) {
70 super(context, theme);
74 public AboutDialog(Context context) {