New method of displaying actions after a task reminder - using list items instead of buttons. Trying it out. Also, fixed up vibration to do the right thing and improved the taskkiller warning.

pull/14/head
Tim Su 16 years ago
parent d170341737
commit 0a015c9813

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid" package="com.timsu.astrid"
android:versionCode="124" android:versionName="2.10.3"> android:versionCode="124" android:versionName="2.11.0">
<!-- ============================ Metadata ============================ --> <!-- ============================ Metadata ============================ -->

@ -348,10 +348,10 @@ Error Message:
<string name="information_title">Information</string> <string name="information_title">Information</string>
<string name="question_title">Question</string> <string name="question_title">Question</string>
<string name="done_label">Done</string> <string name="done_label">Done</string>
<string name="notify_yes">View Task</string> <string name="notify_yes">View This Task</string>
<string name="notify_done">Already Done!</string> <string name="notify_done">Already Done!</string>
<string name="notify_snooze">Snooze</string> <string name="notify_snooze">Snooze...</string>
<string name="notify_no">Quit</string> <string name="notify_no">Go Away!</string>
<string name="notify_snooze_title">Hours/minutes to snooze?</string> <string name="notify_snooze_title">Hours/minutes to snooze?</string>
<string name="delete_title">Delete</string> <string name="delete_title">Delete</string>
@ -370,6 +370,14 @@ Some things you may not know about Astrid:\n
\n \n
Thanks for using Astrid!\n Thanks for using Astrid!\n
</string> </string>
<string name="task_killer_help">
It looks like you are using a task killer application! Please add Astrid to
the exclusion list for your task killer. Otherwise, if Astrid gets killed,
it will not let you know when your tasks are due.\n
\n
(note: No Astrid\'s were harmed in making this message.)
</string>
<!-- Locale Plugin --> <!-- Locale Plugin -->
<skip /> <skip />

@ -125,7 +125,9 @@ public class TaskList extends Activity {
if(savedInstanceState != null && savedInstanceState.containsKey(LAST_ACTIVITY_TAG)) { if(savedInstanceState != null && savedInstanceState.containsKey(LAST_ACTIVITY_TAG)) {
viewFlipper.setDisplayedChild(savedInstanceState.getInt(LAST_ACTIVITY_TAG)); viewFlipper.setDisplayedChild(savedInstanceState.getInt(LAST_ACTIVITY_TAG));
variables.putAll(savedInstanceState.getBundle(LAST_BUNDLE_TAG)); Bundle lastBundle = savedInstanceState.getBundle(LAST_BUNDLE_TAG);
if(lastBundle != null)
variables.putAll(lastBundle);
} }
if(getIntent().hasExtra(VARIABLES_TAG)) if(getIntent().hasExtra(VARIABLES_TAG))
variables.putAll(getIntent().getBundleExtra(VARIABLES_TAG)); variables.putAll(getIntent().getBundleExtra(VARIABLES_TAG));

@ -47,7 +47,6 @@ import android.view.View;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener; import android.view.View.OnCreateContextMenuListener;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ListView; import android.widget.ListView;
@ -447,48 +446,38 @@ public class TaskListSubActivity extends SubActivity {
Notifications.clearAllNotifications(getParent(), task Notifications.clearAllNotifications(getParent(), task
.getTaskIdentifier()); .getTaskIdentifier());
String response; String[] strings = new String[] {
if (Preferences.shouldShowNags(getParent())) { r.getString(R.string.notify_yes),
String[] responses = r.getStringArray(R.array.reminder_responses); r.getString(R.string.notify_done),
response = responses[new Random().nextInt(responses.length)]; r.getString(R.string.notify_snooze),
} else r.getString(R.string.notify_no)
response = r.getString(R.string.taskList_nonag_reminder); };
AlertDialog dialog = new AlertDialog.Builder(getParent()).setTitle(
R.string.taskView_notifyTitle).setMessage(
task.getName() + "\n\n" + response).setIcon(
android.R.drawable.ic_dialog_alert)
// yes, i will do it: just closes this dialog
.setPositiveButton(R.string.notify_yes, null)
// no, i will ignore: quits application
.setNegativeButton(R.string.notify_no,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int which) {
TaskList.shouldCloseInstance = true;
closeActivity();
}
})
// snooze: sets a new temporary alert, closes application new AlertDialog.Builder(getParent()).setTitle(
.setNeutralButton(R.string.notify_snooze, task.getName()).setIcon(
new DialogInterface.OnClickListener() { android.R.drawable.ic_dialog_info)
public void onClick(DialogInterface d, int which) { .setSingleChoiceItems(strings, 0, new DialogInterface.OnClickListener() {
snoozeAlert(task, repeatInterval, flags); @Override
} public void onClick(DialogInterface dialog, int which) {
}) switch(which) {
.create(); case 0:
Button button = new Button(getParent()); break;
button.setText(R.string.notify_done); case 1:
button.setOnClickListener(new OnClickListener() { task.setProgressPercentage(TaskModelForList.COMPLETE_PERCENTAGE);
@Override getTaskController().saveTask(task, false);
public void onClick(View arg0) { break;
task.setProgressPercentage(TaskModelForList.COMPLETE_PERCENTAGE); case 2:
getTaskController().saveTask(task, false); snoozeAlert(task, repeatInterval, flags);
} break;
}); case 3:
dialog. addContentView(button, null); TaskList.shouldCloseInstance = true;
dialog.show(); closeActivity();
break;
}
dialog.dismiss();
}
})
.show();
} }
/** /**
@ -591,7 +580,7 @@ public class TaskListSubActivity extends SubActivity {
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
TaskModelForList task = i.next(); final TaskModelForList task = i.next();
if (!filterShowDone) { if (!filterShowDone) {
if (task.isTaskCompleted()) { if (task.isTaskCompleted()) {
@ -687,7 +676,8 @@ public class TaskListSubActivity extends SubActivity {
} catch (final Exception e) { } catch (final Exception e) {
AstridUtilities.reportFlurryError("task-list-error", e); AstridUtilities.reportFlurryError("task-list-error", e);
Log.e("astrid", "Error loading task list", e); Log.e("astrid", "Error loading task list", e);
// DialogUtilities.okDialog(getParent(), "Error loading task list: " + e.getMessage() + ".\n\nOffending line: " + e.getStackTrace()[0], null); DialogUtilities.okDialog(getParent(), "Error loading task list: " + e.getMessage() + ".\n\nOffending line: " + e.getStackTrace()[0], null);
onTaskListLoaded();
return; return;
} }

@ -17,6 +17,7 @@ import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.os.Vibrator;
import android.util.Log; import android.util.Log;
import com.timsu.astrid.R; import com.timsu.astrid.R;
@ -461,9 +462,9 @@ public class Notifications extends BroadcastReceiver {
notification.sound = null; notification.sound = null;
} else { } else {
if (Preferences.shouldVibrate(context) if (Preferences.shouldVibrate(context)
&& audioManager.getVibrateSetting(AudioManager.STREAM_RING) != && audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
AudioManager.VIBRATE_SETTING_OFF) { Vibrator vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
notification.vibrate = new long[] { 2000, 2000, 2000, 2000 }; vibrator.vibrate(new long[] {0, 1000, 500, 1000, 500, 1000}, 0);
} else { } else {
notification.vibrate = null; notification.vibrate = null;
} }

@ -24,6 +24,7 @@ public class Preferences {
private static final String P_SYNC_LAST_SYNC_ATTEMPT = "lastsyncattempt"; private static final String P_SYNC_LAST_SYNC_ATTEMPT = "lastsyncattempt";
private static final String P_LOCALE_LAST_NOTIFY = "locnot"; private static final String P_LOCALE_LAST_NOTIFY = "locnot";
private static final String P_DID_ANDROID_AND_ME_SURVEY = "aamsurvey"; private static final String P_DID_ANDROID_AND_ME_SURVEY = "aamsurvey";
private static final String P_TASK_KILLER_HELP = "taskkiller";
// pref values // pref values
public static final int ICON_SET_PINK = 0; public static final int ICON_SET_PINK = 0;
@ -114,6 +115,18 @@ public class Preferences {
editor.commit(); editor.commit();
} }
/** TaskKillerHelp: whether we should show task killer help */
public static boolean shouldShowTaskKillerHelp(Context context) {
return getPrefs(context).getBoolean(P_TASK_KILLER_HELP, true);
}
/** TaskKillerHelp: whether we should show task killer help */
public static void setShouldShowTaskKillerHelp(Context context, boolean state) {
Editor editor = getPrefs(context).edit();
editor.putBoolean(P_TASK_KILLER_HELP, state);
editor.commit();
}
/** ShowRepeatHelp: whether help dialog should be shown about repeats */ /** ShowRepeatHelp: whether help dialog should be shown about repeats */
public static boolean shouldShowRepeatHelp(Context context) { public static boolean shouldShowRepeatHelp(Context context) {
return getPrefs(context).getBoolean(P_SHOW_REPEAT_HELP, true); return getPrefs(context).getBoolean(P_SHOW_REPEAT_HELP, true);

@ -1,5 +1,8 @@
package com.timsu.astrid.utilities; package com.timsu.astrid.utilities;
import java.util.List;
import android.Manifest;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -59,6 +62,8 @@ public class StartupReceiver extends BroadcastReceiver {
} }
} }
showTaskKillerHelp(context);
Preferences.setCurrentVersion(context, finalVersion); Preferences.setCurrentVersion(context, finalVersion);
} }
@ -81,4 +86,25 @@ public class StartupReceiver extends BroadcastReceiver {
hasStartedUp = true; hasStartedUp = true;
} }
private static void showTaskKillerHelp(final Context context) {
if(!Preferences.shouldShowTaskKillerHelp(context))
return;
// search for task killers. if they exist, show the help!
PackageManager pm = context.getPackageManager();
List<PackageInfo> apps = pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for(PackageInfo app : apps) {
for(String permission : app.requestedPermissions) {
if(Manifest.permission.RESTART_PACKAGES.equals(permission)) {
DialogUtilities.okDialog(context, context.getString(R.string.task_killer_help), new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Preferences.setShouldShowTaskKillerHelp(context, true);
}
});
}
}
}
}
} }

Loading…
Cancel
Save