Merged from 2.9.1

------------------------------------------------------------
Use --include-merges or -n0 to see merged revisions.
pull/14/head
Tim Su 16 years ago
parent 80fca66a3d
commit eb5451ee47

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>astrid-2.9.0</name>
<name>astrid-2.9.1
</name>
<comment></comment>
<projects>
</projects>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid"
android:versionCode="118" android:versionName="2.9.0.1">
android:versionCode="119" android:versionName="2.9.1">
<!-- ============================ Metadata ============================ -->
@ -22,7 +22,8 @@
<!-- ======================== Activities ========================= -->
<!-- Activity that displays the task list -->
<activity android:name=".activities.TaskList">
<activity android:name=".activities.TaskList"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -31,7 +32,7 @@
<!-- Activity that redirects to a task list, invoked by notifications -->
<activity android:name=".activities.TaskListNotify"
android:launchMode="singleTop" />
android:launchMode="singleTop" /> />
<!-- Activity that creates or edits tasks -->
<activity android:name=".activities.TaskEdit"
@ -92,8 +93,19 @@
</intent-filter>
</receiver>
<receiver android:name=".appwidget.AstridAppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_info" />
</receiver>
<!-- ======================== Services ========================== -->
<service android:name=".appwidget.AstridAppWidgetProvider$UpdateService"></service>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Before

Width:  |  Height:  |  Size: 956 B

After

Width:  |  Height:  |  Size: 956 B

Before

Width:  |  Height:  |  Size: 938 B

After

Width:  |  Height:  |  Size: 938 B

Before

Width:  |  Height:  |  Size: 884 B

After

Width:  |  Height:  |  Size: 884 B

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 484 B

After

Width:  |  Height:  |  Size: 484 B

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

Before

Width:  |  Height:  |  Size: 593 B

After

Width:  |  Height:  |  Size: 593 B

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
style="@style/WidgetBackgroundLand">
<ImageButton
android:id="@+id/widget_button"
android:src="@drawable/button_plus"
android:layout_gravity="right"
android:layout_width="100px"
android:layout_height="50px"
android:background="#00000000"
android:paddingLeft="38px"
android:paddingTop="4px"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/task_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/task_name1"
android:singleLine="true"
android:maxWidth="170dip"
style="@style/Text.Loading"
android:layout_marginLeft="23px"/>
<ImageView
android:id="@+id/separator_1"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="170dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
<ImageView
android:id="@+id/separator_2"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="170dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
<ImageView
android:id="@+id/separator_3"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="50px"/>
<TextView
android:id="@+id/task_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="170dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
<ImageView
android:id="@+id/separator_4"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="170dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
</LinearLayout>
</LinearLayout>

@ -33,21 +33,41 @@
<TextView android:id="@+id/loading"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="@string/loading"
style="@style/TextAppearance.TaskList_Task"
android:gravity="center_vertical"/>
<ListView android:id="@+id/tasklist"
android:layout_weight="1"
android:layout_weight="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<Button android:id="@+id/addtask"
android:layout_width="fill_parent"
<!-- Footer -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
android:text="@string/addtask_label"/>
android:layout_weight="1"
android:orientation="horizontal">
<!-- Quick Add Task -->
<EditText android:id="@+id/quickAddText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="100"
android:hint="@string/quick_add_hint"
android:singleLine="true"
android:autoText="true"
android:capitalize="sentences"/>
<!-- Quick Add Button -->
<ImageButton android:id="@+id/quickAddButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@android:drawable/ic_input_add"/>
</LinearLayout>
</LinearLayout>
<!-- tag list -->
@ -80,19 +100,40 @@
<TextView android:id="@+id/loading"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="@string/loading"
style="@style/TextAppearance.TaskList_Task"
android:gravity="center_vertical"/>
<ListView android:id="@+id/tasklist"
android:layout_weight="1"
android:layout_weight="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<Button android:id="@+id/addtask"
android:layout_width="fill_parent"
<!-- Footer -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="@string/addtask_label"/>
android:layout_weight="1"
android:orientation="horizontal">
<!-- Quick Add Task -->
<EditText android:id="@+id/quickAddText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="100"
android:hint="@string/quick_add_hint"
android:singleLine="true"
android:autoText="true"
android:capitalize="sentences"/>
<!-- Quick Add Button -->
<ImageButton android:id="@+id/quickAddButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@android:drawable/ic_input_add"/>
</LinearLayout>
</LinearLayout>
</ViewFlipper>

@ -113,21 +113,21 @@
android:paddingTop="5dip"
android:baselineAligned="false">
<Button android:id="@+id/save"
<Button android:id="@+id/save_general"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save_label"
/>
<Button android:id="@+id/discard"
<Button android:id="@+id/discard_general"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/discard_label"
/>
<Button android:id="@+id/delete"
<Button android:id="@+id/delete_general"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -285,6 +285,34 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:baselineAligned="false">
<Button android:id="@+id/save_dates"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save_label"
/>
<Button android:id="@+id/discard_dates"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/discard_label"
/>
<Button android:id="@+id/delete_dates"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/delete_label"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
@ -347,6 +375,35 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/flag_nonstop"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:baselineAligned="false">
<Button android:id="@+id/save_notify"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save_label"
/>
<Button android:id="@+id/discard_notify"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/discard_label"
/>
<Button android:id="@+id/delete_notify"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/delete_label"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
style="@style/WidgetBackground">
<ImageButton
android:id="@+id/widget_button"
android:src="@drawable/button_plus"
android:layout_gravity="right"
android:layout_width="100px"
android:layout_height="50px"
android:background="#00000000"
android:paddingLeft="36px"
android:paddingTop="6px"/>
<LinearLayout android:id="@+id/taskbody"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/task_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/task_name1"
android:singleLine="true"
android:maxWidth="115dip"
style="@style/Text.Loading"
android:layout_marginLeft="23px"/>
<ImageView
android:id="@+id/separator_1"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="115dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
<ImageView
android:id="@+id/separator_2"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="115dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
<ImageView
android:id="@+id/separator_3"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="115dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
<ImageView
android:id="@+id/separator_4"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/separator"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="4px"/>
<TextView
android:id="@+id/task_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:maxWidth="115dip"
android:text="@string/task_name2"
style="@style/Text.Loading"
android:layout_marginLeft="23px"
android:layout_marginTop="4px"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
style="@style/WidgetBackground">
<ImageButton
android:src="@drawable/button_plus"
android:layout_gravity="right"
android:layout_width="100px"
android:layout_height="50px"
android:background="#00000000"
android:paddingLeft="38px"
android:paddingTop="8px"/>
<TextView
android:id="@+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="37px"
android:padding="10dip"
android:gravity="center"
android:text="@string/widget_loading"
style="@style/Text.Loading" />
</LinearLayout>

@ -161,6 +161,8 @@
<!-- i.e. Deleted: <delete date> -->
<string name="taskList_deleted">Deleted</string>
<string name="quick_add_hint">Add New Task</string>
<!-- menu items -->
<string name="taskList_menu_insert">New Task</string>
<string name="taskList_menu_tags">Tags</string>
@ -458,4 +460,12 @@ Astrid is the highly-acclaimed open-source task list that is simple enough to no
<!-- Automatically filled in by Launchpad: -->
<string name="about_translators">translator-credits</string>
<!-- Widget text: -->
<string name="widget_loading">Loading...</string>
<string name="task_name1">This is a task one</string>
<string name="task_name2">Task two here</string>
<string name="task_name3">This is task number three</string>
<string name="task_name4">The fourth task</string>
<string name="task_name5">Task five this is</string>
</resources>

@ -49,5 +49,20 @@
<item name="android:textStyle">bold</item>
</style>
<style name="WidgetBackground">
<item name="android:background">@drawable/widget_frame_complete</item>
</style>
<style name="WidgetBackgroundLand">
<item name="android:background">@drawable/widget_frame_land</item>
</style>
<style name="Text">
</style>
<style name="Text.Loading">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/black</item>
</style>
</resources>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="142dip"
android:minHeight="142dip"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/widget_loading" />

@ -43,7 +43,9 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
@ -139,6 +141,23 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
private List<TagIdentifier> taskTags;
private int nameEditInputType;
// OnClickListeners for save, discard and delete
private View.OnClickListener mSaveListener = new View.OnClickListener() {
public void onClick(View v) {
saveButtonClick();
}
};
private View.OnClickListener mDiscardListener = new View.OnClickListener() {
public void onClick(View v) {
discardButtonClick();
}
};
private View.OnClickListener mDeleteListener = new View.OnClickListener() {
public void onClick(View v) {
deleteButtonClick();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -449,29 +468,35 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
/** Set up button listeners */
private void setUpListeners() {
Button saveButton = (Button) findViewById(R.id.save);
saveButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
saveButtonClick();
}
});
Button saveButtonGeneral = (Button) findViewById(R.id.save_general);
saveButtonGeneral.setOnClickListener(mSaveListener);
Button discardButton = (Button) findViewById(R.id.discard);
discardButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
discardButtonClick();
}
});
Button saveButtonDates = (Button) findViewById(R.id.save_dates);
saveButtonDates.setOnClickListener(mSaveListener);
Button deleteButton = (Button) findViewById(R.id.delete);
if(model.getTaskIdentifier() == null)
deleteButton.setVisibility(View.GONE);
else {
deleteButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
deleteButtonClick();
}
});
Button saveButtonNotify = (Button) findViewById(R.id.save_notify);
saveButtonNotify.setOnClickListener(mSaveListener);
Button discardButtonGeneral = (Button) findViewById(R.id.discard_general);
discardButtonGeneral.setOnClickListener(mDiscardListener);
Button discardButtonDates = (Button) findViewById(R.id.discard_dates);
discardButtonDates.setOnClickListener(mDiscardListener);
Button discardButtonNotify = (Button) findViewById(R.id.discard_notify);
discardButtonNotify.setOnClickListener(mDiscardListener);
Button deleteButtonGeneral = (Button) findViewById(R.id.delete_general);
Button deleteButtonDates = (Button) findViewById(R.id.delete_dates);
Button deleteButtonNotify = (Button) findViewById(R.id.delete_notify);
if(model.getTaskIdentifier() == null) {
deleteButtonGeneral.setVisibility(View.GONE);
deleteButtonDates.setVisibility(View.GONE);
deleteButtonNotify.setVisibility(View.GONE);
} else {
deleteButtonGeneral.setOnClickListener(mDeleteListener);
deleteButtonDates.setOnClickListener(mDeleteListener);
deleteButtonNotify.setOnClickListener(mDeleteListener);
}
Button addAlertButton = (Button) findViewById(R.id.addAlert);
@ -487,11 +512,11 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
}
});
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
name.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
name.setInputType(nameEditInputType);
name.setOnTouchListener(null);
return false;
}
});
}

@ -20,6 +20,8 @@
package com.timsu.astrid.activities;
import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@ -32,10 +34,12 @@ import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.RemoteViews;
import android.widget.ViewFlipper;
import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R;
import com.timsu.astrid.appwidget.AstridAppWidgetProvider;
import com.timsu.astrid.data.tag.TagController;
import com.timsu.astrid.data.task.TaskController;
import com.timsu.astrid.sync.Synchronizer;
@ -155,9 +159,20 @@ public class TaskList extends Activity {
@Override
protected void onStop() {
super.onStop();
updateWidget();
FlurryAgent.onEndSession(this);
}
private void updateWidget()
{
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
RemoteViews views = AstridAppWidgetProvider.UpdateService.buildUpdate(this);
ComponentName widgetName = new ComponentName(this, AstridAppWidgetProvider.class);
appWidgetManager.updateAppWidget(widgetName, views);
}
/** Set up user interface components */
private void setupUIComponents() {
gestureDetector = new GestureDetector(new AstridGestureDetector());

@ -31,7 +31,6 @@ import java.util.Random;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.StaleDataException;
@ -46,8 +45,9 @@ 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.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
@ -60,6 +60,7 @@ import com.timsu.astrid.data.tag.TagIdentifier;
import com.timsu.astrid.data.tag.TagModelForView;
import com.timsu.astrid.data.task.TaskController;
import com.timsu.astrid.data.task.TaskIdentifier;
import com.timsu.astrid.data.task.TaskModelForEdit;
import com.timsu.astrid.data.task.TaskModelForList;
import com.timsu.astrid.sync.SynchronizationService;
import com.timsu.astrid.sync.Synchronizer;
@ -121,14 +122,12 @@ public class TaskListSubActivity extends SubActivity {
// other constants
private static final int SORTFLAG_FILTERDONE = (1 << 5);
private static final int SORTFLAG_FILTERHIDDEN = (1 << 6);
private static final int HIDE_ADD_BTN_PORTRAIT = 4;
private static final int HIDE_ADD_BTN_LANDSCPE = 2;
private static final float POSTPONE_STAT_PCT = 0.4f;
private static final int AUTO_REFRESH_MAX_LIST_SIZE = 50;
// UI components
private ListView listView;
private Button addButton;
private ImageButton addButton;
private View layout;
private TextView loadingText;
@ -273,10 +272,17 @@ public class TaskListSubActivity extends SubActivity {
listView = (ListView) findViewById(R.id.tasklist);
loadingText = (TextView) findViewById(R.id.loading);
addButton = (Button) findViewById(R.id.addtask);
addButton.setOnClickListener(new View.OnClickListener() {
addButton = (ImageButton) findViewById(R.id.quickAddButton);
addButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
createTask(null);
TextView quickAdd = (TextView)findViewById(R.id.quickAddText);
if(quickAdd.getText().length() > 0) {
quickAddTask(quickAdd.getText().toString());
quickAdd.setText(""); //$NON-NLS-1$
reloadList();
} else {
createTask(null);
}
}
});
@ -291,6 +297,29 @@ public class TaskListSubActivity extends SubActivity {
});
}
/**
* Quick-add a new task
* @param title
* @return
*/
@SuppressWarnings("nls")
protected TaskModelForEdit quickAddTask(String title) {
TaskModelForEdit task = getTaskController().createNewTaskForEdit();
try {
task.setName(title);
getTaskController().saveTask(task, false);
if (context.filterTag != null) {
getTagController().addTag(task.getTaskIdentifier(),
context.filterTag.getTagIdentifier());
}
return task;
} catch (Exception e) {
AstridUtilities.reportFlurryError("quick-add-task", e);
return task;
}
}
@Override
/* Create options menu (displayed when user presses menu key) */
public boolean onPrepareOptionsMenu(Menu menu) {
@ -679,20 +708,6 @@ public class TaskListSubActivity extends SubActivity {
/** Sets up the interface after everything has been loaded */
private void onTaskListLoaded() {
handler.post(new Runnable() {
public void run() {
// hide "add" button if we have too many tasks
int threshold = HIDE_ADD_BTN_PORTRAIT;
if (getParent().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
threshold = HIDE_ADD_BTN_LANDSCPE;
if (context.taskArray.size() > threshold)
addButton.setVisibility(View.GONE);
else
addButton.setVisibility(View.VISIBLE);
}
});
// set up the title
handler.post(new Runnable() {
public void run() {
@ -701,6 +716,8 @@ public class TaskListSubActivity extends SubActivity {
loadingText.setVisibility(View.GONE);
}
});
// Export top N tasks to ContentProvider here TODO
}
class TaskListHooks implements TaskListAdapterHooks {

@ -0,0 +1,121 @@
package com.timsu.astrid.appwidget;
import java.util.ArrayList;
import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;
import com.timsu.astrid.R;
import com.timsu.astrid.activities.TaskEdit;
import com.timsu.astrid.activities.TaskList;
import com.timsu.astrid.data.task.TaskController;
import com.timsu.astrid.data.task.TaskModelForWidget;
public class AstridAppWidgetProvider extends AppWidgetProvider {
private final static String TAG = "TestAppWidgetProvider";
public final static int[] TEXT_IDS = { R.id.task_1, R.id.task_2,
R.id.task_3, R.id.task_4, R.id.task_5 };
public final static int[] SEPARATOR_IDS = { R.id.separator_1,
R.id.separator_2, R.id.separator_3, R.id.separator_4 };
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
Log.e(TAG, "onUpdate()");
// Start in service to prevent Application Not Responding timeout
context.startService(new Intent(context, UpdateService.class));
}
public static class UpdateService extends Service {
@Override
public void onStart(Intent intent, int startId) {
Log.e("UpdateService", "onStart()");
RemoteViews updateViews = buildUpdate(this);
ComponentName thisWidget = new ComponentName(this,
AstridAppWidgetProvider.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(thisWidget, updateViews);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public static RemoteViews buildUpdate(Context context) {
RemoteViews views = null;
views = new RemoteViews(context.getPackageName(),
R.layout.widget_initialized);
int[] textIDs = TEXT_IDS;
int[] separatorIDs = SEPARATOR_IDS;
int numberOfTasks = 5;
TaskController taskController = new TaskController(context);
taskController.open();
ArrayList<TaskModelForWidget> taskList = taskController
.getTasksForWidget(Integer.toString(numberOfTasks));
taskController.close();
Intent listIntent = new Intent(context, TaskList.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
listIntent, 0);
views.setOnClickPendingIntent(R.id.taskbody, pendingIntent);
for (int i = 0; i < textIDs.length; i++) {
TaskModelForWidget taskModel = (i < taskList.size()) ?
taskList.get(i) : null;
String textContent = "";
int textColor = Color.BLACK;
if (taskModel != null) {
textContent = taskModel.getName();
// tweak color if overdue
if((taskModel.getPreferredDueDate() != null && taskModel.getPreferredDueDate().getTime() < System.currentTimeMillis()) ||
(taskModel.getDefiniteDueDate() != null && taskModel.getDefiniteDueDate().getTime() < System.currentTimeMillis()))
textColor = context.getResources().getColor(R.color.task_list_overdue);
}
if (i < separatorIDs.length) {
if (i < taskList.size() - 1 && taskList.get(i + 1) != null) {
views.setViewVisibility(separatorIDs[i], View.VISIBLE);
} else {
views.setViewVisibility(separatorIDs[i],
View.INVISIBLE);
}
}
views.setTextViewText(textIDs[i], textContent);
views.setTextColor(textIDs[i], textColor);
}
Intent editIntent = new Intent(context, TaskEdit.class);
pendingIntent = PendingIntent.getActivity(context, 0,
editIntent, 0);
views.setOnClickPendingIntent(R.id.widget_button, pendingIntent);
return views;
}
}
}

@ -28,6 +28,7 @@ import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
@ -37,6 +38,7 @@ import android.util.Log;
import com.timsu.astrid.activities.TaskEdit;
import com.timsu.astrid.activities.TaskListSubActivity;
import com.timsu.astrid.appwidget.AstridAppWidgetProvider.UpdateService;
import com.timsu.astrid.data.AbstractController;
import com.timsu.astrid.data.alerts.AlertController;
import com.timsu.astrid.data.sync.SyncDataController;
@ -256,6 +258,12 @@ public class TaskController extends AbstractController {
SyncDataController.taskUpdated(context, task);
}
// notify widget that something changed
if(saveSucessful) {
Intent intent = new Intent(context, UpdateService.class);
context.startService(intent);
}
return saveSucessful;
}
@ -501,6 +509,30 @@ public class TaskController extends AbstractController {
alertController.close();
}
public ArrayList<TaskModelForWidget> getTasksForWidget(String limit) {
Cursor cursor = database.query(TASK_TABLE_NAME, TaskModelForList.FIELD_LIST,
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE + " AND (" +
AbstractTaskModel.HIDDEN_UNTIL + " ISNULL OR " + AbstractTaskModel.HIDDEN_UNTIL + " < " +
System.currentTimeMillis() + ")", null, null, null,
AbstractTaskModel.IMPORTANCE + " * " + (3 * 24 * 3600 * 1000L) +
" + CASE WHEN MAX(" + AbstractTaskModel.DEFINITE_DUE_DATE + "," +
AbstractTaskModel.PREFERRED_DUE_DATE + ") = 0 THEN " +
(System.currentTimeMillis() + 7 * 24 * 3600 * 1000L) +
" ELSE MIN(" + AbstractTaskModel.DEFINITE_DUE_DATE + "," +
AbstractTaskModel.PREFERRED_DUE_DATE + ") END", limit);
try {
ArrayList<TaskModelForWidget> list = new ArrayList<TaskModelForWidget>();
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext())
list.add(new TaskModelForWidget(cursor));
return list;
} finally {
cursor.close();
}
}
// --- boilerplate
/**

@ -0,0 +1,71 @@
/*
* ASTRID: Android's Simple Task Recording Dashboard
*
* Copyright (c) 2009 Tim Su
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.timsu.astrid.data.task;
import java.util.Date;
import android.database.Cursor;
import com.timsu.astrid.data.AbstractController;
import com.timsu.astrid.data.enums.Importance;
/** Fields that you would want to see in the TaskView activity */
public class TaskModelForWidget extends AbstractTaskModel {
static String[] FIELD_LIST = new String[] {
AbstractController.KEY_ROWID,
NAME,
IMPORTANCE,
PREFERRED_DUE_DATE,
DEFINITE_DUE_DATE
};
// --- constructors
public TaskModelForWidget(Cursor cursor) {
super(cursor);
prefetchData(FIELD_LIST);
}
// --- getters
@Override
public String getName() {
return super.getName();
}
@Override
public Importance getImportance() {
return super.getImportance();
}
@Override
public Date getPreferredDueDate() {
return super.getPreferredDueDate();
}
@Override
public Date getDefiniteDueDate() {
return super.getDefiniteDueDate();
}
}

@ -20,12 +20,16 @@ public class DialogUtilities {
*/
public static void okDialog(Context context, String text,
DialogInterface.OnClickListener okListener) {
new AlertDialog.Builder(context)
.setTitle(R.string.information_title)
.setMessage(text)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, okListener)
.show();
try {
new AlertDialog.Builder(context)
.setTitle(R.string.information_title)
.setMessage(text)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, okListener)
.show();
} catch (Exception e) {
AstridUtilities.reportFlurryError("show-dialog", e);
}
}
/**
@ -39,13 +43,17 @@ public class DialogUtilities {
public static void okCancelDialog(Context context, String text,
DialogInterface.OnClickListener okListener,
DialogInterface.OnClickListener cancelListener) {
new AlertDialog.Builder(context)
.setTitle(R.string.information_title)
.setMessage(text)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, okListener)
.setNegativeButton(android.R.string.cancel, cancelListener)
.show();
try {
new AlertDialog.Builder(context)
.setTitle(R.string.information_title)
.setMessage(text)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, okListener)
.setNegativeButton(android.R.string.cancel, cancelListener)
.show();
} catch (Exception e) {
AstridUtilities.reportFlurryError("show-dialog", e);
}
}
/**

@ -122,6 +122,30 @@ public class Preferences {
editor.commit();
}
public static boolean is24HourFormat(Context context) {
String value = android.provider.Settings.System.getString(context.getContentResolver(),
android.provider.Settings.System.TIME_12_24);
boolean b24 = !(value == null || value.equals("12"));
return b24;
}
public static String getTimeFormat(Context context) {
if (is24HourFormat(context)) {
return "H:mm";
} else {
return "h:mm a";
}
}
public static String getDateFormat(Context context) {
String value = android.provider.Settings.System.getString(context.getContentResolver(),
android.provider.Settings.System.DATE_FORMAT);
if (value == null) {
value = "MMM d, yyyy";
}
return "EEE, " + value;
}
// --- notification settings
/** returns hour at which quiet hours start, or null if not set */

@ -38,8 +38,8 @@ import com.timsu.astrid.utilities.Preferences;
public class DateControlSet implements OnTimeSetListener,
OnDateSetListener, View.OnClickListener {
private static final Format dateFormatter = new SimpleDateFormat("EEE, MMM d, yyyy");
private static final Format timeFormatter = new SimpleDateFormat("h:mm a");
private Format dateFormatter = null;
private Format timeFormatter = null;
protected final Activity activity;
protected Button dateButton;
@ -48,10 +48,14 @@ public class DateControlSet implements OnTimeSetListener,
protected DateControlSet(Activity activity) {
this.activity = activity;
this.dateFormatter = new SimpleDateFormat(Preferences.getDateFormat(this.activity));
this.timeFormatter = new SimpleDateFormat(Preferences.getTimeFormat(this.activity));
}
public DateControlSet(Activity activity, Button dateButton, Button timeButton) {
this.activity = activity;
this.dateFormatter = new SimpleDateFormat(Preferences.getDateFormat(this.activity));
this.timeFormatter = new SimpleDateFormat(Preferences.getTimeFormat(this.activity));
this.dateButton = dateButton;
this.timeButton = timeButton;
@ -106,7 +110,7 @@ public class DateControlSet implements OnTimeSetListener,
public void onClick(View v) {
if(v == timeButton)
new TimePickerDialog(activity, this, date.getHours(),
date.getMinutes(), false).show();
date.getMinutes(), Preferences.is24HourFormat(activity)).show();
else
new DatePickerDialog(activity, this, 1900 +
date.getYear(), date.getMonth(), date.getDate()).show();

Loading…
Cancel
Save