Search in sources :

Example 11 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by AOSPA.

the class CacheDataUpdatedTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.initializeData("cache_data_updated_task_data");
    // Add placeholder entries in the cache to simulate update
    Context context = mModelHelper.sandboxContext;
    IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
    CachingLogic<ItemInfo> placeholderLogic = 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, placeholderLogic, 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 12 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by AOSPA.

the class DefaultLayoutProviderTest method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = mModelHelper.sandboxContext;
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 13 with LauncherModelHelper

use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by AOSPA.

the class AddWorkspaceItemsTaskTest method setup.

@Before
public void setup() {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = mModelHelper.sandboxContext;
    mIdp = InvariantDeviceProfile.INSTANCE.get(mTargetContext);
    mIdp.numColumns = mIdp.numRows = 5;
    mAppState = LauncherAppState.getInstance(mTargetContext);
    mExistingScreens = new IntArray();
    mScreenOccupancy = new IntSparseArrayMap<>();
    mNewScreens = new IntArray();
}
Also used : IntArray(com.android.launcher3.util.IntArray) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 14 with LauncherModelHelper

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

the class GridBackupTableTest method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mContext = RuntimeEnvironment.application;
    mDb = mModelHelper.provider.getDb();
    setupGridData();
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 15 with LauncherModelHelper

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

the class GridSizeMigrationTaskV2Test method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mContext = RuntimeEnvironment.application;
    mDb = mModelHelper.provider.getDb();
    mValidPackages = new HashSet<>();
    mValidPackages.add(TEST_PACKAGE);
    mValidPackages.add(testPackage1);
    mValidPackages.add(testPackage2);
    mValidPackages.add(testPackage3);
    mValidPackages.add(testPackage4);
    mValidPackages.add(testPackage5);
    mValidPackages.add(testPackage6);
    mValidPackages.add(testPackage7);
    mValidPackages.add(testPackage8);
    mValidPackages.add(testPackage9);
    mValidPackages.add(testPackage10);
    mIdp = InvariantDeviceProfile.INSTANCE.get(mContext);
    long userSerial = UserCache.INSTANCE.get(mContext).getSerialNumberForUser(Process.myUserHandle());
    dropTable(mDb, LauncherSettings.Favorites.TMP_TABLE);
    LauncherSettings.Favorites.addTableToDb(mDb, userSerial, false, LauncherSettings.Favorites.TMP_TABLE);
}
Also used : 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