diff --git a/.idea/libraries/appcompat_v7_19_0_1.xml b/.idea/libraries/appcompat_v7_19_1_0.xml
similarity index 62%
rename from .idea/libraries/appcompat_v7_19_0_1.xml
rename to .idea/libraries/appcompat_v7_19_1_0.xml
index f8043cf..5408177 100644
--- a/.idea/libraries/appcompat_v7_19_0_1.xml
+++ b/.idea/libraries/appcompat_v7_19_1_0.xml
@@ -1,8 +1,8 @@
-
+
-
-
+
+
diff --git a/.idea/libraries/support_v4_19_0_1.xml b/.idea/libraries/support_v4_19_1_0.xml
similarity index 55%
rename from .idea/libraries/support_v4_19_0_1.xml
rename to .idea/libraries/support_v4_19_1_0.xml
index 617c323..3f6ff2d 100644
--- a/.idea/libraries/support_v4_19_0_1.xml
+++ b/.idea/libraries/support_v4_19_1_0.xml
@@ -1,11 +1,11 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/HypoAlarm/HypoAlarm-HypoAlarm.iml b/HypoAlarm/HypoAlarm-HypoAlarm.iml
index 5ae921d..978d53d 100644
--- a/HypoAlarm/HypoAlarm-HypoAlarm.iml
+++ b/HypoAlarm/HypoAlarm-HypoAlarm.iml
@@ -70,10 +70,10 @@
-
+
+
-
diff --git a/HypoAlarm/build.gradle b/HypoAlarm/build.gradle
index 67638cd..79e84e8 100644
--- a/HypoAlarm/build.gradle
+++ b/HypoAlarm/build.gradle
@@ -23,8 +23,8 @@ repositories {
}
}
dependencies {
- compile 'com.android.support:support-v4:19.0.1'
- compile 'com.android.support:appcompat-v7:19.0.1'
+ compile 'com.android.support:support-v4:19.1.0'
+ compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:+'
//compile 'com.google.android.gms:play-services:4.2.42'
diff --git a/HypoAlarm/src/main/AndroidManifest.xml b/HypoAlarm/src/main/AndroidManifest.xml
index d003b26..f28cadd 100644
--- a/HypoAlarm/src/main/AndroidManifest.xml
+++ b/HypoAlarm/src/main/AndroidManifest.xml
@@ -2,6 +2,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java
index 4a9d4fb..56cafd9 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java
@@ -4,18 +4,13 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
-import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import net.frakbot.glowpadbackport.GlowPadView;
-import java.util.Random;
-
public class AlarmAlertActivity extends Activity {
- private static Intent notifyIntent;
- public static Boolean alertFinished, userCancelled;
public static Activity alertActivity;
@Override
@@ -36,14 +31,14 @@ public class AlarmAlertActivity extends Activity {
| WindowManager.LayoutParams.FLAG_FULLSCREEN
);
- if (Build.VERSION.SDK_INT >= 14) {
+ if (Build.VERSION.SDK_INT >= 11) {
window.getDecorView().
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
setContentView(R.layout.alarm_alert);
- notifyIntent = new Intent(getApplicationContext(), AlarmNotify.class);
+ Intent notifyIntent = new Intent(getApplicationContext(), AlarmNotify.class);
// Disable any current notifications (if we're snoozing)
stopService(notifyIntent);
}
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java
index ff92f1b..be72e25 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java
@@ -16,7 +16,7 @@ import android.util.Log;
import java.io.IOException;
public class AlarmKlaxon {
- public static Boolean klaxonActive = false;
+ private static Boolean klaxonActive = false;
private static final long[] vPattern = {500, 500};
// Volume modification for alarms while a phone call is active, from com.android.deskclock.alarms
private static final float IN_CALL_VOLUME = 0.125f;
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
index d74f34e..aed664d 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
@@ -16,8 +16,8 @@ import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class AlarmNotify extends Service {
- public static final int notifyID = 1;
- public volatile boolean notificationRunning = false;
+ private static final int notifyID = 1;
+ private volatile boolean notificationRunning = false;
@Override
public IBinder onBind(Intent intent) {
@@ -52,8 +52,10 @@ public class AlarmNotify extends Service {
.setSmallIcon(R.drawable.alarm_notification)
.setLargeIcon(bm)
.setOnlyAlertOnce(true)
- .setAutoCancel(false)
- .setPriority(Notification.PRIORITY_HIGH);
+ .setAutoCancel(false);
+ if (Build.VERSION.SDK_INT >= 16) {
+ notification.setPriority(Notification.PRIORITY_HIGH);
+ }
// Set up dismiss action
Intent cancellerIntent = new Intent(getBaseContext(), CancelGraceReceiver.class);
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java
index 44b3fe0..b4186e4 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java
@@ -5,11 +5,10 @@ import android.content.Context;
import android.content.Intent;
public class AlarmReceiver extends BroadcastReceiver {
- private static Intent alarmIntent;
@Override
public void onReceive(final Context context, final Intent intent) {
- alarmIntent = new Intent(context, AlarmService.class);
+ Intent alarmIntent = new Intent(context, AlarmService.class);
context.startService(alarmIntent);
}
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java
index 7205a07..c0f2715 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java
@@ -20,7 +20,7 @@ public class AlarmService extends Service {
private static final int ALERT_LIFE = 1000*60*1; // 2 minutes
private static AlarmManager alarmManager;
private static Intent alarmServiceIntent, alertActivityIntent, notifyIntent;
- public static Boolean alarmStarted = false;
+ private static Boolean alarmStarted = false;
public static volatile String alarmStatus; // Register ALARM_DISMISSED and its brethren here
public static final String ALARM_RUNNING = "ALARM_RUNNING";
public static final String ALARM_DISMISSED = "ALARM_DISMISSED";
@@ -110,7 +110,7 @@ public class AlarmService extends Service {
return super.onStartCommand(intent, flags, startId);
}
- public static void startAlert(final Context context) {
+ private static void startAlert(final Context context) {
Log.d("AlarmService", "Starting alert; status is " + alarmStatus);
// Turn off any notifications first
context.stopService(notifyIntent);
@@ -139,7 +139,7 @@ public class AlarmService extends Service {
}, ALERT_LIFE);
}
- public static void stopAlert(final Context context) {
+ private static void stopAlert(final Context context) {
Log.d("AlarmService", "Stopping alert; status is " + alarmStatus);
if (alarmStarted) {
AlarmKlaxon.stop(context);
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java
index 67fbd14..37cbfb8 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java
@@ -13,13 +13,9 @@ import android.util.Log;
import java.util.Calendar;
public class BootReceiver extends BroadcastReceiver {
- private static SharedPreferences sharedPref;
- private static AlarmManager alarmManager;
- private static PendingIntent alarmPendingIntent;
-
@Override
public void onReceive(Context context, Intent intent) {
- sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
// Reset for tomorrow; as of API 19, setRepeating() is inexact, so we use setExact()
String alarmTimeStr = sharedPref.getString(context.getString(R.string.AlarmTimePref), null);
@@ -27,8 +23,8 @@ public class BootReceiver extends BroadcastReceiver {
if (alarmTimeStr != null && alarmActive) {
// If it's later than alarmTimeStr, Calendar automatically advances the day.
Calendar cal = MainActivity.TimeStringToCalendar(alarmTimeStr);
- alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- alarmPendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
+ AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+ PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
if (Build.VERSION.SDK_INT >= 19) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent);
} else {
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelGraceReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelGraceReceiver.java
index ad7c182..ba8dd13 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelGraceReceiver.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelGraceReceiver.java
@@ -1,7 +1,6 @@
package za.org.treehouse.hypoalarm;
import android.app.AlarmManager;
-import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
index 78a62a5..3f04a8e 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
@@ -32,14 +32,11 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
-import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
-import android.widget.Switch;
import android.widget.TimePicker;
import android.widget.Toast;
-import android.widget.ToggleButton;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -61,17 +58,17 @@ import java.util.regex.Pattern;
// Alerts via Whatsapp and other protocols?
public class MainActivity extends ActionBarActivity {
- public static int ALARM_REQUEST = 1;
- public static int GRACE_REQUEST = 2;
- public static int PRENOTIFY_REQUEST = 3;
- public static int CANCEL_GRACE_REQUEST = 4;
- public static int CANCEL_ALARM_REQUEST = 5;
- public static int PHONE_NUMBER_REQUEST = 6;
- public static int RINGTONE_REQUEST = 7;
+ public static final int ALARM_REQUEST = 1;
+ public static final int GRACE_REQUEST = 2;
+ public static final int PRENOTIFY_REQUEST = 3;
+ public static final int CANCEL_GRACE_REQUEST = 4;
+ public static final int CANCEL_ALARM_REQUEST = 5;
+ public static final int PHONE_NUMBER_REQUEST = 6;
+ public static final int RINGTONE_REQUEST = 7;
private static Button alarmTimeButton;
private static EditText messageButton;
- public static Boolean HYPOALARM_DEBUG = false;
+ public static final Boolean HYPOALARM_DEBUG = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -240,14 +237,9 @@ public class MainActivity extends ActionBarActivity {
messageButton = (EditText) getActivity().findViewById(R.id.message);
messageButton.setText(messageStr);
messageButton.setOnClickListener(new View.OnClickListener() {
- SharedPreferences sharedPref;
-
@Override
public void onClick(View view) {
final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
-
- String messageStr = sharedPref.getString(getString(R.string.MessagePref), getString(R.string.defaultMessage));
-
final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
@@ -520,7 +512,7 @@ public class MainActivity extends ActionBarActivity {
} else {
print = new SimpleDateFormat("E hh:mm a");
}
- return (String) print.format(cal.getTime());
+ return print.format(cal.getTime());
}
public static int GracePeriodToMinutes(String gracePeriod) {
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java
index 8a8152e..afce195 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java
@@ -13,14 +13,12 @@ import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
-import android.text.format.DateFormat;
import android.util.Log;
import java.util.Calendar;
-import java.util.Locale;
public class PreAlarmNotify extends Service {
- public static final int preNotifyID = 2;
+ private static final int preNotifyID = 2;
@Override
public IBinder onBind(Intent intent) {
@@ -54,8 +52,11 @@ public class PreAlarmNotify extends Service {
.setSmallIcon(R.drawable.alarm_notification)
.setLargeIcon(bm)
.setOnlyAlertOnce(true)
- .setAutoCancel(false)
- .setPriority(Notification.PRIORITY_HIGH);
+ .setAutoCancel(false);
+
+ if (Build.VERSION.SDK_INT >= 16) {
+ notification.setPriority(Notification.PRIORITY_DEFAULT);
+ }
// Set up dismiss action
Intent cancelAlarmIntent = new Intent(getBaseContext(), CancelAlarmReceiver.class);
@@ -68,8 +69,8 @@ public class PreAlarmNotify extends Service {
// Allow the user to cancel by selecting the ContentText or ContentTitle
notification.setContentIntent(cancelAlarmPendingIntent);
- nm.cancel(this.preNotifyID);
- nm.notify(this.preNotifyID, notification.build());
+ nm.cancel(preNotifyID);
+ nm.notify(preNotifyID, notification.build());
return super.onStartCommand(intent, flags, startId);
}
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmReceiver.java
index 107c751..9befcb6 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmReceiver.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmReceiver.java
@@ -11,7 +11,6 @@ public class PreAlarmReceiver extends BroadcastReceiver {
public void onReceive(final Context context, Intent intent) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), true);
- String alarmTimeStr = sharedPref.getString(context.getString(R.string.AlarmTimePref), null);
if (alarmActive) {
// Create notification
diff --git a/HypoAlarm/src/main/res/drawable/hypoalarm.png b/HypoAlarm/src/main/res/drawable/hypoalarm.png
deleted file mode 100644
index e091112..0000000
Binary files a/HypoAlarm/src/main/res/drawable/hypoalarm.png and /dev/null differ
diff --git a/HypoAlarm/src/main/res/layout-v14/activeswitch.xml b/HypoAlarm/src/main/res/layout-v14/activeswitch.xml
index 2fc1e8c..7d9ef7e 100644
--- a/HypoAlarm/src/main/res/layout-v14/activeswitch.xml
+++ b/HypoAlarm/src/main/res/layout-v14/activeswitch.xml
@@ -1,11 +1,9 @@
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/layout/activeswitch.xml b/HypoAlarm/src/main/res/layout/activeswitch.xml
index 2324226..472863a 100644
--- a/HypoAlarm/src/main/res/layout/activeswitch.xml
+++ b/HypoAlarm/src/main/res/layout/activeswitch.xml
@@ -1,11 +1,9 @@
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/layout/fragment_main.xml b/HypoAlarm/src/main/res/layout/fragment_main.xml
index 1e44495..dbed999 100644
--- a/HypoAlarm/src/main/res/layout/fragment_main.xml
+++ b/HypoAlarm/src/main/res/layout/fragment_main.xml
@@ -7,7 +7,7 @@
+ layout="@layout/activeswitch"
+ android:layout_column="1" />
Upcoming alarm
- Text message sending
-
- 10 minutes
- 15 minutes