Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a41762f8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding a new attribute to speficy folder label directly in layout" into ub-launcher3-rvc-dev

parents e3a51fec 55e2b163
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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";
+11 −1
Original line number Diff line number Diff line
@@ -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;
+3 −1
Original line number Diff line number Diff line
@@ -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);