Adding a new attribute to speficy folder label directly in layout
Bug: 158141109 Change-Id: I84dccf43981abc910c0d9e75bf316c6b27b3606b
This commit is contained in:
parent
25afca44c4
commit
55e2b1635f
|
@ -89,6 +89,22 @@ public class DefaultLayoutProviderTest {
|
|||
assertEquals(3, ((FolderInfo) info).contents.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomProfileLoaded_with_folder_custom_title() throws Exception {
|
||||
writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putFolder("CustomFolder")
|
||||
.addApp(TEST_PACKAGE, TEST_PACKAGE)
|
||||
.addApp(TEST_PACKAGE, TEST_PACKAGE)
|
||||
.addApp(TEST_PACKAGE, TEST_PACKAGE)
|
||||
.build());
|
||||
|
||||
// Verify folder
|
||||
assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
|
||||
ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
|
||||
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_FOLDER, info.itemType);
|
||||
assertEquals(3, ((FolderInfo) info).contents.size());
|
||||
assertEquals("CustomFolder", info.title.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomProfileLoaded_with_widget() throws Exception {
|
||||
String pendingAppPkg = "com.test.pending";
|
||||
|
|
|
@ -47,6 +47,7 @@ public class LauncherLayoutBuilder {
|
|||
private static final String ATTR_PACKAGE_NAME = "packageName";
|
||||
private static final String ATTR_CLASS_NAME = "className";
|
||||
private static final String ATTR_TITLE = "title";
|
||||
private static final String ATTR_TITLE_TEXT = "titleText";
|
||||
private static final String ATTR_SCREEN = "screen";
|
||||
|
||||
// x and y can be specified as negative integers, in which case -1 represents the
|
||||
|
@ -145,8 +146,17 @@ public class LauncherLayoutBuilder {
|
|||
}
|
||||
|
||||
public FolderBuilder putFolder(int titleResId) {
|
||||
FolderBuilder folderBuilder = new FolderBuilder();
|
||||
items.put(ATTR_TITLE, Integer.toString(titleResId));
|
||||
return putFolder();
|
||||
}
|
||||
|
||||
public FolderBuilder putFolder(String title) {
|
||||
items.put(ATTR_TITLE_TEXT, title);
|
||||
return putFolder();
|
||||
}
|
||||
|
||||
private FolderBuilder putFolder() {
|
||||
FolderBuilder folderBuilder = new FolderBuilder();
|
||||
items.put(ATTR_CHILDREN, folderBuilder.mChildren);
|
||||
mNodes.add(Pair.create(TAG_FOLDER, items));
|
||||
return folderBuilder;
|
||||
|
|
|
@ -132,6 +132,7 @@ public class AutoInstallsLayout {
|
|||
private static final String ATTR_PACKAGE_NAME = "packageName";
|
||||
private static final String ATTR_CLASS_NAME = "className";
|
||||
private static final String ATTR_TITLE = "title";
|
||||
private static final String ATTR_TITLE_TEXT = "titleText";
|
||||
private static final String ATTR_SCREEN = "screen";
|
||||
|
||||
// x and y can be specified as negative integers, in which case -1 represents the
|
||||
|
@ -585,7 +586,8 @@ public class AutoInstallsLayout {
|
|||
if (titleResId != 0) {
|
||||
title = mSourceRes.getString(titleResId);
|
||||
} else {
|
||||
title = "";
|
||||
String titleText = getAttributeValue(parser, ATTR_TITLE_TEXT);
|
||||
title = TextUtils.isEmpty(titleText) ? "" : titleText;
|
||||
}
|
||||
|
||||
mValues.put(Favorites.TITLE, title);
|
||||
|
|
Loading…
Reference in New Issue