Show helpful messages when no accounts configured
Bug: 5145213 Change-Id: I350d59e8afc72d1bad64cf7cf3d44750e8365a99
This commit is contained in:
parent
da1d233916
commit
d3ced7cce9
@ -1202,8 +1202,12 @@ save attachment.</string>
|
||||
<string name="widget_starred">Starred</string>
|
||||
<!-- Shown when waiting for mail data to be loaded into the widget list view [CHAR LIMIT=20] -->
|
||||
<string name="widget_loading">Loading\u2026</string>
|
||||
<!-- Shown when no accounts are configured [CHAR LIMIT=35] -->
|
||||
<!-- Shown when no accounts are configured and the widget supports changing
|
||||
on the fly [CHAR LIMIT=35] -->
|
||||
<string name="widget_touch_to_configure">Touch to configure</string>
|
||||
<!-- Shown in a toast when no accounts are configured and the Email widget
|
||||
cannot be created in the first place [CHAR LIMIT=none] -->
|
||||
<string name="widget_no_accounts">You haven\'t set up an email account yet.</string>
|
||||
|
||||
<!-- Generic string shown instead of regular numbers, when a number is larger than 999.
|
||||
This should not be altered if the original string ("999+") makes sense in the
|
||||
|
@ -146,11 +146,6 @@ public class Email extends Application {
|
||||
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(context, WidgetConfiguration.class),
|
||||
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(context, MailService.class),
|
||||
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
|
||||
@ -171,6 +166,14 @@ public class Email extends Application {
|
||||
MailService.actionReschedule(context);
|
||||
}
|
||||
|
||||
// Note - the Email widget is always enabled as it will show a warning if no accounts are
|
||||
// configured. In previous releases, this was disabled if no accounts were set, so we
|
||||
// need to unconditionally enable it here.
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(context, WidgetConfiguration.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
|
||||
// Start/stop the various services depending on whether there are any accounts
|
||||
startOrStopService(enabled, context, new Intent(context, AttachmentDownloadService.class));
|
||||
NotificationController.getInstance(context).watchForMessages(enabled);
|
||||
|
@ -20,15 +20,19 @@ import android.app.Activity;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.R;
|
||||
import com.android.email.activity.ShortcutPickerFragment.AccountShortcutPickerFragment;
|
||||
import com.android.email.activity.ShortcutPickerFragment.MailboxShortcutPickerFragment;
|
||||
import com.android.email.activity.ShortcutPickerFragment.PickerCallback;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
/**
|
||||
* Activity to configure the Email widget.
|
||||
@ -41,6 +45,9 @@ public class WidgetConfiguration extends Activity implements OnClickListener, Pi
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setResult(RESULT_CANCELED);
|
||||
if (Email.DEBUG) {
|
||||
Log.i(Logging.LOG_TAG, "WidgetConfiguration initiated");
|
||||
}
|
||||
if (!AppWidgetManager.ACTION_APPWIDGET_CONFIGURE.equals(getIntent().getAction())) {
|
||||
// finish() immediately if we aren't supposed to be here
|
||||
finish();
|
||||
@ -98,7 +105,10 @@ public class WidgetConfiguration extends Activity implements OnClickListener, Pi
|
||||
|
||||
@Override
|
||||
public void onMissingData(boolean missingAccount, boolean missingMailbox) {
|
||||
// TODO what's the proper handling if the mailbox list is '0'? display toast?
|
||||
if (Email.DEBUG) {
|
||||
Log.i(Logging.LOG_TAG, "WidgetConfiguration exited abnormally. Probably no accounts.");
|
||||
}
|
||||
Utility.showToast(this, R.string.widget_no_accounts);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user