diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f788ff..39c7de0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,8 @@ package="org.secuso.privacyfriendlybreakreminder"> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlybreakreminder/activities/ExerciseActivity.java b/app/src/main/java/org/secuso/privacyfriendlybreakreminder/activities/ExerciseActivity.java index b5696b6..9245622 100644 --- a/app/src/main/java/org/secuso/privacyfriendlybreakreminder/activities/ExerciseActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlybreakreminder/activities/ExerciseActivity.java @@ -139,23 +139,23 @@ public class ExerciseActivity extends AppCompatActivity implements android.suppo private void initResources() { dbHelper = new SQLiteHelper(this); - playButton = findViewById(R.id.button_playPause); - progressBar = findViewById(R.id.progressBar); - timerText = findViewById(R.id.timerText); - executionText = findViewById(R.id.execution); - descriptionText = findViewById(R.id.description); - exerciseImage = findViewById(R.id.exercise_image); - sectionText = findViewById(R.id.section); - repeatButton = findViewById(R.id.button_repeat); - exerciseContent = findViewById(R.id.exercise_layout); - continuousButton = findViewById(R.id.button_continuous); - prevButton = findViewById(R.id.button_prev); - nextButton = findViewById(R.id.button_next); - exerciseInfoButton = findViewById(R.id.exercise_info_button); + playButton = (ImageButton) findViewById(R.id.button_playPause); + progressBar = (ProgressBar) findViewById(R.id.progressBar); + timerText = (TextView) findViewById(R.id.timerText); + executionText = (TextView) findViewById(R.id.execution); + descriptionText = (TextView) findViewById(R.id.description); + exerciseImage = (ImageView) findViewById(R.id.exercise_image); + sectionText = (TextView) findViewById(R.id.section); + repeatButton = (ImageButton) findViewById(R.id.button_repeat); + exerciseContent = (ConstraintLayout) findViewById(R.id.exercise_layout); + continuousButton = (ImageButton) findViewById(R.id.button_continuous); + prevButton = (ImageButton) findViewById(R.id.button_prev); + nextButton = (ImageButton) findViewById(R.id.button_next); + exerciseInfoButton = (ImageButton) findViewById(R.id.exercise_info_button); - progressBarBig = findViewById(R.id.progressBarBig); - breakTimerTextBig = findViewById(R.id.breakTimerTextBig); - bigProgressBarLayout = findViewById(R.id.bigProgressBarLayout); + progressBarBig = (ProgressBar) findViewById(R.id.progressBarBig); + breakTimerTextBig = (TextView) findViewById(R.id.breakTimerTextBig); + bigProgressBarLayout = (ConstraintLayout) findViewById(R.id.bigProgressBarLayout); setRepeatButtonStatus(repeatStatus); setContinuousButtonStatus(continuousStatus); diff --git a/app/src/main/java/org/secuso/privacyfriendlybreakreminder/service/TimerService.java b/app/src/main/java/org/secuso/privacyfriendlybreakreminder/service/TimerService.java index 7db5ecd..67aa302 100644 --- a/app/src/main/java/org/secuso/privacyfriendlybreakreminder/service/TimerService.java +++ b/app/src/main/java/org/secuso/privacyfriendlybreakreminder/service/TimerService.java @@ -12,7 +12,10 @@ import android.content.SharedPreferences; import android.os.Binder; import android.os.Bundle; import android.os.CountDownTimer; +import android.os.Handler; +import android.os.HandlerThread; import android.os.IBinder; +import android.os.Looper; import android.preference.PreferenceManager; import android.provider.Settings; import android.support.v4.app.NotificationCompat; @@ -115,7 +118,7 @@ public class TimerService extends Service { .setWhen(0) .setOngoing(false) .setAutoCancel(true) - .setSmallIcon(R.mipmap.ic_launcher) + .setSmallIcon(R.mipmap.ic_notification) .setDefaults(Notification.DEFAULT_LIGHTS) .setVibrate(new long[] { 0, 1000, 1000, 1000, 1000, 1000, 1000 }) .setSound(Settings.System.DEFAULT_NOTIFICATION_URI) @@ -153,7 +156,7 @@ public class TimerService extends Service { unregisterReceiver(notificationPreferenceChangedReceiver); } - public synchronized void startTimer(long duration) { + public synchronized void startTimer(final long duration) { if(!isRunning) { initialDuration = duration; @@ -170,10 +173,11 @@ public class TimerService extends Service { sendBroadcast(broadcast); } } + } public synchronized void pauseTimer() { - if(isRunning) { + if (isRunning) { mTimer.cancel(); isRunning = false; @@ -192,7 +196,7 @@ public class TimerService extends Service { } public synchronized void resetTimer() { - if(isRunning) { + if (isRunning) { mTimer.cancel(); mTimer = createTimer(initialDuration); mTimer.start(); @@ -203,7 +207,7 @@ public class TimerService extends Service { } public synchronized void stopAndResetTimer() { - if(isRunning) mTimer.cancel(); + if (isRunning) mTimer.cancel(); isRunning = false; remainingDuration = initialDuration; @@ -263,7 +267,7 @@ public class TimerService extends Service { if (intent != null) { - String action = intent.getAction(); + final String action = intent.getAction(); if (ACTION_START_TIMER.equals(action)) handleRestartTimer(); else if (ACTION_PAUSE_TIMER.equals(action)) pauseTimer(); @@ -314,7 +318,7 @@ public class TimerService extends Service { builder.setPriority(NotificationCompat.PRIORITY_DEFAULT); builder.setWhen(0); builder.setProgress((int) initialDuration, (int) (initialDuration - remainingDuration), false); - builder.setSmallIcon(R.mipmap.ic_launcher); + builder.setSmallIcon(R.mipmap.ic_notification); builder.setOngoing(isRunning() || isPaused()); Intent intent = new Intent(this, TimerActivity.class);