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
);
31 //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
32 // WindowManager.LayoutParams.FLAG_FULLSCREEN);
34 view
= ShisenSho
.app().getView();
35 ShisenSho
.app().activity
= this;
40 protected void onDestroy() {
41 ViewGroup vg
= (ViewGroup
)(view
.getParent());
43 ShisenSho
.app().activity
= null;
48 protected void onPause() {
56 protected void onResume() {
64 public boolean onCreateOptionsMenu(Menu menu
) {
65 MenuInflater inflater
= getMenuInflater();
66 inflater
.inflate(R
.menu
.menu
, menu
);
71 public boolean onOptionsItemSelected(MenuItem item
) {
72 // Handle item selection
73 switch (item
.getItemId()) {
77 return view
.onOptionsItemSelected(item
);
79 startActivity(new Intent("de.cwde.freeshisen.HISCORE", null));
82 startActivity(new Intent("de.cwde.freeshisen.SETTINGS", null));
88 return super.onOptionsItemSelected(item
);
92 private void onAboutActivate() {
93 // Try to load the a package matching the name of our own package
96 pInfo
= getPackageManager().getPackageInfo(getPackageName(), PackageManager
.GET_META_DATA
);
97 String aboutTitle
= String
.format("About %s", getString(R
.string
.app_name
));
98 String versionString
= String
.format("Version: %s", pInfo
.versionName
);
99 String aboutText
= getString(R
.string
.aboutText
);
101 // Set up the TextView
102 final TextView message
= new TextView(this);
103 // We'll use a spannablestring to be able to make links clickable
104 final SpannableString s
= new SpannableString(aboutText
);
107 message
.setPadding(5, 5, 5, 5);
108 // Set up the final string
109 message
.setText(versionString
+ "\n" + s
);
110 // Now linkify the text
111 Linkify
.addLinks(message
, Linkify
.ALL
);
113 new AlertDialog
.Builder(this)
114 .setTitle(aboutTitle
)
116 .setIcon(R
.drawable
.icon
)
117 .setPositiveButton(getString(android
.R
.string
.ok
), null)
118 .setView(message
).create()
120 } catch (NameNotFoundException e
) {