diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b619193c3..d0f09e32e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -208,6 +208,10 @@ android:launchMode="singleTask" android:configChanges="locale" > + + + + accounts = new ArrayList(); + + if (!K9.isHideSpecialAccounts()) { + BaseAccount integratedInboxAccount = new SearchAccount(this, true, null, null); + integratedInboxAccount.setDescription( + getString(R.string.integrated_inbox_title)); + integratedInboxAccount.setEmail( + getString(R.string.integrated_inbox_detail)); + + BaseAccount unreadAccount = new SearchAccount(this, false, null, null); + unreadAccount.setDescription( + getString(R.string.search_all_messages_title)); + unreadAccount.setEmail( + getString(R.string.search_all_messages_detail)); + + accounts.add(integratedInboxAccount); + accounts.add(unreadAccount); + } + + accounts.addAll(Arrays.asList(Preferences.getPreferences(this).getAccounts())); mAdapter = new AccountsAdapter(accounts); getListView().setAdapter(mAdapter); } - private void setupShortcut(Account account) { - final Intent shortcutIntent = FolderList.actionHandleAccountIntent(this, account, null, true); + private void setupShortcut(BaseAccount account) { + Intent shortcutIntent = null; + + if (account instanceof SearchSpecification) { + shortcutIntent = MessageList.actionHandleAccountIntent( + this, account.getDescription(), (SearchSpecification) account); + } else { + shortcutIntent = FolderList.actionHandleAccountIntent(this, + (Account) account, null, true); + } Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); @@ -65,18 +100,18 @@ public class LauncherShortcuts extends K9ListActivity implements OnItemClickList } public void onItemClick(AdapterView parent, View view, int position, long id) { - Account account = (Account) parent.getItemAtPosition(position); + BaseAccount account = (BaseAccount) parent.getItemAtPosition(position); setupShortcut(account); } - class AccountsAdapter extends ArrayAdapter { - public AccountsAdapter(Account[] accounts) { + class AccountsAdapter extends ArrayAdapter { + public AccountsAdapter(List accounts) { super(LauncherShortcuts.this, 0, accounts); } @Override public View getView(int position, View convertView, ViewGroup parent) { - final Account account = getItem(position); + final BaseAccount account = getItem(position); final View view; if (convertView != null) { @@ -110,7 +145,10 @@ public class LauncherShortcuts extends K9ListActivity implements OnItemClickList holder.description.setText(description); - holder.chip.setBackgroundColor(account.getChipColor()); + if (account instanceof Account) { + holder.chip.setBackgroundColor(((Account) account).getChipColor()); + } + holder.chip.getBackground().setAlpha(255); holder.description.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getAccountName()); diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 89d1366ef..867fb53fe 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -52,10 +52,12 @@ import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.AccountStats; +import com.fsck.k9.BaseAccount; import com.fsck.k9.FontSizes; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.R; +import com.fsck.k9.SearchAccount; import com.fsck.k9.SearchSpecification; import com.fsck.k9.activity.setup.AccountSettings; import com.fsck.k9.activity.setup.FolderSettings; @@ -614,7 +616,11 @@ public class MessageList context.startActivity(intent); } - public static void actionHandle(Context context, String title, SearchSpecification searchSpecification) { + /** + * Creates and returns an intent that opens Unified Inbox or All Messages screen. + */ + public static Intent actionHandleAccountIntent(Context context, String title, + SearchSpecification searchSpecification) { Intent intent = new Intent(context, MessageList.class); intent.putExtra(EXTRA_QUERY, searchSpecification.getQuery()); if (searchSpecification.getRequiredFlags() != null) { @@ -630,6 +636,13 @@ public class MessageList intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); + + return intent; + } + + public static void actionHandle(Context context, String title, + SearchSpecification searchSpecification) { + Intent intent = actionHandleAccountIntent(context, title, searchSpecification); context.startActivity(intent); }