Added new layouts for astrid reminders, can get in-app notifications with a popup

pull/14/head
Sam Bosley 13 years ago
parent 44f8c82d9a
commit aa4359ac7a

@ -165,6 +165,12 @@
<receiver android:name="com.todoroo.astrid.reminders.Notifications" />
<receiver android:name="com.todoroo.astrid.reminders.Notifications$ShowNotificationReceiver">
<intent-filter>
<action android:name="com.timsu.astrid.IN_APP_NOTIFY"/>
</intent-filter>
</receiver>
<!-- widgets -->
<receiver android:name="com.todoroo.astrid.widget.TasksWidget">
<intent-filter>

@ -166,7 +166,7 @@ public class AlarmService {
Intent intent = new Intent(context, Notifications.class);
intent.setAction("ALARM" + alarm.getId()); //$NON-NLS-1$
intent.putExtra(Notifications.ID_KEY, taskId);
intent.putExtra(Notifications.TYPE_KEY, type);
intent.putExtra(Notifications.EXTRAS_TYPE, type);
AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, (int)alarm.getId(),

@ -21,6 +21,7 @@ package com.todoroo.astrid.reminders;
import java.util.Date;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
@ -32,7 +33,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Spinner;
@ -61,7 +61,7 @@ import com.todoroo.astrid.ui.NumberPicker;
* @author timsu
*
*/
public class NotificationFragment extends TaskListFragment implements OnTimeSetListener {
public class NotificationFragment extends TaskListFragment implements OnTimeSetListener, SnoozeCallback {
// --- constants
@ -121,33 +121,37 @@ public class NotificationFragment extends TaskListFragment implements OnTimeSetL
// instantiate reminder window
ViewGroup parent = (ViewGroup) getView().findViewById(R.id.taskListParent);
getActivity().getLayoutInflater().inflate(R.layout.notification_control, parent, true);
getActivity().getLayoutInflater().inflate(R.layout.astrid_reminder_view, parent, true);
getView().findViewById(R.id.reminder_root).setBackgroundResource(R.color.reminder_background);
String reminder = Notifications.getRandomReminder(getResources().getStringArray(R.array.reminder_responses));
if(Preferences.getBoolean(R.string.p_rmd_nagging, true))
((TextView)getView().findViewById(R.id.reminderLabel)).setText(reminder);
((TextView)getView().findViewById(R.id.reminder_message)).setText(reminder);
else {
getView().findViewById(R.id.reminderLabel).setVisibility(View.GONE);
getView().findViewById(R.id.reminder_message).setVisibility(View.GONE);
getView().findViewById(R.id.astridIcon).setVisibility(View.GONE);
getView().findViewById(R.id.speech_bubble_content).setVisibility(View.GONE);
}
getView().findViewById(R.id.reminder_edit).setVisibility(View.GONE);
// set up listeners
((Button)getView().findViewById(R.id.goAway)).setOnClickListener(new OnClickListener() {
getView().findViewById(R.id.dismiss).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
getActivity().finish();
}
});
((Button)getView().findViewById(R.id.snooze)).setOnClickListener(new OnClickListener() {
getView().findViewById(R.id.reminder_snooze).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
snooze();
snooze(getActivity(), NotificationFragment.this, NotificationFragment.this);
}
});
((Button)getView().findViewById(R.id.done)).setOnClickListener(new OnClickListener() {
getView().findViewById(R.id.reminder_complete).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Task task = new Task();
@ -163,13 +167,13 @@ public class NotificationFragment extends TaskListFragment implements OnTimeSetL
LinearLayout snoozePicker;
NumberPicker snoozeValue;
Spinner snoozeUnits;
NotificationFragment parent;
SnoozeCallback snoozeCallback;
public SnoozeDialog(NotificationFragment parent) {
super(parent.getActivity());
this.parent = parent;
public SnoozeDialog(Activity activity, SnoozeCallback callback) {
super(activity);
this.snoozeCallback = callback;
LayoutInflater mInflater = (LayoutInflater) parent.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mInflater.inflate(R.layout.snooze_dialog, this, true);
snoozePicker = (LinearLayout) findViewById(R.id.snoozePicker);
@ -206,7 +210,7 @@ public class NotificationFragment extends TaskListFragment implements OnTimeSetL
break;
}
parent.snoozeTime(time);
snoozeCallback.snoozeForTime(time);
}
}
@ -214,24 +218,24 @@ public class NotificationFragment extends TaskListFragment implements OnTimeSetL
/**
* Snooze and re-trigger this alarm
*/
private void snooze() {
public static void snooze(Activity activity, OnTimeSetListener onTimeSet, SnoozeCallback snoozeCallback) {
if(Preferences.getBoolean(R.string.p_rmd_snooze_dialog, false)) {
Date now = new Date();
now.setHours(now.getHours() + 1);
int hour = now.getHours();
int minute = now.getMinutes();
TimePickerDialog tpd = new TimePickerDialog(getActivity(), this, hour, minute,
DateUtilities.is24HourFormat(getActivity()));
TimePickerDialog tpd = new TimePickerDialog(activity, onTimeSet, hour, minute,
DateUtilities.is24HourFormat(activity));
tpd.show();
tpd.setOwnerActivity(getActivity());
tpd.setOwnerActivity(activity);
} else {
SnoozeDialog sd = new SnoozeDialog(this);
new AlertDialog.Builder(getActivity())
SnoozeDialog sd = new SnoozeDialog(activity, snoozeCallback);
new AlertDialog.Builder(activity)
.setTitle(R.string.rmd_NoA_snooze)
.setView(sd)
.setPositiveButton(android.R.string.ok, sd)
.setNegativeButton(android.R.string.cancel, null)
.show().setOwnerActivity(getActivity());
.show().setOwnerActivity(activity);
}
}
@ -243,10 +247,10 @@ public class NotificationFragment extends TaskListFragment implements OnTimeSetL
alarmTime.setMinutes(minutes);
if(alarmTime.getTime() < DateUtilities.now())
alarmTime.setDate(alarmTime.getDate() + 1);
snoozeTime(alarmTime.getTime());
snoozeForTime(alarmTime.getTime());
}
public void snoozeTime(long time) {
public void snoozeForTime(long time) {
Task task = new Task();
task.setId(taskId);
task.setValue(Task.REMINDER_SNOOZE, time);

@ -26,6 +26,7 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.AstridDependencyInjector;
@ -39,14 +40,24 @@ public class Notifications extends BroadcastReceiver {
/** task id extra */
public static final String ID_KEY = "id"; //$NON-NLS-1$
/** notification type extra */
public static final String TYPE_KEY = "type"; //$NON-NLS-1$
/** preference values */
public static final int ICON_SET_PINK = 0;
public static final int ICON_SET_BORING = 1;
public static final int ICON_SET_ASTRID = 2;
/**
* Action name for broadcast intent notifying that task was created from repeating template
*/
public static final String BROADCAST_IN_APP_NOTIFY = Constants.PACKAGE + ".IN_APP_NOTIFY"; //$NON-NLS-1$
public static final String EXTRAS_CUSTOM_INTENT = "intent";
public static final String EXTRAS_NOTIF_ID = "notifId";
/** notification type extra */
public static final String EXTRAS_TYPE = "type"; //$NON-NLS-1$
public static final String EXTRAS_TITLE = "title";
public static final String EXTRAS_TEXT = "text";
public static final String EXTRAS_RING_TIMES = "ringTimes";
// --- instance variables
@Autowired
@ -73,7 +84,7 @@ public class Notifications extends BroadcastReceiver {
ContextManager.setContext(context);
long id = intent.getLongExtra(ID_KEY, 0);
int type = intent.getIntExtra(TYPE_KEY, (byte) 0);
int type = intent.getIntExtra(EXTRAS_TYPE, (byte) 0);
Resources r = context.getResources();
String reminder;
@ -169,10 +180,41 @@ public class Notifications extends BroadcastReceiver {
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
notifyIntent.putExtra(TaskListFragment.TOKEN_SOURCE, Constants.SOURCE_NOTIFICATION);
showNotification((int)id, notifyIntent, type, title, text, ringTimes);
requestNotification((int)id, notifyIntent, type, title, text, ringTimes);
return true;
}
private static void requestNotification(int notificationId, Intent intent, int type, String title, String text, int ringTimes) {
Context context = ContextManager.getContext();
Intent inAppNotify = new Intent(BROADCAST_IN_APP_NOTIFY);
inAppNotify.putExtra(EXTRAS_NOTIF_ID, notificationId);
inAppNotify.putExtra(EXTRAS_CUSTOM_INTENT, intent);
inAppNotify.putExtra(EXTRAS_TYPE, type);
inAppNotify.putExtra(EXTRAS_TITLE, title);
inAppNotify.putExtra(EXTRAS_TEXT, text);
inAppNotify.putExtra(EXTRAS_RING_TIMES, ringTimes);
context.sendOrderedBroadcast(inAppNotify, AstridApiConstants.PERMISSION_READ);
}
/**
* Receives requests to show an Astrid notification if they were not intercepted and handled
* by the in-app reminders in AstridActivity.
* @author Sam
*
*/
public static class ShowNotificationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int notificationId = intent.getIntExtra(EXTRAS_NOTIF_ID, 0);
Intent customIntent = intent.getParcelableExtra(EXTRAS_CUSTOM_INTENT);
int type = intent.getIntExtra(EXTRAS_TYPE, 0);
String title = intent.getStringExtra(EXTRAS_TITLE);
String text = intent.getStringExtra(EXTRAS_TEXT);
int ringTimes = intent.getIntExtra(EXTRAS_RING_TIMES, 1);
showNotification(notificationId, customIntent, type, title, text, ringTimes);
}
}
/**
* Shows an Astrid notification. Pulls in ring tone and quiet hour settings
* from preferences. You can make it say anything you like.
@ -181,6 +223,7 @@ public class Notifications extends BroadcastReceiver {
public static void showNotification(int notificationId, Intent intent, int type, String title,
String text, int ringTimes) {
Context context = ContextManager.getContext();
if(notificationManager == null)
notificationManager = new AndroidNotificationManager(context);

@ -0,0 +1,89 @@
package com.todoroo.astrid.reminders;
import java.util.Date;
import android.app.Dialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.TimePicker;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
public class ReminderDialog {
public static Dialog createReminderDialog(final AstridActivity activity, final long taskId, String title) {
final Dialog d = new Dialog(activity, R.style.ReminderDialog);
final SnoozeCallback dialogSnooze = new SnoozeCallback() {
@Override
public void snoozeForTime(long time) {
Task task = new Task();
task.setId(taskId);
task.setValue(Task.REMINDER_SNOOZE, time);
PluginServices.getTaskService().save(task);
d.dismiss();
StatisticsService.reportEvent(StatisticsConstants.TASK_SNOOZE);
}
};
final OnTimeSetListener onTimeSet = new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hours, int minutes) {
Date alarmTime = new Date();
alarmTime.setHours(hours);
alarmTime.setMinutes(minutes);
if(alarmTime.getTime() < DateUtilities.now())
alarmTime.setDate(alarmTime.getDate() + 1);
dialogSnooze.snoozeForTime(alarmTime.getTime());
}
};
d.setContentView(R.layout.astrid_reminder_view);
// set up listeners
d.findViewById(R.id.dismiss).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
d.dismiss();
}
});
d.findViewById(R.id.reminder_snooze).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
NotificationFragment.snooze(activity, onTimeSet, dialogSnooze);
}
});
d.findViewById(R.id.reminder_complete).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Task task = new Task();
task.setId(taskId);
PluginServices.getTaskService().setComplete(task, true);
d.dismiss();
}
});
d.findViewById(R.id.reminder_edit).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
activity.onTaskListItemClicked(taskId);
}
});
((TextView) d.findViewById(R.id.reminder_title)).setText(title);
((TextView) d.findViewById(R.id.reminder_message)).setText(
Notifications.getRandomReminder(activity.getResources().getStringArray(R.array.reminder_responses)));
return d;
}
}

@ -446,7 +446,7 @@ public final class ReminderService {
intent.setType(Long.toString(task.getId()));
intent.setAction(Integer.toString(type));
intent.putExtra(Notifications.ID_KEY, task.getId());
intent.putExtra(Notifications.TYPE_KEY, type);
intent.putExtra(Notifications.EXTRAS_TYPE, type);
// calculate the unique requestCode as a combination of the task-id and alarm-type:
// concatenate id+type to keep the combo unique

@ -0,0 +1,14 @@
package com.todoroo.astrid.reminders;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class ReminderView extends LinearLayout {
public ReminderView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
}

@ -0,0 +1,7 @@
package com.todoroo.astrid.reminders;
public interface SnoozeCallback {
public void snoozeForTime(long time);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="5dip"/>
<solid
android:color="@color/reminder_background"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reminder_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="20dip"
android:layout_marginLeft="10dip">
<TextView
android:id="@+id/reminder_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@android:color/white"
android:layout_weight="1"/>
<ImageView
android:id="@+id/dismiss"
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="2dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:gravity="bottom">
<ImageView
android:id="@+id/astridIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:src="@drawable/icon"
android:scaleType="fitCenter"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>
<LinearLayout
android:id="@+id/speech_bubble_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_marginBottom="5dip"
android:minHeight="60dip"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:background="@drawable/speech_bubble_reminder"
android:layout_toRightOf="@id/astridIcon">
<TextView
android:id="@+id/reminder_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.TLA_Reminder"
android:gravity="center_vertical"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/reminder_edit"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:text="@string/TAd_actionEditTask"
android:background="#707070"/>
<Button
android:id="@+id/reminder_snooze"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:text="@string/rmd_NoA_snooze"
android:background="#707070"/>
<Button
android:id="@+id/reminder_complete"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:text="@string/rmd_NoA_done"
android:background="?attr/asThemeTextColor"/>
</LinearLayout>

@ -4,7 +4,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_weight="1">
android:layout_weight="1"
android:background="@color/reminder_background">
<LinearLayout android:id="@+id/buttons"
@ -24,19 +25,15 @@
</LinearLayout>
<TextView android:id="@+id/reminderLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/buttons"
android:text="I want you to be the walrus."
android:background="@drawable/reminder_popup"
style="@style/TextAppearance.TLA_Reminder" />
<include
android:id="@+id/reminder_layout"
layout="@layout/astrid_reminder_view"
android:layout_below="@id/buttons"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/reminderLabel"
android:layout_below="@id/reminder_layout"
android:layout_alignParentLeft="true"
android:orientation="horizontal">
@ -44,25 +41,28 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="49"
android:textSize="16sp"
android:drawableLeft="@drawable/tango_clock"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:textSize="20sp"
android:textColor="@android:color/white"
android:background="#707070"
android:text="@string/rmd_NoA_snooze" />
<Button android:id="@+id/goAway"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="49"
android:textSize="16sp"
android:drawableLeft="@drawable/tango_stop"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:textSize="20sp"
android:textColor="@android:color/white"
android:background="?attr/asThemeTextColor"
android:text="@string/rmd_NoA_goAway" />
<ImageView android:id="@+id/astridIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingRight="15dip"
android:paddingLeft="5dip"
android:src="@drawable/icon_blank" />
</LinearLayout>
</RelativeLayout>

@ -30,6 +30,7 @@
<color name="red_theme_color">#d90000</color>
<color name="tablet_list_bg">#292929</color>
<color name="tablet_list_selected">#101010</color>
<color name="reminder_background">#262626</color>
</resources>

@ -49,10 +49,10 @@
<string name="rmd_NoA_filter">Reminder!</string>
<!-- Reminder: Task was already done -->
<string name="rmd_NoA_done">Already Done!</string>
<string name="rmd_NoA_done">Complete</string>
<!-- Reminder: Snooze button (remind again later) -->
<string name="rmd_NoA_snooze">Snooze...</string>
<string name="rmd_NoA_snooze">Snooze</string>
<!-- Reminder: Cancel reminder -->
<string name="rmd_NoA_goAway">Go Away!</string>

@ -199,6 +199,17 @@
<item name="android:textSize">18sp</item>
<item name="android:background">#323331</item>
</style>
<style name="ReminderDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/reminder_dialog_background</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
</style>
<!--=============================================== TaskListActivity == -->
@ -214,7 +225,7 @@
</style>
<style name="TextAppearance.TLA_Reminder">
<item name="android:textSize">18sp</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">#000000</item>
</style>

@ -1,6 +1,9 @@
package com.todoroo.astrid.activity;
import android.app.Dialog;
import android.app.PendingIntent.CanceledException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -16,6 +19,9 @@ import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.api.IntentFilter;
import com.todoroo.astrid.core.SearchFilter;
import com.todoroo.astrid.reminders.NotificationFragment;
import com.todoroo.astrid.reminders.Notifications;
import com.todoroo.astrid.reminders.ReminderDialog;
import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
@ -42,6 +48,8 @@ public class AstridActivity extends FragmentActivity
protected int fragmentLayout = LAYOUT_SINGLE;
private final ReminderReceiver reminderReceiver = new ReminderReceiver();
public FilterListFragment getFilterListFragment() {
FilterListFragment frag = (FilterListFragment) getSupportFragmentManager()
.findFragmentByTag(FilterListFragment.TAG_FILTERLIST_FRAGMENT);
@ -80,6 +88,20 @@ public class AstridActivity extends FragmentActivity
}
}
@Override
protected void onResume() {
super.onResume();
android.content.IntentFilter intentFilter = new android.content.IntentFilter(Notifications.BROADCAST_IN_APP_NOTIFY);
intentFilter.setPriority(1);
registerReceiver(reminderReceiver, intentFilter);
}
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(reminderReceiver);
}
/**
* Handles items being clicked from the filterlist-fragment. Return true if item is handled.
*/
@ -248,4 +270,22 @@ public class AstridActivity extends FragmentActivity
return fragmentLayout != LAYOUT_SINGLE;
}
private class ReminderReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Process in app notification
Intent customIntent = intent.getExtras().getParcelable(Notifications.EXTRAS_CUSTOM_INTENT);
long taskId = customIntent.getLongExtra(NotificationFragment.TOKEN_ID, 0);
if (taskId > 0) {
String text = intent.getStringExtra(Notifications.EXTRAS_TEXT);
Dialog d = ReminderDialog.createReminderDialog(AstridActivity.this, taskId, text);
d.show();
}
// Remove broadcast
abortBroadcast();
}
}
}

Loading…
Cancel
Save