-
Notifications
You must be signed in to change notification settings - Fork 288
/
AboutActivity.java
70 lines (62 loc) · 2.42 KB
/
AboutActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* FreeOTP
*
* Authors: Nathaniel McCallum <npmccallum@redhat.com>
*
* Copyright (C) 2013 Nathaniel McCallum, Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fedorahosted.freeotp;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
public class AboutActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
}
@Override
@SuppressWarnings("deprecation")
//suppress because Html.fromHtml(String, int) requires minSdkVersion 24
public void onStart() {
super.onStart();
Resources res = getResources();
TextView tv;
try {
PackageManager pm = getPackageManager();
PackageInfo info = pm.getPackageInfo(getPackageName(), 0);
String version = res.getString(R.string.about_version, info.versionName, info.versionCode);
tv = findViewById(R.id.about_version);
tv.setText(version);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
String apache2 = res.getString(R.string.link_apache2);
String license = res.getString(R.string.about_license, apache2);
tv = findViewById(R.id.about_license);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setText(Html.fromHtml(license));
String lwebsite = res.getString(R.string.link_website);
String swebsite = res.getString(R.string.about_website, lwebsite);
tv = findViewById(R.id.about_website);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setText(Html.fromHtml(swebsite));
}
}