1 package org
.proofofconcept
.shisensho
;
3 import android
.app
.Activity
;
4 import android
.app
.AlertDialog
;
5 import android
.content
.Intent
;
6 import android
.content
.pm
.PackageInfo
;
7 import android
.content
.pm
.PackageManager
;
8 import android
.content
.pm
.PackageManager
.NameNotFoundException
;
9 import android
.os
.Bundle
;
10 import android
.text
.SpannableString
;
11 import android
.text
.util
.Linkify
;
12 import android
.view
.Menu
;
13 import android
.view
.MenuInflater
;
14 import android
.view
.MenuItem
;
15 import android
.view
.ViewGroup
;
16 import android
.view
.Window
;
17 import android
.widget
.TextView
;
19 public class ShisenShoActivity
extends Activity
{
20 private ShisenShoView view
;
22 /** Called when the activity is first created. */
24 public void onCreate(Bundle savedInstanceState
) {
25 super.onCreate(savedInstanceState
);
27 requestWindowFeature(Window
.FEATURE_NO_TITLE
);
28 //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
29 // WindowManager.LayoutParams.FLAG_FULLSCREEN);
31 view
= ShisenSho
.app().getView();
32 ShisenSho
.app().activity
= this;
37 protected void onDestroy() {
38 ViewGroup vg
= (ViewGroup
)(view
.getParent());
40 ShisenSho
.app().activity
= null;
45 protected void onPause() {
53 protected void onResume() {
61 public boolean onCreateOptionsMenu(Menu menu
) {
62 MenuInflater inflater
= getMenuInflater();
63 inflater
.inflate(R
.menu
.menu
, menu
);
68 public boolean onOptionsItemSelected(MenuItem item
) {
69 // Handle item selection
70 switch (item
.getItemId()) {
74 return view
.onOptionsItemSelected(item
);
76 startActivityForResult(new Intent("org.proofofconcept.shisensho.SETTINGS", null), 0);
82 return super.onOptionsItemSelected(item
);
86 private void onAboutActivate() {
87 // Try to load the a package matching the name of our own package
90 pInfo
= getPackageManager().getPackageInfo(getPackageName(), PackageManager
.GET_META_DATA
);
91 String aboutTitle
= String
.format("About %s", getString(R
.string
.app_name
));
92 String versionString
= String
.format("Version: %s", pInfo
.versionName
);
93 String aboutText
= getString(R
.string
.aboutText
);
95 // Set up the TextView
96 final TextView message
= new TextView(this);
97 // We'll use a spannablestring to be able to make links clickable
98 final SpannableString s
= new SpannableString(aboutText
);
101 message
.setPadding(5, 5, 5, 5);
102 // Set up the final string
103 message
.setText(versionString
+ "\n" + s
);
104 // Now linkify the text
105 Linkify
.addLinks(message
, Linkify
.ALL
);
107 new AlertDialog
.Builder(this)
108 .setTitle(aboutTitle
)
110 .setIcon(R
.drawable
.icon
)
111 .setPositiveButton(getString(android
.R
.string
.ok
), null)
112 .setView(message
).create()
114 } catch (NameNotFoundException e
) {