New notification popup custom dialog thing. Allows Astrid to provide a reminder message as well as arbitrary number of options.

pull/14/head
Tim Su 15 years ago
parent 160bfc7e15
commit 555d990bdd

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:orientation="vertical">
<TextView android:id="@+id/message"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="5dip" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#888888"
/>
<ListView android:id="@+id/items"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="12sp" />
</LinearLayout>

@ -371,10 +371,11 @@ Some things you may not know about Astrid:\n
Thanks for using Astrid!\n
</string>
<!-- %s => name of the application -->
<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
It looks like you are using an app that can kill processes (%s)! If you can,
add Astrid to the exclusion list so it doesn\'t get killed. Otherwise,
Astrid might not let you know when your tasks are due.\n
</string>
<string name="task_killer_help_ok">I Won\'t Kill Astrid!</string>

@ -29,6 +29,7 @@ import java.util.List;
import java.util.Random;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
@ -41,17 +42,21 @@ import android.os.Handler;
import android.util.Log;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R;
@ -453,31 +458,58 @@ public class TaskListSubActivity extends SubActivity {
r.getString(R.string.notify_no)
};
new AlertDialog.Builder(getParent()).setTitle(
task.getName()).setIcon(
android.R.drawable.ic_dialog_info)
.setSingleChoiceItems(strings, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case 0:
break;
case 1:
task.setProgressPercentage(TaskModelForList.COMPLETE_PERCENTAGE);
getTaskController().saveTask(task, false);
break;
case 2:
snoozeAlert(task, repeatInterval, flags);
break;
case 3:
TaskList.shouldCloseInstance = true;
closeActivity();
break;
}
dialog.dismiss();
String response;
if (Preferences.shouldShowNags(getParent())) {
String[] responses = r.getStringArray(R.array.reminder_responses);
response = responses[new Random().nextInt(responses.length)];
} else
response = r.getString(R.string.taskList_nonag_reminder);
AlertDialog.Builder builder = new AlertDialog.Builder(getParent());
final AlertDialog dialog;
LayoutInflater inflater = (LayoutInflater) getParent().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.notification_dialog, null);
builder.setTitle(task.getName());
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setCancelable(true);
builder.setView(dialogView);
dialog = builder.create();
TextView message = (TextView)dialogView.findViewById(R.id.message);
message.setText(response);
message.setTextSize(18);
ListView items = (ListView)dialogView.findViewById(R.id.items);
items.setAdapter(new ArrayAdapter<String>(getParent(),
android.R.layout.simple_list_item_checked, strings));
items.setFocusableInTouchMode(true);
items.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int which,
long id) {
switch(which) {
case 0:
break;
case 1:
task.setProgressPercentage(TaskModelForList.COMPLETE_PERCENTAGE);
getTaskController().saveTask(task, false);
break;
case 2:
snoozeAlert(task, repeatInterval, flags);
break;
case 3:
TaskList.shouldCloseInstance = true;
closeActivity();
break;
}
})
.show();
dialog.dismiss();
}
});
dialog.show();
}
/**

@ -463,8 +463,7 @@ public class Notifications extends BroadcastReceiver {
} else {
if (Preferences.shouldVibrate(context)
&& audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
Vibrator vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(new long[] {0, 1000, 500, 1000, 500, 1000}, 0);
notification.vibrate = new long[] {0, 1000, 500, 1000, 500, 1000};
} else {
notification.vibrate = null;
}

@ -111,6 +111,7 @@ public class StartupReceiver extends BroadcastReceiver {
continue;
for (String permission : app.requestedPermissions) {
if (Manifest.permission.RESTART_PACKAGES.equals(permission)) {
CharSequence appName = app.applicationInfo.loadLabel(pm);
Log.e("astrid", "found task killer: " + app.packageName);
OnClickListener listener = new OnClickListener() {
@ -124,7 +125,8 @@ public class StartupReceiver extends BroadcastReceiver {
new AlertDialog.Builder(context)
.setTitle(R.string.information_title)
.setMessage(R.string.task_killer_help)
.setMessage(context.getString(R.string.task_killer_help,
appName))
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(R.string.task_killer_help_ok, listener)
.show();

Loading…
Cancel
Save