Some changes
+ Added new Layout (New Profile, Exercise Type) + Added Notifications(Vibrations + Permission, Screen stays on, show how much time is left,, trigger the alarm)
This commit is contained in:
parent
34dca39341
commit
286c19ede5
10 changed files with 681 additions and 54 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder">
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
|
@ -28,6 +28,8 @@
|
|||
</activity>
|
||||
<activity android:name=".BreakDeciderActivity" />
|
||||
<activity android:name=".BreakActivity"></activity>
|
||||
<activity android:name=".ProfileActivity"></activity>
|
||||
<activity android:name=".ExerciseTypeActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -1,10 +1,20 @@
|
|||
package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
|
@ -24,29 +34,28 @@ public class BreakActivity extends AppCompatActivity implements View.OnClickList
|
|||
setContentView(R.layout.activity_break);
|
||||
|
||||
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
int mins = sharedPrefs.getInt("break_value", 5);
|
||||
String bufferZeroMinute = "";
|
||||
|
||||
if(mins < 10)
|
||||
if (mins < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text =(TextView)findViewById(R.id.textViewBreak);
|
||||
ct_text.setText(bufferZeroMinute+mins+":00");
|
||||
ct_text = (TextView) findViewById(R.id.textViewBreak);
|
||||
ct_text.setText(bufferZeroMinute + mins + ":00");
|
||||
|
||||
Button playStopButton = (Button)findViewById(R.id.button_playStopBreak);
|
||||
Button playStopButton = (Button) findViewById(R.id.button_playStopBreak);
|
||||
playStopButton.setOnClickListener(this);
|
||||
Button resetButton = (Button)findViewById(R.id.button_cancel);
|
||||
Button resetButton = (Button) findViewById(R.id.button_cancel);
|
||||
resetButton.setOnClickListener(this);
|
||||
ct_text.setOnClickListener(this);
|
||||
|
||||
|
||||
LinearLayout ll = (LinearLayout)findViewById(R.id.layout_break);
|
||||
LinearLayout ll = (LinearLayout) findViewById(R.id.layout_break);
|
||||
// TODO Do it dynamically
|
||||
for (int i = 0; i < 20; i++){
|
||||
for (int i = 0; i < 20; i++) {
|
||||
ImageView image = new ImageView(this);
|
||||
image.setLayoutParams(new android.view.ViewGroup.LayoutParams(80,60));
|
||||
image.setLayoutParams(new android.view.ViewGroup.LayoutParams(80, 60));
|
||||
image.setImageResource(R.drawable.statistic_logo);
|
||||
ll.addView(image);
|
||||
}
|
||||
|
|
@ -55,38 +64,38 @@ public class BreakActivity extends AppCompatActivity implements View.OnClickList
|
|||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
int mins = sharedPrefs.getInt("break_value", 10);
|
||||
String bufferZeroMinute = "";
|
||||
String bufferZeroSecond = "";
|
||||
int time = mins * 60 * 1000;
|
||||
int oldTime = time;
|
||||
|
||||
if(stopTime == "" && !isRunning) {
|
||||
if (stopTime == "" && !isRunning) {
|
||||
if (time / 1000 / 60 < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + time / 1000 / 60 + ":00");
|
||||
} else if(!isRunning){
|
||||
} else if (!isRunning) {
|
||||
ct_text.setText(stopTime);
|
||||
String stringTime = (String)ct_text.getText();
|
||||
String stringTime = (String) ct_text.getText();
|
||||
String[] timef = stringTime.split(":");
|
||||
int minute = Integer.parseInt(timef[0]);
|
||||
int second = Integer.parseInt(timef[1]);
|
||||
System.out.println("Minute: "+ minute + " Second: "+second);
|
||||
time = (1000 * (minute*60)) + (1000 * second);
|
||||
System.out.println("Minute: " + minute + " Second: " + second);
|
||||
time = (1000 * (minute * 60)) + (1000 * second);
|
||||
|
||||
if(minute < 10)
|
||||
if (minute < 10)
|
||||
bufferZeroMinute = "0";
|
||||
if(second < 10)
|
||||
if (second < 10)
|
||||
bufferZeroSecond = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + minute + ":" + bufferZeroSecond + second);
|
||||
|
||||
}
|
||||
|
||||
|
||||
System.out.println(time +" "+ ct_text.getText());
|
||||
|
||||
System.out.println(time + " " + ct_text.getText());
|
||||
|
||||
|
||||
switch (v.getId()) {
|
||||
|
|
@ -99,6 +108,7 @@ public class BreakActivity extends AppCompatActivity implements View.OnClickList
|
|||
isRunning = false;
|
||||
} else {
|
||||
ct = new CountDownTimer(time, 1000) {
|
||||
boolean timeLeft = false;
|
||||
|
||||
public void onTick(long millisUntilFinished) {
|
||||
String bufferZeroMinute = "";
|
||||
|
|
@ -111,12 +121,56 @@ public class BreakActivity extends AppCompatActivity implements View.OnClickList
|
|||
bufferZeroSecond = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + (millisUntilFinished / 1000) / 60 + ":" + bufferZeroSecond + millisUntilFinished / 1000 % 60);
|
||||
|
||||
//Show how much time is left
|
||||
timeLeft = sharedPrefs.getBoolean("notifications_new_message_timeLeft", false);
|
||||
if (timeLeft) {
|
||||
Notification notification = new NotificationCompat.Builder(getApplicationContext()).setCategory(Notification.CATEGORY_MESSAGE)
|
||||
.setSmallIcon(R.drawable.ic_notifications_black_24dp)
|
||||
.setContentTitle("Break Activity Reminder: ")
|
||||
.setContentText(((millisUntilFinished / 1000) / 60) + "Minutes and " + (millisUntilFinished / 1000 % 60) + " seconds")
|
||||
.setAutoCancel(true)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build();
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(999, notification);
|
||||
}
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
isRunning = false;
|
||||
ct_text.setText("00:00");
|
||||
//TODO trigger the alarm
|
||||
//Trigger the alarm
|
||||
String ringPref = sharedPrefs.getString("notifications_new_message_ringtone", "");
|
||||
System.out.println("Sound: " + ringPref);
|
||||
if (!ringPref.equals("")) {
|
||||
System.out.println("-----------------PLAY NOTIFICATION SOUND----------------");
|
||||
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), Uri.parse(ringPref));
|
||||
r.play();
|
||||
}
|
||||
|
||||
//FIXME Vibrate
|
||||
boolean vibrateChecked = sharedPrefs.getBoolean("notifications_new_message_vibrate", false);
|
||||
System.out.println("Vibrate is : " + vibrateChecked);
|
||||
if (vibrateChecked) {
|
||||
// Get instance of Vibrator from current Context
|
||||
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
||||
if (v == null) {
|
||||
System.out.println("No vibrator! :D");
|
||||
} else {
|
||||
// Vibrate for 3000 milliseconds
|
||||
System.out.println("Vibrate for 3000 ms");
|
||||
v.vibrate(3000);
|
||||
}
|
||||
}
|
||||
|
||||
//Cancel the notification
|
||||
if (timeLeft) {
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager.cancel(999);
|
||||
}
|
||||
finish();
|
||||
//startBreak();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,24 @@
|
|||
package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
|
|
@ -14,11 +28,15 @@ import android.support.v7.app.AppCompatActivity;
|
|||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class BreakReminder extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener, View.OnClickListener{
|
||||
implements NavigationView.OnNavigationItemSelectedListener, View.OnClickListener {
|
||||
|
||||
private boolean isRunning = false;
|
||||
private TextView ct_text;
|
||||
|
|
@ -44,21 +62,54 @@ public class BreakReminder extends AppCompatActivity
|
|||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
// If chosen, set screen to "stay on"
|
||||
boolean stayOn = sharedPrefs.getBoolean("notifications_stayOn", false);
|
||||
if(stayOn)
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
int mins = sharedPrefs.getInt("work_value", 50);
|
||||
String bufferZeroMinute = "";
|
||||
|
||||
if(mins < 10)
|
||||
if (mins < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text =(TextView)findViewById(R.id.textView);
|
||||
ct_text.setText(bufferZeroMinute+mins+":00");
|
||||
ct_text = (TextView) findViewById(R.id.textView);
|
||||
ct_text.setText(bufferZeroMinute + mins + ":00");
|
||||
|
||||
Button playStopButton = (Button)findViewById(R.id.button_playStop);
|
||||
Button playStopButton = (Button) findViewById(R.id.button_playStop);
|
||||
playStopButton.setOnClickListener(this);
|
||||
Button resetButton = (Button)findViewById(R.id.button_reset);
|
||||
Button resetButton = (Button) findViewById(R.id.button_reset);
|
||||
resetButton.setOnClickListener(this);
|
||||
ct_text.setOnClickListener(this);
|
||||
|
||||
Button profileButton = (Button) findViewById(R.id.button_profile);
|
||||
profileButton.setOnClickListener(this);
|
||||
|
||||
Spinner profileSpinner = (Spinner) findViewById(R.id.spinner);
|
||||
String[] some_array = getResources().getStringArray(R.array.profile_entries);
|
||||
ArrayAdapter<String> adapter = new
|
||||
ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, some_array);
|
||||
profileSpinner.setAdapter(adapter);
|
||||
|
||||
//Set the ClickListener for Spinner
|
||||
profileSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
System.out.println("Selected item: " + parent.getItemAtPosition(position) + " with id: " + id);
|
||||
//TODO Match the work and break value to the assigned profile
|
||||
switch ((String) parent.getItemAtPosition(position)){
|
||||
case "New Profile":
|
||||
createNewProfile();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -117,7 +168,7 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
int mins = sharedPrefs.getInt("work_value", 50);
|
||||
String bufferZeroMinute = "";
|
||||
String bufferZeroSecond = "";
|
||||
|
|
@ -125,62 +176,118 @@ public class BreakReminder extends AppCompatActivity
|
|||
time = 5000;
|
||||
int oldTime = time;
|
||||
|
||||
if(stopTime == "" && !isRunning) {
|
||||
if (stopTime == "" && !isRunning) {
|
||||
if (time / 1000 / 60 < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + time / 1000 / 60 + ":00");
|
||||
} else if(!isRunning){
|
||||
} else if (!isRunning) {
|
||||
ct_text.setText(stopTime);
|
||||
String stringTime = (String)ct_text.getText();
|
||||
String stringTime = (String) ct_text.getText();
|
||||
String[] timef = stringTime.split(":");
|
||||
int minute = Integer.parseInt(timef[0]);
|
||||
int second = Integer.parseInt(timef[1]);
|
||||
System.out.println("Minute: "+ minute + " Second: "+second);
|
||||
time = (1000 * (minute*60)) + (1000 * second);
|
||||
System.out.println("Minute: " + minute + " Second: " + second);
|
||||
time = (1000 * (minute * 60)) + (1000 * second);
|
||||
|
||||
if(minute < 10)
|
||||
if (minute < 10)
|
||||
bufferZeroMinute = "0";
|
||||
if(second < 10)
|
||||
if (second < 10)
|
||||
bufferZeroSecond = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + minute + ":" + bufferZeroSecond + second);
|
||||
}
|
||||
|
||||
|
||||
System.out.println(time +" "+ ct_text.getText());
|
||||
|
||||
System.out.println(time + " " + ct_text.getText());
|
||||
|
||||
|
||||
switch (v.getId()) {
|
||||
|
||||
case R.id.textView:
|
||||
case R.id.button_playStop:
|
||||
if (isRunning){
|
||||
//FIXME
|
||||
case R.id.button_profile:
|
||||
FragmentManager fm = getFragmentManager();
|
||||
ProfileDialog pd = new ProfileDialog();
|
||||
pd.show(fm, "Profile Dialog");
|
||||
|
||||
//createNewProfile();
|
||||
break;
|
||||
|
||||
case R.id.textView:
|
||||
case R.id.button_playStop:
|
||||
if (isRunning) {
|
||||
ct.cancel();
|
||||
stopTime = (String)ct_text.getText();
|
||||
stopTime = (String) ct_text.getText();
|
||||
isRunning = false;
|
||||
}else{
|
||||
} else {
|
||||
ct = new CountDownTimer(time, 1000) {
|
||||
boolean timeLeft = false;
|
||||
|
||||
public void onTick(long millisUntilFinished) {
|
||||
String bufferZeroMinute = "";
|
||||
String bufferZeroSecond = "";
|
||||
|
||||
if ((millisUntilFinished / 1000)/60 < 10)
|
||||
if ((millisUntilFinished / 1000) / 60 < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
if (millisUntilFinished / 1000 % 60 < 10)
|
||||
bufferZeroSecond = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute+(millisUntilFinished / 1000)/60 + ":" + bufferZeroSecond + millisUntilFinished / 1000 % 60);
|
||||
ct_text.setText(bufferZeroMinute + (millisUntilFinished / 1000) / 60 + ":" + bufferZeroSecond + millisUntilFinished / 1000 % 60);
|
||||
|
||||
//Show how much time is left
|
||||
//String timeLeft = bufferZeroMinute + (millisUntilFinished / 1000) / 60 + ":" + bufferZeroSecond + millisUntilFinished / 1000 % 60;
|
||||
//System.out.println("Time left: " + timeLeft);
|
||||
timeLeft = sharedPrefs.getBoolean("notifications_new_message_timeLeft", false);
|
||||
if (timeLeft) {
|
||||
Notification notification = new NotificationCompat.Builder(getApplicationContext()).setCategory(Notification.CATEGORY_MESSAGE)
|
||||
.setSmallIcon(R.drawable.ic_notifications_black_24dp)
|
||||
.setContentTitle("Break Reminder: ")
|
||||
.setContentText("Take a break in " + ((millisUntilFinished / 1000) / 60) + " minutes and " + ((millisUntilFinished / 1000) % 60) + " seconds")
|
||||
.setAutoCancel(true)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build();
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(1000, notification);
|
||||
}
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
isRunning = false;
|
||||
ct_text.setText("00:00");
|
||||
//TODO trigger the alarm
|
||||
//trigger the alarm
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
String ringPref = sharedPrefs.getString("notifications_new_message_ringtone", "");
|
||||
System.out.println("Sound: " + ringPref);
|
||||
if (!ringPref.equals("")) {
|
||||
System.out.println("-----------------PLAY NOTIFICATION SOUND----------------");
|
||||
// Get the current ringtone
|
||||
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), Uri.parse(ringPref));
|
||||
|
||||
// Play ringtone
|
||||
r.play();
|
||||
}
|
||||
//FIXME Vibrate
|
||||
boolean vibrateChecked = sharedPrefs.getBoolean("notifications_new_message_vibrate", false);
|
||||
System.out.println("Vibrate is : " + vibrateChecked);
|
||||
if (vibrateChecked) {
|
||||
// Get instance of Vibrator from current Context
|
||||
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
||||
if (v == null) {
|
||||
System.out.println("No vibrator! :D");
|
||||
} else {
|
||||
// Vibrate for 3000 milliseconds
|
||||
System.out.println("Vibrate for 3000 ms");
|
||||
v.vibrate(3000);
|
||||
}
|
||||
}
|
||||
|
||||
//Cancel the notification
|
||||
if (timeLeft) {
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager.cancel(1000);
|
||||
}
|
||||
startBreak();
|
||||
}
|
||||
}.start();
|
||||
|
|
@ -193,17 +300,22 @@ public class BreakReminder extends AppCompatActivity
|
|||
if (ct != null)
|
||||
ct.cancel();
|
||||
|
||||
if(oldTime/1000/60 < 10)
|
||||
if (oldTime / 1000 / 60 < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + oldTime/1000/60+":00");
|
||||
stopTime = oldTime/1000/60+":00";
|
||||
ct_text.setText(bufferZeroMinute + oldTime / 1000 / 60 + ":00");
|
||||
stopTime = oldTime / 1000 / 60 + ":00";
|
||||
isRunning = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void startBreak(){
|
||||
private void createNewProfile() {
|
||||
Intent intent = new Intent(this, ProfileActivity.class);
|
||||
this.startActivity(intent);
|
||||
}
|
||||
|
||||
public void startBreak() {
|
||||
Intent intent = new Intent(this, BreakDeciderActivity.class);
|
||||
this.startActivity(intent);
|
||||
|
||||
|
|
@ -212,9 +324,28 @@ public class BreakReminder extends AppCompatActivity
|
|||
String bufferZeroMinute = "";
|
||||
int time = mins * 60 * 1000;
|
||||
|
||||
if(time/1000/60 < 10)
|
||||
if (time / 1000 / 60 < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text.setText(bufferZeroMinute + time/1000/60+":00");
|
||||
ct_text.setText(bufferZeroMinute + time / 1000 / 60 + ":00");
|
||||
}
|
||||
|
||||
|
||||
public static class ProfileDialog extends DialogFragment {
|
||||
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
builder.setTitle("")
|
||||
.setItems(R.array.profile_entries, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// The 'which' argument contains the index position
|
||||
// of the selected item
|
||||
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class ExerciseTypeActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.exercise_type);
|
||||
|
||||
Button addButton = (Button) findViewById(R.id.button_et_add);
|
||||
addButton.setOnClickListener(this);
|
||||
|
||||
Button editButton = (Button) findViewById(R.id.button_et_edit);
|
||||
editButton.setOnClickListener(this);
|
||||
|
||||
Button saveButton = (Button) findViewById(R.id.button_et_save);
|
||||
saveButton.setOnClickListener(this);
|
||||
|
||||
Button cancelButton = (Button) findViewById(R.id.button_et_cancel);
|
||||
cancelButton.setOnClickListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO
|
||||
switch (v.getId()) {
|
||||
case R.id.button_et_add:
|
||||
System.out.println("Add new Exercise Type!");
|
||||
|
||||
break;
|
||||
|
||||
case R.id.button_et_edit:
|
||||
System.out.println("Edit new Exercise Type!");
|
||||
|
||||
break;
|
||||
|
||||
case R.id.button_et_save:
|
||||
System.out.println("Save new Exercise Type!");
|
||||
|
||||
break;
|
||||
|
||||
case R.id.button_et_cancel:
|
||||
System.out.println("Cancel!");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ProfileActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.new_profile);
|
||||
|
||||
Button cancelButton = (Button) findViewById(R.id.button_profile_cancel);
|
||||
cancelButton.setOnClickListener(this);
|
||||
|
||||
Button saveButton = (Button) findViewById(R.id.button_profile_save);
|
||||
saveButton.setOnClickListener(this);
|
||||
|
||||
Button selectButton = (Button) findViewById(R.id.button_profile_select);
|
||||
selectButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.button_profile_save:
|
||||
//Fixme Add new Profile to the Array of Profiles (doesn´t work with xml because it is not possible to add values dynamically to any part of resources)
|
||||
System.out.println("Save new profile!");
|
||||
// Spinner profileSpinner = (Spinner) findViewById(R.id.spinner);
|
||||
// String[] array = getResources().getStringArray(R.array.profile_entries);
|
||||
// List<String> stringList = new ArrayList<String>(Arrays.asList(array));
|
||||
// EditText profileName =
|
||||
// (EditText) findViewById(R.id.editProfileName);
|
||||
// stringList.add(4, profileName.getText().toString());
|
||||
// ArrayAdapter<String> adapter = new
|
||||
// ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, stringList);
|
||||
// profileSpinner.setAdapter(adapter);
|
||||
|
||||
finish();
|
||||
break;
|
||||
|
||||
case R.id.button_profile_cancel:
|
||||
System.out.println("New profile canceled!");
|
||||
finish();
|
||||
break;
|
||||
|
||||
case R.id.button_profile_select:
|
||||
System.out.println("Select Exercise Type!");
|
||||
createExerciseType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createExerciseType() {
|
||||
Intent intent = new Intent(this, ExerciseTypeActivity.class);
|
||||
this.startActivity(intent);
|
||||
System.out.println("Exercise Type Activity!");
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/spinner"
|
||||
android:spinnerMode="dropdown"
|
||||
android:spinnerMode="dialog"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
|
|
@ -60,6 +60,14 @@
|
|||
android:layout_above="@+id/button_playStop"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/button_profile"
|
||||
android:layout_above="@+id/textView"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="52dp"
|
||||
android:text="Select Profile" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
146
app/src/main/res/layout/exercise_type.xml
Normal file
146
app/src/main/res/layout/exercise_type.xml
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Exercise-name"
|
||||
android:id="@+id/textView8"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="43dp"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/editText2"
|
||||
android:layout_marginLeft="54dp"
|
||||
android:layout_marginStart="54dp"
|
||||
android:layout_alignBottom="@+id/textView8"
|
||||
android:layout_toRightOf="@+id/textView8"
|
||||
android:layout_toEndOf="@+id/textView8"
|
||||
android:inputType="text" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Exercise time"
|
||||
android:id="@+id/textView9"
|
||||
android:layout_marginTop="42dp"
|
||||
android:layout_below="@+id/textView8"
|
||||
android:layout_toRightOf="@+id/textView8"
|
||||
android:layout_toEndOf="@+id/textView8" />
|
||||
|
||||
<SeekBar
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/seekBar3"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_below="@+id/textView9"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Repetitions"
|
||||
android:id="@+id/textView10"
|
||||
android:layout_below="@+id/seekBar3"
|
||||
android:layout_alignLeft="@+id/textView9"
|
||||
android:layout_alignStart="@+id/textView9" />
|
||||
|
||||
<SeekBar
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/seekBar4"
|
||||
android:layout_below="@+id/textView10"
|
||||
android:layout_alignLeft="@+id/seekBar3"
|
||||
android:layout_alignStart="@+id/seekBar3" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Type"
|
||||
android:id="@+id/textView11"
|
||||
android:textSize="24sp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/editText2"
|
||||
android:layout_toStartOf="@+id/editText2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Sequential"
|
||||
android:id="@+id/textView12"
|
||||
android:textSize="24sp"
|
||||
android:layout_below="@+id/textView11"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="46dp" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/checkBox3"
|
||||
android:layout_alignBottom="@+id/textView12"
|
||||
android:layout_toRightOf="@+id/textView12"
|
||||
android:layout_toEndOf="@+id/textView12"
|
||||
android:checked="false" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Add"
|
||||
android:id="@+id/button_et_add"
|
||||
android:layout_marginTop="23dp"
|
||||
android:layout_below="@+id/textView12"
|
||||
android:layout_alignRight="@+id/checkBox3"
|
||||
android:layout_alignEnd="@+id/checkBox3" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Edit"
|
||||
android:id="@+id/button_et_edit"
|
||||
android:layout_alignBottom="@+id/button_et_add"
|
||||
android:layout_toRightOf="@+id/textView9"
|
||||
android:layout_toEndOf="@+id/textView9" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Save"
|
||||
android:id="@+id/button_et_save"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignRight="@+id/button_et_add"
|
||||
android:layout_alignEnd="@+id/button_et_add"
|
||||
android:layout_marginBottom="30dp" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
android:id="@+id/button_et_cancel"
|
||||
android:layout_alignBottom="@+id/button_et_save"
|
||||
android:layout_alignLeft="@+id/button_et_edit"
|
||||
android:layout_alignStart="@+id/button_et_edit" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
145
app/src/main/res/layout/new_profile.xml
Normal file
145
app/src/main/res/layout/new_profile.xml
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Profile Name"
|
||||
android:id="@+id/textView3"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="53dp"
|
||||
android:textSize="24dp" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/editProfileName"
|
||||
android:textSize="25dp"
|
||||
android:layout_alignBottom="@+id/textView3"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginRight="42dp"
|
||||
android:layout_marginEnd="42dp"
|
||||
android:inputType="text" />
|
||||
|
||||
<SeekBar
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/new_profile_interval"
|
||||
android:layout_below="@+id/textView4"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="interval"
|
||||
android:id="@+id/textView4"
|
||||
android:layout_below="@+id/editProfileName"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Exercise Type"
|
||||
android:id="@+id/textView6"
|
||||
android:layout_marginTop="48dp"
|
||||
android:textSize="24dp"
|
||||
android:layout_below="@+id/seekBar2"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Break"
|
||||
android:id="@+id/textView5"
|
||||
android:layout_marginTop="40dp"
|
||||
android:layout_below="@+id/new_profile_interval"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<SeekBar
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/seekBar2"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignLeft="@+id/new_profile_interval"
|
||||
android:layout_alignStart="@+id/new_profile_interval" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/checkBox"
|
||||
android:layout_alignBottom="@+id/textView6"
|
||||
android:checked="false"
|
||||
android:layout_alignTop="@+id/textView6"
|
||||
android:layout_alignLeft="@+id/textView5"
|
||||
android:layout_alignStart="@+id/textView5"
|
||||
android:layout_alignRight="@+id/textView5"
|
||||
android:layout_alignEnd="@+id/textView5" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Select"
|
||||
android:id="@+id/button_profile_select"
|
||||
android:layout_alignBottom="@+id/checkBox"
|
||||
android:layout_toRightOf="@+id/checkBox"
|
||||
android:layout_toEndOf="@+id/checkBox" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Continuosly"
|
||||
android:id="@+id/textView7"
|
||||
android:layout_marginTop="40dp"
|
||||
android:textSize="24sp"
|
||||
android:layout_below="@+id/textView6"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/checkBox2"
|
||||
android:checked="false"
|
||||
android:layout_alignTop="@+id/textView7"
|
||||
android:layout_alignLeft="@+id/checkBox"
|
||||
android:layout_alignStart="@+id/checkBox" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Save"
|
||||
android:id="@+id/button_profile_save"
|
||||
android:layout_below="@+id/checkBox2"
|
||||
android:layout_toLeftOf="@+id/checkBox2"
|
||||
android:layout_toStartOf="@+id/checkBox2" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
android:id="@+id/button_profile_cancel"
|
||||
android:layout_below="@+id/checkBox2"
|
||||
android:layout_toRightOf="@+id/textView4"
|
||||
android:layout_toEndOf="@+id/textView4" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
9
app/src/main/res/values/profiles.xml
Normal file
9
app/src/main/res/values/profiles.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="profile_entries">
|
||||
<item>Sport</item>
|
||||
<item>Exam</item>
|
||||
<item>Work</item>
|
||||
<item>New Profile</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue