4 * Authors: Nathaniel McCallum <npmccallum@redhat.com>
6 * Copyright (C) 2013 Nathaniel McCallum, Red Hat
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 package org.fedorahosted.freeotp;
23 import android.content.DialogInterface;
24 import android.content.pm.PackageInfo;
25 import android.content.pm.PackageManager;
26 import android.content.res.Resources;
27 import android.text.Html;
28 import android.text.method.LinkMovementMethod;
29 import android.view.View;
30 import android.widget.TextView;
32 public class AboutDialogFragment extends BaseAlertDialogFragment {
33 public static final String FRAGMENT_TAG = "fragment_about";
35 public AboutDialogFragment() {
36 super(R.string.about, R.layout.about, 0, android.R.string.ok, 0);
40 protected void onViewInflated(View view) {
41 Resources res = getActivity().getResources();
45 PackageManager pm = getActivity().getPackageManager();
46 PackageInfo info = pm.getPackageInfo(getActivity().getPackageName(), 0);
47 String version = res.getString(R.string.about_version,
50 tv = (TextView) view.findViewById(R.id.about_version);
52 } catch (PackageManager.NameNotFoundException e) {
56 String apache2 = res.getString(R.string.link_apache2);
57 String license = res.getString(R.string.about_license, apache2);
58 tv = (TextView) view.findViewById(R.id.about_license);
59 tv.setMovementMethod(LinkMovementMethod.getInstance());
60 tv.setText(Html.fromHtml(license));
62 String lwebsite = res.getString(R.string.link_website);
63 String swebsite = res.getString(R.string.about_website, lwebsite);
64 tv = (TextView) view.findViewById(R.id.about_website);
65 tv.setMovementMethod(LinkMovementMethod.getInstance());
66 tv.setText(Html.fromHtml(swebsite));
68 String problem = res.getString(R.string.link_report_a_problem);
69 String help = res.getString(R.string.link_ask_for_help);
70 String feedback = res.getString(R.string.about_feedback, problem, help);
71 tv = (TextView) view.findViewById(R.id.about_feedback);
72 tv.setMovementMethod(LinkMovementMethod.getInstance());
73 tv.setText(Html.fromHtml(feedback));
77 public void onStart() {
80 Resources res = getActivity().getResources();
81 String title = res.getString(R.string.about_title,
82 res.getString(R.string.app_name));
83 getDialog().setTitle(title);
87 public void onClick(DialogInterface arg0, int arg1) {