diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 87accd564..543e3a012 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -210,7 +210,7 @@ - + diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/NotificationFragment.java b/astrid/plugin-src/com/todoroo/astrid/reminders/NotificationFragment.java index a4a44cd4b..e4183d6ed 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/NotificationFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/NotificationFragment.java @@ -43,7 +43,6 @@ import com.todoroo.astrid.activity.DisposableTaskListFragment; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.repeats.RepeatControlSet; -import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.ui.NumberPicker; @@ -66,13 +65,6 @@ public class NotificationFragment extends DisposableTaskListFragment implements private long taskId; - @Override - public void onCreate(Bundle savedInstanceState) { - StartupService.bypassInitialization(); - - super.onCreate(savedInstanceState); - } - /* (non-Javadoc) * @see com.todoroo.astrid.activity.TaskListActivity#onActivityCreated(android.os.Bundle) */ diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementActivity.java b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementActivity.java deleted file mode 100644 index f967bf09d..000000000 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementActivity.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.todoroo.astrid.reminders; - -import android.app.Activity; -import android.os.Bundle; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.TextView; - -import com.timsu.astrid.R; -import com.todoroo.andlib.service.DependencyInjectionService; -import com.todoroo.andlib.utility.AndroidUtilities; -import com.todoroo.andlib.utility.Preferences; -import com.todoroo.astrid.service.StartupService; -import com.todoroo.astrid.service.ThemeService; - -public class ReengagementActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - new StartupService().onStartupApplication(this); - super.onCreate(savedInstanceState); - DependencyInjectionService.getInstance().inject(this); - - setContentView(R.layout.reengagement_activity); - - setUpUi(); - } - - private void setUpUi() { - View dismiss1 = findViewById(R.id.dismiss); - View dismiss2 = findViewById(R.id.dismiss_button); - OnClickListener dismissListener = new OnClickListener() { - @Override - public void onClick(View v) { - finish(); - AndroidUtilities.callOverridePendingTransition(ReengagementActivity.this, 0, android.R.anim.fade_out); - } - }; - - dismiss1.setOnClickListener(dismissListener); - dismiss2.setOnClickListener(dismissListener); - - TextView seeTasksButton = (TextView) findViewById(R.id.see_tasks_button); - seeTasksButton.setBackgroundColor(getResources().getColor(ThemeService.getThemeColor())); - seeTasksButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - // - } - }); - - - ((TextView) findViewById(R.id.reminder_title)).setText("TITLE"); - - if (!Preferences.getBoolean(R.string.p_rmd_nagging, true)) { - findViewById(R.id.missed_calls_speech_bubble).setVisibility(View.GONE); - } else { - TextView dialogView = (TextView) findViewById(R.id.reminder_message); - dialogView.setText(Notifications.getRandomReminder(getResources().getStringArray(R.array.rmd_reengage_dialog_options))); - } - } - -} diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementFragment.java b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementFragment.java new file mode 100644 index 000000000..696c81160 --- /dev/null +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementFragment.java @@ -0,0 +1,49 @@ +package com.todoroo.astrid.reminders; + +import android.content.res.Resources; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.timsu.astrid.R; +import com.todoroo.astrid.activity.DisposableTaskListFragment; +import com.todoroo.astrid.service.ThemeService; + +public class ReengagementFragment extends DisposableTaskListFragment { + + @Override + protected void initializeData() { + // hide quick add + getView().findViewById(R.id.taskListFooter).setVisibility(View.GONE); + + Resources r = getActivity().getResources(); + + int color = r.getColor(ThemeService.getThemeColor()); + + View snooze = getView().findViewById(R.id.reminder_snooze); + snooze.setBackgroundColor(color); + snooze.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + getActivity().finish(); + } + }); + + TextView reminder = (TextView) getView().findViewById(R.id.reminder_message); + reminder.setText(Notifications.getRandomReminder(r.getStringArray(R.array.rmd_reengage_dialog_options))); + + super.initializeData(); + } + + @Override + protected View getListBody(ViewGroup root) { + ViewGroup parent = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.task_list_body_reengagement, root, false); + + View taskListView = super.getListBody(parent); + parent.addView(taskListView, 0); + + return parent; + } + +} diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementReceiver.java b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementReceiver.java index 3a75ffb68..4e685adda 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementReceiver.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementReceiver.java @@ -1,14 +1,28 @@ package com.todoroo.astrid.reminders; +import android.app.Notification; +import android.app.PendingIntent; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.graphics.Color; +import com.timsu.astrid.R; +import com.todoroo.andlib.service.NotificationManager; +import com.todoroo.andlib.service.NotificationManager.AndroidNotificationManager; +import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.Preferences; +import com.todoroo.astrid.activity.TaskListActivity; +import com.todoroo.astrid.activity.TaskListFragment; +import com.todoroo.astrid.api.FilterWithCustomIntent; +import com.todoroo.astrid.core.SortHelper; +import com.todoroo.astrid.data.TaskApiDao.TaskCriteria; +import com.todoroo.astrid.utility.Constants; public class ReengagementReceiver extends BroadcastReceiver { - + private static final int TASK_LIMIT = 3; @Override public void onReceive(Context context, Intent intent) { @@ -16,9 +30,47 @@ public class ReengagementReceiver extends BroadcastReceiver { int reengagementReminders = Preferences.getInt(ReengagementService.PREF_REENGAGEMENT_COUNT, 1); Preferences.setInt(ReengagementService.PREF_REENGAGEMENT_COUNT, reengagementReminders + 1); - Intent reengagement = new Intent(context, ReengagementActivity.class); - reengagement.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); - context.startActivity(reengagement); + Intent notifIntent = new Intent(context, TaskListActivity.class); + + QueryTemplate template = new QueryTemplate().where(TaskCriteria.activeVisibleMine()); + String sql = SortHelper.adjustQueryForFlagsAndSort(template.toString(), 0, SortHelper.SORT_AUTO) + " LIMIT " + TASK_LIMIT; //$NON-NLS-1$ + + FilterWithCustomIntent filter = new FilterWithCustomIntent(context.getString(R.string.rmd_NoA_filter), + context.getString(R.string.rmd_NoA_filter), + sql, + null); + filter.customTaskList = new ComponentName(context, ReengagementFragment.class); + + notifIntent.setAction("NOTIFY_reengagement"); //$NON-NLS-1$ + notifIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter); + notifIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); + notifIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_REENGAGEMENT); + + String text = context.getString(R.string.rmd_reengage_notif); + NotificationManager manager = new AndroidNotificationManager(context); + Notification notification = new Notification(R.drawable.notif_astrid, + text, System.currentTimeMillis()); + + PendingIntent pendingIntent = PendingIntent.getActivity(context, + 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); + + notification.setLatestEventInfo(context, + "", //$NON-NLS-1$ + text, + pendingIntent); + + notification.flags |= Notification.FLAG_AUTO_CANCEL; + if(Preferences.getBoolean(R.string.p_rmd_persistent, true)) { + notification.flags |= Notification.FLAG_NO_CLEAR | + Notification.FLAG_SHOW_LIGHTS; + notification.ledOffMS = 5000; + notification.ledOnMS = 700; + notification.ledARGB = Color.YELLOW; + } else { + notification.defaults = Notification.DEFAULT_LIGHTS; + } + + manager.notify(0, notification); ReengagementService.scheduleReengagementAlarm(context); } diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java index 6b6a1cde5..632f1352c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java @@ -31,9 +31,9 @@ public final class ReengagementService { int reengagementReminders = Preferences.getInt(PREF_REENGAGEMENT_COUNT, 1); int days; if (reengagementReminders >= 4) - days = 12; + days = 8; else - days = 3 * reengagementReminders; + days = 2 * reengagementReminders; return DateUtilities.now() + DateUtilities.ONE_DAY * days; } diff --git a/astrid/res/drawable-hdpi/speech_bubble_reminder.9.png b/astrid/res/drawable-hdpi/speech_bubble_reminder.9.png index aa29d212e..50b1902ef 100644 Binary files a/astrid/res/drawable-hdpi/speech_bubble_reminder.9.png and b/astrid/res/drawable-hdpi/speech_bubble_reminder.9.png differ diff --git a/astrid/res/drawable/speech_bubble_reminder.9.png b/astrid/res/drawable/speech_bubble_reminder.9.png index aa29d212e..50b1902ef 100644 Binary files a/astrid/res/drawable/speech_bubble_reminder.9.png and b/astrid/res/drawable/speech_bubble_reminder.9.png differ diff --git a/astrid/res/layout/astrid_reengagement_view.xml b/astrid/res/layout/astrid_reengagement_view.xml deleted file mode 100644 index c88db9640..000000000 --- a/astrid/res/layout/astrid_reengagement_view.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/astrid/res/layout/reengagement_activity.xml b/astrid/res/layout/reengagement_activity.xml deleted file mode 100644 index ebe33d588..000000000 --- a/astrid/res/layout/reengagement_activity.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/astrid/res/layout/task_list_body_reengagement.xml b/astrid/res/layout/task_list_body_reengagement.xml new file mode 100644 index 000000000..f96b95c19 --- /dev/null +++ b/astrid/res/layout/task_list_body_reengagement.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + +