diff --git a/res/menu/folder_list_option.xml b/res/menu/folder_list_option.xml
index 0e77995b1..6af522cfd 100644
--- a/res/menu/folder_list_option.xml
+++ b/res/menu/folder_list_option.xml
@@ -35,6 +35,11 @@
android:id="@+id/list_folders"
android:title="@string/refresh_folders_action"
android:icon="@drawable/ic_menu_refresh"
+ />
+
diff --git a/res/menu/folder_select_option.xml b/res/menu/folder_select_option.xml
index 968d6c113..8b9d7a240 100644
--- a/res/menu/folder_select_option.xml
+++ b/res/menu/folder_select_option.xml
@@ -31,6 +31,11 @@
android:title="@string/refresh_folders_action"
android:icon="@drawable/ic_menu_refresh"
/>
+
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index b5bab4360..4cf96f6e6 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -71,6 +71,7 @@
Nachricht senden
Ordnerliste
Ordnerliste aktualisieren
+ Finde Ordner
Alle als gelesen markieren
Konto hinzufügen
Verfassen
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3133fb111..1198480fc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -72,6 +72,7 @@
Send messages
Folder list
Refresh folders
+ Find folder
Mark all messages as read
Add account
Compose
diff --git a/src/com/fsck/k9/activity/ChooseFolder.java b/src/com/fsck/k9/activity/ChooseFolder.java
index 2003d7f7d..dc4a88115 100644
--- a/src/com/fsck/k9/activity/ChooseFolder.java
+++ b/src/com/fsck/k9/activity/ChooseFolder.java
@@ -1,9 +1,13 @@
package com.fsck.k9.activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -11,6 +15,7 @@ import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
+import android.widget.EditText;
import android.widget.Filter;
import android.widget.ListView;
import android.widget.TextView;
@@ -196,11 +201,73 @@ public class ChooseFolder extends K9ListActivity {
setDisplayMode(FolderMode.ALL);
return true;
}
+
+ case R.id.list_folders: {
+ onRefresh();
+
+ return true;
+ }
+ case R.id.filter_folders: {
+ onEnterFilter();
+ }
+ return true;
default:
return super.onOptionsItemSelected(item);
}
}
+
+ private void onRefresh() {
+
+ MessagingController.getInstance(getApplication()).listFolders(mAccount, true, mListener);
+
+ }
+
+ /**
+ * Show an alert with an input-field for a filter-expression.
+ * Filter {@link #mAdapter} with the user-input.
+ */
+ private void onEnterFilter() {
+ final AlertDialog.Builder filterAlert = new AlertDialog.Builder(this);
+
+ final EditText input = new EditText(this);
+ input.addTextChangedListener(new TextWatcher() {
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ mAdapter.getFilter().filter(input.getText().toString());
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ });
+ input.setHint(R.string.folder_list_filter_hint);
+ filterAlert.setView(input);
+
+ filterAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ String value = input.getText().toString().trim();
+ mAdapter.getFilter().filter(value);
+ }
+ });
+
+ filterAlert.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ mAdapter.getFilter().filter("");
+ }
+ });
+
+ filterAlert.show();
+
+ }
+
private void setDisplayMode(FolderMode aMode) {
mMode = aMode;
// invalidate the current filter as it is working on an inval
diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java
index 5e0155332..e225c8689 100644
--- a/src/com/fsck/k9/activity/FolderList.java
+++ b/src/com/fsck/k9/activity/FolderList.java
@@ -3,11 +3,14 @@ package com.fsck.k9.activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.Config;
import android.util.Log;
import android.util.TypedValue;
@@ -152,7 +155,6 @@ public class FolderList extends K9ListActivity {
}
}
-
/**
* This class is responsible for reloading the list of local messages for a
* given folder, notifying the adapter that the message have been loaded and
@@ -422,6 +424,51 @@ public class FolderList extends K9ListActivity {
}
+ /**
+ * Show an alert with an input-field for a filter-expression.
+ * Filter {@link #mAdapter} with the user-input.
+ */
+ private void onEnterFilter() {
+ final AlertDialog.Builder filterAlert = new AlertDialog.Builder(this);
+
+ final EditText input = new EditText(this);
+ input.addTextChangedListener(new TextWatcher() {
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ mAdapter.getFilter().filter(input.getText().toString());
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ });
+ input.setHint(R.string.folder_list_filter_hint);
+ filterAlert.setView(input);
+
+ filterAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ String value = input.getText().toString().trim();
+ mAdapter.getFilter().filter(value);
+ }
+ });
+
+ filterAlert.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ mAdapter.getFilter().filter("");
+ }
+ });
+
+ filterAlert.show();
+
+ }
+
private void onEditPrefs() {
Prefs.actionPrefs(this);
}
@@ -504,6 +551,11 @@ public class FolderList extends K9ListActivity {
return true;
+ case R.id.filter_folders:
+ onEnterFilter();
+
+ return true;
+
case R.id.account_settings:
onEditAccount();