package com.example.denis_niko.projektjanez;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Vibrator;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Created by Niko
 */

public class TimerActivity extends Activity implements View.OnClickListener{

    private CountDownTimer countDownTimer;
    private boolean timerHasStarted = false;
    private Button startB;
    public TextView text;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_INTEGER);
        int num = Integer.parseInt(message);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_timer);
        startB = (Button) this.findViewById(R.id.button);
        startB.setOnClickListener(this);
        text = (TextView) this.findViewById(R.id.timer);
        countDownTimer = new MyCountDownTimer(num * 60000, 1000);           // StartTime in ms, Interval in sec
        text.setText(text.getText() + String.valueOf(num + " minutes"));    // Confirms set time
    }

    @Override
    public void onClick(View v) {
        if(!timerHasStarted) {
            countDownTimer.start();
            timerHasStarted = true;
            startB.setText("Stop");
        } else {
            countDownTimer.cancel();
            timerHasStarted = false;
            startB.setText("Restart");
        }
    }

    public class MyCountDownTimer extends CountDownTimer {
        public MyCountDownTimer(long startTime, long interval) {
            super(startTime, interval);
        }

        Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

        @Override
        public void onFinish() {
            text.setText("Time is up!");
            vib.vibrate(1000);   // vibrates for 1 sec on completion
        }

        @Override
        public void onTick(long millisUntilFinished) {
            long minutes = millisUntilFinished / 60000, seconds = millisUntilFinished / 1000;
            text.setText(minutes + ":" + (seconds - (minutes*60)));
        }
    }

}

@@ -1125,38 +1125,122 @@
 ime 
-in ms, Interval in sec
+& Interval in ms%0A%0A        if(num == 1) %7B text.setText(text.getText() + String.valueOf(num + %22 minute%22)); %7D
 %0A       
  tex
@@ -1231,24 +1231,31 @@
 ); %7D%0A       
+ else %7B
  text.setTex
@@ -1312,31 +1312,173 @@
 )); 
-   // Confirms set time
+%7D%0A    %7D%0A%0A    @Override%0A    public void onBackPressed() %7B%0A        countDownTimer.cancel();    // Cancel timer%0A        finish();                   // and stop activity
 %0A   

fix #2 and spelling error