mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-02 14:02:17 -05:00
Add cloud search icon to local search result screen. Implement pull-to-remote-search.
This commit is contained in:
parent
7631af1572
commit
360b3f1be8
@ -39,4 +39,15 @@
|
|||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textSize="36sp" />
|
android:textSize="36sp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/actionbar_remote_search"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:focusable="false"
|
||||||
|
android:layout_marginRight="3dip"
|
||||||
|
android:background="?attr/iconActionRemoteSearch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/action_remote_search"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,6 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/search_remote"
|
||||||
|
android:icon="?attr/iconActionRemoteSearch"
|
||||||
|
android:showAsAction="always"
|
||||||
|
android:title="@string/action_remote_search"
|
||||||
|
android:visible="false"
|
||||||
|
/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/compose"
|
android:id="@+id/compose"
|
||||||
android:alphabeticShortcut="c"
|
android:alphabeticShortcut="c"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<attr name="iconActionSpam" format="reference" />
|
<attr name="iconActionSpam" format="reference" />
|
||||||
<attr name="iconActionToggleFlag" format="reference" />
|
<attr name="iconActionToggleFlag" format="reference" />
|
||||||
<attr name="iconActionToggleRead" format="reference" />
|
<attr name="iconActionToggleRead" format="reference" />
|
||||||
|
<attr name="iconActionRemoteSearch" format="reference" />
|
||||||
<attr name="iconMenuAdd" format="reference" />
|
<attr name="iconMenuAdd" format="reference" />
|
||||||
<attr name="iconMenuAttachment" format="reference" />
|
<attr name="iconMenuAttachment" format="reference" />
|
||||||
<attr name="iconMenuClear" format="reference" />
|
<attr name="iconMenuClear" format="reference" />
|
||||||
|
@ -1120,8 +1120,7 @@ http://k9mail.googlecode.com/
|
|||||||
|
|
||||||
<string name="image_saved_as">Saved image as \"<xliff:g id="filename">%s</xliff:g>\"</string>
|
<string name="image_saved_as">Saved image as \"<xliff:g id="filename">%s</xliff:g>\"</string>
|
||||||
<string name="image_saving_failed">Saving the image failed.</string>
|
<string name="image_saving_failed">Saving the image failed.</string>
|
||||||
<string name="account_settings_allow_remote_search_label">Allow remote search</string>
|
|
||||||
<string name="account_settings_allow_remote_search_summary">Enable remote searching for this account</string>
|
|
||||||
<string name="account_settings_remote_search_num_results_entries_all">All</string>
|
<string name="account_settings_remote_search_num_results_entries_all">All</string>
|
||||||
<string name="account_settings_remote_search_num_results_entries_10">10</string>
|
<string name="account_settings_remote_search_num_results_entries_10">10</string>
|
||||||
<string name="account_settings_remote_search_num_results_entries_25">25</string>
|
<string name="account_settings_remote_search_num_results_entries_25">25</string>
|
||||||
@ -1130,19 +1129,19 @@ http://k9mail.googlecode.com/
|
|||||||
<string name="account_settings_remote_search_num_results_entries_250">250</string>
|
<string name="account_settings_remote_search_num_results_entries_250">250</string>
|
||||||
<string name="account_settings_remote_search_num_results_entries_500">500</string>
|
<string name="account_settings_remote_search_num_results_entries_500">500</string>
|
||||||
<string name="account_settings_remote_search_num_results_entries_1000">1000</string>
|
<string name="account_settings_remote_search_num_results_entries_1000">1000</string>
|
||||||
<string name="account_settings_remote_search_num_label">Results limit</string>
|
<string name="account_settings_remote_search_num_label">Server search result limit</string>
|
||||||
<string name="search_mode_local_all">All Local Folders</string>
|
<string name="account_settings_remote_search_num_summary">Search will stop after <xliff:g id="num_results">%s</xliff:g> results have been found.</string>
|
||||||
<string name="search_mode_remote">Remote Folder</string>
|
|
||||||
<string name="search_mode_title">Search Location</string>
|
|
||||||
<string name="account_settings_remote_search">Remote folder searching</string>
|
<string name="account_settings_remote_search">Remote folder searching</string>
|
||||||
<string name="account_settings_remote_search_full_text_summary">Can be slow</string>
|
<string name="account_settings_remote_search_full_text">Include body text in server search</string>
|
||||||
<string name="account_settings_remote_search_full_text">Include body text</string>
|
<string name="account_settings_remote_search_full_text_summary">Full text searches can be slow.</string>
|
||||||
<string name="account_settings_allow_remote_search_help">
|
|
||||||
To perform a remote search, press your device\'s Search button while viewing a folder from this account.
|
|
||||||
\n\nNote: Remote search is NOT available from the Unified Inbox or from a list of folders.
|
|
||||||
</string>
|
|
||||||
<string name="remote_search_sending_query">Sending query to server</string>
|
<string name="remote_search_sending_query">Sending query to server</string>
|
||||||
<string name="no_show_again">Don\'t Show Again</string>
|
|
||||||
<string name="remote_search_downloading">Fetching %d results</string>
|
<string name="remote_search_downloading">Fetching %d results</string>
|
||||||
<string name="remote_search_downloading_limited">Fetching %1$d of %2$d results</string>
|
<string name="remote_search_downloading_limited">Fetching %1$d of %2$d results</string>
|
||||||
|
|
||||||
|
<string name="account_settings_search">Search</string>
|
||||||
|
<string name="account_settings_remote_search_enabled">Enable server search</string>
|
||||||
|
<string name="account_settings_remote_search_enabled_summary">Search messages on the server in addition to those on your device</string>
|
||||||
|
<string name="action_remote_search">Search messages on server</string>
|
||||||
|
<string name="pull_to_refresh_remote_search_from_local_search_pull">Pull to search server…</string>
|
||||||
|
<string name="pull_to_refresh_remote_search_from_local_search_release">Release to search server…</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<item name="iconActionSpam">@drawable/ic_action_spam_light</item>
|
<item name="iconActionSpam">@drawable/ic_action_spam_light</item>
|
||||||
<item name="iconActionToggleFlag">@drawable/ic_action_toggle_flag_light</item>
|
<item name="iconActionToggleFlag">@drawable/ic_action_toggle_flag_light</item>
|
||||||
<item name="iconActionToggleRead">@drawable/ic_action_toggle_read_light</item>
|
<item name="iconActionToggleRead">@drawable/ic_action_toggle_read_light</item>
|
||||||
|
<item name="iconActionRemoteSearch">@drawable/ic_action_remote_search_light</item>
|
||||||
<item name="iconMenuAdd">@drawable/ic_menu_add</item>
|
<item name="iconMenuAdd">@drawable/ic_menu_add</item>
|
||||||
<item name="iconMenuAttachment">@drawable/ic_menu_attachment</item>
|
<item name="iconMenuAttachment">@drawable/ic_menu_attachment</item>
|
||||||
<item name="iconMenuClear">@drawable/ic_menu_clear</item>
|
<item name="iconMenuClear">@drawable/ic_menu_clear</item>
|
||||||
@ -67,6 +68,7 @@
|
|||||||
<item name="iconActionSpam">@drawable/ic_action_spam_dark</item>
|
<item name="iconActionSpam">@drawable/ic_action_spam_dark</item>
|
||||||
<item name="iconActionToggleFlag">@drawable/ic_action_toggle_flag_dark</item>
|
<item name="iconActionToggleFlag">@drawable/ic_action_toggle_flag_dark</item>
|
||||||
<item name="iconActionToggleRead">@drawable/ic_action_toggle_read_dark</item>
|
<item name="iconActionToggleRead">@drawable/ic_action_toggle_read_dark</item>
|
||||||
|
<item name="iconActionRemoteSearch">@drawable/ic_action_remote_search_dark</item>
|
||||||
<item name="iconMenuAdd">@drawable/ic_menu_add</item>
|
<item name="iconMenuAdd">@drawable/ic_menu_add</item>
|
||||||
<item name="iconMenuAttachment">@drawable/ic_menu_attachment</item>
|
<item name="iconMenuAttachment">@drawable/ic_menu_attachment</item>
|
||||||
<item name="iconMenuClear">@drawable/ic_menu_clear</item>
|
<item name="iconMenuClear">@drawable/ic_menu_clear</item>
|
||||||
|
@ -462,10 +462,11 @@
|
|||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceScreen android:title="@string/account_settings_remote_search" android:key="remote_search">
|
<PreferenceScreen android:title="@string/account_settings_search" android:key="search">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="account_allow_remote_search"
|
android:key="remote_search_enabled"
|
||||||
android:title="@string/account_settings_allow_remote_search_label"
|
android:title="@string/account_settings_remote_search_enabled"
|
||||||
|
android:summary="@string/account_settings_remote_search_enabled_summary"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
@ -474,14 +475,14 @@
|
|||||||
android:key="account_remote_search_num_results"
|
android:key="account_remote_search_num_results"
|
||||||
android:title="@string/account_settings_remote_search_num_label"
|
android:title="@string/account_settings_remote_search_num_label"
|
||||||
android:dialogTitle="@string/account_settings_remote_search_num_label"
|
android:dialogTitle="@string/account_settings_remote_search_num_label"
|
||||||
android:dependency="account_allow_remote_search"/>
|
android:dependency="remote_search_enabled"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="account_remote_search_full_text"
|
android:key="account_remote_search_full_text"
|
||||||
android:title="@string/account_settings_remote_search_full_text"
|
android:title="@string/account_settings_remote_search_full_text"
|
||||||
android:summary="@string/account_settings_remote_search_full_text_summary"
|
android:summary="@string/account_settings_remote_search_full_text_summary"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:dependency="account_allow_remote_search"/>
|
android:dependency="remote_search_enabled"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ import java.util.Map;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -28,10 +28,8 @@ import android.text.style.ForegroundColorSpan;
|
|||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.GestureDetector;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -926,14 +924,34 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
|||||||
mStars = K9.messageListStars();
|
mStars = K9.messageListStars();
|
||||||
mCheckboxes = K9.messageListCheckboxes();
|
mCheckboxes = K9.messageListCheckboxes();
|
||||||
|
|
||||||
// TODO Add support for pull to fresh on searches.
|
final Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
||||||
if(mQueryString == null) {
|
|
||||||
|
boolean allowRemoteSearch = false;
|
||||||
|
if (mSearchAccount != null) {
|
||||||
|
final Account searchAccount = prefs.getAccount(mSearchAccount);
|
||||||
|
if (searchAccount != null) {
|
||||||
|
allowRemoteSearch = searchAccount.allowRemoteSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mQueryString == null) {
|
||||||
mPullToRefreshView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
|
mPullToRefreshView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
|
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
|
||||||
checkMail(mAccount, mFolderName);
|
checkMail(mAccount, mFolderName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (allowRemoteSearch && !mRemoteSearch && !mIntegrate) {
|
||||||
|
// mQueryString != null is implied if we get this far.
|
||||||
|
mPullToRefreshView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
|
||||||
|
mPullToRefreshView.onRefreshComplete();
|
||||||
|
onRemoteSearchRequested(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mPullToRefreshView.setPullLabel(getString(R.string.pull_to_refresh_remote_search_from_local_search_pull));
|
||||||
|
mPullToRefreshView.setReleaseLabel(getString(R.string.pull_to_refresh_remote_search_from_local_search_release));
|
||||||
} else {
|
} else {
|
||||||
mPullToRefreshView.setMode(PullToRefreshBase.Mode.DISABLED);
|
mPullToRefreshView.setMode(PullToRefreshBase.Mode.DISABLED);
|
||||||
}
|
}
|
||||||
@ -943,7 +961,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
|||||||
//Cancel pending new mail notifications when we open an account
|
//Cancel pending new mail notifications when we open an account
|
||||||
Account[] accountsWithNotification;
|
Account[] accountsWithNotification;
|
||||||
|
|
||||||
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
|
||||||
Account account = getCurrentAccount(prefs);
|
Account account = getCurrentAccount(prefs);
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
@ -1285,44 +1302,47 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
|||||||
AccountSettings.actionSettings(this, mAccount);
|
AccountSettings.actionSettings(this, mAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean onSearchRequested() {
|
* User has requested a remote search. Setup the bundle and start the intent.
|
||||||
|
* @param fromLocalSearch true if this is being called from a local search result screen. This affects
|
||||||
if (mAccount != null && mCurrentFolder != null && mAccount.allowRemoteSearch()) {
|
* where we pull the account and folder info used for the next search.
|
||||||
//if in a remote searchable folder, ask user what they want.
|
*/
|
||||||
//TODO: Add ability to remember selection?
|
public void onRemoteSearchRequested(final boolean fromLocalSearch) {
|
||||||
final CharSequence[] items = new CharSequence[2];
|
final Bundle appData = new Bundle();
|
||||||
items[0] = getString(R.string.search_mode_local_all);
|
if (fromLocalSearch) {
|
||||||
items[1] = getString(R.string.search_mode_remote);
|
appData.putString(EXTRA_SEARCH_ACCOUNT, mSearchAccount);
|
||||||
|
appData.putString(EXTRA_SEARCH_FOLDER, mSearchFolder);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
} else {
|
||||||
builder.setTitle(getString(R.string.search_mode_title));
|
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
|
||||||
|
|
||||||
Bundle appData = null;
|
|
||||||
if (item == 1) {
|
|
||||||
appData = new Bundle();
|
|
||||||
appData.putString(EXTRA_SEARCH_ACCOUNT, mAccount.getUuid());
|
appData.putString(EXTRA_SEARCH_ACCOUNT, mAccount.getUuid());
|
||||||
appData.putString(EXTRA_SEARCH_FOLDER, mCurrentFolder.name);
|
appData.putString(EXTRA_SEARCH_FOLDER, mCurrentFolder.name);
|
||||||
|
}
|
||||||
appData.putBoolean(EXTRA_REMOTE_SEARCH, true);
|
appData.putBoolean(EXTRA_REMOTE_SEARCH, true);
|
||||||
}
|
|
||||||
//else do regular search, which doesn't require any special parameter setup
|
|
||||||
|
|
||||||
|
final Intent intent = new Intent(Intent.ACTION_SEARCH);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.putExtra(SearchManager.QUERY, mQueryString);
|
||||||
|
intent.putExtra(SearchManager.APP_DATA, appData);
|
||||||
|
intent.setComponent(new ComponentName(context.getApplicationContext(), MessageList.class));
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSearchRequested() {
|
||||||
|
// If this search was started from a MessageList of a single folder, pass along that folder info
|
||||||
|
// so that we can enable remote search.
|
||||||
|
if (mAccount != null && mCurrentFolder != null) {
|
||||||
|
final Bundle appData = new Bundle();
|
||||||
|
appData.putString(EXTRA_SEARCH_ACCOUNT, mAccount.getUuid());
|
||||||
|
appData.putString(EXTRA_SEARCH_FOLDER, mCurrentFolder.name);
|
||||||
startSearch(null, false, appData, false);
|
startSearch(null, false, appData, false);
|
||||||
}
|
} else {
|
||||||
});
|
// TODO Handle the case where we're searching from within a search result.
|
||||||
AlertDialog alert = builder.create();
|
|
||||||
alert.show();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
startSearch(null, false, null, false);
|
startSearch(null, false, null, false);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void changeSort(SortType sortType) {
|
private void changeSort(SortType sortType) {
|
||||||
Boolean sortAscending = (mSortType == sortType) ? !mSortAscending : null;
|
Boolean sortAscending = (mSortType == sortType) ? !mSortAscending : null;
|
||||||
changeSort(sortType, sortAscending);
|
changeSort(sortType, sortAscending);
|
||||||
@ -1627,6 +1647,10 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
|||||||
onEditPrefs();
|
onEditPrefs();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case R.id.search_remote: {
|
||||||
|
onRemoteSearchRequested(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mQueryString != null) {
|
if (mQueryString != null) {
|
||||||
@ -1679,6 +1703,21 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
|||||||
menu.findItem(R.id.send_messages).setVisible(false);
|
menu.findItem(R.id.send_messages).setVisible(false);
|
||||||
menu.findItem(R.id.folder_settings).setVisible(false);
|
menu.findItem(R.id.folder_settings).setVisible(false);
|
||||||
menu.findItem(R.id.account_settings).setVisible(false);
|
menu.findItem(R.id.account_settings).setVisible(false);
|
||||||
|
// If this is an explicit local search, show the option to search the cloud.
|
||||||
|
|
||||||
|
final Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
||||||
|
|
||||||
|
boolean allowRemoteSearch = false;
|
||||||
|
if (mSearchAccount != null) {
|
||||||
|
final Account searchAccount = prefs.getAccount(mSearchAccount);
|
||||||
|
if (searchAccount != null) {
|
||||||
|
allowRemoteSearch = searchAccount.allowRemoteSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowRemoteSearch && mQueryString != null && !mRemoteSearch && !mIntegrate && mSearchFolder != null) {
|
||||||
|
menu.findItem(R.id.search_remote).setVisible(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mCurrentFolder != null && mCurrentFolder.name.equals(mAccount.getOutboxFolderName())) {
|
if (mCurrentFolder != null && mCurrentFolder.name.equals(mAccount.getOutboxFolderName())) {
|
||||||
menu.findItem(R.id.check_mail).setVisible(false);
|
menu.findItem(R.id.check_mail).setVisible(false);
|
||||||
|
@ -58,11 +58,12 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
|
|
||||||
private static final int ACTIVITY_MANAGE_IDENTITIES = 2;
|
private static final int ACTIVITY_MANAGE_IDENTITIES = 2;
|
||||||
|
|
||||||
|
private static final String PREFERENCE_SCREEN_MAIN = "main";
|
||||||
private static final String PREFERENCE_SCREEN_COMPOSING = "composing";
|
private static final String PREFERENCE_SCREEN_COMPOSING = "composing";
|
||||||
private static final String PREFERENCE_SCREEN_INCOMING = "incoming_prefs";
|
private static final String PREFERENCE_SCREEN_INCOMING = "incoming_prefs";
|
||||||
private static final String PREFERENCE_SCREEN_PUSH_ADVANCED = "push_advanced";
|
private static final String PREFERENCE_SCREEN_PUSH_ADVANCED = "push_advanced";
|
||||||
private static final String PREFERENCE_SCREEN_NOTIFICATIONS = "notifications";
|
private static final String PREFERENCE_SCREEN_NOTIFICATIONS = "notifications";
|
||||||
private static final String PREFERENCE_SCREEN_REMOTE_SEARCH = "remote_search";
|
private static final String PREFERENCE_SCREEN_SEARCH = "search";
|
||||||
|
|
||||||
private static final String PREFERENCE_DESCRIPTION = "account_description";
|
private static final String PREFERENCE_DESCRIPTION = "account_description";
|
||||||
private static final String PREFERENCE_MARK_MESSAGE_AS_READ_ON_VIEW = "mark_message_as_read_on_view";
|
private static final String PREFERENCE_MARK_MESSAGE_AS_READ_ON_VIEW = "mark_message_as_read_on_view";
|
||||||
@ -112,7 +113,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
private static final String PREFERENCE_CRYPTO_APP = "crypto_app";
|
private static final String PREFERENCE_CRYPTO_APP = "crypto_app";
|
||||||
private static final String PREFERENCE_CRYPTO_AUTO_SIGNATURE = "crypto_auto_signature";
|
private static final String PREFERENCE_CRYPTO_AUTO_SIGNATURE = "crypto_auto_signature";
|
||||||
private static final String PREFERENCE_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt";
|
private static final String PREFERENCE_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt";
|
||||||
private static final String PREFERENCE_ALLOW_REMOTE_SEARCH = "account_allow_remote_search";
|
private static final String PREFERENCE_CLOUD_SEARCH_ENABLED = "cloud_search_enabled";
|
||||||
private static final String PREFERENCE_REMOTE_SEARCH_NUM_RESULTS = "account_remote_search_num_results";
|
private static final String PREFERENCE_REMOTE_SEARCH_NUM_RESULTS = "account_remote_search_num_results";
|
||||||
private static final String PREFERENCE_REMOTE_SEARCH_FULL_TEXT = "account_remote_search_full_text";
|
private static final String PREFERENCE_REMOTE_SEARCH_FULL_TEXT = "account_remote_search_full_text";
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
private boolean mIsPushCapable = false;
|
private boolean mIsPushCapable = false;
|
||||||
private boolean mIsExpungeCapable = false;
|
private boolean mIsExpungeCapable = false;
|
||||||
|
|
||||||
|
private PreferenceScreen mMainScreen;
|
||||||
private PreferenceScreen mComposingScreen;
|
private PreferenceScreen mComposingScreen;
|
||||||
|
|
||||||
private EditTextPreference mAccountDescription;
|
private EditTextPreference mAccountDescription;
|
||||||
@ -177,9 +179,12 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
private ListPreference mCryptoApp;
|
private ListPreference mCryptoApp;
|
||||||
private CheckBoxPreference mCryptoAutoSignature;
|
private CheckBoxPreference mCryptoAutoSignature;
|
||||||
private CheckBoxPreference mCryptoAutoEncrypt;
|
private CheckBoxPreference mCryptoAutoEncrypt;
|
||||||
private CheckBoxPreference mAllowRemoteSearch;
|
|
||||||
|
private PreferenceScreen mSearchScreen;
|
||||||
|
private CheckBoxPreference mCloudSearchEnabled;
|
||||||
private ListPreference mRemoteSearchNumResults;
|
private ListPreference mRemoteSearchNumResults;
|
||||||
private CheckBoxPreference mRemoteSearchFullText;
|
private CheckBoxPreference mRemoteSearchFullText;
|
||||||
|
|
||||||
private ListPreference mLocalStorageProvider;
|
private ListPreference mLocalStorageProvider;
|
||||||
private ListPreference mArchiveFolder;
|
private ListPreference mArchiveFolder;
|
||||||
private ListPreference mDraftsFolder;
|
private ListPreference mDraftsFolder;
|
||||||
@ -213,6 +218,8 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
|
|
||||||
addPreferencesFromResource(R.xml.account_settings_preferences);
|
addPreferencesFromResource(R.xml.account_settings_preferences);
|
||||||
|
|
||||||
|
mMainScreen = (PreferenceScreen) findPreference(PREFERENCE_SCREEN_MAIN);
|
||||||
|
|
||||||
mAccountDescription = (EditTextPreference) findPreference(PREFERENCE_DESCRIPTION);
|
mAccountDescription = (EditTextPreference) findPreference(PREFERENCE_DESCRIPTION);
|
||||||
mAccountDescription.setSummary(mAccount.getDescription());
|
mAccountDescription.setSummary(mAccount.getDescription());
|
||||||
mAccountDescription.setText(mAccount.getDescription());
|
mAccountDescription.setText(mAccount.getDescription());
|
||||||
@ -489,27 +496,30 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// IMAP-specific preferences
|
|
||||||
mAllowRemoteSearch = (CheckBoxPreference) findPreference(PREFERENCE_ALLOW_REMOTE_SEARCH);
|
|
||||||
|
|
||||||
mAllowRemoteSearch.setOnPreferenceChangeListener(
|
// IMAP-specific preferences
|
||||||
|
|
||||||
|
mSearchScreen = (PreferenceScreen) findPreference(PREFERENCE_SCREEN_SEARCH);
|
||||||
|
mCloudSearchEnabled = (CheckBoxPreference) findPreference(PREFERENCE_CLOUD_SEARCH_ENABLED);
|
||||||
|
mRemoteSearchNumResults = (ListPreference) findPreference(PREFERENCE_REMOTE_SEARCH_NUM_RESULTS);
|
||||||
|
mRemoteSearchNumResults.setOnPreferenceChangeListener(
|
||||||
new OnPreferenceChangeListener() {
|
new OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference pref, Object newVal) {
|
public boolean onPreferenceChange(Preference pref, Object newVal) {
|
||||||
if ((Boolean) newVal) {
|
updateRemoteSearchLimit((String)newVal);
|
||||||
showRemoteSearchHelp();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
mRemoteSearchNumResults = (ListPreference) findPreference(PREFERENCE_REMOTE_SEARCH_NUM_RESULTS);
|
);
|
||||||
|
updateRemoteSearchLimit(mRemoteSearchNumResults.getValue());
|
||||||
mRemoteSearchFullText = (CheckBoxPreference) findPreference(PREFERENCE_REMOTE_SEARCH_FULL_TEXT);
|
mRemoteSearchFullText = (CheckBoxPreference) findPreference(PREFERENCE_REMOTE_SEARCH_FULL_TEXT);
|
||||||
|
|
||||||
mPushPollOnConnect = (CheckBoxPreference) findPreference(PREFERENCE_PUSH_POLL_ON_CONNECT);
|
mPushPollOnConnect = (CheckBoxPreference) findPreference(PREFERENCE_PUSH_POLL_ON_CONNECT);
|
||||||
mIdleRefreshPeriod = (ListPreference) findPreference(PREFERENCE_IDLE_REFRESH_PERIOD);
|
mIdleRefreshPeriod = (ListPreference) findPreference(PREFERENCE_IDLE_REFRESH_PERIOD);
|
||||||
mMaxPushFolders = (ListPreference) findPreference(PREFERENCE_MAX_PUSH_FOLDERS);
|
mMaxPushFolders = (ListPreference) findPreference(PREFERENCE_MAX_PUSH_FOLDERS);
|
||||||
if (mIsPushCapable) {
|
if (mIsPushCapable) {
|
||||||
mPushPollOnConnect.setChecked(mAccount.isPushPollOnConnect());
|
mPushPollOnConnect.setChecked(mAccount.isPushPollOnConnect());
|
||||||
|
|
||||||
mAllowRemoteSearch.setChecked(mAccount.allowRemoteSearch());
|
mCloudSearchEnabled.setChecked(mAccount.allowRemoteSearch());
|
||||||
mRemoteSearchNumResults.setValue(Integer.toString(mAccount.getRemoteSearchNumResults()));
|
mRemoteSearchNumResults.setValue(Integer.toString(mAccount.getRemoteSearchNumResults()));
|
||||||
mRemoteSearchFullText.setChecked(mAccount.isRemoteSearchFullText());
|
mRemoteSearchFullText.setChecked(mAccount.isRemoteSearchFullText());
|
||||||
|
|
||||||
@ -552,9 +562,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
PreferenceScreen incomingPrefs = (PreferenceScreen) findPreference(PREFERENCE_SCREEN_INCOMING);
|
PreferenceScreen incomingPrefs = (PreferenceScreen) findPreference(PREFERENCE_SCREEN_INCOMING);
|
||||||
incomingPrefs.removePreference((PreferenceScreen) findPreference(PREFERENCE_SCREEN_PUSH_ADVANCED));
|
incomingPrefs.removePreference((PreferenceScreen) findPreference(PREFERENCE_SCREEN_PUSH_ADVANCED));
|
||||||
incomingPrefs.removePreference((ListPreference) findPreference(PREFERENCE_PUSH_MODE));
|
incomingPrefs.removePreference((ListPreference) findPreference(PREFERENCE_PUSH_MODE));
|
||||||
|
mMainScreen.removePreference(mSearchScreen);
|
||||||
((PreferenceScreen) findPreference("main")).removePreference((PreferenceScreen) findPreference(PREFERENCE_SCREEN_REMOTE_SEARCH));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
|
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
|
||||||
@ -714,31 +722,6 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
handleCryptoAppDependencies();
|
handleCryptoAppDependencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showRemoteSearchHelp() {
|
|
||||||
final String noShowHelpPref = "account_settings_remote_search_hide_help";
|
|
||||||
final SharedPreferences prefs = getPreferences(MODE_PRIVATE);
|
|
||||||
if (!prefs.getBoolean(noShowHelpPref, false)) {
|
|
||||||
AlertDialog.Builder adb = new AlertDialog.Builder(this);
|
|
||||||
final CheckBox noShowAgain = new CheckBox(this);
|
|
||||||
noShowAgain.setChecked(false);
|
|
||||||
noShowAgain.setText(R.string.no_show_again);
|
|
||||||
adb.setView(noShowAgain)
|
|
||||||
.setMessage(getString(R.string.account_settings_allow_remote_search_help))
|
|
||||||
.setCancelable(false)
|
|
||||||
.setPositiveButton(R.string.okay_action, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if(noShowAgain.isChecked()){
|
|
||||||
Editor edit = prefs.edit();
|
|
||||||
edit.putBoolean(noShowHelpPref, true);
|
|
||||||
edit.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
adb.create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleCryptoAppDependencies() {
|
private void handleCryptoAppDependencies() {
|
||||||
if ("".equals(mCryptoApp.getValue())) {
|
if ("".equals(mCryptoApp.getValue())) {
|
||||||
mCryptoAutoSignature.setEnabled(false);
|
mCryptoAutoSignature.setEnabled(false);
|
||||||
@ -812,7 +795,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
mAccount.setPushPollOnConnect(mPushPollOnConnect.isChecked());
|
mAccount.setPushPollOnConnect(mPushPollOnConnect.isChecked());
|
||||||
mAccount.setIdleRefreshMinutes(Integer.parseInt(mIdleRefreshPeriod.getValue()));
|
mAccount.setIdleRefreshMinutes(Integer.parseInt(mIdleRefreshPeriod.getValue()));
|
||||||
mAccount.setMaxPushFolders(Integer.parseInt(mMaxPushFolders.getValue()));
|
mAccount.setMaxPushFolders(Integer.parseInt(mMaxPushFolders.getValue()));
|
||||||
mAccount.setAllowRemoteSearch(mAllowRemoteSearch.isChecked());
|
mAccount.setAllowRemoteSearch(mCloudSearchEnabled.isChecked());
|
||||||
mAccount.setRemoteSearchNumResults(Integer.parseInt(mRemoteSearchNumResults.getValue()));
|
mAccount.setRemoteSearchNumResults(Integer.parseInt(mRemoteSearchNumResults.getValue()));
|
||||||
mAccount.setRemoteSearchFullText(mRemoteSearchFullText.isChecked());
|
mAccount.setRemoteSearchFullText(mRemoteSearchFullText.isChecked());
|
||||||
}
|
}
|
||||||
@ -989,6 +972,20 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
Integer.parseInt(mAccountVibrateTimes.getValue())), -1);
|
Integer.parseInt(mAccountVibrateTimes.getValue())), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remote search result limit summary contains the current limit. On load or change, update this value.
|
||||||
|
* @param maxResults Search limit to update the summary with.
|
||||||
|
*/
|
||||||
|
private void updateRemoteSearchLimit(String maxResults) {
|
||||||
|
if (maxResults != null) {
|
||||||
|
if (maxResults.equals("0")) {
|
||||||
|
maxResults = getString(R.string.account_settings_remote_search_num_results_entries_all);
|
||||||
|
}
|
||||||
|
|
||||||
|
mRemoteSearchNumResults.setSummary(String.format(getString(R.string.account_settings_remote_search_num_summary), maxResults));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class PopulateFolderPrefsTask extends AsyncTask<Void, Void, Void> {
|
private class PopulateFolderPrefsTask extends AsyncTask<Void, Void, Void> {
|
||||||
List <? extends Folder > folders = new LinkedList<LocalFolder>();
|
List <? extends Folder > folders = new LinkedList<LocalFolder>();
|
||||||
String[] allFolderValues;
|
String[] allFolderValues;
|
||||||
|
Loading…
Reference in New Issue
Block a user