Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Refine, Clear buttons on actionbar for filter/search results

Closes #111, #131
  • Loading branch information...
commit ee8cb29bfe5f9b1bae247c42a61301aaa7ce3fbb 1 parent 3b1b5a6
@hrayr-artunyan hrayr-artunyan authored ginatrapani committed
View
0  res/drawable-hdpi/ic_subtitle_filter.png → res/drawable-hdpi/ic_actionbar_filter.png
File renamed without changes
View
0  res/drawable-hdpi/ic_subtitle_search.png → res/drawable-hdpi/ic_actionbar_search.png
File renamed without changes
View
2  res/drawable/actionbar_background.xml
@@ -29,7 +29,7 @@ You should have received a copy of the GNU General Public License along with Tod
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
- android:startColor="#ffCCCCCC"
+ android:startColor="#FFCCCCCC"
android:endColor="#FFEEEEEE"
android:angle="270" />
</shape>
View
35 res/layout/main.xml
@@ -32,7 +32,8 @@ You should have received a copy of the GNU General Public License along with Tod
android:id="@+id/home_root"
android:orientation="vertical"
android:layout_width="fill_parent"
- android:layout_height="fill_parent">
+ android:layout_height="fill_parent"
+ android:background="@color/white">
<LinearLayout
style="@style/TitleBar">
@@ -53,25 +54,43 @@ You should have received a copy of the GNU General Public License along with Tod
android:src="@drawable/ic_title_add"
android:onClick="onAddTaskClick" />
</LinearLayout>
- <LinearLayout style="@style/SubTitleBar"
- android:id="@+id/subtitle_bar">
+
+ <LinearLayout style="@style/ActionBar"
+ android:id="@+id/actionbar"
+ android:visibility="gone">
+
<ImageView
- android:id="@+id/subtitle_icon"
+ android:id="@+id/actionbar_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
- android:src="@drawable/ic_subtitle_filter"/>
+ android:src="@drawable/ic_actionbar_filter"/>
<TextView
android:id="@+id/filter_text"
- android:layout_width="fill_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:textColor="@color/subtitle_label" />
- </LinearLayout>
+ android:textColor="@color/actionbar_label" />
+ <View style="@style/TitleBarSpring" />
+
+ <LinearLayout style="@style/ActionBarButtonSet"
+ android:scrollbars="horizontal">
+ <Button style="@style/ActionBarLeftButton"
+ android:text="Refine"
+ android:onClick="onRefineClick" />
+ <ImageView style="@style/ActionBarSeparator" />
+ <ImageView style="@style/ActionBarSeparatorWhite" />
+ <Button style="@style/ActionBarRightButton"
+ android:text="Clear"
+ android:onClick="onClearClick" />
+ </LinearLayout>
+ </LinearLayout>
+ <ImageView style="@style/HorizontalRule" />
+
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
View
2  res/values/colors.xml
@@ -37,10 +37,10 @@ You should have received a copy of the GNU General Public License along with Tod
<color name="white">#FFFFFF</color>
<color name="grey">#888888</color>
<color name="title_separator">#40ffffff</color>
- <color name="subtitle_label">#FF666666</color>
<color name="black_trans">#bb000000</color>
<!-- action bar colors -->
+ <color name="actionbar_label">#FF666666</color>
<color name="actionbar_btn_default_light">#FFFFFFFF</color>
<color name="actionbar_btn_default_dark">#FFCCCCCC</color>
<color name="actionbar_btn_default_stroke">#FFBBBBBB</color>
View
4 res/values/strings.xml
@@ -115,8 +115,8 @@ You should have received a copy of the GNU General Public License along with Tod
<string name="filter_tab_contexts">Contexts</string>
<string name="filter_tab_search">Keywords</string>
<!-- title bar changes -->
- <string name="title_search_results">Search results for: </string>
- <string name="title_filter_applied">Filter applied: </string>
+ <string name="title_search_results">Search term: </string>
+ <string name="title_filter_applied">Filtered by: </string>
<string name="add_task_priority_btn">Priority</string>
<string name="add_task_context_btn">Context</string>
<string name="add_task_project_btn">Project</string>
View
3  src/com/todotxt/todotxttouch/Filter.java
@@ -117,6 +117,8 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View v) {
Log.v(TAG, "onClick OK");
Intent data = new Intent();
+ Log.v(TAG, "Clearing all filter types.");
+ appliedFilters = new ArrayList<String>();
data.putStringArrayListExtra(Constants.EXTRA_PRIORITIES,
getItems(priorities, "Priority"));
data.putStringArrayListExtra(Constants.EXTRA_PROJECTS,
@@ -167,6 +169,7 @@ public void onClick(View v) {
+ " to applied filters.");
if (!appliedFilters.contains(type)) {
appliedFilters.add(type);
+ Log.v(TAG, " Adding " + type + " to applied filter types.");
}
}
}
View
71 src/com/todotxt/todotxttouch/TodoTxtTouch.java
@@ -558,24 +558,7 @@ public boolean onMenuItemSelected(int featureId, MenuItem item) {
startActivityForResult(settingsActivity, REQUEST_PREFERENCES);
break;
case R.id.filter:
- Intent i = new Intent(this, Filter.class);
-
- i.putStringArrayListExtra(Constants.EXTRA_PRIORITIES,
- TaskHelper.getPrios(m_tasks));
- i.putStringArrayListExtra(Constants.EXTRA_PROJECTS,
- TaskHelper.getProjects(m_tasks));
- i.putStringArrayListExtra(Constants.EXTRA_CONTEXTS,
- TaskHelper.getContexts(m_tasks));
-
- i.putStringArrayListExtra(Constants.EXTRA_PRIORITIES_SELECTED,
- m_prios);
- i.putStringArrayListExtra(Constants.EXTRA_PROJECTS_SELECTED,
- m_projects);
- i.putStringArrayListExtra(Constants.EXTRA_CONTEXTS_SELECTED,
- m_contexts);
- i.putExtra(Constants.EXTRA_SEARCH, m_search);
-
- startActivityIfNeeded(i, REQUEST_FILTER);
+ startFilterActivity();
break;
case R.id.sort:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -697,15 +680,30 @@ public void onSyncClick(View v) {
populateFromExternal();
}
+ /** Handle refine filter click **/
+ public void onRefineClick(View v) {
+ startFilterActivity();
+ }
+
+ /** Handle clear filter click **/
+ public void onClearClick(View v) {
+ /* TODO not the best way to do this */
+ clearFilter();
+ setFilteredTasks(false);
+ if (m_search != "") {
+ finish();
+ }
+ }
+
void clearFilter() {
m_prios = new ArrayList<String>(); // Collections.emptyList();
m_contexts = new ArrayList<String>(); // Collections.emptyList();
m_projects = new ArrayList<String>(); // Collections.emptyList();
+ m_filters = new ArrayList<String>();
m_search = "";
}
void setFilteredTasks(boolean reload) {
-
if (reload) {
try {
m_tasks = TodoUtil.loadTasksFromFile();
@@ -737,8 +735,8 @@ void setFilteredTasks(boolean reload) {
}
final TextView filterText = (TextView) findViewById(R.id.filter_text);
- final LinearLayout subtitle_bar = (LinearLayout) findViewById(R.id.subtitle_bar);
- final ImageView subtitle_icon = (ImageView) findViewById(R.id.subtitle_icon);
+ final LinearLayout actionbar = (LinearLayout) findViewById(R.id.actionbar);
+ final ImageView actionbar_icon = (ImageView) findViewById(R.id.actionbar_icon);
if (filterText != null) {
if (m_filters.size() > 0) {
@@ -751,24 +749,24 @@ void setFilteredTasks(boolean reload) {
if (!Strings.isEmptyOrNull(m_search)) {
filterTitle += "Keyword";
}
- subtitle_icon.setImageResource(R.drawable.ic_subtitle_filter);
+ actionbar_icon.setImageResource(R.drawable.ic_actionbar_filter);
- subtitle_bar.setVisibility(View.VISIBLE);
+ actionbar.setVisibility(View.VISIBLE);
filterText.setText(filterTitle);
} else if (!Strings.isEmptyOrNull(m_search)) {
if (filterText != null) {
- subtitle_icon
- .setImageResource(R.drawable.ic_subtitle_search);
+ actionbar_icon
+ .setImageResource(R.drawable.ic_actionbar_search);
filterText.setText(getString(R.string.title_search_results)
+ " " + m_search);
- subtitle_bar.setVisibility(View.VISIBLE);
+ actionbar.setVisibility(View.VISIBLE);
}
} else {
filterText.setText("");
- subtitle_bar.setVisibility(View.GONE);
+ actionbar.setVisibility(View.GONE);
}
}
}
@@ -784,7 +782,7 @@ private void updateRefreshStatus() {
m_app.m_syncing ? View.GONE : View.VISIBLE);
findViewById(R.id.title_refresh_progress).setVisibility(
m_app.m_syncing ? View.VISIBLE : View.GONE);
- findViewById(R.id.subtitle_bar).setVisibility(View.GONE);
+ findViewById(R.id.actionbar).setVisibility(View.GONE);
}
@@ -921,4 +919,21 @@ public void showToast(String string) {
Util.showToastLong(this, string);
}
+ public void startFilterActivity() {
+ Intent i = new Intent(this, Filter.class);
+
+ i.putStringArrayListExtra(Constants.EXTRA_PRIORITIES,
+ TaskHelper.getPrios(m_tasks));
+ i.putStringArrayListExtra(Constants.EXTRA_PROJECTS,
+ TaskHelper.getProjects(m_tasks));
+ i.putStringArrayListExtra(Constants.EXTRA_CONTEXTS,
+ TaskHelper.getContexts(m_tasks));
+
+ i.putStringArrayListExtra(Constants.EXTRA_PRIORITIES_SELECTED, m_prios);
+ i.putStringArrayListExtra(Constants.EXTRA_PROJECTS_SELECTED, m_projects);
+ i.putStringArrayListExtra(Constants.EXTRA_CONTEXTS_SELECTED, m_contexts);
+ i.putExtra(Constants.EXTRA_SEARCH, m_search);
+
+ startActivityIfNeeded(i, REQUEST_FILTER);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.