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);
}
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);
}
}
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;
}
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();
}
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);
}
Aggregations