Search in sources :

Example 6 with GridBackupTable

use of com.android.launcher3.model.GridBackupTable in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatRestoreHelper method createBackup.

/**
 * Creates a snapshot backup of Favorite table for future restoration use.
 */
public static void createBackup(Context context) {
    MODEL_EXECUTOR.execute(() -> {
        try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction) LauncherSettings.Settings.call(context.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_TRANSACTION).getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
            InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
            GridBackupTable backupTable = new GridBackupTable(context, transaction.getDb(), idp.numDatabaseHotseatIcons, idp.numColumns, idp.numRows);
            backupTable.createCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE);
            transaction.commit();
            LauncherSettings.Settings.call(context.getContentResolver(), LauncherSettings.Settings.METHOD_REFRESH_HOTSEAT_RESTORE_TABLE);
        }
    });
}
Also used : GridBackupTable(com.android.launcher3.model.GridBackupTable) LauncherDbUtils(com.android.launcher3.provider.LauncherDbUtils) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile)

Example 7 with GridBackupTable

use of com.android.launcher3.model.GridBackupTable in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatRestoreHelper method restoreBackup.

/**
 * Finds and restores a previously saved snapshow of Favorites table
 */
public static void restoreBackup(Context context) {
    MODEL_EXECUTOR.execute(() -> {
        try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction) LauncherSettings.Settings.call(context.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_TRANSACTION).getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
            if (!tableExists(transaction.getDb(), HYBRID_HOTSEAT_BACKUP_TABLE)) {
                return;
            }
            InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
            GridBackupTable backupTable = new GridBackupTable(context, transaction.getDb(), idp.numDatabaseHotseatIcons, idp.numColumns, idp.numRows);
            backupTable.restoreFromCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE, true);
            transaction.commit();
            LauncherAppState.getInstance(context).getModel().forceReload();
        }
    });
}
Also used : GridBackupTable(com.android.launcher3.model.GridBackupTable) LauncherDbUtils(com.android.launcher3.provider.LauncherDbUtils) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile)

Example 8 with GridBackupTable

use of com.android.launcher3.model.GridBackupTable in project android_packages_apps_Launcher3 by crdroidandroid.

the class RestoreDbTask method backupWorkspace.

/**
 * Backup the workspace so that if things go south in restore, we can recover these entries.
 */
private void backupWorkspace(Context context, SQLiteDatabase db) throws Exception {
    InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
    new GridBackupTable(context, db, idp.numDatabaseHotseatIcons, idp.numColumns, idp.numRows).doBackup(getDefaultProfileId(db), GridBackupTable.OPTION_REQUIRES_SANITIZATION);
}
Also used : GridBackupTable(com.android.launcher3.model.GridBackupTable) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile)

Example 9 with GridBackupTable

use of com.android.launcher3.model.GridBackupTable in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatRestoreHelper method restoreBackup.

/**
 * Finds and restores a previously saved snapshow of Favorites table
 */
public void restoreBackup() {
    MODEL_EXECUTOR.execute(() -> {
        try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction) LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_TRANSACTION).getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
            if (!tableExists(transaction.getDb(), HYBRID_HOTSEAT_BACKUP_TABLE)) {
                return;
            }
            InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
            GridBackupTable backupTable = new GridBackupTable(mLauncher, transaction.getDb(), idp.numHotseatIcons, idp.numColumns, idp.numRows);
            backupTable.restoreFromCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE, true);
            transaction.commit();
            mLauncher.getModel().forceReload();
        }
    });
}
Also used : GridBackupTable(com.android.launcher3.model.GridBackupTable) LauncherDbUtils(com.android.launcher3.provider.LauncherDbUtils) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile)

Example 10 with GridBackupTable

use of com.android.launcher3.model.GridBackupTable in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatRestoreHelper method createBackup.

/**
 * Creates a snapshot backup of Favorite table for future restoration use.
 */
public void createBackup() {
    MODEL_EXECUTOR.execute(() -> {
        try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction) LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_TRANSACTION).getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
            InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
            GridBackupTable backupTable = new GridBackupTable(mLauncher, transaction.getDb(), idp.numHotseatIcons, idp.numColumns, idp.numRows);
            backupTable.createCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE);
            transaction.commit();
            LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_REFRESH_HOTSEAT_RESTORE_TABLE);
        }
    });
}
Also used : GridBackupTable(com.android.launcher3.model.GridBackupTable) LauncherDbUtils(com.android.launcher3.provider.LauncherDbUtils) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile)

Aggregations

InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)9 GridBackupTable (com.android.launcher3.model.GridBackupTable)8 LauncherDbUtils (com.android.launcher3.provider.LauncherDbUtils)4 SharedPreferences (android.content.SharedPreferences)3 Cursor (android.database.Cursor)3 Point (android.graphics.Point)3 Utilities.getPointString (com.android.launcher3.Utilities.getPointString)3 Utilities.parsePoint (com.android.launcher3.Utilities.parsePoint)3 SQLiteTransaction (com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction)3