package com.harmoneye.tonecircle;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
import android.widget.ToggleButton;

public class MainActivity extends Activity {

//	private TextView titleView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

//		titleView = (TextView) findViewById(R.id.title);

//		CircleLayout circle = (CircleLayout) findViewById(R.id.circleLayout);
//
//		for (int i = 0; i < 12; i++) {
//			ToggleButton toggle = new ToggleButton(getApplicationContext());
//			CharSequence title = TONE_NAMES[i];
//			toggle.setText(title);
//			toggle.setTextOn(title);
//			toggle.setTextOff(title);
//			//toggle.setBackgroundResource(R.drawable.magenta_shape);
//			toggle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 40);
//			toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
//				@Override
//				public void onCheckedChanged(CompoundButton buttonView,
//					boolean isChecked) {
//					updateChordName();
//				}
//			});
//			toggles.add(toggle);
//			circle.addView(toggle);
//		}
	}

//	protected void updateChordName() {
//		StringBuilder title = new StringBuilder();
//		for () {
//			if (toggle.isChecked()) {
//				title.append(toggle.getText()).append(" ");
//			}
//		}
//		titleView.setText(title.toString());
//	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

@@ -109,16 +109,58 @@
 tivity;%0A
+import android.content.SharedPreferences;%0A
 import a
@@ -348,16 +348,117 @@
 tleView;
+%0A%09private static final String ACTIVE_TONES = %22active_tones%22;%0A%0A%09private ToneCircleView toneCircleView;
 %0A%0A%09@Over
@@ -649,16 +649,83 @@
 .title);
+%0A%09%09toneCircleView = (ToneCircleView) findViewById(R.id.toneCircle);
 %0A%0A//%09%09Ci
@@ -1437,246 +1437,812 @@
 %09%7D%0A%09
-%7D%0A%0A//%09protected void updateChordName() %7B%0A//%09%09StringBuilder title = new StringBuilder();%0A//%09%09for () %7B%0A//%09%09%09if (toggle.isChecked()) %7B%0A//%09%09%09%09title.append(toggle.getText()).append(%22 %22);%0A//%09%09%09%7D%0A//%09%09%7D%0A//%09%09titleView.setText(title.toString());%0A//
+@Override%0A%09protected void onResume() %7B%0A%09%09SharedPreferences prefs = getPreferences(MODE_PRIVATE);%0A%09%09int activeTones = prefs.getInt(ACTIVE_TONES, 0);%0A%09%09if (activeTones %3E 0) %7B%0A%09%09%09toneCircleView.setActiveTones(PitchClassSet.fromIndex(activeTones));%0A%09%09%7D%0A%09%09super.onResume();%0A%09%7D%0A%0A//%09protected void updateChordName() %7B%0A//%09%09StringBuilder title = new StringBuilder();%0A//%09%09for () %7B%0A//%09%09%09if (toggle.isChecked()) %7B%0A//%09%09%09%09title.append(toggle.getText()).append(%22 %22);%0A//%09%09%09%7D%0A//%09%09%7D%0A//%09%09titleView.setText(title.toString());%0A//%09%7D%0A%09@Override%0A%09protected void onPause() %7B%0A%09%09int activeTones = toneCircleView.getActiveTones().getIndex();%0A%09%09SharedPreferences prefs = getPreferences(MODE_PRIVATE);%0A%09%09SharedPreferences.Editor editor = prefs.edit();%0A%09%09editor.putInt(ACTIVE_TONES, activeTones);%0A%09%09editor.commit();%0A%09%09super.onPause();%0A
 %09%7D%0A%0A

Allow persisting the active tones to shared preferences.