- Activate for smaller screens and older devices (Samsung Galaxy S Mini, 2.3.6 / API 10).

- Turn off debugging
This commit is contained in:
Timothy Allen 2014-04-14 15:16:39 +02:00
parent e6266d4ed6
commit 66e615bb20
14 changed files with 301 additions and 331 deletions

View File

@ -11,7 +11,10 @@
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

View File

@ -9,7 +9,6 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
//import com.triggertrap.seekarc.SeekArc;
import net.frakbot.glowpadbackport.GlowPadView;
import java.util.Random;
@ -53,25 +52,6 @@ public class AlarmAlertActivity extends Activity {
public void onStart() {
super.onStart();
/* CANCEL SEEKARC
final SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc);
cancelArc.setOnSeekArcChangeListener(new SeekArc.OnSeekArcChangeListener() {
volatile Boolean seekFinished = false;
@Override
public void onProgressChanged(SeekArc seekArc, int progress, boolean fromUser) {
if (progress > 98 && !seekFinished && fromUser) {
AlarmService.dismissAlarm(alertActivity);
seekFinished = true;
}
}
@Override
public void onStartTrackingTouch(SeekArc seekArc) {
}
@Override
public void onStopTrackingTouch(SeekArc seekArc) {
}
});
*/
final GlowPadView cancelGlowPad = (GlowPadView) findViewById(R.id.cancel_glowpad);
cancelGlowPad.setOnTriggerListener(new GlowPadView.OnTriggerListener() {
@Override

View File

@ -12,6 +12,7 @@ import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class AlarmNotify extends Service {
@ -45,8 +46,7 @@ public class AlarmNotify extends Service {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_grey);
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= 11) {
final Notification.Builder notification = new Notification.Builder(this)
final NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.app_name))
.setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(gracePeriod)))
.setSmallIcon(R.drawable.alarm_notification)
@ -109,7 +109,7 @@ public class AlarmNotify extends Service {
stopSelf(); // stop notification service
}
}).start();
}
return super.onStartCommand(intent, flags, startId);
}
}

View File

@ -16,8 +16,8 @@ import android.util.Log;
import java.util.Calendar;
public class AlarmService extends Service {
private static final int SNOOZE_TIME = 1000*60;//60*5; // Snooze for 5 minutes if need be
private static final int ALERT_LIFE = 1000*10;//60*2; // 2 minutes
private static final int SNOOZE_TIME = 1000*60*5; // Snooze for 5 minutes if need be
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;

View File

@ -77,7 +77,6 @@ public class GraceReceiver extends BroadcastReceiver {
}
private void sendText(Context context) {
SmsManager sms = SmsManager.getDefault();
// TODO uncomment sendTextMessage
if (!MainActivity.HYPOALARM_DEBUG) {
sms.sendTextMessage(phoneNumber, null, message, null, null);
}

View File

@ -32,12 +32,14 @@ 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;
@ -69,7 +71,7 @@ public class MainActivity extends ActionBarActivity {
private static Button alarmTimeButton;
private static EditText messageButton;
public static Boolean HYPOALARM_DEBUG = true;
public static Boolean HYPOALARM_DEBUG = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -92,7 +94,6 @@ public class MainActivity extends ActionBarActivity {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
@ -104,7 +105,7 @@ public class MainActivity extends ActionBarActivity {
// Allow alarm to activate
Boolean alarmActive = sharedPref.getBoolean(getString(R.string.AlarmActivePref), true);
Switch alarmActiveSwitch = (Switch) getActivity().findViewById(R.id.alarm_active_switch);
CompoundButton alarmActiveSwitch = (CompoundButton) getActivity().findViewById(R.id.alarm_active_switch);
alarmActiveSwitch.setChecked(alarmActive);
alarmActiveSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -145,6 +146,7 @@ public class MainActivity extends ActionBarActivity {
}
});
// Set alarm time
String defaultTimeStr = "09:00";
String alarmTimeStr = verifyTimeString(sharedPref.getString(getString(R.string.AlarmTimePref), defaultTimeStr));
@ -512,18 +514,13 @@ public class MainActivity extends ActionBarActivity {
}
public static String formattedTime(Context context, Calendar cal) {
String pattern;
if (Build.VERSION.SDK_INT >= 18) {
String skeleton = DateFormat.is24HourFormat(context) ? "EHm" : "Ehma";
pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
SimpleDateFormat print;
if (DateFormat.is24HourFormat(context)) {
print = new SimpleDateFormat("E HH:mm");
} else {
pattern = "EHm";
print = new SimpleDateFormat("E hh:mm a");
}
return (String) DateFormat.format(pattern, cal);
}
public static String debugDate(Calendar cal) {
SimpleDateFormat print = new SimpleDateFormat("dd-MM-yyyy HH:mm:ssZ");
return print.format(cal.getTime());
return (String) print.format(cal.getTime());
}
public static int GracePeriodToMinutes(String gracePeriod) {
@ -569,6 +566,11 @@ public class MainActivity extends ActionBarActivity {
return remMinutes + minStr;
}
public static String debugDate(Calendar cal) {
SimpleDateFormat print = new SimpleDateFormat("dd-MM-yyyy HH:mm:ssZ");
return print.format(cal.getTime());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

View File

@ -12,6 +12,7 @@ import android.graphics.BitmapFactory;
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;
@ -47,8 +48,7 @@ public class PreAlarmNotify extends Service {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_grey);
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= 11) {
final Notification.Builder notification = new Notification.Builder(this)
final NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.preNotificationTitle))
.setContentText(alarmTimeStr)
.setSmallIcon(R.drawable.alarm_notification)
@ -70,7 +70,7 @@ public class PreAlarmNotify extends Service {
nm.cancel(this.preNotifyID);
nm.notify(this.preNotifyID, notification.build());
}
return super.onStartCommand(intent, flags, startId);
}
}

View File

@ -0,0 +1,11 @@
<?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">
<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>

View File

@ -0,0 +1,11 @@
<?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">
<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>

View File

@ -6,68 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AlarmNotificationActivity">
<!--
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:background="#000000"
-->
<!-- SEEKARC
<com.triggertrap.seekarc.SeekArc
android:id="@+id/cancel_dialog_seekArc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
seekarc:thumb="@drawable/ic_launcher"
seekarc:clockwise="false"
seekarc:rotation="0"
seekarc:startAngle="35"
seekarc:sweepAngle="295"
seekarc:arcWidth="10dp"
seekarc:progressWidth="20dp"
seekarc:roundEdges="true"
seekarc:touchInside="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="HypoAlarm!"
android:id="@+id/cancel_dialog_title"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="25dp" />
-->
<!-- BUTTON
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancel_dialog_imageView"
android:src="@drawable/hypoalarm"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="HypoAlarm!"
android:id="@+id/cancel_dialog_title"
android:layout_below="@+id/cancel_dialog_imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I'm awake"
android:id="@+id/cancel_dialog_button"
android:layout_marginTop="25dp"
android:layout_below="@+id/cancel_dialog_title"
android:layout_centerHorizontal="true" />
-->
<TextView
android:layout_width="wrap_content"
@ -77,9 +15,8 @@
android:id="@+id/cancel_dialog_title"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp" />
android:layout_marginTop="@dimen/alarm_widget_vertical_margin" />
<!--net.sebastianopoggi.ui.GlowPadBackport.GlowPadView-->
<net.frakbot.glowpadbackport.GlowPadView
android:id="@+id/cancel_glowpad"
android:layout_width="fill_parent"

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
@ -36,12 +41,8 @@
android:id="@+id/alarm_active_text"
android:layout_column="0" />
<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" />
<include
layout="@layout/activeswitch" />
</TableRow>
<TableRow
@ -157,4 +158,7 @@
android:layout_span="2"
android:layout_column="0" />
</TableRow>
</TableLayout>
</ScrollView>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">8dp</dimen>
<dimen name="activity_vertical_margin">8dp</dimen>
<!-- Default target placement radius for GlowPadView. Should be 1/2 of outerring diameter. -->
<dimen name="glowpadview_target_placement_radius">110dip</dimen>
<!-- Default glow radius for GlowPadView -->
<dimen name="glowpadview_glow_radius">50dip</dimen>
<!-- Default distance beyond which GlowPadView snaps to the matching target -->
<dimen name="glowpadview_snap_margin">20dip</dimen>
<!-- Default distance from each snap target that GlowPadView considers a "hit" -->
<dimen name="glowpadview_inner_radius">10dip</dimen>
<!-- Size of lockscreen outerring -->
<dimen name="alarm_outerring_diameter">220dp</dimen>
<!-- Circle size for incoming call widget's each item. -->
<dimen name="alarm_widget_circle_size">72dp</dimen>
<!-- Margin used for alarm widget's icon for each item.
This should be same as "(alarm_widget_circle_size - icon_size)/2".
Right now answer/decline/reject icons have 38dp width/height.
So, (72 - 38)/2 ==> 17dp -->
<dimen name="alarm_widget_asset_margin">11dp</dimen>
<dimen name="alarm_widget_vertical_margin">20dp</dimen>
</resources>

View File

@ -4,7 +4,6 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- Default target placement radius for GlowPadView. Should be 1/2 of outerring diameter. -->
<dimen name="glowpadview_target_placement_radius">135dip</dimen>
@ -29,4 +28,6 @@
So, (94 - 38)/2 ==> 28dp -->
<dimen name="alarm_widget_asset_margin">11dp</dimen>
<dimen name="alarm_widget_vertical_margin">60dp</dimen>
</resources>

View File

@ -1,17 +1,6 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
</style>
<!--
<style name="SeekArc">
<item name="arcColor">@color/progress_gray_dark</item>
</style>
<style name="SeekArcLight">
<item name="arcColor">@color/progress_gray</item>
</style>
-->
</resources>