Deleted some unused stuff, made prettier filters

pull/14/head
Tim Su 14 years ago
parent fffc9f4a46
commit 4b85db1e46

@ -21,4 +21,5 @@ public final class Constants {
static final String WHERE = "WHERE";
public static final String EXISTS = "EXISTS";
public static final String NOT = "NOT";
public static final String LIMIT = "LIMIT";
}

@ -2,6 +2,7 @@ package com.todoroo.andlib.sql;
import static com.todoroo.andlib.sql.Constants.COMMA;
import static com.todoroo.andlib.sql.Constants.GROUP_BY;
import static com.todoroo.andlib.sql.Constants.LIMIT;
import static com.todoroo.andlib.sql.Constants.ORDER_BY;
import static com.todoroo.andlib.sql.Constants.SPACE;
import static com.todoroo.andlib.sql.Constants.WHERE;
@ -23,6 +24,7 @@ public final class QueryTemplate {
private final ArrayList<Field> groupBies = new ArrayList<Field>();
private final ArrayList<Order> orders = new ArrayList<Order>();
private final ArrayList<Criterion> havings = new ArrayList<Criterion>();
private Integer limit = null;
public QueryTemplate join(Join... join) {
joins.addAll(asList(join));
@ -51,6 +53,8 @@ public final class QueryTemplate {
visitWhereClause(sql);
visitGroupByClause(sql);
visitOrderByClause(sql);
if(limit != null)
sql.append(LIMIT).append(SPACE).append(limit);
return sql.toString();
}
@ -105,4 +109,9 @@ public final class QueryTemplate {
this.havings.add(criterion);
return this;
}
public QueryTemplate limit(int limitValue) {
this.limit = limitValue;
return this;
}
}

@ -7,7 +7,10 @@ import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import com.timsu.astrid.R;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.QueryTemplate;
@ -30,6 +33,8 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Resources r = context.getResources();
// build filters
FilterListHeader header = new FilterListHeader(ExtendedPlugin.pluginIdentifier,
"Extended");
@ -41,6 +46,14 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
TaskCriteria.isVisible(DateUtilities.now()))).
orderBy(Order.asc(Task.TITLE)),
null);
alphabetical.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_alpha)).getBitmap();
Filter recent = new Filter(ExtendedPlugin.pluginIdentifier,
"Recently Modified",
"Recently Modified",
new QueryTemplate().orderBy(Order.desc(Task.MODIFICATION_DATE)).limit(15),
null);
recent.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_recent)).getBitmap();
ContentValues hiddenValues = new ContentValues();
hiddenValues.put(Task.HIDE_UNTIL.name, DateUtilities.now() + DateUtilities.ONE_DAY);
@ -50,7 +63,8 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
new QueryTemplate().where(Criterion.and(TaskCriteria.isActive(),
Criterion.not(TaskCriteria.isVisible(DateUtilities.now())))).
orderBy(Order.asc(Task.HIDE_UNTIL)),
hiddenValues);
hiddenValues);
hidden.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_hidden)).getBitmap();
Filter deleted = new Filter(ExtendedPlugin.pluginIdentifier,
"Deleted Tasks",
@ -58,13 +72,15 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
new QueryTemplate().where(TaskCriteria.isDeleted()).
orderBy(Order.desc(Task.DELETION_DATE)),
null);
deleted.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_deleted)).getBitmap();
// transmit filter list
FilterListItem[] list = new FilterListItem[4];
FilterListItem[] list = new FilterListItem[5];
list[0] = header;
list[1] = alphabetical;
list[2] = hidden;
list[3] = deleted;
list[2] = recent;
list[3] = hidden;
list[4] = deleted;
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ITEMS, list);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);

@ -7,6 +7,8 @@ import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import com.timsu.astrid.R;
import com.todoroo.andlib.sql.QueryTemplate;
@ -62,6 +64,8 @@ public class FilterExposer extends BroadcastReceiver {
if(tagsByAlpha.length == 0)
return;
Resources r = context.getResources();
Tag[] tagsBySize = tagService.getGroupedTags(TagService.GROUPED_TAGS_BY_SIZE);
Filter[] filtersByAlpha = new Filter[tagsByAlpha.length];
for(int i = 0; i < tagsByAlpha.length; i++)
@ -73,16 +77,25 @@ public class FilterExposer extends BroadcastReceiver {
FilterListHeader tagsHeader = new FilterListHeader(TagsPlugin.IDENTIFIER,
context.getString(R.string.tag_FEx_header));
Filter untagged = new Filter(TagsPlugin.IDENTIFIER,
"Untagged",
"Untagged",
tagService.untaggedTemplate(),
null);
untagged.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_untagged)).getBitmap();
FilterCategory tagsCategoryBySize = new FilterCategory(TagsPlugin.IDENTIFIER,
context.getString(R.string.tag_FEx_by_size), filtersBySize);
tagsCategoryBySize.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_tags1)).getBitmap();
FilterCategory tagsCategoryByAlpha = new FilterCategory(TagsPlugin.IDENTIFIER,
context.getString(R.string.tag_FEx_alpha), filtersByAlpha);
tagsCategoryByAlpha.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_tags2)).getBitmap();
// transmit filter list
FilterListItem[] list = new FilterListItem[3];
FilterListItem[] list = new FilterListItem[4];
list[0] = tagsHeader;
list[1] = tagsCategoryBySize;
list[2] = tagsCategoryByAlpha;
list[1] = untagged;
list[2] = tagsCategoryBySize;
list[3] = tagsCategoryByAlpha;
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ITEMS, list);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);

@ -15,6 +15,7 @@ import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.model.Metadata;
import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.service.MetadataService;
@ -79,6 +80,13 @@ public class TagService {
}
}
public QueryTemplate untaggedTemplate() {
return new QueryTemplate().join(Join.inner(Metadata.TABLE,
Task.ID.eq(Metadata.TASK))).where(Criterion.and(
TaskCriteria.isActive(), MetadataCriteria.withKey(KEY),
Metadata.VALUE.eq(null)));
}
/**
* Return all tags ordered by given clause
*

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Enabled states -->
<item android:state_checked="true" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_on_pressed" />
<item android:state_checked="false" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_off_pressed" />
<item android:state_checked="false"
android:state_enabled="true"
android:drawable="@drawable/btn_check_25" />
<item android:state_checked="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_on" />
</selector>

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Enabled states -->
<item android:state_checked="true" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_on_pressed" />
<item android:state_checked="false" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_off_pressed" />
<item android:state_checked="false"
android:state_enabled="true"
android:drawable="@drawable/btn_check_50" />
<item android:state_checked="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_on" />
</selector>

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
t
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Enabled states -->
<item android:state_checked="true" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_on_pressed" />
<item android:state_checked="false" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_off_pressed" />
<item android:state_checked="false"
android:state_enabled="true"
android:drawable="@drawable/btn_check_75" />
<item android:state_checked="true"
android:state_enabled="true"
android:drawable="@drawable/btn_check_on" />
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 780 B

@ -93,14 +93,14 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
private static Format alarmFormat = null;
private final Activity activity;
private List<TaskModelForList> objects;
private int resource;
private LayoutInflater inflater;
private TaskListAdapterHooks hooks;
private TextView deletedItemView = new TextView(getContext());
private final List<TaskModelForList> objects;
private final int resource;
private final LayoutInflater inflater;
private final TaskListAdapterHooks hooks;
private final TextView deletedItemView = new TextView(getContext());
private Integer fontSizePreference;
private AlertController alarmController;
private final Integer fontSizePreference;
private final AlertController alarmController;
private TaskModelForList recentlyCompleted = null;
@ -734,21 +734,7 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
} else {
name.setPaintFlags(name.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
name.setTextColor(r.getColor(task.getTaskColorResource(getContext())));
float completedPercentage = 0;
if(task.getEstimatedSeconds() > 0) {
completedPercentage = 1.0f * task.getElapsedSeconds() /
task.getEstimatedSeconds();
}
if(completedPercentage < 0.25f)
progress.setButtonDrawable(R.drawable.btn_check0);
else if(completedPercentage < 0.5f)
progress.setButtonDrawable(R.drawable.btn_check25);
else if(completedPercentage < 0.75f)
progress.setButtonDrawable(R.drawable.btn_check50);
else
progress.setButtonDrawable(R.drawable.btn_check75);
progress.setButtonDrawable(R.drawable.btn_check0);
}
}

Loading…
Cancel
Save