package skylight1.sevenwonders;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;

public class MenuActivity extends Activity {

	private static final String TAG = MenuActivity.class.getName();
	private boolean SOUNDENABLED; 
	
	@Override
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Log.i(TAG, "started");
		setContentView(R.layout.menu);
		final CheckBox soundCB = (CheckBox)findViewById(R.id.soundCheckBox);
		soundCB.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View aV) {
				SOUNDENABLED = soundCB.isChecked();
			}
		});
		
		final View view = findViewById(R.id.EnterEgypt);
		view.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View aV) {
				final Intent gameActivity = new Intent(MenuActivity.this, PlayActivity.class);
				gameActivity.putExtra("ENABLESOUND", SOUNDENABLED);
				startActivity(gameActivity);
			}
		});
	}
}
@@ -90,16 +90,59 @@
 ntent;%0D%0A
+import android.content.SharedPreferences;%0D%0A
 import a
@@ -160,16 +160,16 @@
 undle;%0D%0A
-
 import a
@@ -339,16 +339,84 @@
 ty %7B%0D%0A%0D%0A
+    public static final String PREFS_NAME = %22SevenWondersPrefs%22;%0D%0A%0D%0A
 %09private
@@ -620,16 +620,191 @@
 te);%0D%0A%0D%0A
+        // Restore preferences%0D%0A       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);%0D%0A       SOUNDENABLED = settings.getBoolean(%22SOUNDENABLED%22, false);%0D%0A%0D%0A
 %09%09Log.i(
@@ -927,16 +927,59 @@
 kBox);%0D%0A
+        soundCB.setChecked(SOUNDENABLED);%0D%0A
 %09%09soundC
@@ -1069,24 +1069,24 @@
 View aV) %7B%0D%0A
-
 %09%09%09%09SOUNDENA
@@ -1113,16 +1113,304 @@
 cked();%0D
+%0A%0D%0A                //save preference%0D%0A                SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);%0D%0A                SharedPreferences.Editor editor = settings.edit();%0D%0A                editor.putBoolean(%22SOUNDENABLED%22, SOUNDENABLED);%0D%0A                editor.commit();%0D
 %0A%09%09%09%7D%0D%0A%09

save sound preference