Skip to content

Commit

Permalink
reduced amount of buttons to three
Browse files Browse the repository at this point in the history
  • Loading branch information
Roel Blaauwgeers committed Apr 14, 2012
1 parent b334655 commit ba2aeae
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 127 deletions.
15 changes: 6 additions & 9 deletions gen/nl/ttys0/simplec25k/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ public static final class id {
public static final int chronometer1=0x7f060004;
public static final int icon=0x7f060000;
public static final int label=0x7f060001;
public static final int name=0x7f060005;
public static final int pauseButton=0x7f060008;
public static final int name=0x7f060003;
public static final int pauseButton=0x7f060009;
public static final int relativeLayout1=0x7f060002;
public static final int resumeButton=0x7f060003;
public static final int skipButton=0x7f06000c;
public static final int startButton=0x7f060009;
public static final int stopButton=0x7f06000a;
public static final int textView1=0x7f060007;
public static final int textView2=0x7f060006;
public static final int textView3=0x7f06000b;
public static final int skipButton=0x7f060008;
public static final int startButton=0x7f060007;
public static final int textView1=0x7f060006;
public static final int textView2=0x7f060005;
}
public static final class layout {
public static final int main=0x7f030000;
Expand Down
43 changes: 7 additions & 36 deletions res/layout/timer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<Button
android:id="@+id/resumeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/chronometer1"
android:text="Resume" />

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -51,51 +42,31 @@
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />

<Button
android:id="@+id/pauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/resumeButton"
android:layout_alignLeft="@+id/resumeButton"
android:layout_alignParentRight="true"
android:text="Pause" />

<Button
android:id="@+id/startButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/pauseButton"
android:layout_toLeftOf="@+id/chronometer1"
android:layout_toLeftOf="@+id/skipButton"
android:text="Start" />

<Button
android:id="@+id/stopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/startButton"
android:layout_below="@+id/startButton"
android:text="Stop"
android:visibility="visible" />

<TextView
android:id="@+id/textView3"
android:id="@+id/pauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/startButton"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="17dp"
android:text="TextView" />
android:layout_toRightOf="@+id/skipButton"
android:text="Pause" />

<Button
android:id="@+id/skipButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/chronometer1"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/chronometer1"
android:layout_below="@+id/startButton"
android:text="Skip" />

</RelativeLayout>
149 changes: 67 additions & 82 deletions src/nl/ttys0/simplec25k/TimerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public class TimerActivity extends Activity {
private AlertDialog.Builder startedAlertbox;
private AlertDialog.Builder completedAlertbox;
private AlertDialog.Builder stopAlertbox;

private Button startButton;
private Button pauseButton;
private Button skipButton;

private Boolean paused=false;
private Boolean started=false;

private AlertDialog.Builder skipAlertbox;

Expand All @@ -67,6 +74,7 @@ public class TimerActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.timer);


// setup descriptions, there is probably an easier way that I don't know
// of:)
Expand Down Expand Up @@ -140,25 +148,23 @@ public void onCreate(Bundle savedInstanceState) {
mainTitle.setText(selectedProgram.replace("w", "Week ").replace(
"d", ", Day "));

// Watch for button clicks.
button = (Button) findViewById(R.id.startButton);
button.setOnClickListener(mStartListener);

button = (Button) findViewById(R.id.stopButton);
button.setOnClickListener(mStopListener);
button.setClickable(false);


button = (Button) findViewById(R.id.pauseButton);
button.setOnClickListener(mPauseListener);
button.setClickable(false);
startButton=(Button) findViewById(R.id.startButton);
pauseButton=(Button) findViewById(R.id.pauseButton);
skipButton= (Button) findViewById(R.id.skipButton);

// Watch for button clicks.
//button = (Button) findViewById(R.id.startButton);
startButton.setOnClickListener(mStartListener);

button = (Button) findViewById(R.id.resumeButton);
button.setOnClickListener(mResumeListener);
button.setClickable(false);
//button = (Button) findViewById(R.id.pauseButton);
pauseButton.setOnClickListener(mPauseListener);
pauseButton.setClickable(false);

button = (Button) findViewById(R.id.skipButton);
button.setOnClickListener(mSkipListener);
button.setClickable(false);
//button = (Button) findViewById(R.id.skipButton);
skipButton.setOnClickListener(mSkipListener);
skipButton.setClickable(false);

// set text fields
description = (TextView) findViewById(R.id.textView1);
Expand All @@ -167,8 +173,6 @@ public void onCreate(Bundle savedInstanceState) {
current = (TextView) findViewById(R.id.textView2);
current.setText("Press Start to begin.");

infotxt = (TextView) findViewById(R.id.textView3);
infotxt.setText("");

countdown = (CountdownChronometer) findViewById(R.id.chronometer1);

Expand Down Expand Up @@ -203,79 +207,67 @@ protected void onPause() {
// Start button
View.OnClickListener mStartListener = new OnClickListener() {
public void onClick(View v) {

// disable startbutton
button = (Button) findViewById(R.id.startButton);
button.setClickable(false);

// enable stopbutton
button = (Button) findViewById(R.id.stopButton);
button.setClickable(true);


if(!started){

//change into stopbutton
started=true;
startButton.setText("Stop");

// enable skipbutton
button = (Button) findViewById(R.id.skipButton);
button.setClickable(true);
skipButton.setClickable(true);

// enable pausebutton
button = (Button) findViewById(R.id.pauseButton);
button.setClickable(true);
pauseButton.setClickable(true);

// Start our own service
// Start our service
Intent svcIntent = new Intent(TimerActivity.this,
nl.ttys0.simplec25k.ProgramService.class);
svcIntent.putExtra("INIT_DATA", selectedProgram);
startService(svcIntent);


}
else
stopAlertbox.show();
}
};

// pause button
View.OnClickListener mPauseListener = new OnClickListener() {
public void onClick(View v) {
// mChronometer.stop();

if(!paused){

//change pausebutton into a resume button
paused=true;
pauseButton.setText("resume");

// disable skipbutton
skipButton.setClickable(false);

//send pause broadcast
Intent myIntent = new Intent();
myIntent.setAction(MY_ACTION);
myIntent.putExtra("DATA_TO_PS", "PAUSE");
sendBroadcast(myIntent);

countdown.stop();

}
else{

//change into pausebutton
paused=false;
skipButton.setClickable(true);

Intent myIntent = new Intent();
myIntent.setAction(MY_ACTION);
myIntent.putExtra("DATA_TO_PS", "RESUME");
sendBroadcast(myIntent);

}

// enable resumebutton
button = (Button) findViewById(R.id.resumeButton);
button.setClickable(true);

// disable skipbutton
button = (Button) findViewById(R.id.skipButton);
button.setClickable(false);

// disable pausebutton
button = (Button) findViewById(R.id.pauseButton);
button.setClickable(false);

Intent myIntent = new Intent();
myIntent.setAction(MY_ACTION);
myIntent.putExtra("DATA_TO_PS", "PAUSE");
sendBroadcast(myIntent);

countdown.stop();

}
};

// resume button
View.OnClickListener mResumeListener = new OnClickListener() {
public void onClick(View v) {

// disable resumebutton
button = (Button) findViewById(R.id.resumeButton);
button.setClickable(false);

// enable pausebutton
button = (Button) findViewById(R.id.pauseButton);
button.setClickable(true);

// enable skipbutton
button = (Button) findViewById(R.id.skipButton);
button.setClickable(true);

Intent myIntent = new Intent();
myIntent.setAction(MY_ACTION);
myIntent.putExtra("DATA_TO_PS", "RESUME");
sendBroadcast(myIntent);
}
};

Expand All @@ -286,13 +278,6 @@ public void onClick(View v) {
}
};

// stop button
View.OnClickListener mStopListener = new OnClickListener() {
public void onClick(View v) {
stopAlertbox.show();
}
};

// back button (hard button)
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Expand Down

0 comments on commit ba2aeae

Please sign in to comment.