1 package de
.cwde
.shisensho
;
3 import android
.app
.Application
;
4 import android
.content
.SharedPreferences
;
5 import android
.preference
.PreferenceManager
;
6 import android
.util
.Log
;
8 public class ShisenSho
extends Application
{
9 private static ShisenSho instance
= null;
10 private ShisenShoView view
= null;
11 public ShisenShoActivity activity
= null;
14 public int[] boardSize
=new int[2];
15 public int difficulty
=1; // 1=Hard, 2=Easy
16 public int size
=3; // 1=Small, 2=Medium, 3=Big
17 public boolean gravity
=true;
18 public boolean timeCounter
=true;
20 public static void log(String msg
) {
21 Log
.w("ShisenSho", msg
);
24 public void newPlay() {
26 board
.buildRandomBoard(boardSize
[0],boardSize
[1],difficulty
,gravity
);
29 public void setSize(int s
) {
50 public void sleep(int deciSeconds
) {
52 Thread
.sleep(deciSeconds
*100);
53 } catch (InterruptedException e
) { }
61 public static synchronized ShisenSho
app() {
65 public ShisenShoView
getView() {
66 if (view
== null) view
= new ShisenShoView(this);
70 /** Called when the activity is first created. */
72 public void onCreate() {
74 PreferenceManager
.setDefaultValues(this, R
.xml
.preferences
, false);
77 public void setOptions() {
78 SharedPreferences sharedPref
= PreferenceManager
.getDefaultSharedPreferences(this);
80 int size
= sharedPref
.getInt("size", 1);
81 int difficulty
= sharedPref
.getInt("difficulty", 1);
82 boolean gravity
= sharedPref
.getBoolean("gravity", true);
83 boolean timeCounter
= sharedPref
.getBoolean("timeCounter", true);
85 boolean needsReset
= false;
87 if (size
!= this.size
) {
92 if (difficulty
!= this.difficulty
) {
93 this.difficulty
= difficulty
;
97 if (gravity
!= this.gravity
) {
98 this.gravity
= gravity
;
102 if (timeCounter
!= this.timeCounter
) {
103 this.timeCounter
= timeCounter
;
104 view
.onTimeCounterActivate();