mirror of https://github.com/tasks/tasks
Added new layouts for astrid reminders, can get in-app notifications with a popup
parent
44f8c82d9a
commit
aa4359ac7a
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
Loading…
Reference in New Issue