package cu.volvox.preferences;

import cu.volvox.app.R;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.util.Log;

public class ClearAllData extends DialogPreference{

	SharedPreferences preferences;
	Editor editor;
	public ClearAllData(Context context, AttributeSet attrs) {
		super(context, attrs);
		preferences = context.getSharedPreferences(Keys.PREF_KEY, Context.MODE_PRIVATE);
		editor = preferences.edit();
		this.setPersistent(true);
		this.setDialogLayoutResource(R.layout.clearalldata_layout);
	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
		switch(which){
		case -1:	//OKボタン
			editor.putLong(Keys.CLEAR_TIME_KEY, System.currentTimeMillis());
			editor.commit();
			Log.i("", "OK");
			break;
		case -2:	//キャンセルボタン
			Log.i("", "Cancel");
			break;
		}
		super.onClick(dialog, which);
	}

}
