- Disable SeekArc and enable GlowPadView

- Correct fullscreen ability
- Add debugging options
This commit is contained in:
Timothy Allen 2014-04-13 15:38:16 +02:00
parent d7bf2832ea
commit 249a185649
37 changed files with 284 additions and 131 deletions

View File

@ -43,6 +43,8 @@
<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 -->

View File

@ -1,13 +1,9 @@
package za.org.treehouse.hypoalarm;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.Window;
@ -16,6 +12,8 @@ import android.widget.Button;
import com.triggertrap.seekarc.SeekArc;
import net.sebastianopoggi.ui.GlowPadBackport.GlowPadView;
// TODO See GlowPad.
public class AlarmAlertActivity extends Activity {
@ -31,7 +29,7 @@ public class AlarmAlertActivity extends Activity {
alertActivity = this;
requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = getWindow();
final Window window = getWindow();
// Set to use the full screen
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
@ -40,11 +38,12 @@ public class AlarmAlertActivity extends Activity {
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_FULLSCREEN
);
if (Build.VERSION.SDK_INT >= 16) {
if (Build.VERSION.SDK_INT >= 14) {
window.getDecorView().
setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN);
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
setContentView(R.layout.alarm_alert);
notifyIntent = new Intent(getApplicationContext(), AlarmNotify.class);
@ -56,8 +55,9 @@ public class AlarmAlertActivity extends Activity {
@Override
public void onStart() {
super.onStart();
/*
Button cancelButton = (Button) findViewById(R.id.cancel_dialog_button);
/* CANCEL BUTTON
final Button cancelButton = (Button) findViewById(R.id.cancel_dialog_button);
cancelButton.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -65,7 +65,8 @@ public class AlarmAlertActivity extends Activity {
}
});
*/
SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc);
/* CANCEL SEEKARC
final SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc);
cancelArc.setOnSeekArcChangeListener(new SeekArc.OnSeekArcChangeListener() {
volatile Boolean seekFinished = false;
@Override
@ -82,7 +83,35 @@ public class AlarmAlertActivity extends Activity {
public void onStopTrackingTouch(SeekArc seekArc) {
}
});
*/
final GlowPadView cancelGlowPad = (GlowPadView) findViewById(R.id.cancel_glowpad);
cancelGlowPad.setOnTriggerListener(new GlowPadView.OnTriggerListener() {
@Override
public void onGrabbed(View v, int handle) {
// Do nothing
}
@Override
public void onReleased(View v, int handle) {
// Do nothing
}
@Override
public void onTrigger(View v, int target) {
// if (target == "")
AlarmReceiver.dismissAlarm(alertActivity);
}
@Override
public void onGrabbedStateChange(View v, int handle) {
// Do nothing
}
@Override
public void onFinishFinalAnimation() {
// Do nothing
}
});
}
/**

View File

@ -55,8 +55,6 @@ public class AlarmNotify extends Service {
.setAutoCancel(false)
.setPriority(Notification.PRIORITY_HIGH);
// TODO if alarm alert is snoozing and we cancel, cancel the snooze.
// Set up dismiss action
Intent cancellerIntent = new Intent(getBaseContext(), CancelGraceReceiver.class);
PendingIntent cancellerPendingIntent = PendingIntent.getBroadcast(getBaseContext(), MainActivity.CANCEL_GRACE_REQUEST, cancellerIntent, PendingIntent.FLAG_CANCEL_CURRENT);
@ -86,10 +84,6 @@ public class AlarmNotify extends Service {
public void run() {
notificationRunning = true;
int max = 1000;
/* TODO check that graceEndTime is always set.
if (AlarmReceiver.graceEndTime == 0) {
AlarmReceiver.graceEndTime = System.currentTimeMillis() + (gracePeriod * 60 * 1000);
}*/
// Count in milliseconds for greater progress resolution
int milliSecondsLeft = (int) ((AlarmReceiver.graceEndTime - System.currentTimeMillis()));
int gracePeriodMilliSeconds = gracePeriod * 60 * 1000;

View File

@ -23,8 +23,8 @@ import java.util.Calendar;
*/
public class AlarmReceiver extends BroadcastReceiver {
private static final int SNOOZE_TIME = 1000*20; //1000*60*5; // Snooze for 5 minutes if need be
private static final int ALERT_LIFE = 1000*10; //1000*60*2; // 2 minutes
private static final int SNOOZE_TIME = 1000*20; //TODO 1000*60*5; // Snooze for 5 minutes if need be
private static final int ALERT_LIFE = 1000*60; //TODO 1000*60*2; // 2 minutes
private static SharedPreferences sharedPref;
private static AlarmManager alarmManager, graceManager;
private static PendingIntent alarmPendingIntent, gracePendingIntent;

View File

@ -6,6 +6,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Log;
@ -14,7 +15,7 @@ import java.util.Calendar;
public class BootReceiver extends BroadcastReceiver {
private static SharedPreferences sharedPref;
private static AlarmManager alarmManager;
private static PendingIntent alarmIntent;
private static PendingIntent alarmPendingIntent;
@Override
public void onReceive(Context context, Intent intent) {
@ -22,13 +23,17 @@ public class BootReceiver extends BroadcastReceiver {
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);
if (alarmTimeStr != null) {
Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), true);
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);
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
// TODO use set() for older APIs
alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);
alarmPendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
if (Build.VERSION.SDK_INT >= 19) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent);
}
Log.d("BootReceiver", "Setting alarm for "+MainActivity.debugDate(cal));
}
}

View File

@ -17,6 +17,8 @@ public class GraceReceiver extends BroadcastReceiver {
sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), true);
// TODO get location of phone and send in the message
if (alarmActive) {
String phoneNumber = sharedPref.getString(context.getString(R.string.PhoneNumberPref), null);
String message = sharedPref.getString(context.getString(R.string.MessagePref), null);

View File

@ -69,6 +69,8 @@ public class MainActivity extends ActionBarActivity {
private static EditText phoneNumberButton;
private static EditText messageButton;
public static Boolean HYPOALARM_DEBUG=true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -143,10 +145,11 @@ public class MainActivity extends ActionBarActivity {
String alarmTimeStr = verifyTimeString(sharedPref.getString(getString(R.string.AlarmTimePref), defaultTimeStr));
alarmTimeButton = (Button) getActivity().findViewById(R.id.alarm_time);
// TODO remove this testing stuff
if (HYPOALARM_DEBUG) {
Calendar c = Calendar.getInstance();
c.add(Calendar.MINUTE, 1);
alarmTimeStr = CalendarToTimeString(c);
}
alarmTimeButton.setText(alarmTimeStr);
alarmTimeButton.setOnClickListener(new View.OnClickListener() {
@ -157,11 +160,11 @@ public class MainActivity extends ActionBarActivity {
}
});
// TODO remove these simulated clicks
if (HYPOALARM_DEBUG) {
DialogFragment alarmFragment = new TimePickerFragment();
alarmFragment.show(getActivity().getSupportFragmentManager(), "alarmTimePicker");
alarmFragment.dismiss();
}
// Set grace period
int defaultGrace = 60;

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 738 B

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 538 B

After

Width:  |  Height:  |  Size: 538 B

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 964 B

After

Width:  |  Height:  |  Size: 964 B

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Used with alarm widget. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true" android:state_active="false" android:state_focused="false"
android:drawable="@drawable/ic_alarm_normal_layer"/>
<item
android:state_enabled="true" android:state_active="true" android:state_focused="false"
android:drawable="@drawable/ic_alarm_activated_layer" />
<item
android:state_enabled="true" android:state_active="false" android:state_focused="true"
android:drawable="@drawable/ic_alarm_activated_layer" />
</selector>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#58c233"/>
<size
android:width="@dimen/alarm_widget_circle_size"
android:height="@dimen/alarm_widget_circle_size" />
</shape>
</item>
<item
android:top="@dimen/alarm_widget_asset_margin"
android:right="@dimen/alarm_widget_asset_margin"
android:bottom="@dimen/alarm_widget_asset_margin"
android:left="@dimen/alarm_widget_asset_margin"
android:drawable="@drawable/ic_alarm_activated" />
</layer-list>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- A fake circle to fix the size of this layer asset. -->
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#00000000"/>
<size
android:width="@dimen/alarm_widget_circle_size"
android:height="@dimen/alarm_widget_circle_size" />
</shape>
</item>
<item
android:top="@dimen/alarm_widget_asset_margin"
android:right="@dimen/alarm_widget_asset_margin"
android:bottom="@dimen/alarm_widget_asset_margin"
android:left="@dimen/alarm_widget_asset_margin"
android:drawable="@drawable/ic_alarm_normal" />
</layer-list>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<size android:height="@dimen/alarm_outerring_diameter"
android:width="@dimen/alarm_outerring_diameter" />
<solid android:color="#00000000" />
<stroke android:color="#1affffff" android:width="2dp" />
</shape>

View File

@ -1,19 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
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"
tools:context=".AlarmNotificationActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
-->
<!-- SEEKARC
<com.triggertrap.seekarc.SeekArc
android:id="@+id/cancel_dialog_seekArc"
android:layout_width="match_parent"
@ -40,7 +38,8 @@
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="25dp" />
<!--
-->
<!-- BUTTON
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -69,27 +68,33 @@
android:layout_below="@+id/cancel_dialog_title"
android:layout_centerHorizontal="true" />
-->
<!--
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/app_name"
android:id="@+id/cancel_dialog_title"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp" />
<net.sebastianopoggi.ui.GlowPadBackport.GlowPadView
android:id="@+id/incomingCallWidget"
android:id="@+id/cancel_glowpad"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_below="@+id/cancel_dialog_title"
android:background="@android:color/black"
android:visibility="visible"
android:gravity="top"
android:gravity="center"
app:targetDrawables="@array/incoming_call_widget_2way_targets"
app:handleDrawable="@drawable/ic_in_call_touch_handle"
app:targetDrawables="@array/glowpad_target"
app:handleDrawable="@drawable/ic_alarm_activated"
app:innerRadius="@dimen/glowpadview_inner_radius"
app:outerRadius="@dimen/glowpadview_target_placement_radius"
app:outerRingDrawable="@drawable/ic_lockscreen_outerring"
app:outerRingDrawable="@drawable/ic_outerring"
app:snapMargin="@dimen/glowpadview_snap_margin"
app:vibrationDuration="20"
app:feedbackCount="1"
app:glowRadius="@dimen/glowpadview_glow_radius"
app:pointDrawable="@drawable/ic_lockscreen_glowdot"/>
-->
app:pointDrawable="@drawable/ic_glowdot" />
</RelativeLayout>
</FrameLayout>

View File

@ -17,16 +17,16 @@
<!-- Default distance from each snap target that GlowPadView considers a "hit" -->
<dimen name="glowpadview_inner_radius">15dip</dimen>
<!-- Size of lockscreen outerring on unsecure unlock LockScreen -->
<dimen name="keyguard_lockscreen_outerring_diameter">270dp</dimen>
<!-- Size of lockscreen outerring -->
<dimen name="alarm_outerring_diameter">270dp</dimen>
<!-- Circle size for incoming call widget's each item. -->
<dimen name="incoming_call_widget_circle_size">94dp</dimen>
<dimen name="alarm_widget_circle_size">94dp</dimen>
<!-- Margin used for incoming call widget's icon for each item.
This should be same as "(incoming_call_widget_circle_size - icon_size)/2".
<!-- 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, (94 - 38)/2 ==> 28dp -->
<dimen name="incoming_call_widget_asset_margin">28dp</dimen>
<dimen name="alarm_widget_asset_margin">11dp</dimen>
</resources>

View File

@ -57,11 +57,11 @@
<string name="alarmCancelled">All HypoAlarms cancelled</string>
<array name="incoming_call_widget_2way_targets">
<item>@drawable/ic_lockscreen_answer</item>
<array name="glowpad_target">
<item>@null</item>
<item>@drawable/ic_lockscreen_decline</item>
<item>@null</item>"
<item>@null</item>
<item>@null</item>
<item>@drawable/ic_alarm</item>
</array>
</resources>

View File

@ -135,12 +135,11 @@ containing a value of this type.
public static int progress_gray_dark=0x7f030001;
}
public static final class drawable {
public static int ic_launcher=0x7f020000;
public static int scrubber_control_disabled_holo=0x7f020001;
public static int scrubber_control_focused_holo=0x7f020002;
public static int scrubber_control_normal_holo=0x7f020003;
public static int scrubber_control_pressed_holo=0x7f020004;
public static int seek_arc_control_selector=0x7f020005;
public static int scrubber_control_disabled_holo=0x7f020000;
public static int scrubber_control_focused_holo=0x7f020001;
public static int scrubber_control_normal_holo=0x7f020002;
public static int scrubber_control_pressed_holo=0x7f020003;
public static int seek_arc_control_selector=0x7f020004;
}
public static final class string {
public static int app_name=0x7f040000;