diff --git a/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java b/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java
index 36d015652..bf652eaa4 100644
--- a/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java
+++ b/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java
@@ -3,11 +3,14 @@ package com.todoroo.astrid.api;
import android.content.ComponentName;
import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import com.todoroo.andlib.sql.QueryTemplate;
+import com.todoroo.astrid.activity.TaskListActivity;
public class FilterWithCustomIntent extends Filter {
@@ -35,6 +38,14 @@ public class FilterWithCustomIntent extends Filter {
super(listingTitle, title, sqlQuery, valuesForNewTasks);
}
+ public void start(Context context) {
+ Intent intent = new Intent();
+ intent.putExtra(TaskListActivity.TOKEN_FILTER, this);
+ intent.setComponent(customTaskList);
+ if(customExtras != null)
+ intent.putExtras(customExtras);
+ context.startActivity(intent);
+ }
// --- parcelable
diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java
index 400c1aa71..c360efcab 100644
--- a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java
+++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java
@@ -66,7 +66,7 @@ public class TagFilterExposer extends BroadcastReceiver {
/** Create filter from new tag object */
@SuppressWarnings("nls")
- public static Filter filterFromTag(Context context, Tag tag, Criterion criterion, boolean useTagViewActivity) {
+ public static FilterWithCustomIntent filterFromTag(Context context, Tag tag, Criterion criterion, boolean useTagViewActivity) {
String listTitle = tag.tag + " (" + tag.count + ")";
String title = context.getString(R.string.tag_FEx_name, tag.tag);
QueryTemplate tagTemplate = tag.queryTemplate(criterion);
@@ -139,8 +139,6 @@ public class TagFilterExposer extends BroadcastReceiver {
addTags(list);
// transmit filter list
- if(list.size() <= 2)
- return;
FilterListItem[] listAsArray = list.toArray(new FilterListItem[list.size()]);
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, listAsArray);
diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagsPlugin.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagsPlugin.java
index 7a3f168fd..5d41a19da 100644
--- a/astrid/plugin-src/com/todoroo/astrid/tags/TagsPlugin.java
+++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagsPlugin.java
@@ -1,16 +1,33 @@
package com.todoroo.astrid.tags;
+import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+import com.timsu.astrid.R;
+import com.todoroo.andlib.service.Autowired;
+import com.todoroo.andlib.service.DependencyInjectionService;
+import com.todoroo.andlib.utility.DialogUtilities;
+import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.api.Addon;
import com.todoroo.astrid.api.AstridApiConstants;
+import com.todoroo.astrid.api.FilterWithCustomIntent;
+import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
+import com.todoroo.astrid.service.TagDataService;
+import com.todoroo.astrid.tags.TagService.Tag;
public class TagsPlugin extends BroadcastReceiver {
static final String IDENTIFIER = "tags"; //$NON-NLS-1$
+ @Autowired TagDataService tagDataService;
+
+ @Autowired ActFmPreferenceService actFmPreferenceService;
+
@SuppressWarnings("nls")
@Override
public void onReceive(Context context, Intent intent) {
@@ -22,4 +39,30 @@ public class TagsPlugin extends BroadcastReceiver {
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
}
+
+ /**
+ * Create new tag data
+ * @param activity
+ */
+ public void showNewTagDialog(final Activity activity) {
+ DependencyInjectionService.getInstance().inject(this);
+
+ FrameLayout frame = new FrameLayout(activity);
+ final EditText editText = new EditText(activity);
+ frame.addView(editText);
+ frame.setPadding(10, 0, 10, 0);
+
+ DialogUtilities.viewDialog(activity,
+ activity.getString(R.string.tag_new_list),
+ frame, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Tag tag = new Tag(editText.getText().toString(), 0, 0);
+ FilterWithCustomIntent filter = TagFilterExposer.filterFromTag(activity,
+ tag, TaskCriteria.isActive(), actFmPreferenceService.isLoggedIn());
+ filter.start(activity);
+ }
+ }, null);
+ }
+
}
diff --git a/astrid/res/values/strings-actfm.xml b/astrid/res/values/strings-actfm.xml
index dd7fc783f..b0a22d366 100644
--- a/astrid/res/values/strings-actfm.xml
+++ b/astrid/res/values/strings-actfm.xml
@@ -29,7 +29,7 @@
Pick from Gallery
- Refresh Tags
+ Refresh Lists
diff --git a/astrid/res/values/strings-tags.xml b/astrid/res/values/strings-tags.xml
index a40f18978..88e229409 100644
--- a/astrid/res/values/strings-tags.xml
+++ b/astrid/res/values/strings-tags.xml
@@ -25,8 +25,14 @@
Show List
+
+ New List Name:
+
+
+ New
+
Lists
diff --git a/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java b/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java
index e8b7ab48b..f22f9d24f 100644
--- a/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java
@@ -229,15 +229,14 @@ public class FilterListActivity extends ExpandableListActivity {
protected boolean onItemClicked(FilterListItem item) {
if(item instanceof Filter) {
Filter filter = (Filter)item;
- Intent intent = new Intent(FilterListActivity.this, TaskListActivity.class);
- intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
if(filter instanceof FilterWithCustomIntent) {
FilterWithCustomIntent customFilter = ((FilterWithCustomIntent)filter);
- intent.setComponent(customFilter.customTaskList);
- if(customFilter.customExtras != null)
- intent.putExtras(customFilter.customExtras);
+ customFilter.start(this);
+ } else {
+ Intent intent = new Intent(FilterListActivity.this, TaskListActivity.class);
+ intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
+ startActivity(intent);
}
- startActivity(intent);
AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$
new Class>[] { Integer.TYPE, Integer.TYPE },
R.anim.slide_left_in, R.anim.slide_left_out);
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
index dd95f2cab..4cb375c07 100644
--- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
@@ -1124,6 +1124,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
}
}
+ @SuppressWarnings("nls")
private void showFilterListActivity() {
Intent intent = new Intent(TaskListActivity.this,
FilterListActivity.class);
diff --git a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java
index ad203e92b..1df13efaf 100644
--- a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java
+++ b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java
@@ -21,6 +21,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
+import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.TextView;
@@ -35,6 +36,7 @@ import com.todoroo.astrid.api.FilterCategory;
import com.todoroo.astrid.api.FilterListHeader;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.service.TaskService;
+import com.todoroo.astrid.tags.TagsPlugin;
public class FilterAdapter extends BaseExpandableListAdapter {
@@ -159,6 +161,7 @@ public class FilterAdapter extends BaseExpandableListAdapter {
viewHolder.icon = (ImageView)convertView.findViewById(R.id.icon);
viewHolder.name = (TextView)convertView.findViewById(R.id.name);
viewHolder.selected = (ImageView)convertView.findViewById(R.id.selected);
+ viewHolder.decoration = null;
convertView.setTag(viewHolder);
}
return convertView;
@@ -171,6 +174,7 @@ public class FilterAdapter extends BaseExpandableListAdapter {
public TextView name;
public ImageView selected;
public View view;
+ public View decoration;
}
/* ======================================================================
@@ -390,6 +394,11 @@ public class FilterAdapter extends BaseExpandableListAdapter {
viewHolder.view.setBackgroundResource(0);
viewHolder.expander.setVisibility(View.GONE);
+ if(viewHolder.decoration != null) {
+ ((ViewGroup)viewHolder.view).removeView(viewHolder.decoration);
+ viewHolder.decoration = null;
+ }
+
if(viewHolder.item instanceof FilterListHeader) {
viewHolder.name.setTextAppearance(activity, headerStyle);
viewHolder.view.setBackgroundResource(R.drawable.edit_titlebar);
@@ -420,6 +429,28 @@ public class FilterAdapter extends BaseExpandableListAdapter {
viewHolder.view.setBackgroundColor(Color.rgb(128, 230, 0));
} else
viewHolder.selected.setVisibility(View.GONE);
+
+ updateForActFm(viewHolder);
+ }
+
+ private void updateForActFm(ViewHolder viewHolder) {
+ if(viewHolder.item instanceof FilterListHeader &&
+ viewHolder.item.listingTitle.equals(activity.getString(R.string.tag_FEx_header))) {
+ Button add = new Button(activity);
+ add.setText(R.string.tag_FEx_add_new);
+ add.setBackgroundColor(Color.TRANSPARENT);
+ add.setTextColor(Color.WHITE);
+ add.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tango_add,0,0,0);
+ viewHolder.decoration = add;
+ ((ViewGroup)viewHolder.view).addView(add);
+
+ add.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new TagsPlugin().showNewTagDialog(activity);
+ }
+ });
+ }
}
}