12
12
import android .graphics .drawable .Drawable ;
13
13
import android .net .Uri ;
14
14
import android .os .Bundle ;
15
+ import android .provider .Settings ;
15
16
import android .support .annotation .*;
16
17
import android .support .v7 .app .AlertDialog ;
17
18
import android .support .v7 .app .AlertDialog .Builder ;
18
19
import android .text .TextUtils ;
19
20
import android .text .method .LinkMovementMethod ;
20
21
import android .view .View ;
22
+ import android .view .View .OnClickListener ;
21
23
import android .widget .*;
22
24
23
25
import static android .widget .ArrayAdapter .*;
@@ -43,42 +45,60 @@ public class AboutActivity extends ListActivity {
43
45
licenseContents = getResources ().getTextArray (R .array .about_licenses_content );
44
46
AndroidTools .displayedIf (findViewById (R .id .about_licenses_title ), !getListAdapter ().isEmpty ());
45
47
46
- final AboutInfo aboutInfo = getAboutInfo ();
48
+ AboutInfo aboutInfo = getAboutInfo ();
47
49
LOG .trace ("About info: {}" , aboutInfo );
50
+ populateInfo (aboutInfo );
51
+ }
48
52
49
- TextView feedback = ( TextView ) findViewById ( R . id . about_feedback );
50
- feedback . setOnClickListener ( new View . OnClickListener () {
53
+ protected void populateInfo ( final AboutInfo aboutInfo ) {
54
+ OnClickListener feedbackAction = new OnClickListener () {
51
55
@ Override public void onClick (View v ) {
52
56
onFeedback (aboutInfo );
53
57
}
54
- });
55
- populateInfo (aboutInfo );
56
- }
58
+ };
59
+ OnClickListener settingsAction = new OnClickListener () {
60
+ @ Override public void onClick (View v ) {
61
+ openInSettings (aboutInfo );
62
+ }
63
+ };
64
+ OnClickListener playStoreAction = new OnClickListener () {
65
+ @ Override public void onClick (View v ) {
66
+ openInPlayStore (aboutInfo );
67
+ }
68
+ };
69
+
70
+ TextView feedback = (TextView )findViewById (R .id .about_feedback );
71
+ feedback .setOnClickListener (feedbackAction );
57
72
58
- protected void populateInfo (AboutInfo aboutInfo ) {
59
73
TextView nameText = (TextView )findViewById (R .id .about_name );
60
74
nameText .setText (aboutInfo .appLabel );
61
75
nameText .setSelected (true ); // hack to start marquee
76
+ nameText .setOnClickListener (playStoreAction );
62
77
63
78
ImageView iconImage = (ImageView )findViewById (R .id .about_icon );
64
79
iconImage .setImageDrawable (aboutInfo .appIcon );
80
+ iconImage .setOnClickListener (playStoreAction );
65
81
66
82
TextView versionText = (TextView )findViewById (R .id .about_version );
67
83
versionText .setText (getString (R .string .about_version , aboutInfo .versionName ));
68
84
versionText .setSelected (true ); // hack to start marquee
85
+ versionText .setOnClickListener (settingsAction );
69
86
70
87
TextView versionCodeText = (TextView )findViewById (R .id .about_version_code );
71
88
versionCodeText .setText (String .valueOf (aboutInfo .versionCode ));
72
- versionCodeText .setVisibility (getResources ().getBoolean (R .bool .in_test )? View .VISIBLE : View .GONE );
89
+ versionCodeText .setOnClickListener (settingsAction );
90
+ AndroidTools .displayedIf (versionCodeText , getResources ().getBoolean (R .bool .in_test ));
73
91
74
92
TextView packageText = (TextView )findViewById (R .id .about_package );
75
93
packageText .setText (aboutInfo .applicationId );
76
94
packageText .setSelected (true ); // hack to start marquee
95
+ packageText .setOnClickListener (settingsAction );
77
96
78
97
initSection (R .id .about_faq , R .id .about_faq_title );
79
98
initSection (R .id .about_help , R .id .about_help_title );
80
99
initSection (R .id .about_tips , R .id .about_tips_title );
81
100
}
101
+
82
102
private void initSection (@ IdRes int sectionContentID , @ IdRes int sectionTitleID ) {
83
103
TextView contentView = (TextView )findViewById (sectionContentID );
84
104
contentView .setMovementMethod (LinkMovementMethod .getInstance ());
@@ -96,6 +116,26 @@ protected void onFeedback(AboutInfo aboutInfo) {
96
116
}
97
117
}
98
118
119
+ protected void openInSettings (AboutInfo aboutInfo ) {
120
+ try {
121
+ startActivity (new Intent (Settings .ACTION_APPLICATION_DETAILS_SETTINGS )
122
+ .setData (Uri .parse ("package:" + aboutInfo .applicationId ))
123
+ );
124
+ } catch (ActivityNotFoundException ex ) {
125
+ LOG .warn ("Cannot open app info in Settings" , ex );
126
+ }
127
+ }
128
+
129
+ protected void openInPlayStore (AboutInfo aboutInfo ) {
130
+ try {
131
+ startActivity (new Intent (Intent .ACTION_VIEW )
132
+ .setData (Uri .parse ("market://details?id=" + aboutInfo .applicationId ))
133
+ );
134
+ } catch (ActivityNotFoundException ex ) {
135
+ LOG .warn ("Cannot open app info in Play Store" , ex );
136
+ }
137
+ }
138
+
99
139
protected @ NonNull Intent createFeedbackIntent (AboutInfo aboutInfo ) {
100
140
final Intent feedbackIntent = new Intent (Intent .ACTION_VIEW );
101
141
feedbackIntent .setData (Uri .parse ("mailto:" + aboutInfo .email ));
0 commit comments