Give the user the choice of whether to enable Push as they create a new IMAP account.

TODO: explanatory prose underneath
This commit is contained in:
Jesse Vincent 2009-11-16 19:33:01 +00:00
parent 849a1de91e
commit 84ab290046
3 changed files with 52 additions and 8 deletions

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ScrollView
@ -21,11 +21,19 @@
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
/>
/>
<Spinner
android:id="@+id/account_check_frequency"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<CheckBox
android:id="@+id/account_enable_push"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/account_setup_options_enable_push_label"
android:summary="@string/account_setup_options_enable_push_summary"
/>
<TextView
android:text="@string/account_setup_options_mail_display_count_label"
android:layout_height="wrap_content"
@ -60,20 +68,20 @@
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
</ScrollView>
<RelativeLayout
android:layout_marginTop="-54dip"
android:gravity="bottom|right"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:id="@+id/next"
android:text="@string/next_action"
<Button
android:id="@+id/next"
android:text="@string/next_action"
android:layout_width="wrap_content"
android:minWidth="@dimen/button_minWidth"
android:layout_height="wrap_content"
android:drawableRight="@drawable/button_indicator_next"
android:layout_alignParentRight="true"
android:layout_centerVertical="false" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

View File

@ -344,7 +344,11 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android based
<string name="account_setup_options_mail_check_frequency_6hour">Every 6 hours</string>
<string name="account_setup_options_mail_check_frequency_12hour">Every 12 hours</string>
<string name="account_setup_options_mail_check_frequency_24hour">Every 24 hours</string>
<string name="account_setup_options_enable_push_label">Enable server push for this account</string>
<string name="account_setup_options_enable_push_summary">If your server supports it, new messages will appear instantly. This option can dramatically improve or hurt performance.</string>
<string name="account_setup_options_default_label">Send mail from this account by default</string>
<string name="account_setup_options_notify_label">Notify me when mail arrives</string>
<string name="account_setup_options_notify_sync_label">Notify me while mail is being checked</string>

View File

@ -5,6 +5,7 @@ import com.android.email.K9Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
@ -14,6 +15,7 @@ import android.widget.Spinner;
import com.android.email.Account;
import com.android.email.Email;
import com.android.email.Preferences;
import com.android.email.mail.Store;
import com.android.email.R;
public class AccountSetupOptions extends K9Activity implements OnClickListener {
@ -29,6 +31,7 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
private CheckBox mNotifyView;
private CheckBox mNotifySyncView;
private CheckBox mPushEnable;
private Account mAccount;
@ -49,6 +52,7 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
mDefaultView = (CheckBox)findViewById(R.id.account_default);
mNotifyView = (CheckBox)findViewById(R.id.account_notify);
mNotifySyncView = (CheckBox)findViewById(R.id.account_notify_sync);
mPushEnable = (CheckBox)findViewById(R.id.account_enable_push);
findViewById(R.id.next).setOnClickListener(this);
@ -114,6 +118,27 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
.getAutomaticCheckIntervalMinutes());
SpinnerOption.setSpinnerOptionValue(mDisplayCountView, mAccount
.getDisplayCount());
boolean isPushCapable = false;
try
{
Store store = Store.getInstance(mAccount.getStoreUri(), getApplication());
isPushCapable = store.isPushCapable();
}
catch (Exception e)
{
Log.e(Email.LOG_TAG, "Could not get remote store", e);
}
if(!isPushCapable) {
mPushEnable.setVisibility(View.GONE);
} else {
mPushEnable.setChecked(true);
}
}
private void onDone() {
@ -124,6 +149,13 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
.getSelectedItem()).value);
mAccount.setDisplayCount((Integer)((SpinnerOption)mDisplayCountView
.getSelectedItem()).value);
if (mPushEnable.isChecked()) {
mAccount.setFolderPushMode(Account.FolderMode.FIRST_CLASS);
} else {
mAccount.setFolderPushMode(Account.FolderMode.NONE);
}
mAccount.save(Preferences.getPreferences(this));
if (mDefaultView.isChecked()) {
Preferences.getPreferences(this).setDefaultAccount(mAccount);