Merge "Add proper wording for "all accounts" picker item"

This commit is contained in:
Todd Kennedy 2011-06-02 11:56:05 -07:00 committed by Android (Google) Code Review
commit 8121876fef
2 changed files with 17 additions and 5 deletions

View File

@ -225,6 +225,13 @@
<string name="picker_mailbox_name_all_unread">Inbox (unread)</string>
<!-- In the shortcut/widget configuration UI, the label for selecting all messages in an account's inbox [CHAR LIMIT=30] -->
<string name="picker_mailbox_name_all_inbox">Inbox (all)</string>
<!-- In the shortcut/widget configuration UI, use this for the "all accounts" account list item [CHAR LIMIT=30] -->
<string name="picker_combined_view_fmt">Combined view (<xliff:g id="count">%s</xliff:g>)</string>
<!-- Count of accounts; used in picker_combined_view_fmt -->
<plurals name="picker_combined_view_account_count">
<item quantity="one" ><xliff:g id="account_count" example="1">%d</xliff:g> account</item>
<item quantity="other"><xliff:g id="account_count" example="9">%d</xliff:g> accounts</item>
</plurals>
<!-- Version number, shown only on debug screen -->
<string name="debug_version_fmt">Version: <xliff:g id="version">%s</xliff:g></string>

View File

@ -30,6 +30,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MergeCursor;
@ -147,12 +148,13 @@ public abstract class ShortcutPickerFragment extends ListFragment
@Override
public Cursor loadInBackground() {
Cursor parentCursor = super.loadInBackground();
Cursor returnCursor;
int cursorCount = parentCursor.getCount();
final Cursor returnCursor;
if (parentCursor.getCount() > 1) {
if (cursorCount > 1) {
// Only add "All accounts" if there is more than 1 account defined
MatrixCursor allAccountCursor = new MatrixCursor(getProjection());
addCombinedAccountRow(allAccountCursor);
addCombinedAccountRow(allAccountCursor, cursorCount);
returnCursor = new MergeCursor(new Cursor[] { allAccountCursor, parentCursor });
} else {
returnCursor = parentCursor;
@ -161,11 +163,14 @@ public abstract class ShortcutPickerFragment extends ListFragment
}
/** Adds a row for "All Accounts" into the given cursor */
private void addCombinedAccountRow(MatrixCursor cursor) {
private void addCombinedAccountRow(MatrixCursor cursor, int accountCount) {
Context context = getContext();
Account account = new Account();
account.mId = Account.ACCOUNT_ID_COMBINED_VIEW;
account.mDisplayName = context.getString(R.string.account_name_display_all);
Resources res = context.getResources();
String countString = res.getQuantityString(R.plurals.picker_combined_view_account_count,
accountCount, accountCount);
account.mDisplayName = res.getString(R.string.picker_combined_view_fmt, countString);
ContentValues values = account.toContentValues();
RowBuilder row = cursor.newRow();
for (String rowName : cursor.getColumnNames()) {