mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-26 01:28:50 -05:00
Merge pull request #108 from MarcusWolschon/master
Allow filtering in folder-list with Android 4 devices (no menu key anymore)
This commit is contained in:
commit
6cce0dfdea
@ -35,6 +35,11 @@
|
|||||||
android:id="@+id/list_folders"
|
android:id="@+id/list_folders"
|
||||||
android:title="@string/refresh_folders_action"
|
android:title="@string/refresh_folders_action"
|
||||||
android:icon="@drawable/ic_menu_refresh"
|
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>
|
</menu>
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
android:title="@string/refresh_folders_action"
|
android:title="@string/refresh_folders_action"
|
||||||
android:icon="@drawable/ic_menu_refresh"
|
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>
|
<!-- </menu>
|
||||||
</item>-->
|
</item>-->
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
<string name="send_messages_action">Nachricht senden</string>
|
<string name="send_messages_action">Nachricht senden</string>
|
||||||
<string name="list_folders_action">Ordnerliste</string>
|
<string name="list_folders_action">Ordnerliste</string>
|
||||||
<string name="refresh_folders_action">Ordnerliste aktualisieren</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="mark_all_as_read_action">Alle als gelesen markieren</string>
|
||||||
<string name="add_account_action">Konto hinzufügen</string>
|
<string name="add_account_action">Konto hinzufügen</string>
|
||||||
<string name="compose_action">Verfassen</string>
|
<string name="compose_action">Verfassen</string>
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
<string name="send_messages_action">Send messages</string>
|
<string name="send_messages_action">Send messages</string>
|
||||||
<string name="list_folders_action">Folder list</string>
|
<string name="list_folders_action">Folder list</string>
|
||||||
<string name="refresh_folders_action">Refresh folders</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="mark_all_as_read_action">Mark all messages as read</string>
|
||||||
<string name="add_account_action">Add account</string>
|
<string name="add_account_action">Add account</string>
|
||||||
<string name="compose_action">Compose</string>
|
<string name="compose_action">Compose</string>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
|
||||||
package com.fsck.k9.activity;
|
package com.fsck.k9.activity;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -11,6 +15,7 @@ import android.view.View;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -196,11 +201,73 @@ public class ChooseFolder extends K9ListActivity {
|
|||||||
setDisplayMode(FolderMode.ALL);
|
setDisplayMode(FolderMode.ALL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case R.id.list_folders: {
|
||||||
|
onRefresh();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case R.id.filter_folders: {
|
||||||
|
onEnterFilter();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
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) {
|
private void setDisplayMode(FolderMode aMode) {
|
||||||
mMode = aMode;
|
mMode = aMode;
|
||||||
// invalidate the current filter as it is working on an inval
|
// invalidate the current filter as it is working on an inval
|
||||||
|
@ -3,11 +3,14 @@ package com.fsck.k9.activity;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
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
|
* 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
|
* 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() {
|
private void onEditPrefs() {
|
||||||
Prefs.actionPrefs(this);
|
Prefs.actionPrefs(this);
|
||||||
}
|
}
|
||||||
@ -504,6 +551,11 @@ public class FolderList extends K9ListActivity {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case R.id.filter_folders:
|
||||||
|
onEnterFilter();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
case R.id.account_settings:
|
case R.id.account_settings:
|
||||||
onEditAccount();
|
onEditAccount();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user