Bug 748898 - Use "mobile" as title for Mobile Bookmarks folder on upload. a=blocking-fennec

This commit is contained in:
Richard Newman 2012-04-26 12:31:02 -07:00
parent d18af6cc2d
commit 49c9fd24e1
2 changed files with 51 additions and 1 deletions

View File

@ -197,11 +197,20 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo
if (SPECIAL_GUIDS_MAP == null) {
HashMap<String, String> m = new HashMap<String, String>();
// Note that we always use the literal name "mobile" for the Mobile Bookmarks
// folder, regardless of its actual name in the database or the Fennec UI.
// This is to match desktop (working around Bug 747699) and to avoid a similar
// issue locally. See Bug 748898.
m.put("mobile", "mobile");
// Other folders use their contextualized names, and we simply rely on
// these not changing, matching desktop, and such to avoid issues.
m.put("menu", context.getString(R.string.bookmarks_folder_menu));
m.put("places", context.getString(R.string.bookmarks_folder_places));
m.put("toolbar", context.getString(R.string.bookmarks_folder_toolbar));
m.put("unfiled", context.getString(R.string.bookmarks_folder_unfiled));
m.put("mobile", context.getString(R.string.bookmarks_folder_mobile));
SPECIAL_GUIDS_MAP = Collections.unmodifiableMap(m);
}
@ -594,6 +603,27 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo
return reconciled;
}
/**
* Rename mobile folders to "mobile", both in and out. The other half of
* this logic lives in {@link #computeParentFields(BookmarkRecord, String, String)}, where
* the parent name of a record is set from {@link #SPECIAL_GUIDS_MAP} rather than
* from source data.
*
* Apply this approach generally for symmetry.
*/
@Override
protected void fixupRecord(Record record) {
final BookmarkRecord r = (BookmarkRecord) record;
final String parentName = SPECIAL_GUIDS_MAP.get(r.parentID);
if (parentName == null) {
return;
}
if (Logger.logVerbose(LOG_TAG)) {
Logger.trace(LOG_TAG, "Replacing parent name \"" + r.parentName + "\" with \"" + parentName + "\".");
}
r.parentName = parentName;
}
@Override
protected Record prepareRecord(Record record) {
if (record.deleted) {

View File

@ -93,8 +93,24 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
return false;
}
/**
* Perform any necessary transformation of a record prior to searching by
* any field other than GUID.
*
* Example: translating remote folder names into local names.
*/
protected void fixupRecord(Record record) {
return;
}
/**
* Override in subclass to implement record extension.
*
* Populate any fields of the record that are expensive to calculate,
* prior to reconciling.
*
* Example: computing children arrays.
*
* Return null if this record should not be processed.
*
* @param record
@ -429,6 +445,9 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
// End deletion logic.
// Now we're processing a non-deleted incoming record.
// Apply any changes we need in order to correctly find existing records.
fixupRecord(record);
if (existingRecord == null) {
trace("Looking up match for record " + record.guid);
existingRecord = findExistingRecord(record);
@ -649,6 +668,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
}
protected abstract Record prepareRecord(Record record);
protected void updateBookkeeping(Record record) throws NoGuidForIdException,
NullCursorException,
ParentNotFoundException {