Convert Controller to a full service
Change-Id: I2078fd047ff46f85936c8bf798a5edd3678bb5b4
This commit is contained in:
parent
a14a24a5bc
commit
0e6d972641
|
@ -277,9 +277,10 @@
|
||||||
>
|
>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service
|
<!-- Controller runs at all times -->
|
||||||
|
--><service
|
||||||
android:name=".Controller"
|
android:name=".Controller"
|
||||||
android:enabled="false"
|
android:enabled="true"
|
||||||
>
|
>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.email;
|
package com.android.email;
|
||||||
|
|
||||||
|
import com.android.email.activity.Debug;
|
||||||
import com.android.email.mail.AuthenticationFailedException;
|
import com.android.email.mail.AuthenticationFailedException;
|
||||||
import com.android.email.mail.MessagingException;
|
import com.android.email.mail.MessagingException;
|
||||||
import com.android.email.mail.Store;
|
import com.android.email.mail.Store;
|
||||||
|
@ -33,6 +34,7 @@ import com.android.email.provider.EmailContent.MessageColumns;
|
||||||
import com.android.email.service.EmailServiceStatus;
|
import com.android.email.service.EmailServiceStatus;
|
||||||
import com.android.email.service.IEmailService;
|
import com.android.email.service.IEmailService;
|
||||||
import com.android.email.service.IEmailServiceCallback;
|
import com.android.email.service.IEmailServiceCallback;
|
||||||
|
import com.android.email.service.MailService;
|
||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
@ -64,9 +66,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class Controller extends Service {
|
public class Controller extends Service {
|
||||||
private static final String TAG = "Controller";
|
private static final String TAG = "Controller";
|
||||||
private static Controller sInstance;
|
private static Controller sInstance;
|
||||||
private final Context mContext;
|
private Context mContext;
|
||||||
private Context mProviderContext;
|
private Context mProviderContext;
|
||||||
private final MessagingController mLegacyController;
|
private MessagingController mLegacyController;
|
||||||
private final LegacyListener mLegacyListener = new LegacyListener();
|
private final LegacyListener mLegacyListener = new LegacyListener();
|
||||||
private final ServiceCallback mServiceCallback = new ServiceCallback();
|
private final ServiceCallback mServiceCallback = new ServiceCallback();
|
||||||
private final HashSet<Result> mListeners = new HashSet<Result>();
|
private final HashSet<Result> mListeners = new HashSet<Result>();
|
||||||
|
@ -105,11 +107,31 @@ public class Controller extends Service {
|
||||||
private static RemoteCallbackList<IEmailServiceCallback> sCallbackList =
|
private static RemoteCallbackList<IEmailServiceCallback> sCallbackList =
|
||||||
new RemoteCallbackList<IEmailServiceCallback>();
|
new RemoteCallbackList<IEmailServiceCallback>();
|
||||||
|
|
||||||
protected Controller(Context _context) {
|
@Override
|
||||||
mContext = _context.getApplicationContext();
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
mProviderContext = _context;
|
sInstance = this;
|
||||||
|
mContext = getApplicationContext();
|
||||||
|
mProviderContext = mContext;
|
||||||
mLegacyController = MessagingController.getInstance(mProviderContext, this);
|
mLegacyController = MessagingController.getInstance(mProviderContext, this);
|
||||||
mLegacyController.addListener(mLegacyListener);
|
mLegacyController.addListener(mLegacyListener);
|
||||||
|
// Tie MailRefreshManager to the Controller.
|
||||||
|
RefreshManager.getInstance(this);
|
||||||
|
// Reset all accounts to default visible window
|
||||||
|
resetVisibleLimits();
|
||||||
|
// Enable logging in the EAS service, so it starts up as early as possible.
|
||||||
|
Debug.updateLoggingFlags(this);
|
||||||
|
MailService.actionReschedule(this);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
sInstance = null;
|
||||||
|
Log.d(TAG, "Controller.onDestroy()");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Controller getInstance() {
|
||||||
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,39 +144,6 @@ public class Controller extends Service {
|
||||||
mLegacyController.removeListener(mLegacyListener);
|
mLegacyController.removeListener(mLegacyListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* As a Service, Controller needs this no-argument constructor, but only because there is
|
|
||||||
* another constructor defined for the class. In the typical case for a Service, there are
|
|
||||||
* no defined constructors, so the default constructor is used when the Service is instantiated
|
|
||||||
* by ServiceManager (initialization would be performed in onCreate or onStartCommand, etc.)
|
|
||||||
*
|
|
||||||
* Because of this, the Controller Service, when bound, creates a second instance of the class,
|
|
||||||
* i.e. in addition to the "singleton" created/returned by getInstance. This is unfortunate,
|
|
||||||
* but not disruptive, as the Service Controller instance references members of sInstance (the
|
|
||||||
* previously-singleton Controller); it's perhaps best to think of the Service instance as a
|
|
||||||
* delegate.
|
|
||||||
*
|
|
||||||
* TODO: Have Controller behave more like a real Service. This means that the lifecycle of
|
|
||||||
* the Service (and thus the singleton instance) should be managed by ServiceManager (as happens
|
|
||||||
* with AttachmentDownloadService and MailService), its initialization should be handled in
|
|
||||||
* onCreate(), etc. When this is done (and it should be relatively simple), we will be back
|
|
||||||
* to a true singleton
|
|
||||||
*/
|
|
||||||
public Controller() {
|
|
||||||
mContext = mProviderContext = this;
|
|
||||||
mLegacyController = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets or creates the singleton instance of Controller.
|
|
||||||
*/
|
|
||||||
public synchronized static Controller getInstance(Context _context) {
|
|
||||||
if (sInstance == null) {
|
|
||||||
sInstance = new Controller(_context);
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject a mock controller. Used only for testing. Affects future calls to getInstance().
|
* Inject a mock controller. Used only for testing. Affects future calls to getInstance().
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package com.android.email;
|
package com.android.email;
|
||||||
|
|
||||||
import com.android.email.activity.AccountShortcutPicker;
|
import com.android.email.activity.AccountShortcutPicker;
|
||||||
import com.android.email.activity.Debug;
|
|
||||||
import com.android.email.activity.MessageCompose;
|
import com.android.email.activity.MessageCompose;
|
||||||
import com.android.email.provider.EmailContent;
|
import com.android.email.provider.EmailContent;
|
||||||
import com.android.email.service.AttachmentDownloadService;
|
import com.android.email.service.AttachmentDownloadService;
|
||||||
|
@ -29,11 +28,9 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.text.format.DateUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class Email extends Application {
|
public class Email extends Application {
|
||||||
public static final String LOG_TAG = "Email";
|
public static final String LOG_TAG = "Email";
|
||||||
|
@ -266,7 +263,11 @@ public class Email extends Application {
|
||||||
* And now if accounts do exist then we've just enabled the service and we want to
|
* And now if accounts do exist then we've just enabled the service and we want to
|
||||||
* schedule alarms for the new accounts.
|
* schedule alarms for the new accounts.
|
||||||
*/
|
*/
|
||||||
MailService.actionReschedule(context);
|
// If this is running at start-up, Controller might not be running as a Service yet
|
||||||
|
// In this case, ignore - when it starts, it will call MailService.actionReschedule()
|
||||||
|
if (Controller.getInstance() != null) {
|
||||||
|
MailService.actionReschedule(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Start/stop the AttachmentDownloadService, depending on whether there are any accounts
|
// Start/stop the AttachmentDownloadService, depending on whether there are any accounts
|
||||||
Intent intent = new Intent(context, AttachmentDownloadService.class);
|
Intent intent = new Intent(context, AttachmentDownloadService.class);
|
||||||
|
@ -275,6 +276,7 @@ public class Email extends Application {
|
||||||
} else {
|
} else {
|
||||||
context.stopService(intent);
|
context.stopService(intent);
|
||||||
}
|
}
|
||||||
|
context.startService(new Intent(context, Controller.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -283,14 +285,6 @@ public class Email extends Application {
|
||||||
Preferences prefs = Preferences.getPreferences(this);
|
Preferences prefs = Preferences.getPreferences(this);
|
||||||
DEBUG = prefs.getEnableDebugLogging();
|
DEBUG = prefs.getEnableDebugLogging();
|
||||||
setTempDirectory(this);
|
setTempDirectory(this);
|
||||||
|
|
||||||
// Tie MailRefreshManager to the Controller.
|
|
||||||
RefreshManager.getInstance(this);
|
|
||||||
// Reset all accounts to default visible window
|
|
||||||
Controller.getInstance(this).resetVisibleLimits();
|
|
||||||
|
|
||||||
// Enable logging in the EAS service, so it starts up as early as possible.
|
|
||||||
Debug.updateLoggingFlags(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,10 +17,8 @@
|
||||||
package com.android.email;
|
package com.android.email;
|
||||||
|
|
||||||
import com.android.email.mail.MessagingException;
|
import com.android.email.mail.MessagingException;
|
||||||
import com.android.email.provider.EmailContent;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -153,7 +151,7 @@ public class RefreshManager {
|
||||||
*/
|
*/
|
||||||
public static synchronized RefreshManager getInstance(Context context) {
|
public static synchronized RefreshManager getInstance(Context context) {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
sInstance = new RefreshManager(context, Controller.getInstance(context),
|
sInstance = new RefreshManager(context, Controller.getInstance(),
|
||||||
Clock.INSTANCE, new Handler());
|
Clock.INSTANCE, new Handler());
|
||||||
}
|
}
|
||||||
return sInstance;
|
return sInstance;
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class AccountFolderList extends Activity implements AccountFolderListFrag
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Controller.getInstance(getApplication()).removeResultCallback(mControllerCallback);
|
Controller.getInstance().removeResultCallback(mControllerCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,7 +117,7 @@ public class AccountFolderList extends Activity implements AccountFolderListFrag
|
||||||
getSystemService(Context.NOTIFICATION_SERVICE);
|
getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
notifMgr.cancel(1);
|
notifMgr.cancel(1);
|
||||||
|
|
||||||
Controller.getInstance(getApplication()).addResultCallback(mControllerCallback);
|
Controller.getInstance().addResultCallback(mControllerCallback);
|
||||||
|
|
||||||
// Exit immediately if the accounts list has changed (e.g. externally deleted)
|
// Exit immediately if the accounts list has changed (e.g. externally deleted)
|
||||||
if (Email.getNotifyUiAccountsChanged()) {
|
if (Email.getNotifyUiAccountsChanged()) {
|
||||||
|
@ -150,7 +150,7 @@ public class AccountFolderList extends Activity implements AccountFolderListFrag
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
showProgressIcon(true);
|
showProgressIcon(true);
|
||||||
Controller.getInstance(getApplication()).updateMailboxList(accountId);
|
Controller.getInstance().updateMailboxList(accountId);
|
||||||
// TODO update the inbox too
|
// TODO update the inbox too
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ public class AccountFolderList extends Activity implements AccountFolderListFrag
|
||||||
Account.CONTENT_URI, null, null);
|
Account.CONTENT_URI, null, null);
|
||||||
mListFragment.hideDeletingAccount(mSelectedContextAccount.mId);
|
mListFragment.hideDeletingAccount(mSelectedContextAccount.mId);
|
||||||
|
|
||||||
Controller.getInstance(AccountFolderList.this).deleteAccount(
|
Controller.getInstance().deleteAccount(
|
||||||
mSelectedContextAccount.mId);
|
mSelectedContextAccount.mId);
|
||||||
if (numAccounts == 1) {
|
if (numAccounts == 1) {
|
||||||
AccountSetupBasics.actionNewAccount(AccountFolderList.this);
|
AccountSetupBasics.actionNewAccount(AccountFolderList.this);
|
||||||
|
|
|
@ -38,14 +38,14 @@ import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
|
||||||
import android.widget.CursorAdapter;
|
import android.widget.CursorAdapter;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
public class AccountFolderListFragment extends ListFragment
|
public class AccountFolderListFragment extends ListFragment
|
||||||
implements OnItemClickListener, AccountsAdapter.Callback {
|
implements OnItemClickListener, AccountsAdapter.Callback {
|
||||||
|
@ -139,7 +139,7 @@ public class AccountFolderListFragment extends ListFragment
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
Controller.getInstance(mActivity).addResultCallback(mControllerCallback);
|
Controller.getInstance().addResultCallback(mControllerCallback);
|
||||||
updateAccounts();
|
updateAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public class AccountFolderListFragment extends ListFragment
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Controller.getInstance(mActivity).removeResultCallback(mControllerCallback);
|
Controller.getInstance().removeResultCallback(mControllerCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,7 +88,7 @@ public final class ActivityHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteMessage(Activity activity, long messageId) {
|
public static void deleteMessage(Activity activity, long messageId) {
|
||||||
Controller.getInstance(activity).deleteMessage(messageId, -1);
|
Controller.getInstance().deleteMessage(messageId, -1);
|
||||||
Utility.showToast(activity,
|
Utility.showToast(activity,
|
||||||
activity.getResources().getQuantityString(R.plurals.message_deleted_toast, 1));
|
activity.getResources().getQuantityString(R.plurals.message_deleted_toast, 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class Debug extends Activity implements OnCheckedChangeListener {
|
||||||
int exchangeLogging = prefs.getEnableExchangeLogging() ? Eas.DEBUG_EXCHANGE_BIT : 0;
|
int exchangeLogging = prefs.getEnableExchangeLogging() ? Eas.DEBUG_EXCHANGE_BIT : 0;
|
||||||
int fileLogging = prefs.getEnableExchangeFileLogging() ? Eas.DEBUG_FILE_BIT : 0;
|
int fileLogging = prefs.getEnableExchangeFileLogging() ? Eas.DEBUG_FILE_BIT : 0;
|
||||||
int debugBits = debugLogging | exchangeLogging | fileLogging;
|
int debugBits = debugLogging | exchangeLogging | fileLogging;
|
||||||
Controller.getInstance(context).serviceLogging(debugBits);
|
Controller.getInstance().serviceLogging(debugBits);
|
||||||
//EXCHANGE-REMOVE-SECTION-END
|
//EXCHANGE-REMOVE-SECTION-END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class MailboxFinder {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mController = Controller.getInstance(context);
|
mController = Controller.getInstance();
|
||||||
mAccountId = accountId;
|
mAccountId = accountId;
|
||||||
mMailboxType = mailboxType;
|
mMailboxType = mailboxType;
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class MailboxList extends Activity implements MailboxListFragment.Callbac
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String accountName = (String) result[0];
|
final String accountName = result[0];
|
||||||
// accountName is null if account name can't be retrieved or query exception
|
// accountName is null if account name can't be retrieved or query exception
|
||||||
if (accountName == null) {
|
if (accountName == null) {
|
||||||
// something is wrong with this account
|
// something is wrong with this account
|
||||||
|
@ -134,13 +134,13 @@ public class MailboxList extends Activity implements MailboxListFragment.Callbac
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Controller.getInstance(getApplication()).removeResultCallback(mControllerCallback);
|
Controller.getInstance().removeResultCallback(mControllerCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
Controller.getInstance(getApplication()).addResultCallback(mControllerCallback);
|
Controller.getInstance().addResultCallback(mControllerCallback);
|
||||||
|
|
||||||
// Exit immediately if the accounts list has changed (e.g. externally deleted)
|
// Exit immediately if the accounts list has changed (e.g. externally deleted)
|
||||||
if (Email.getNotifyUiAccountsChanged()) {
|
if (Email.getNotifyUiAccountsChanged()) {
|
||||||
|
@ -211,7 +211,7 @@ public class MailboxList extends Activity implements MailboxListFragment.Callbac
|
||||||
* Refresh the mailbox list
|
* Refresh the mailbox list
|
||||||
*/
|
*/
|
||||||
private void onRefresh() {
|
private void onRefresh() {
|
||||||
Controller controller = Controller.getInstance(getApplication());
|
Controller controller = Controller.getInstance();
|
||||||
showProgressIcon(true);
|
showProgressIcon(true);
|
||||||
mListFragment.onRefresh();
|
mListFragment.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||||
setContentView(R.layout.message_compose);
|
setContentView(R.layout.message_compose);
|
||||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.list_title);
|
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.list_title);
|
||||||
|
|
||||||
mController = Controller.getInstance(getApplication());
|
mController = Controller.getInstance();
|
||||||
initViews();
|
initViews();
|
||||||
setDraftNeedsSaving(false);
|
setDraftNeedsSaving(false);
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.Animation.AnimationListener;
|
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.view.animation.Animation.AnimationListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -69,7 +69,7 @@ public class MessageList extends Activity implements OnClickListener,
|
||||||
private Button mDeleteButton;
|
private Button mDeleteButton;
|
||||||
private TextView mErrorBanner;
|
private TextView mErrorBanner;
|
||||||
|
|
||||||
private final Controller mController = Controller.getInstance(getApplication());
|
private final Controller mController = Controller.getInstance();
|
||||||
private ControllerResultUiThreadWrapper<ControllerResults> mControllerCallback;
|
private ControllerResultUiThreadWrapper<ControllerResults> mControllerCallback;
|
||||||
|
|
||||||
private TextView mLeftTitle;
|
private TextView mLeftTitle;
|
||||||
|
@ -386,6 +386,7 @@ public class MessageList extends Activity implements OnClickListener,
|
||||||
*
|
*
|
||||||
* @deprecated not used any longer. remove them.
|
* @deprecated not used any longer. remove them.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void onSelectionChanged() {
|
public void onSelectionChanged() {
|
||||||
showMultiPanel(mListFragment.getSelectedCount() > 0);
|
showMultiPanel(mListFragment.getSelectedCount() > 0);
|
||||||
}
|
}
|
||||||
|
@ -394,6 +395,7 @@ public class MessageList extends Activity implements OnClickListener,
|
||||||
* @deprecated not used any longer. remove them. (with associated resources, strings,
|
* @deprecated not used any longer. remove them. (with associated resources, strings,
|
||||||
* members, etc)
|
* members, etc)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
private void updateFooterButtonNames () {
|
private void updateFooterButtonNames () {
|
||||||
// Show "unread_action" when one or more read messages are selected.
|
// Show "unread_action" when one or more read messages are selected.
|
||||||
if (mListFragment.doesSelectionContainReadMessage()) {
|
if (mListFragment.doesSelectionContainReadMessage()) {
|
||||||
|
@ -414,6 +416,7 @@ public class MessageList extends Activity implements OnClickListener,
|
||||||
*
|
*
|
||||||
* @deprecated not used any longer. remove them.
|
* @deprecated not used any longer. remove them.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
private void showMultiPanel(boolean show) {
|
private void showMultiPanel(boolean show) {
|
||||||
if (show && mMultiSelectPanel.getVisibility() != View.VISIBLE) {
|
if (show && mMultiSelectPanel.getVisibility() != View.VISIBLE) {
|
||||||
mMultiSelectPanel.setVisibility(View.VISIBLE);
|
mMultiSelectPanel.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -42,15 +42,15 @@ import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
|
||||||
import android.widget.AdapterView.OnItemLongClickListener;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.AdapterView.OnItemLongClickListener;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -161,7 +161,7 @@ public class MessageListFragment extends ListFragment
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
mController = Controller.getInstance(mActivity);
|
mController = Controller.getInstance();
|
||||||
mRefreshManager = RefreshManager.getInstance(mActivity);
|
mRefreshManager = RefreshManager.getInstance(mActivity);
|
||||||
mRefreshManager.registerListener(mRefreshListener);
|
mRefreshManager.registerListener(mRefreshListener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,7 @@ import com.android.email.Controller;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Browser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for {@link MessageView} and {@link MessageFileView}.
|
* Base class for {@link MessageView} and {@link MessageFileView}.
|
||||||
|
@ -66,7 +62,7 @@ public abstract class MessageViewBase extends Activity implements MessageViewFra
|
||||||
mFetchAttachmentProgressDialog.setIndeterminate(true);
|
mFetchAttachmentProgressDialog.setIndeterminate(true);
|
||||||
mFetchAttachmentProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
mFetchAttachmentProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||||
|
|
||||||
mController = Controller.getInstance(getApplication());
|
mController = Controller.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -210,7 +210,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
mDateFormat = android.text.format.DateFormat.getDateFormat(mContext); // short format
|
mDateFormat = android.text.format.DateFormat.getDateFormat(mContext); // short format
|
||||||
mTimeFormat = android.text.format.DateFormat.getTimeFormat(mContext); // 12/24 date format
|
mTimeFormat = android.text.format.DateFormat.getTimeFormat(mContext); // 12/24 date format
|
||||||
|
|
||||||
mController = Controller.getInstance(mContext);
|
mController = Controller.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class MailService extends Service {
|
||||||
this.mStartId = startId;
|
this.mStartId = startId;
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
|
||||||
mController = Controller.getInstance(this);
|
mController = Controller.getInstance();
|
||||||
mController.addResultCallback(mControllerCallback);
|
mController.addResultCallback(mControllerCallback);
|
||||||
mContentResolver = getContentResolver();
|
mContentResolver = getContentResolver();
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ public class MailService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
Controller.getInstance(getApplication()).removeResultCallback(mControllerCallback);
|
Controller.getInstance().removeResultCallback(mControllerCallback);
|
||||||
// Unregister our account listener
|
// Unregister our account listener
|
||||||
if (mAccountsUpdatedListener != null) {
|
if (mAccountsUpdatedListener != null) {
|
||||||
AccountManager.get(this).removeOnAccountsUpdatedListener(mAccountsUpdatedListener);
|
AccountManager.get(this).removeOnAccountsUpdatedListener(mAccountsUpdatedListener);
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class PopImapSyncAdapterService extends Service {
|
||||||
Mailbox.TYPE_INBOX);
|
Mailbox.TYPE_INBOX);
|
||||||
if (mailboxId > 0) {
|
if (mailboxId > 0) {
|
||||||
Log.d(TAG, "Starting manual sync for account " + emailAddress);
|
Log.d(TAG, "Starting manual sync for account " + emailAddress);
|
||||||
Controller.getInstance(context).updateMailbox(accountId, mailboxId);
|
Controller.getInstance().updateMailbox(accountId, mailboxId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
package com.android.email;
|
package com.android.email;
|
||||||
|
|
||||||
import com.android.email.provider.EmailContent;
|
import com.android.email.provider.EmailContent;
|
||||||
|
import com.android.email.provider.EmailProvider;
|
||||||
|
import com.android.email.provider.ProviderTestUtils;
|
||||||
import com.android.email.provider.EmailContent.Account;
|
import com.android.email.provider.EmailContent.Account;
|
||||||
import com.android.email.provider.EmailContent.Body;
|
import com.android.email.provider.EmailContent.Body;
|
||||||
import com.android.email.provider.EmailContent.HostAuth;
|
import com.android.email.provider.EmailContent.HostAuth;
|
||||||
import com.android.email.provider.EmailContent.Mailbox;
|
import com.android.email.provider.EmailContent.Mailbox;
|
||||||
import com.android.email.provider.EmailContent.Message;
|
import com.android.email.provider.EmailContent.Message;
|
||||||
import com.android.email.provider.EmailProvider;
|
|
||||||
import com.android.email.provider.ProviderTestUtils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -72,7 +72,7 @@ public class ControllerProviderOpsTests extends ProviderTestCase2<EmailProvider>
|
||||||
public static class TestController extends Controller {
|
public static class TestController extends Controller {
|
||||||
|
|
||||||
protected TestController(Context providerContext, Context systemContext) {
|
protected TestController(Context providerContext, Context systemContext) {
|
||||||
super(systemContext);
|
super();
|
||||||
setProviderContext(providerContext);
|
setProviderContext(providerContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package com.android.email;
|
package com.android.email;
|
||||||
|
|
||||||
import com.android.email.mail.MessagingException;
|
import com.android.email.mail.MessagingException;
|
||||||
import com.android.email.provider.EmailContent.Account;
|
|
||||||
import com.android.email.provider.EmailProvider;
|
import com.android.email.provider.EmailProvider;
|
||||||
import com.android.email.provider.ProviderTestUtils;
|
import com.android.email.provider.ProviderTestUtils;
|
||||||
|
import com.android.email.provider.EmailContent.Account;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
|
@ -55,7 +55,7 @@ public class RefreshManagerTest extends InstrumentationTestCase {
|
||||||
|
|
||||||
mClock = new MockClock();
|
mClock = new MockClock();
|
||||||
mContext = getInstrumentation().getTargetContext();
|
mContext = getInstrumentation().getTargetContext();
|
||||||
mController = new MockController(mContext);
|
mController = new MockController();
|
||||||
mListener = new RefreshListener();
|
mListener = new RefreshListener();
|
||||||
mProviderContext = DBTestHelper.ProviderContextSetupHelper.getProviderContext(
|
mProviderContext = DBTestHelper.ProviderContextSetupHelper.getProviderContext(
|
||||||
mContext, EmailProvider.class);
|
mContext, EmailProvider.class);
|
||||||
|
@ -474,8 +474,8 @@ public class RefreshManagerTest extends InstrumentationTestCase {
|
||||||
public volatile boolean mCalledUpdateMailboxList;
|
public volatile boolean mCalledUpdateMailboxList;
|
||||||
public volatile Result mListener;
|
public volatile Result mListener;
|
||||||
|
|
||||||
protected MockController(Context context) {
|
protected MockController() {
|
||||||
super(context);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
|
|
@ -22,10 +22,10 @@ import com.android.email.Email;
|
||||||
import com.android.email.TestUtils;
|
import com.android.email.TestUtils;
|
||||||
import com.android.email.mail.MessagingException;
|
import com.android.email.mail.MessagingException;
|
||||||
import com.android.email.provider.EmailContent;
|
import com.android.email.provider.EmailContent;
|
||||||
import com.android.email.provider.EmailContent.Account;
|
|
||||||
import com.android.email.provider.EmailContent.Mailbox;
|
|
||||||
import com.android.email.provider.EmailProvider;
|
import com.android.email.provider.EmailProvider;
|
||||||
import com.android.email.provider.ProviderTestUtils;
|
import com.android.email.provider.ProviderTestUtils;
|
||||||
|
import com.android.email.provider.EmailContent.Account;
|
||||||
|
import com.android.email.provider.EmailContent.Mailbox;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
|
@ -337,7 +337,7 @@ public class MailboxFinderTest extends InstrumentationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MockController(Context context) {
|
protected MockController(Context context) {
|
||||||
super(context);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class MailServiceTests extends AccountTestCase {
|
||||||
public static class TestController extends Controller {
|
public static class TestController extends Controller {
|
||||||
|
|
||||||
protected TestController(Context providerContext, Context systemContext) {
|
protected TestController(Context providerContext, Context systemContext) {
|
||||||
super(systemContext);
|
super();
|
||||||
setProviderContext(providerContext);
|
setProviderContext(providerContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue