Search in sources :

Example 16 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Trebuchet by LineageOS.

the class BackupRestoreTest method setUp.

@Before
public void setUp() {
    setupUserManager();
    setupBackupManager();
    mModelHelper = new LauncherModelHelper();
    RestoreDbTask.setPending(RuntimeEnvironment.application, true);
    mDb = mModelHelper.provider.getDb();
    mIdp = InvariantDeviceProfile.INSTANCE.get(RuntimeEnvironment.application);
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 17 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Trebuchet by LineageOS.

the class CacheDataUpdatedTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.initializeData("/cache_data_updated_task_data.txt");
    // Add dummy entries in the cache to simulate update
    Context context = RuntimeEnvironment.application;
    IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
    CachingLogic<ItemInfo> dummyLogic = new CachingLogic<ItemInfo>() {

        @Override
        public ComponentName getComponent(ItemInfo info) {
            return info.getTargetComponent();
        }

        @Override
        public UserHandle getUser(ItemInfo info) {
            return info.user;
        }

        @Override
        public CharSequence getLabel(ItemInfo info) {
            return NEW_LABEL_PREFIX + info.id;
        }

        @NonNull
        @Override
        public BitmapInfo loadIcon(Context context, ItemInfo info) {
            return BitmapInfo.of(Bitmap.createBitmap(1, 1, Config.ARGB_8888), Color.RED);
        }
    };
    UserManager um = context.getSystemService(UserManager.class);
    for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
        iconCache.addIconToDBAndMemCache(info, dummyLogic, new PackageInfo(), um.getSerialNumberForUser(info.user), true);
    }
}
Also used : Context(android.content.Context) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserManager(android.os.UserManager) PackageInfo(android.content.pm.PackageInfo) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) IconCache(com.android.launcher3.icons.IconCache) CachingLogic(com.android.launcher3.icons.cache.CachingLogic) Before(org.junit.Before)

Example 18 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a dummy provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    Context context = RuntimeEnvironment.application;
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(context);
    idp.numRows = idp.numColumns = idp.numHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    Settings.Secure.putString(context.getContentResolver(), "launcher3.layout.provider", TEST_PROVIDER_AUTHORITY);
    shadowOf(context.getPackageManager()).addProviderIfNotPresent(new ComponentName("com.test", "Dummy")).authority = TEST_PROVIDER_AUTHORITY;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    builder.build(new OutputStreamWriter(bos));
    Uri layoutUri = LauncherProvider.getLayoutUri(TEST_PROVIDER_AUTHORITY, context);
    shadowOf(context.getContentResolver()).registerInputStream(layoutUri, new ByteArrayInputStream(bos.toByteArray()));
    return this;
}
Also used : Context(android.content.Context) ByteArrayInputStream(java.io.ByteArrayInputStream) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ComponentName(android.content.ComponentName) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri)

Example 19 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Trebuchet by LineageOS.

the class SDWorkModeTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = RuntimeEnvironment.application;
    mIdp = InvariantDeviceProfile.INSTANCE.get(mTargetContext);
    ShadowOverrides.setProvider(UserEventDispatcher.class, c -> mock(UserEventDispatcher.class));
    Settings.Global.putFloat(mTargetContext.getContentResolver(), Settings.Global.WINDOW_ANIMATION_SCALE, 0);
    mModelHelper.installApp(TEST_PACKAGE);
    mLayoutBuilder = new LauncherLayoutBuilder();
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 20 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherUIScrollTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = RuntimeEnvironment.application;
    mIdp = InvariantDeviceProfile.INSTANCE.get(mTargetContext);
    ShadowOverrides.setProvider(UserEventDispatcher.class, c -> mock(UserEventDispatcher.class));
    Settings.Global.putFloat(mTargetContext.getContentResolver(), Settings.Global.WINDOW_ANIMATION_SCALE, 0);
    mModelHelper.installApp(TEST_PACKAGE);
    // LayoutBuilder with 3 workspace pages
    mLayoutBuilder = new LauncherLayoutBuilder().atWorkspace(0, mIdp.numRows - 1, 0).putApp(TEST_PACKAGE, TEST_PACKAGE).atWorkspace(0, mIdp.numRows - 1, 1).putApp(TEST_PACKAGE, TEST_PACKAGE).atWorkspace(0, mIdp.numRows - 1, 2).putApp(TEST_PACKAGE, TEST_PACKAGE);
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Aggregations

LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)55 Before (org.junit.Before)55 Context (android.content.Context)8 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)7 PackageInfo (android.content.pm.PackageInfo)6 Uri (android.net.Uri)6 UserManager (android.os.UserManager)6 IconCache (com.android.launcher3.icons.IconCache)6 CachingLogic (com.android.launcher3.icons.cache.CachingLogic)6 ItemInfo (com.android.launcher3.model.data.ItemInfo)6 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)6 IntArray (com.android.launcher3.util.IntArray)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 OutputStreamWriter (java.io.OutputStreamWriter)6 AppWidgetManager (android.appwidget.AppWidgetManager)5 ComponentWithLabel (com.android.launcher3.icons.ComponentWithLabel)5 ComponentName (android.content.ComponentName)4 ContentProvider (android.content.ContentProvider)4 MatrixCursor (android.database.MatrixCursor)4 ParcelFileDescriptor (android.os.ParcelFileDescriptor)4