Copy updates, more reengagement strings

pull/14/head
Sam Bosley 13 years ago
parent 40a26ab405
commit b66377901a

@ -12,6 +12,8 @@ import com.todoroo.astrid.service.ThemeService;
public class ReengagementFragment extends DisposableTaskListFragment {
public static final String EXTRA_TEXT = "dialogText"; //$NON-NLS-1$
@Override
protected void initializeData() {
// hide quick add
@ -25,7 +27,6 @@ public class ReengagementFragment extends DisposableTaskListFragment {
snooze.setBackgroundColor(r.getColor(ThemeService.getThemeColor()));
TextView reminder = (TextView) getView().findViewById(R.id.reminder_message);
if (taskAdapter.getCount() == 0) {
reminder.setText(Notifications.getRandomReminder(r.getStringArray(R.array.rmd_reengage_dialog_empty_options)));
snooze.setText(R.string.rmd_reengage_add_tasks);
snooze.setOnClickListener(new OnClickListener() {
@Override
@ -34,7 +35,6 @@ public class ReengagementFragment extends DisposableTaskListFragment {
}
});
} else {
reminder.setText(Notifications.getRandomReminder(r.getStringArray(R.array.rmd_reengage_dialog_options)));
snooze.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@ -42,6 +42,8 @@ public class ReengagementFragment extends DisposableTaskListFragment {
}
});
}
reminder.setText(extras.getString(EXTRA_TEXT));
}
@Override

@ -1,5 +1,7 @@
package com.todoroo.astrid.reminders;
import org.json.JSONObject;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@ -7,27 +9,41 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.NotificationManager;
import com.todoroo.andlib.service.NotificationManager.AndroidNotificationManager;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
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.Task;
import com.todoroo.astrid.data.TaskApiDao.TaskCriteria;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.ABTests;
import com.todoroo.astrid.utility.Constants;
public class ReengagementReceiver extends BroadcastReceiver {
@Autowired ActFmPreferenceService actFmPreferenceService;
@Autowired TaskService taskService;
private static final int TASK_LIMIT = 3;
@Override
public void onReceive(Context context, Intent intent) {
DependencyInjectionService.getInstance().inject(this);
if (ABChooser.readChoiceForTest(ABTests.AB_TEST_REENGAGEMENT_ENABLED) == 0)
return;
@ -39,18 +55,45 @@ public class ReengagementReceiver extends BroadcastReceiver {
QueryTemplate template = new QueryTemplate().where(TaskCriteria.activeVisibleMine());
String sql = SortHelper.adjustQueryForFlagsAndSort(template.toString(), 0, SortHelper.SORT_AUTO) + " LIMIT " + TASK_LIMIT; //$NON-NLS-1$
boolean hasTasks = false;
TodorooCursor<Task> tasks = taskService.query(Query.select(Task.ID).where(TaskCriteria.activeVisibleMine()).limit(TASK_LIMIT));
try {
hasTasks = tasks.getCount() > 0;
} finally {
tasks.close();
}
String title = Notifications.getRandomReminder(context.getResources().getStringArray(R.array.rmd_reengage_notif_titles));
if (title.contains("%s")) { //$NON-NLS-1$
String name = ""; //$NON-NLS-1$
if (actFmPreferenceService.isLoggedIn()) {
JSONObject thisUser = ActFmPreferenceService.thisUser();
name = thisUser.optString("first_name"); //$NON-NLS-1$
if (TextUtils.isEmpty(name))
name = thisUser.optString("name"); //$NON-NLS-1$
if (TextUtils.isEmpty(name))
name = context.getString(R.string.rmd_reengage_name_default);
}
title = String.format(title, name);
}
String text = Notifications.getRandomReminder(context.getResources().getStringArray(hasTasks ? R.array.rmd_reengage_dialog_options : R.array.rmd_reengage_dialog_empty_options));
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);
filter.customExtras = new Bundle();
filter.customExtras.putString(ReengagementFragment.EXTRA_TEXT, text);
notifIntent.setAction("NOTIFY_reengagement"); //$NON-NLS-1$
notifIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter);
notifIntent.putExtra(ReengagementFragment.EXTRA_TEXT, text);
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());
@ -59,7 +102,7 @@ public class ReengagementReceiver extends BroadcastReceiver {
0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context,
"", //$NON-NLS-1$
title,
text,
pendingIntent);

@ -62,18 +62,36 @@
<!-- ==================================================== user reengagement == -->
<string name="rmd_reengage_notif">Here are some tasks you might have missed!</string>
<string-array name="rmd_reengage_notif_titles">
<item>A note from Astrid</item>
<item>Memo for %s.</item> <!-- %s -> first name -->
<item>Your Astrid digest</item>
<item>Reminders from Astrid</item>
</string-array>
<string name="rmd_reengage_name_default">you</string>
<string name="rmd_reengage_snooze">Snooze all</string>
<string name="rmd_reengage_add_tasks">Add a task</string>
<string-array name="rmd_reengage_dialog_options">
<item>Time to shorten your to-do list!</item>
<item>Time to shorten your to-do list!</item>
<item>Dear sir or madam, some tasks await your inspection!</item>
<item>Hi there, could you take a look at these?</item>
<item>I\'ve got some tasks with your name on them!</item>
<item>A fresh batch of tasks for you today!</item>
<item>You look fabulous! Ready to get started?</item>
<item>A lovely day for getting some work done, I think!</item>
</string-array>
<string-array name="rmd_reengage_dialog_empty_options">
<item>Don\'t you want to get organized?</item>
<item>Don\'t you want to get organized?</item>
<item>I\'m Astrid! I\'m here to help you do more!</item>
<item>You look busy! Let me take some of those tasks off of your plate.</item>
<item>I can help you keep track of all of the details in your life.</item>
<item>You\'re serious about getting more done? So am I!</item>
<item>Pleasure to make your acquaintance!</item>
</string-array>
<!-- ============================================= reminder preferences == -->

Loading…
Cancel
Save