10package org.libreoffice;
12import android.annotation.SuppressLint;
13import android.app.AlertDialog;
14import android.app.Dialog;
15import android.content.ComponentName;
16import android.content.DialogInterface;
17import android.content.Intent;
18import android.content.pm.PackageManager;
19import android.net.Uri;
20import android.os.Bundle;
21import androidx.annotation.NonNull;
22import androidx.fragment.app.DialogFragment;
23import android.text.Html;
24import android.text.Spanned;
25import android.text.method.LinkMovementMethod;
26import android.view.View;
27import android.widget.TextView;
34 @SuppressLint(
"InflateParams")
35 View messageView = getActivity().getLayoutInflater().inflate(
R.layout.about,
null,
false);
39 TextView textView = messageView.findViewById(
R.id.about_credits);
40 int defaultColor = textView.getTextColors().getDefaultColor();
41 textView.setTextColor(defaultColor);
44 TextView versionView = messageView.findViewById(
R.id.about_version);
45 TextView vendorView = messageView.findViewById(
R.id.about_vendor);
48 String versionName = getActivity().getPackageManager()
49 .getPackageInfo(getActivity().getPackageName(), 0).versionName;
53 String version =
String.format(versionView.getText().toString().replace(
"\n",
"<br/>"),
54 tokens[0],
"<a href=\"https://hub.libreoffice.org/git-core/" +
tokens[1] +
"\">" +
tokens[1] +
"</a>");
55 @SuppressWarnings(
"deprecation")
56 Spanned versionString =
Html.fromHtml(version);
57 versionView.setText(versionString);
58 versionView.setMovementMethod(LinkMovementMethod.getInstance());
59 String vendor = vendorView.getText().toString();
60 vendor = vendor.replace(
"$VENDOR",
tokens[2]);
61 vendorView.setText(vendor);
64 throw new PackageManager.NameNotFoundException();
66 catch (PackageManager.NameNotFoundException e)
68 versionView.setText(
"");
69 vendorView.setText(
"");
72 AlertDialog.Builder builder =
new AlertDialog.Builder(getActivity());
73 builder .setIcon(
R.drawable.lo_icon)
74 .setTitle(
R.string.app_name)
76 .setNegativeButton(
R.string.about_license,
new DialogInterface.OnClickListener() {
78 public void onClick(DialogInterface dialog, int id) {
79 loadFromAbout(R.raw.license);
83 .setPositiveButton(
R.string.about_notice,
new DialogInterface.OnClickListener() {
85 public void onClick(DialogInterface dialog, int id) {
86 loadFromAbout(R.raw.notice);
90 .setNeutralButton(
R.string.about_moreinfo,
new DialogInterface.OnClickListener() {
92 public void onClick(DialogInterface dialog, int id) {
93 loadFromAbout(R.raw.example);
98 return builder.create();
102 Intent
i =
new Intent(Intent.ACTION_VIEW, Uri.parse(
"android.resource://" + BuildConfig.APPLICATION_ID +
"/" + resourceId));
103 String packageName = getActivity().getApplicationContext().getPackageName();
105 i.setComponent(componentName);
106 getActivity().startActivity(
i);
Dialog onCreateDialog(Bundle savedInstanceState)
void loadFromAbout(int resourceId)
Main activity of the LibreOffice App.