- Some lintian checks.
This commit is contained in:
parent
66e615bb20
commit
b98934c15d
@ -1,8 +1,8 @@
|
||||
<component name="libraryTable">
|
||||
<library name="appcompat-v7-19.0.1">
|
||||
<library name="appcompat-v7-19.1.0">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.android.support/appcompat-v7/19.0.1/res" />
|
||||
<root url="jar://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.android.support/appcompat-v7/19.0.1/classes.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.android.support/appcompat-v7/19.1.0/classes.jar!/" />
|
||||
<root url="file://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.android.support/appcompat-v7/19.1.0/res" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="support-v4-19.0.1">
|
||||
<library name="support-v4-19.1.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.0.1/support-v4-19.0.1.jar!/" />
|
||||
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.0.1/support-v4-19.0.1-sources.jar!/" />
|
||||
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -70,10 +70,10 @@
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-19.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-4.3.23" level="project" />
|
||||
<orderEntry type="library" exported="" name="glowpadbackport-2.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-19.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
@ -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'
|
||||
|
@ -2,6 +2,23 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="za.org.treehouse.hypoalarm" >
|
||||
|
||||
<!-- permission required to read contacts -->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<!-- permission required to tell if a phone call is active -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<!-- permission required to set an alarm -->
|
||||
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
||||
<!-- permission required to Send SMS -->
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<!-- permission required to message the user's location -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- permission to restart the alarm on device boot -->
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<!-- permission required to vibrate -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<!-- permission required to wake the device -->
|
||||
<!-- uses-permission android:name="android.permission.WAKE_LOCK"/ -->
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
@ -50,22 +67,4 @@
|
||||
android:value="@integer/google_play_services_version" />
|
||||
|
||||
</application>
|
||||
|
||||
<!-- permission required to read contacts -->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<!-- permission required to tell if a phone call is active -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<!-- permission required to set an alarm -->
|
||||
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
||||
<!-- permission required to Send SMS -->
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<!-- permission required to message the user's location -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- permission to restart the alarm on device boot -->
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<!-- permission required to vibrate -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<!-- permission required to wake the device -->
|
||||
<!-- uses-permission android:name="android.permission.WAKE_LOCK"/ -->
|
||||
|
||||
</manifest>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 67 KiB |
@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/alarm_active_switch"
|
||||
android:layout_column="1"
|
||||
android:layout_gravity="left" />
|
||||
</FrameLayout>
|
||||
</merge>
|
@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ToggleButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/alarm_active_switch"
|
||||
android:layout_column="1"
|
||||
android:layout_gravity="left" />
|
||||
</FrameLayout>
|
||||
</merge>
|
@ -7,7 +7,7 @@
|
||||
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stretchColumns="0"
|
||||
android:shrinkColumns="1"
|
||||
android:dividerPadding="10dp"
|
||||
@ -42,7 +42,8 @@
|
||||
android:layout_column="0" />
|
||||
|
||||
<include
|
||||
layout="@layout/activeswitch" />
|
||||
layout="@layout/activeswitch"
|
||||
android:layout_column="1" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
@ -152,6 +153,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/message"
|
||||
android:inputType="textShortMessage|textMultiLine|textCapSentences"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:clickable="true"
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
<string name="pre_alarm_notification">Upcoming alarm</string>
|
||||
|
||||
<string name="text_message_service">Text message sending</string>
|
||||
|
||||
<string-array name="grace_period_array">
|
||||
<item>10 minutes</item>
|
||||
<item>15 minutes</item>
|
||||
|
Loading…
Reference in New Issue
Block a user