Android Open Source - donatello-y-raphael Settings Activity






From Project

Back to project page donatello-y-raphael.

License

The source code is released under:

MIT License

If you think the Android project donatello-y-raphael listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.ATracePath;
/*from   w w w  .  ja v  a 2s.c om*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

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

/**
 * Created by ranrath on 21/09/14.
 */
public class SettingsActivity extends Activity {

    private Global global = Global.getInstance();
    private final int CONFIRM_RESET = 42;

    private ProgressAdapter pa;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings);
        pa = new ProgressAdapter(this);
        Button vibrate = (Button) findViewById(R.id.vibrate);
        setVibrateText(vibrate);
    }


    public void buttonClick(View view) {
        if (view.getId() == R.id.vibrate) {
            Button vibrate = (Button) findViewById(R.id.vibrate);
            global.vibrate = !global.vibrate;
            setVibrateText(vibrate);
        } else if (view.getId() == R.id.reset) {
            dispDialog(CONFIRM_RESET);
        }
    }

    private void setVibrateText(Button button) {
        if (global.vibrate) {
            button.setText("Vibration ON");
        } else {
            button.setText("Vibration OFF");
        }
    }

    private void dispDialog( int id ) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        switch ( id ) {
            case CONFIRM_RESET:
                builder.setMessage("Are you sure?");
                builder.setCancelable(true);
                builder.setPositiveButton( "Yes", new resetClass() );
                builder.setNegativeButton( "No", null );
        }
        AlertDialog dialog = builder.create();
        dialog.show();
    }

    private final class resetClass implements DialogInterface.OnClickListener {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            pa.resetProgress();
        }
    }
}




Java Source Code List

com.example.ATracePath.Board.java
com.example.ATracePath.Cellpath.java
com.example.ATracePath.Challenge.java
com.example.ATracePath.Coordinate.java
com.example.ATracePath.DbHelper.java
com.example.ATracePath.Global.java
com.example.ATracePath.LevelsActivity.java
com.example.ATracePath.MainActivity.java
com.example.ATracePath.MapsActivity.java
com.example.ATracePath.Pack.java
com.example.ATracePath.PlayActivity.java
com.example.ATracePath.ProgressAdapter.java
com.example.ATracePath.Puzzle.java
com.example.ATracePath.SettingsActivity.java