Temporary UI for setting mailbox sync frequency/lookback

* Just in MessageListXL for now, as with search
* This allows us to test functionality within EAS, and confirm that
  it's all working w/ unbundled Exchange (API 1)

Change-Id: I4f062ae871a28d2b57a23a269d6ec65903181d26
This commit is contained in:
Marc Blank 2011-04-07 13:22:59 -07:00
parent 007d0be4ed
commit d4a1500ae9
3 changed files with 91 additions and 5 deletions

View File

@ -45,4 +45,16 @@
android:title="@string/account_settings_action"
android:icon="@android:drawable/ic_menu_preferences"
/>
<item
android:id="@+id/sync_frequency"
android:orderInCategory="3000"
android:title="@string/mailbox_options_check_frequency_label"
android:icon="@android:drawable/ic_menu_preferences"
/>
<item
android:id="@+id/sync_lookback"
android:orderInCategory="3100"
android:title="@string/mailbox_options_lookback_label"
android:icon="@android:drawable/ic_menu_preferences"
/>
</menu>

View File

@ -1087,4 +1087,10 @@ save attachment.</string>
<string name="search_title">Email</string>
<!-- The hint used in the search EditText field [CHAR LIMIT=35] -->
<string name="search_hint">Search email</string>
<!-- STOPSHIP Temporary UI DO NOT TRANSLATE-->
<!-- In Mailbox setings, label for email check frequency selector -->
<string name="mailbox_options_check_frequency_label">Mailbox check frequency</string>
<!-- In Mailbox setings, label for email check lookback selector -->
<string name="mailbox_options_lookback_label">Mailbox check lookback</string>
</resources>

View File

@ -29,18 +29,22 @@ import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.utility.EmailAsyncTask;
import com.android.emailcommon.utility.Utility;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.LoaderManager.LoaderCallbacks;
import android.app.SearchManager;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
@ -70,6 +74,9 @@ public class MessageListXL extends Activity implements MessageListXLFragmentMana
/* package */ static final int MAILBOX_REFRESH_MIN_INTERVAL = 30 * 1000; // in milliseconds
/* package */ static final int INBOX_AUTO_REFRESH_MIN_INTERVAL = 10 * 1000; // in milliseconds
private static final int MAILBOX_SYNC_FREQUENCY_DIALOG = 1;
private static final int MAILBOX_SYNC_LOOKBACK_DIALOG = 2;
private Context mContext;
private Controller mController;
private RefreshManager mRefreshManager;
@ -502,16 +509,20 @@ public class MessageListXL extends Activity implements MessageListXLFragmentMana
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// STOPSHIP Temporary search UI
// Only show search for EAS
boolean showSearch = false;
// STOPSHIP Temporary search/sync options UI
// Only show search/sync options for EAS
boolean isEas = false;
long accountId = mFragmentManager.getActualAccountId();
if (accountId > 0) {
if ("eas".equals(Account.getProtocol(mContext, accountId))) {
showSearch = true;
isEas = true;
}
}
menu.findItem(R.id.search).setVisible(showSearch);
// Should use an isSearchable call to prevent search on inappropriate accounts/boxes
menu.findItem(R.id.search).setVisible(isEas);
// Should use an isSyncable call to prevent drafts/outbox from allowing this
menu.findItem(R.id.sync_lookback).setVisible(isEas);
menu.findItem(R.id.sync_frequency).setVisible(isEas);
ActivityHelper.updateRefreshMenuIcon(
menu.findItem(R.id.refresh), shouldShowRefreshButton(), isProgressActive());
@ -533,6 +544,57 @@ public class MessageListXL extends Activity implements MessageListXLFragmentMana
return true;
}
// STOPSHIP Set column from user options
private void setMailboxColumn(String column, String value) {
final long mailboxId = mFragmentManager.getMailboxId();
if (mailboxId > 0) {
ContentValues cv = new ContentValues();
cv.put(column, value);
getContentResolver().update(
ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId),
cv, null, null);
onRefresh();
}
}
// STOPSHIP Temporary mailbox settings UI
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case MAILBOX_SYNC_FREQUENCY_DIALOG:
return new AlertDialog.Builder(this)
.setTitle(R.string.mailbox_options_check_frequency_label)
.setItems(R.array.account_settings_check_frequency_entries_push,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String[] items = getResources().getStringArray(
R.array.account_settings_check_frequency_entries_push);
String[] values = getResources().getStringArray(
R.array.account_settings_check_frequency_values_push);
new AlertDialog.Builder(MessageListXL.this)
.setMessage("You selected " + items[which])
.show();
setMailboxColumn(MailboxColumns.SYNC_INTERVAL, values[which]);
}}).create();
case MAILBOX_SYNC_LOOKBACK_DIALOG:
return new AlertDialog.Builder(this)
.setTitle(R.string.mailbox_options_lookback_label)
.setItems(R.array.account_settings_mail_window_entries,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String[] items = getResources().getStringArray(
R.array.account_settings_mail_window_entries);
String[] values = getResources().getStringArray(
R.array.account_settings_mail_window_values);
new AlertDialog.Builder(MessageListXL.this)
.setMessage("You selected " + items[which])
.show();
setMailboxColumn(MailboxColumns.SYNC_LOOKBACK, values[which]);
}}).create();
}
return null;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@ -545,6 +607,12 @@ public class MessageListXL extends Activity implements MessageListXLFragmentMana
case R.id.refresh:
onRefresh();
return true;
case R.id.sync_lookback:
showDialog(MAILBOX_SYNC_LOOKBACK_DIALOG);
return true;
case R.id.sync_frequency:
showDialog(MAILBOX_SYNC_FREQUENCY_DIALOG);
return true;
case R.id.search:
onSearchRequested();
return true;