Merged from 2.9.1
------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.pull/14/head
|
After Width: | Height: | Size: 233 B |
|
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 |
|
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 |
|
After Width: | Height: | Size: 7.1 KiB |
|
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>
|
||||
@ -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>
|
||||
@ -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" />
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||