Awesome shortcuts: 'create new task' anycut shortcut, tag direct shortcuts.

pull/14/head
Tim Su 15 years ago
parent 037dc35c5d
commit c792d99467

@ -13,9 +13,11 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- Activity that displays the task list -->
<activity android:name=".activities.TaskList">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -23,14 +25,32 @@
</intent-filter>
</activity>
<!-- Activity that redirects to a task list, invoked by notifications -->
<activity android:name=".activities.TaskListNotify"
android:launchMode="singleTop" />
<activity android:name=".activities.TaskEdit"
android:label="@string/taskEdit_label"/>
<!-- Activity that creates or edits tasks -->
<activity android:name=".activities.TaskEdit"
android:icon="@drawable/icon_add"
android:label="@string/taskEdit_label">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
<!-- Activity that views tags -->
<activity android:name=".activities.TagView">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
<!-- Activity that lets users edit app preferences -->
<activity android:name=".activities.EditPreferences"/>
<!-- Activity that les users edit synchronization preferences -->
<activity android:name=".activities.SyncPreferences"/>
<!-- Receivers -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

@ -101,6 +101,7 @@
<string name="taskList_titleTagPrefix">Tagged \"%s\": </string>
<string name="taskList_hiddenSuffix"> hidden</string>
<string name="addtask_label">New Task</string>
<string name="missing_tag">Could Not Find Requested Tag!</string>
<!-- text in the actual list -->
<string name="taskList_hiddenPrefix">H</string><!-- prefix to show that a task is hidden -->
@ -227,6 +228,9 @@ If you don\'t want to see the new task right after you complete the old one, you
<string name="tagList_context_delete">Delete Tag</string>
<string name="tagList_context_showTag">Show on Home Page</string>
<string name="tagList_context_hideTag">Hide on Home Page</string>
<string name="tagList_context_shortcut">Create Shortcut</string>
<string name="tagList_shortcut_created">Shortcut created on your home screen!</string>
<string name="tagList_shortcut_prefix">Tag:</string>
<string name="tagList_menu_sortAlpha">Sort A-Z</string>
<string name="tagList_menu_sortSize">Sort by Size</string>

@ -25,12 +25,15 @@ import java.util.LinkedList;
import java.util.List;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.StaleDataException;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
@ -48,6 +51,7 @@ import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
@ -55,7 +59,6 @@ import com.timsu.astrid.R;
import com.timsu.astrid.data.tag.TagIdentifier;
import com.timsu.astrid.data.tag.TagModelForView;
import com.timsu.astrid.data.task.TaskIdentifier;
import com.timsu.astrid.data.task.TaskModelForList;
import com.timsu.astrid.utilities.DialogUtilities;
@ -73,10 +76,10 @@ public class TagListSubActivity extends SubActivity {
private static final int CONTEXT_CREATE_ID = Menu.FIRST + 10;
private static final int CONTEXT_DELETE_ID = Menu.FIRST + 11;
private static final int CONTEXT_SHOWHIDE_ID = Menu.FIRST + 12;
private static final int CONTEXT_SHORTCUT_ID = Menu.FIRST + 13;
private ListView listView;
private LinkedList<TagModelForView> tagArray;
private HashMap<Long, TaskModelForList> taskMap;
HashMap<TagModelForView, Integer> tagToTaskCount;
private Handler handler;
private TextView loadingText;
@ -126,26 +129,13 @@ public class TagListSubActivity extends SubActivity {
// get all tasks
Cursor taskCursor = getTaskController().getActiveTaskListCursor();
startManagingCursor(taskCursor);
List<TaskModelForList> taskArray =
getTaskController().createTaskListFromCursor(taskCursor);
taskMap = new HashMap<Long, TaskModelForList>();
for(TaskModelForList task : taskArray) {
if(task.isHidden())
continue;
taskMap.put(task.getTaskIdentifier().getId(), task);
}
// get accurate task count for each tag
// get task count for each tag
tagToTaskCount = new HashMap<TagModelForView, Integer>();
for(TagModelForView tag : tagArray) {
int count = 0;
List<TaskIdentifier> tasks = getTagController().getTaggedTasks(
LinkedList<TaskIdentifier> tasks = getTagController().getTaggedTasks(
getParent(), tag.getTagIdentifier());
for(TaskIdentifier taskId : tasks)
if(taskMap.containsKey(taskId.getId()))
count++;
tagToTaskCount.put(tag, count);
tagToTaskCount.put(tag, tasks.size());
}
// do sort
@ -240,6 +230,9 @@ public class TagListSubActivity extends SubActivity {
menu.add(position, CONTEXT_SHOWHIDE_ID, Menu.NONE,
showHideLabel);
menu.add(position, CONTEXT_SHORTCUT_ID, Menu.NONE,
R.string.tagList_context_shortcut);
menu.setHeaderTitle(tagArray.get(position).getName());
}
});
@ -332,6 +325,27 @@ public class TagListSubActivity extends SubActivity {
}
fillData();
return true;
case CONTEXT_SHORTCUT_ID:
tag = tagArray.get(item.getGroupId());
Resources r = getResources();
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setComponent(new ComponentName(
getParent().getApplicationContext(), TagView.class));
shortcutIntent.setData(Uri.parse("tag:" + tag.getTagIdentifier().getId()));
Intent createShortcutIntent = new Intent();
createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
String label = tag.getName();
if(tag.shouldHideFromMainList())
label = label.substring(1);
createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON,
((BitmapDrawable)r.getDrawable(R.drawable.icon_tag)).getBitmap());
createShortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getParent().sendBroadcast(createShortcutIntent);
Toast.makeText(getParent(), R.string.tagList_shortcut_created, Toast.LENGTH_SHORT).show();
return true;
}
return false;

@ -0,0 +1,62 @@
/*
* 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.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
/**
* This activity is launched from a desktop shortcut and takes the user to
* view a specific tag
*
* @author timsu
*
*/
public class TagView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
launchTaskList(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
launchTaskList(intent);
}
private void launchTaskList(Intent intent) {
String tag = intent.getData().toString();
long tagId = Long.parseLong(tag.substring(tag.indexOf(":")+1));
Bundle variables = new Bundle();
variables.putLong(TaskListSubActivity.TAG_TOKEN, tagId);
Intent taskListIntent = new Intent(this, TaskList.class);
taskListIntent.putExtra(TaskList.VARIABLES_TAG, variables);
startActivity(taskListIntent);
finish();
}
}

@ -263,6 +263,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
if(name.getText().length() == 0)
return;
// tell the task list to update itself
TaskListSubActivity.shouldRefreshTaskList = true;
model.setName(name.getText().toString());
model.setEstimatedSeconds(estimatedDuration.getTimeDurationInSeconds());
model.setElapsedSeconds(elapsedDuration.getTimeDurationInSeconds());
@ -553,6 +556,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// tell the task list to update itself
TaskListSubActivity.shouldRefreshTaskList = true;
controller.deleteTask(model.getTaskIdentifier());
shouldSaveState = false;
setResult(Constants.RESULT_GO_HOME);

@ -25,7 +25,7 @@ import android.os.Bundle;
/**
* This activity is launched when a user opens up a notification from the
* tray. It launches the appropriate activity based on the passed in parametes.
* tray. It launches the appropriate activity based on the passed in parameters.
*
* @author timsu
*

@ -49,6 +49,7 @@ import android.view.View.OnCreateContextMenuListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.timsu.astrid.R;
import com.timsu.astrid.activities.TaskListAdapter.TaskListAdapterHooks;
@ -123,6 +124,10 @@ public class TaskListSubActivity extends SubActivity {
private View layout;
private TextView loadingText;
// indicator flag set if task list should be refreshed (something changed
// in another activity)
static boolean shouldRefreshTaskList = false;
// other instance variables
class TaskListContext {
Map<TagIdentifier, TagModelForView> tagMap;
@ -194,7 +199,10 @@ public class TaskListSubActivity extends SubActivity {
if(variables != null && variables.containsKey(TAG_TOKEN)) {
TagIdentifier identifier = new TagIdentifier(variables.getLong(TAG_TOKEN));
context.tagMap = getTagController().getAllTagsAsMap(getParent());
context.filterTag = context.tagMap.get(identifier);
if(context.tagMap.containsKey(identifier))
context.filterTag = context.tagMap.get(identifier);
else
Toast.makeText(getParent(), R.string.missing_tag, Toast.LENGTH_SHORT).show();
}
// time to go!
@ -776,6 +784,15 @@ public class TaskListSubActivity extends SubActivity {
context.loadingThread.stop();
}
@Override
void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(shouldRefreshTaskList)
reloadList();
shouldRefreshTaskList = false;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == Constants.RESULT_SYNCHRONIZE) {
@ -792,11 +809,6 @@ public class TaskListSubActivity extends SubActivity {
});
} else if(requestCode == ACTIVITY_TAGS) {
switchToActivity(TaskList.AC_TAG_LIST, null);
} else if((requestCode == ACTIVITY_EDIT || requestCode == ACTIVITY_CREATE) &&
resultCode != Constants.RESULT_DISCARD) {
// refresh, since stuff might have changed...
reloadList();
}
}

Loading…
Cancel
Save