1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

Issue 17: Hierarchical folder list / folder tree

This commit is contained in:
mwolschon 2011-12-15 10:34:29 +01:00
parent de9d934b89
commit 2bfe1f4533
6 changed files with 132 additions and 1 deletions

View File

@ -35,6 +35,11 @@
android:id="@+id/list_folders"
android:title="@string/refresh_folders_action"
android:icon="@drawable/ic_menu_refresh"
/>
<item
android:id="@+id/filter_folders"
android:title="@string/filter_folders_action"
android:icon="@drawable/ic_menu_search"
/>
</menu>

View File

@ -31,6 +31,11 @@
android:title="@string/refresh_folders_action"
android:icon="@drawable/ic_menu_refresh"
/>
<item
android:id="@+id/filter_folders"
android:title="@string/filter_folders_action"
android:icon="@drawable/ic_menu_search"
/>
<!-- </menu>
</item>-->

View File

@ -71,6 +71,7 @@
<string name="send_messages_action">Nachricht senden</string>
<string name="list_folders_action">Ordnerliste</string>
<string name="refresh_folders_action">Ordnerliste aktualisieren</string>
<string name="filter_folders_action">Finde Ordner</string>
<string name="mark_all_as_read_action">Alle als gelesen markieren</string>
<string name="add_account_action">Konto hinzufügen</string>
<string name="compose_action">Verfassen</string>

View File

@ -72,6 +72,7 @@
<string name="send_messages_action">Send messages</string>
<string name="list_folders_action">Folder list</string>
<string name="refresh_folders_action">Refresh folders</string>
<string name="filter_folders_action">Find folder</string>
<string name="mark_all_as_read_action">Mark all messages as read</string>
<string name="add_account_action">Add account</string>
<string name="compose_action">Compose</string>

View File

@ -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

View File

@ -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();