Continuous Mode implementation. Still some more functions missing.
|
|
@ -1,15 +1,15 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion '26.0.2'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.secuso.privacyfriendlybreakreminder"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
versionCode 2
|
||||
versionName "2.0"
|
||||
targetSdkVersion 26
|
||||
versionCode 3
|
||||
versionName "2.1"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
buildTypes {
|
||||
|
|
@ -32,13 +32,12 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:25.4.0'
|
||||
//compile 'com.android.support:preference-v7:25.4.0'
|
||||
compile 'com.android.support:design:25.4.0'
|
||||
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||
compile 'com.android.support:design:26.1.0'
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
compile 'com.android.support:support-v4:25.4.0'
|
||||
compile 'com.android.support:support-v4:26.1.0'
|
||||
compile 'com.android.support:support-annotations:27.0.0'
|
||||
compile 'com.android.support:cardview-v7:25.4.0'
|
||||
compile 'com.android.support:cardview-v7:26.1.0'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
compile 'com.nex3z:flow-layout:1.0.0'
|
||||
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
|
||||
|
|
|
|||
|
|
@ -111,6 +111,20 @@
|
|||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name=".service.NotificationDeletedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="org.secuso.privacyfriendlybreakreminder.NotificationDeleted" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".service.PreferenceChangeReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="org.secuso.privacyfriendlybreakreminder.ACTION_PREF_CHANGE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -18,6 +18,7 @@ import android.support.v7.app.ActionBar;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
|
@ -38,7 +39,6 @@ import org.secuso.privacyfriendlybreakreminder.exercises.ExerciseLocale;
|
|||
import java.util.Locale;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.support.design.R.id.center_vertical;
|
||||
|
||||
/**
|
||||
* This activity handles showing the exercises and the exercise timer.
|
||||
|
|
@ -106,7 +106,7 @@ public class ExerciseActivity extends AppCompatActivity implements android.suppo
|
|||
exerciseSetId = pref.getLong(PrefManager.DEFAULT_EXERCISE_SET, 0L);
|
||||
pauseDuration = pref.getLong(PrefManager.PAUSE_TIME, 5 * 60 * 1000);
|
||||
repeatStatus = pref.getBoolean(PrefManager.REPEAT_STATUS, false);
|
||||
continuousStatus = pref.getBoolean(PrefManager.CONTINUOUS_STATUS, false);
|
||||
continuousStatus = pref.getBoolean(PrefManager.REPEAT_EXERCISES, false);
|
||||
try {
|
||||
exerciseTime = Long.parseLong(pref.getString(PrefManager.EXERCISE_DURATION, "30")) * 1000;
|
||||
} catch(NumberFormatException e) {
|
||||
|
|
@ -175,7 +175,7 @@ public class ExerciseActivity extends AppCompatActivity implements android.suppo
|
|||
breakTimerText = (TextView) MenuItemCompat.getActionView(timerItem);
|
||||
breakTimerText.setTextColor(Color.WHITE);
|
||||
breakTimerText.setTextSize(20);
|
||||
breakTimerText.setGravity(center_vertical);
|
||||
breakTimerText.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
breakTimerText.setPadding(16, 0, 16, 0);
|
||||
//breakTimerText.set(10, 0, 10, 0);
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ public class ExerciseActivity extends AppCompatActivity implements android.suppo
|
|||
private void handleContinuousClicked() {
|
||||
continuousStatus = !continuousStatus;
|
||||
|
||||
pref.edit().putBoolean(PrefManager.CONTINUOUS_STATUS, continuousStatus).apply();
|
||||
pref.edit().putBoolean(PrefManager.REPEAT_EXERCISES, continuousStatus).apply();
|
||||
|
||||
setContinuousButtonStatus(continuousStatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.MultiSelectListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
|
@ -18,7 +19,11 @@ import android.view.MenuItem;
|
|||
import org.secuso.privacyfriendlybreakreminder.R;
|
||||
import org.secuso.privacyfriendlybreakreminder.activities.helper.AppCompatPreferenceActivity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Christopher Beckmann
|
||||
|
|
@ -26,8 +31,6 @@ import java.util.List;
|
|||
*/
|
||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
|
||||
// Helper
|
||||
private Handler mHandler;
|
||||
protected SharedPreferences mSharedPreferences;
|
||||
|
||||
@Override
|
||||
|
|
@ -35,7 +38,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
mHandler = new Handler();
|
||||
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
|
|
@ -94,6 +96,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
String stringValue = value.toString();
|
||||
|
||||
if (preference instanceof ListPreference) {
|
||||
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
|
|
@ -104,6 +107,42 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
index >= 0
|
||||
? listPreference.getEntries()[index]
|
||||
: null);
|
||||
} if(preference instanceof MultiSelectListPreference) {
|
||||
MultiSelectListPreference mslPreference = (MultiSelectListPreference) preference;
|
||||
|
||||
if(stringValue.length() >= 2) {
|
||||
stringValue = stringValue.substring(1, stringValue.length() - 1);
|
||||
}
|
||||
|
||||
String[] setValues = stringValue.split(",");
|
||||
|
||||
if(setValues.length == 7) {
|
||||
mslPreference.setSummary(preference.getContext().getString(R.string.pref_schedule_exercise_days_allselectedsummary));
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < mslPreference.getEntries().length; i++) {
|
||||
String preferenceEntryString = mslPreference.getEntryValues()[i].toString();
|
||||
|
||||
for(String chosenValue : setValues) {
|
||||
if (chosenValue.trim().equals(preferenceEntryString)) {
|
||||
sb.append(mslPreference.getEntries()[i]);
|
||||
sb.append(", ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(sb.length() > 0) {
|
||||
sb.setLength(sb.length() - 2);
|
||||
}
|
||||
|
||||
if(sb.length() == 0) {
|
||||
sb.append(preference.getContext().getString(R.string.pref_schedule_exercise_days_defaultsummary));
|
||||
}
|
||||
|
||||
mslPreference.setSummary(sb.toString());
|
||||
|
||||
} else {
|
||||
// For all other preferences, set the summary to the value's
|
||||
|
|
@ -129,10 +168,15 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
// Trigger the listener immediately with the preference's
|
||||
// current value.
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
if(preference instanceof MultiSelectListPreference) {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getStringSet(preference.getKey(), new HashSet<String>()));
|
||||
} else {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
}
|
||||
|
||||
protected int getNavigationDrawerID() {
|
||||
|
|
@ -161,6 +205,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_scheduler);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
bindPreferenceSummaryToValue(findPreference("pref_schedule_exercise_days"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -278,7 +278,8 @@ public class TimerActivity extends BaseActivity implements android.support.v4.ap
|
|||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
pref.edit().putInt(PrefManager.PREF_PICKER_SECONDS, secondsPicker.getValue())
|
||||
.putInt(PrefManager.PREF_PICKER_MINUTES, minutesPicker.getValue())
|
||||
.putInt(PrefManager.PREF_PICKER_HOURS, hoursPicker.getValue()).apply();
|
||||
.putInt(PrefManager.PREF_PICKER_HOURS, hoursPicker.getValue())
|
||||
.putLong(PrefManager.WORK_TIME, getCurrentSetDuration()).apply();
|
||||
}
|
||||
|
||||
private long getCurrentSetDuration() {
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
|
|||
final String expandedListText = (String) getChild(listPosition, expandedListPosition);
|
||||
if (convertView == null) {
|
||||
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = layoutInflater.inflate(R.layout.help_list_item, parent);
|
||||
convertView = layoutInflater.inflate(R.layout.help_list_item, parent, false);
|
||||
}
|
||||
TextView expandedListTextView = (TextView) convertView.findViewById(R.id.expandedListItem);
|
||||
TextView expandedListTextView = convertView.findViewById(R.id.expandedListItem);
|
||||
expandedListTextView.setText(expandedListText);
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Class structure taken from tutorial at http://www.androidhive.info/2016/05/android-build-intro-slider-app/
|
||||
*/
|
||||
|
|
@ -19,9 +22,12 @@ public class PrefManager {
|
|||
public static final String DEFAULT_EXERCISE_SET = "DEFAULT_EXERCISE_SET";
|
||||
public static final String PAUSE_TIME = "PAUSE TIME";
|
||||
public static final String REPEAT_STATUS = "REPEAT_STATUS";
|
||||
public static final String CONTINUOUS_STATUS = "CONTINUOUS_STATUS";
|
||||
public static final String REPEAT_EXERCISES = "REPEAT_EXERCISES";
|
||||
public static final String EXERCISE_DURATION = "pref_exercise_time";
|
||||
public static final String KEEP_SCREEN_ON_DURING_EXERCISE = "pref_keep_screen_on_during_exercise";
|
||||
public static final String PREF_SCHEDULE_EXERCISE_DAYS = "pref_schedule_exercise_days";
|
||||
public static final String PREF_EXERCISE_CONTINUOUS = "pref_exercise_continuous";
|
||||
public static final String WORK_TIME = "WORK_TIME";
|
||||
|
||||
|
||||
private SharedPreferences pref;
|
||||
|
|
@ -42,16 +48,19 @@ public class PrefManager {
|
|||
if(isFirstTimeLaunch)
|
||||
pref.edit()
|
||||
.putLong(DEFAULT_EXERCISE_SET, 0L)
|
||||
.putLong(PAUSE_TIME, 5 * 60 * 1000)
|
||||
.putLong(PAUSE_TIME, 5 * 60 * 1000) // 5 minutes
|
||||
.putBoolean(REPEAT_STATUS, false)
|
||||
.putBoolean(CONTINUOUS_STATUS, false)
|
||||
.putBoolean(REPEAT_EXERCISES, false)
|
||||
.putInt(PREF_BREAK_PICKER_SECONDS, 0)
|
||||
.putInt(PREF_BREAK_PICKER_MINUTES, 5)
|
||||
.putInt(PREF_PICKER_SECONDS, 0)
|
||||
.putInt(PREF_PICKER_MINUTES, 0)
|
||||
.putInt(PREF_PICKER_HOURS, 1)
|
||||
.putLong(WORK_TIME, 1000L * 60L * 60L) // 1 hour
|
||||
.putString(EXERCISE_DURATION, "30")
|
||||
.putBoolean(KEEP_SCREEN_ON_DURING_EXERCISE, true)
|
||||
.putBoolean(PREF_EXERCISE_CONTINUOUS, false)
|
||||
.putStringSet(PREF_SCHEDULE_EXERCISE_DAYS, new HashSet<String>(Arrays.asList("Mo","Di","Mi","Do","Fr","Sa","So")))
|
||||
.apply();
|
||||
|
||||
return isFirstTimeLaunch;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
package org.secuso.privacyfriendlybreakreminder.service;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.secuso.privacyfriendlybreakreminder.activities.TimerActivity;
|
||||
|
||||
import static org.secuso.privacyfriendlybreakreminder.activities.tutorial.PrefManager.PREF_EXERCISE_CONTINUOUS;
|
||||
|
||||
/**
|
||||
* @author Christopher Beckmann
|
||||
* @version 2.0
|
||||
|
|
@ -18,8 +27,12 @@ public class NotificationDeletedReceiver extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
// TODO: Notification was swiped away.
|
||||
Log.d(TAG, "Notification swiped away");
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
if(pref.getBoolean(PREF_EXERCISE_CONTINUOUS, false)) {
|
||||
Intent serviceIntent = new Intent(context, TimerService.class);
|
||||
serviceIntent.setAction(TimerService.ACTION_START_TIMER);
|
||||
context.startService(serviceIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
package org.secuso.privacyfriendlybreakreminder.service;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.secuso.privacyfriendlybreakreminder.activities.tutorial.PrefManager.PREF_EXERCISE_CONTINUOUS;
|
||||
|
||||
/**
|
||||
* @author Christopher Beckmann
|
||||
* @version 1.0
|
||||
* @since 02.11.2017
|
||||
* created 02.11.2017
|
||||
*/
|
||||
|
||||
public class PreferenceChangeReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = PreferenceManager.class.getSimpleName();
|
||||
|
||||
public static final String ACTION_PREF_CHANGE = "org.secuso.privacyfriendlybreakreminder.ACTION_PREF_CHANGE";
|
||||
public static final String EXTRA_DISABLE_CONTINUOUS = "EXTRA_DISABLE_CONTINUOUS";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if(intent == null) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
|
||||
if(bundle == null) return;
|
||||
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
// Map<String, ?> prefMap = pref.getAll();
|
||||
|
||||
for(String key : intent.getExtras().keySet()) {
|
||||
|
||||
if(EXTRA_DISABLE_CONTINUOUS.equals(key)) {
|
||||
pref.edit().putBoolean(PREF_EXERCISE_CONTINUOUS, false).apply();
|
||||
}
|
||||
|
||||
// if(prefMap.containsKey(key)) {
|
||||
//
|
||||
// Object bundleValue = bundle.get(key);
|
||||
//
|
||||
// if(prefMap.get(key).getClass().isInstance(bundleValue)) {
|
||||
// if(bundleValue instanceof String) {
|
||||
// pref.edit().putString(key, (String)bundleValue).apply();
|
||||
// } else if(bundleValue instanceof Boolean) {
|
||||
// pref.edit().putBoolean(key, (Boolean)bundleValue).apply();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -8,16 +8,19 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Binder;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import org.secuso.privacyfriendlybreakreminder.R;
|
||||
import org.secuso.privacyfriendlybreakreminder.activities.ExerciseActivity;
|
||||
|
|
@ -30,6 +33,10 @@ import java.util.Timer;
|
|||
import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
|
||||
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static org.secuso.privacyfriendlybreakreminder.activities.tutorial.PrefManager.PREF_EXERCISE_CONTINUOUS;
|
||||
import static org.secuso.privacyfriendlybreakreminder.activities.tutorial.PrefManager.WORK_TIME;
|
||||
import static org.secuso.privacyfriendlybreakreminder.service.PreferenceChangeReceiver.ACTION_PREF_CHANGE;
|
||||
import static org.secuso.privacyfriendlybreakreminder.service.PreferenceChangeReceiver.EXTRA_DISABLE_CONTINUOUS;
|
||||
|
||||
/**
|
||||
* The main timer service. It handles the work timer and sends updates to the notification and the {@link TimerActivity}.
|
||||
|
|
@ -44,6 +51,14 @@ public class TimerService extends Service {
|
|||
public static final String NOTIFICATION_BROADCAST = TAG + ".NOTIFICATION_BROADCAST";
|
||||
public static final String TIMER_BROADCAST = TAG + ".TIMER_BROADCAST";
|
||||
|
||||
public static final String ACTION_START_TIMER = TAG + "ACTION_START_TIMER";
|
||||
public static final String ACTION_PAUSE_TIMER = TAG + "ACTION_PAUSE_TIMER";
|
||||
public static final String ACTION_RESUME_TIMER = TAG + "ACTION_RESUME_TIMER";
|
||||
public static final String ACTION_STOP_TIMER = TAG + "ACTION_STOP_TIMER";
|
||||
public static final String ACTION_SNOOZE_TIMER = TAG + "ACTION_SNOOZE_TIMER";
|
||||
|
||||
public static final String NOTIFICATION_DELETED_ACTION = "org.secuso.privacyfriendlybreakreminder.NotificationDeleted";
|
||||
|
||||
private static final int UPDATE_INTERVAL = 100;
|
||||
private static final int NOTIFICATION_ID = 31337;
|
||||
|
||||
|
|
@ -77,10 +92,9 @@ public class TimerService extends Service {
|
|||
// limit the notification updates
|
||||
int remainingSeconds = intent.getIntExtra("countdown_seconds", 0);
|
||||
|
||||
if(remainingSeconds != lastTime) {
|
||||
if(remainingSeconds != lastTime || isPaused()) {
|
||||
lastTime = remainingSeconds;
|
||||
updateNotification();
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -90,10 +104,12 @@ public class TimerService extends Service {
|
|||
// send a notification with sound and vibration
|
||||
stopForeground(false);
|
||||
|
||||
PendingIntent startExercises = PendingIntent.getActivity(this, 0, new Intent(this, ExerciseActivity.class), FLAG_CANCEL_CURRENT);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
||||
builder.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(R.string.take_a_break_now))
|
||||
.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, ExerciseActivity.class), FLAG_CANCEL_CURRENT))
|
||||
.setContentIntent(startExercises)
|
||||
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
|
||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||
.setWhen(0)
|
||||
|
|
@ -104,7 +120,18 @@ public class TimerService extends Service {
|
|||
.setVibrate(new long[] { 0, 1000, 1000, 1000, 1000, 1000, 1000 })
|
||||
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
|
||||
.setOnlyAlertOnce(false)
|
||||
.setDeleteIntent(PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(this, NotificationDeletedReceiver.class), 0));
|
||||
.setDeleteIntent(PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFICATION_DELETED_ACTION), 0));
|
||||
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(pref.getBoolean(PREF_EXERCISE_CONTINUOUS, false)) {
|
||||
Intent prefIntent = new Intent(ACTION_PREF_CHANGE);
|
||||
prefIntent.putExtra(EXTRA_DISABLE_CONTINUOUS, false);
|
||||
builder.addAction(0, getString(R.string.dismiss_and_dont_repeat), PendingIntent.getBroadcast(getApplicationContext(), 0, prefIntent, 0));
|
||||
}
|
||||
|
||||
|
||||
builder.addAction(R.drawable.ic_play_arrow_black, getString(R.string.start), startExercises);
|
||||
|
||||
notificationManager.notify(NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
|
|
@ -230,11 +257,38 @@ public class TimerService extends Service {
|
|||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
|
||||
if (intent != null) {
|
||||
|
||||
String action = intent.getAction();
|
||||
|
||||
if (ACTION_START_TIMER.equals(action)) handleRestartTimer();
|
||||
else if (ACTION_PAUSE_TIMER.equals(action)) pauseTimer();
|
||||
else if (ACTION_RESUME_TIMER.equals(action)) resumeTimer();
|
||||
else if (ACTION_STOP_TIMER.equals(action)) stopAndResetTimer();
|
||||
else if (ACTION_SNOOZE_TIMER.equals(action)) handleSnoozeTimer();
|
||||
}
|
||||
|
||||
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void handleSnoozeTimer() {
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
long snoozeTime = (long)((float)pref.getLong(WORK_TIME, 1000 * 60 * 60) / 60f * 5f);
|
||||
|
||||
startTimer(snoozeTime);
|
||||
}
|
||||
|
||||
private void handleRestartTimer() {
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if(pref.getBoolean(PREF_EXERCISE_CONTINUOUS, false)) {
|
||||
long duration = pref.getLong(WORK_TIME, 1000 * 60 * 60);
|
||||
startTimer(duration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Notification buildNotification() {
|
||||
|
|
@ -250,17 +304,29 @@ public class TimerService extends Service {
|
|||
String time = String.format(Locale.US, "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
|
||||
builder.setContentText(time);
|
||||
|
||||
builder.setColor(ContextCompat.getColor(this, R.color.colorAccent));
|
||||
builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||
builder.setWhen(0);
|
||||
builder.setProgress((int) initialDuration, (int) (initialDuration - remainingDuration), false);
|
||||
builder.setSmallIcon(R.mipmap.ic_launcher);
|
||||
builder.setOngoing(isRunning() || isPaused());
|
||||
|
||||
Intent intent = new Intent(this, TimerActivity.class);
|
||||
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
builder.setContentIntent(PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT));
|
||||
builder.setColor(ContextCompat.getColor(this, R.color.colorAccent));
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
builder.setWhen(0);
|
||||
builder.setSmallIcon(R.mipmap.ic_launcher);
|
||||
builder.setOngoing(isRunning() || isPaused());
|
||||
|
||||
Intent stopIntent = new Intent(this, TimerService.class);
|
||||
stopIntent.setAction(ACTION_STOP_TIMER);
|
||||
builder.addAction(R.drawable.ic_replay_black_48dp, getString(R.string.stop), PendingIntent.getService(this, 0, stopIntent, FLAG_UPDATE_CURRENT));
|
||||
|
||||
Intent pauseIntent = new Intent(this, TimerService.class);
|
||||
if(!isPaused()) {
|
||||
pauseIntent.setAction(ACTION_PAUSE_TIMER);
|
||||
builder.addAction(R.drawable.ic_pause_black_48dp, getString(R.string.pause), PendingIntent.getService(this, 0, pauseIntent, FLAG_UPDATE_CURRENT));
|
||||
} else {
|
||||
pauseIntent.setAction(ACTION_RESUME_TIMER);
|
||||
builder.addAction(R.drawable.ic_play_arrow_black, getString(R.string.resume), PendingIntent.getService(this, 0, pauseIntent, FLAG_UPDATE_CURRENT));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
|
@ -268,7 +334,6 @@ public class TimerService extends Service {
|
|||
private void updateNotification() {
|
||||
if(isRunning() || isPaused()) {
|
||||
startForeground(NOTIFICATION_ID, buildNotification());
|
||||
notificationManager.notify(NOTIFICATION_ID, buildNotification());
|
||||
} else {
|
||||
stopForeground(true);
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 987 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 778 B |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
|
@ -1,9 +1,35 @@
|
|||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:timePickerStyle">@style/TimePickerDialogStyle</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="TimePickerDialogStyle" parent="@android:style/Widget.Material.Light.TimePicker">
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:timePickerMode">clock</item>
|
||||
<item name="android:headerBackground">@color/white</item>
|
||||
<item name="android:headerTimeTextAppearance">@style/TextAppearance.TimePickerDialogStyle.TimeLabel</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.TimePickerDialogStyle.TimeLabel" parent="@android:style/TextAppearance.Material">
|
||||
<item name="android:textSize">60sp</item> <!-- from -->
|
||||
<item name="android:textColor">@color/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="timePickerStyle" parent="@android:style/Widget.Material.Light.TimePicker">
|
||||
<item name="android:headerBackground">@color/white</item>
|
||||
<item name="android:textColorPrimary">#ff0000</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
21
app/src/main/res/values/arrays.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="pref_schedule_exercise_days">
|
||||
<item>Monday</item>
|
||||
<item>Tuesday</item>
|
||||
<item>Wednesday</item>
|
||||
<item>Thursday</item>
|
||||
<item>Friday</item>
|
||||
<item>Saturday</item>
|
||||
<item>Sunday</item>
|
||||
</string-array>
|
||||
<string-array name="pref_schedule_exercise_days_entries">
|
||||
<item>Mo</item>
|
||||
<item>Di</item>
|
||||
<item>Mi</item>
|
||||
<item>Do</item>
|
||||
<item>Fr</item>
|
||||
<item>Sa</item>
|
||||
<item>So</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
@ -156,10 +156,10 @@
|
|||
<string name="numberpicker_formatter" translatable="false">%02d</string>
|
||||
<string name="pref_exercise_time">Exercise time (in Seconds)</string>
|
||||
<string name="pref_keep_screen_on_during_exercise">Keep screen on during exercise</string>
|
||||
<string name="pref_category_exercise">exercise settings</string>
|
||||
<string name="pref_category_exercise">Exercise Settings</string>
|
||||
<string name="pref_category_schedule">schedule an exercise</string>
|
||||
<string name="pref_schedule_exercise_switch">enable exercise schedule</string>
|
||||
<string name="pref_schedule_exercise_time">Schedule Time</string>
|
||||
<string name="pref_schedule_exercise_switch">Enable exercise schedule</string>
|
||||
<string name="pref_schedule_exercise_time">Schedule time</string>
|
||||
<string name="help_whatis">What is Privacy Friendly Break Reminder?</string>
|
||||
<string name="help_whatis_answer">Privacy Friendly Break Reminder is an app, that reminds you to take breaks during your work sessions. It allows you to select exercises, that are then shown during your break time.</string>
|
||||
<string name="help_permission">Which permissions does the app require?</string>
|
||||
|
|
@ -231,8 +231,17 @@
|
|||
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||
|
||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
||||
<string name="pref_exercise_continuous">Continuous Exercises</string>
|
||||
<string name="pref_exercise_continuous">Continuous exercises</string>
|
||||
<string name="pref_exercise_continuous_summary">Start the next timer automatically</string>
|
||||
<string name="pref_schedule_exercise_days">Choose days</string>
|
||||
<string name="pref_schedule_exercise_daystrigger">Only trigger on certain days</string>
|
||||
<string name="pref_schedule_exercise_days_defaultsummary">No days selected.</string>
|
||||
<string name="pref_schedule_exercise_days_allselectedsummary">every day</string>
|
||||
<string name="pause">Pause</string>
|
||||
<string name="resume">Resume</string>
|
||||
<string name="stop">Stop</string>
|
||||
<string name="start">Start</string>
|
||||
<string name="dismiss_and_dont_repeat">Dismiss and don\'t start again</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,24 @@
|
|||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="android:alertDialogTheme">@style/AppTheme.AlertDialog</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimary</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.DatePickerDialog" parent="AppTheme.Dialog">
|
||||
<item name="android:textColorPrimary">@color/black</item>
|
||||
<item name="android:textColorSecondary">@color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AlertDialog" parent="AppTheme.Dialog">
|
||||
<item name="android:textColorPrimary">@color/black</item>
|
||||
<item name="android:textColorSecondary">@color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
|
|
|
|||
|
|
@ -7,14 +7,34 @@
|
|||
android:defaultValue="false"
|
||||
android:key="pref_schedule_exercise"/>
|
||||
|
||||
<EditTextPreference
|
||||
<!-- <EditTextPreference
|
||||
android:defaultValue="30"
|
||||
android:inputType="number"
|
||||
android:numeric="integer"
|
||||
android:maxLength="2"
|
||||
android:dependency="pref_schedule_exercise"
|
||||
android:key="pref_schedule_exercise_time"
|
||||
android:title="@string/pref_schedule_exercise_time"/> -->
|
||||
|
||||
<org.secuso.privacyfriendlybreakreminder.preferences.TimePreference
|
||||
android:dependency="pref_schedule_exercise"
|
||||
android:defaultValue="32400000"
|
||||
android:key="pref_schedule_exercise_time"
|
||||
android:title="@string/pref_schedule_exercise_time"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="pref_schedule_exercise"
|
||||
android:title="@string/pref_schedule_exercise_daystrigger"
|
||||
android:key="pref_schedule_exercise_daystrigger"/>
|
||||
|
||||
<MultiSelectListPreference
|
||||
android:dependency="pref_schedule_exercise_daystrigger"
|
||||
android:entries="@array/pref_schedule_exercise_days"
|
||||
android:entryValues="@array/pref_schedule_exercise_days_entries"
|
||||
android:title="@string/pref_schedule_exercise_days"
|
||||
android:key="pref_schedule_exercise_days"/>
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||