diff --git a/app/src/main/java/nz/ac/otago/infosci/timekeeper/SettingsActivity.java b/app/src/main/java/nz/ac/otago/infosci/timekeeper/SettingsActivity.java new file mode 100644 index 0000000..b664be8 --- /dev/null +++ b/app/src/main/java/nz/ac/otago/infosci/timekeeper/SettingsActivity.java @@ -0,0 +1,50 @@ +package nz.ac.otago.infosci.timekeeper; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.TimePicker; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatDelegate; + +public class SettingsActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings); + + Button startBtn = findViewById(R.id.startButton); + final Button resetBtn = findViewById(R.id.resetButton); + + final TimePicker picker = findViewById(R.id.endPicker); + picker.setIs24HourView(false); + + resetBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // need to reset the clock, but so far the only way I have found to do this is recreate the entire activity + recreate(); + } + }); + + startBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int endHour = picker.getHour(); + int endMinutes = picker.getMinute(); + + Intent it = new Intent(SettingsActivity.this, TimerActivity.class); + it.putExtra("endHour", endHour); + it.putExtra("endMinutes", endMinutes); + SettingsActivity.this.startActivity(it); + } + }); + + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + + } + +}