1 package de
.cwde
.shisensho
;
3 import de
.cwde
.shisensho
.R
;
5 import android
.app
.Activity
;
6 import android
.app
.AlertDialog
;
7 import android
.content
.Intent
;
8 import android
.content
.pm
.PackageInfo
;
9 import android
.content
.pm
.PackageManager
;
10 import android
.content
.pm
.PackageManager
.NameNotFoundException
;
11 import android
.os
.Bundle
;
12 import android
.text
.SpannableString
;
13 import android
.text
.util
.Linkify
;
14 import android
.view
.Menu
;
15 import android
.view
.MenuInflater
;
16 import android
.view
.MenuItem
;
17 import android
.view
.ViewGroup
;
18 import android
.view
.Window
;
19 import android
.widget
.TextView
;
21 public class ShisenShoActivity
extends Activity
{
22 private ShisenShoView view
;
24 /** Called when the activity is first created. */
26 public void onCreate(Bundle savedInstanceState
) {
27 super.onCreate(savedInstanceState
);
29 requestWindowFeature(Window
.FEATURE_NO_TITLE
);
30 //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
31 // WindowManager.LayoutParams.FLAG_FULLSCREEN);
33 view
= ShisenSho
.app().getView();
34 ShisenSho
.app().activity
= this;
39 protected void onDestroy() {
40 ViewGroup vg
= (ViewGroup
)(view
.getParent());
42 ShisenSho
.app().activity
= null;
47 protected void onPause() {
55 protected void onResume() {
63 public boolean onCreateOptionsMenu(Menu menu
) {
64 MenuInflater inflater
= getMenuInflater();
65 inflater
.inflate(R
.menu
.menu
, menu
);
70 public boolean onOptionsItemSelected(MenuItem item
) {
71 // Handle item selection
72 switch (item
.getItemId()) {
76 return view
.onOptionsItemSelected(item
);
78 startActivityForResult(new Intent("de.cwde.shisensho.SETTINGS", null), 0);
84 return super.onOptionsItemSelected(item
);
88 private void onAboutActivate() {
89 // Try to load the a package matching the name of our own package
92 pInfo
= getPackageManager().getPackageInfo(getPackageName(), PackageManager
.GET_META_DATA
);
93 String aboutTitle
= String
.format("About %s", getString(R
.string
.app_name
));
94 String versionString
= String
.format("Version: %s", pInfo
.versionName
);
95 String aboutText
= getString(R
.string
.aboutText
);
97 // Set up the TextView
98 final TextView message
= new TextView(this);
99 // We'll use a spannablestring to be able to make links clickable
100 final SpannableString s
= new SpannableString(aboutText
);
103 message
.setPadding(5, 5, 5, 5);
104 // Set up the final string
105 message
.setText(versionString
+ "\n" + s
);
106 // Now linkify the text
107 Linkify
.addLinks(message
, Linkify
.ALL
);
109 new AlertDialog
.Builder(this)
110 .setTitle(aboutTitle
)
112 .setIcon(R
.drawable
.icon
)
113 .setPositiveButton(getString(android
.R
.string
.ok
), null)
114 .setView(message
).create()
116 } catch (NameNotFoundException e
) {