1 package de
.cwde
.freeshisen
;
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
.preference
.PreferenceManager
;
11 import android
.text
.SpannableString
;
12 import android
.text
.util
.Linkify
;
13 import android
.view
.Menu
;
14 import android
.view
.MenuInflater
;
15 import android
.view
.MenuItem
;
16 import android
.view
.ViewGroup
;
17 import android
.view
.Window
;
18 import android
.widget
.TextView
;
20 public class ShisenShoActivity
extends Activity
{
21 private ShisenShoView view
;
23 /** Called when the activity is first created. */
25 public void onCreate(Bundle savedInstanceState
) {
26 super.onCreate(savedInstanceState
);
28 PreferenceManager
.setDefaultValues(this, R
.xml
.preferences
, false);
30 requestWindowFeature(Window
.FEATURE_NO_TITLE
);
32 view
= ShisenSho
.app().getView();
33 ShisenSho
.app().activity
= this;
38 protected void onDestroy() {
39 ViewGroup vg
= (ViewGroup
)(view
.getParent());
41 ShisenSho
.app().activity
= null;
46 protected void onPause() {
54 protected void onResume() {
62 public boolean onCreateOptionsMenu(Menu menu
) {
63 MenuInflater inflater
= getMenuInflater();
64 inflater
.inflate(R
.menu
.menu
, menu
);
69 public boolean onOptionsItemSelected(MenuItem item
) {
70 // Handle item selection
71 switch (item
.getItemId()) {
75 return view
.onOptionsItemSelected(item
);
77 startActivity(new Intent("de.cwde.freeshisen.HISCORE", null));
80 startActivity(new Intent("de.cwde.freeshisen.SETTINGS", null));
86 return super.onOptionsItemSelected(item
);
90 private void onAboutActivate() {
91 // Try to load the a package matching the name of our own package
94 pInfo
= getPackageManager().getPackageInfo(getPackageName(), PackageManager
.GET_META_DATA
);
95 String aboutTitle
= String
.format("About %s", getString(R
.string
.app_name
));
96 String versionString
= String
.format("Version: %s", pInfo
.versionName
);
97 String aboutText
= getString(R
.string
.aboutText
);
99 // Set up the TextView
100 final TextView message
= new TextView(this);
101 // We'll use a spannablestring to be able to make links clickable
102 final SpannableString s
= new SpannableString(aboutText
);
105 message
.setPadding(5, 5, 5, 5);
106 // Set up the final string
107 message
.setText(versionString
+ "\n" + s
);
108 // Now linkify the text
109 Linkify
.addLinks(message
, Linkify
.ALL
);
111 new AlertDialog
.Builder(this)
112 .setTitle(aboutTitle
)
114 .setIcon(R
.drawable
.icon
)
115 .setPositiveButton(getString(android
.R
.string
.ok
), null)
116 .setView(message
).create()
118 } catch (NameNotFoundException e
) {