summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-10-22 02:18:40 +0200
committerMichael Bestas <mikeioannina@gmail.com>2016-12-30 20:18:32 +0200
commite44e69533551c1c5003aec373705c9222294c192 (patch)
tree2429141545a91ad3b67484c75cca0d28f8d30fa9
parentddbed0923f9721eaacbbd87fd38beb74a7142339 (diff)
downloadandroid_packages_apps_Email-e44e69533551c1c5003aec373705c9222294c192.tar.gz
android_packages_apps_Email-e44e69533551c1c5003aec373705c9222294c192.tar.bz2
android_packages_apps_Email-e44e69533551c1c5003aec373705c9222294c192.zip
email: return default folder name for subfolders
For subfolders of system folder type return the remote folder name instead of translate it to the default folder type resource name. Subfolders shouldn't be considered as system folders. For example a SPAM folder of a SPAM root folder (Junk/Ham should be displayed as Ham instead of Junk). Change-Id: I2644b8da336e3f0983d24355aefe961aa8acf30b Signed-off-by: Jorge Ruesga <jorge@ruesga.com> (cherry picked from commit db1ca54cd325c64971240d92ed11dad175d83579)
-rw-r--r--provider_src/com/android/email/provider/EmailProvider.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/provider_src/com/android/email/provider/EmailProvider.java b/provider_src/com/android/email/provider/EmailProvider.java
index c606b001c..a3c32c677 100644
--- a/provider_src/com/android/email/provider/EmailProvider.java
+++ b/provider_src/com/android/email/provider/EmailProvider.java
@@ -4072,7 +4072,8 @@ public class EmailProvider extends ContentProvider
values[i] = combinedUriString("uifolder", idString);
} else if (column.equals(UIProvider.FolderColumns.NAME)) {
// default empty string since all of these should use resource strings
- values[i] = getFolderDisplayName(getFolderTypeFromMailboxType(mailboxType), "");
+ values[i] = getFolderDisplayName(
+ getFolderTypeFromMailboxType(mailboxType), "", false);
} else if (column.equals(UIProvider.FolderColumns.HAS_CHILDREN)) {
values[i] = 0;
} else if (column.equals(UIProvider.FolderColumns.CAPABILITIES)) {
@@ -4578,7 +4579,7 @@ public class EmailProvider extends ContentProvider
*/
private Cursor getUiFolderCursorRowFromMailboxCursorRow(
MatrixCursor mc, int projectionLength, Cursor mailboxCursor,
- int nameColumn, int typeColumn) {
+ int nameColumn, int typeColumn, int parentUriColumn) {
final MatrixCursor.RowBuilder builder = mc.newRow();
for (int i = 0; i < projectionLength; i++) {
// If we are at the name column, get the type
@@ -4590,7 +4591,9 @@ public class EmailProvider extends ContentProvider
// type has also been requested. If not, this will
// error in unknown ways.
final int type = mailboxCursor.getInt(typeColumn);
- builder.add(getFolderDisplayName(type, mailboxCursor.getString(i)));
+ final boolean rootFolder = parentUriColumn == -1 ||
+ TextUtils.isEmpty(mailboxCursor.getString(parentUriColumn));
+ builder.add(getFolderDisplayName(type, mailboxCursor.getString(i), rootFolder));
} else {
builder.add(mailboxCursor.getString(i));
}
@@ -4626,6 +4629,7 @@ public class EmailProvider extends ContentProvider
final int idColumn = inputCursor.getColumnIndex(BaseColumns._ID);
final int typeColumn = inputCursor.getColumnIndex(UIProvider.FolderColumns.TYPE);
final int nameColumn = inputCursor.getColumnIndex(UIProvider.FolderColumns.NAME);
+ final int parentUriColumn = inputCursor.getColumnIndex(UIProvider.FolderColumns.PARENT_URI);
final int capabilitiesColumn =
inputCursor.getColumnIndex(UIProvider.FolderColumns.CAPABILITIES);
final int persistentIdColumn =
@@ -4643,6 +4647,7 @@ public class EmailProvider extends ContentProvider
while (inputCursor.moveToNext()) {
final MatrixCursor.RowBuilder builder = outputCursor.newRow();
final int folderType = inputCursor.getInt(typeColumn);
+ final boolean rootFolder = TextUtils.isEmpty(inputCursor.getString(parentUriColumn));
for (int i = 0; i < uiProjection.length; i++) {
// Find the index in the input cursor corresponding the column requested in the
// output projection.
@@ -4657,7 +4662,7 @@ public class EmailProvider extends ContentProvider
final boolean remapped;
if (nameColumn == index) {
// Remap folder name for system folders.
- builder.add(getFolderDisplayName(folderType, value));
+ builder.add(getFolderDisplayName(folderType, value, rootFolder));
remapped = true;
} else if (capabilitiesColumn == index) {
// Get the correct capabilities for this folder.
@@ -4707,9 +4712,15 @@ public class EmailProvider extends ContentProvider
* @param folderType {@link UIProvider.FolderType} value for the folder
* @param defaultName a {@link String} to use in case the {@link UIProvider.FolderType}
* provided is not a system folder.
+ * @param rootFolder whether the folder is a root folder
* @return a {@link String} to use as the display name for the folder
*/
- private String getFolderDisplayName(int folderType, String defaultName) {
+ private String getFolderDisplayName(int folderType, String defaultName, boolean rootFolder) {
+ if (!rootFolder && !TextUtils.isEmpty(defaultName)) {
+ // If the folder is not a root, we must use the provided folder name
+ return defaultName;
+ }
+
final int resId;
switch (folderType) {
case UIProvider.FolderType.INBOX:
@@ -4970,12 +4981,15 @@ public class EmailProvider extends ContentProvider
final List<String> projectionList = Arrays.asList(uiProjection);
final int nameColumn = projectionList.indexOf(UIProvider.FolderColumns.NAME);
final int typeColumn = projectionList.indexOf(UIProvider.FolderColumns.TYPE);
+ final int parentUriColumn =
+ projectionList.indexOf(UIProvider.FolderColumns.PARENT_URI);
if (c.moveToFirst()) {
final Cursor closeThis = c;
try {
c = getUiFolderCursorRowFromMailboxCursorRow(
new MatrixCursorWithCachedColumns(uiProjection),
- uiProjection.length, c, nameColumn, typeColumn);
+ uiProjection.length, c, nameColumn,
+ typeColumn, parentUriColumn);
} finally {
closeThis.close();
}