[DO NOT MERGE] Adding minSpanX and minSpanY for all the launcher widgets

Bug: 22353460
Change-Id: Id4450dee42a83e4603dcd56e1c4dec2b0e405858
This commit is contained in:
Sunny Goyal
2015-07-16 17:27:43 -07:00
parent 3fec14bedc
commit 249a510ab3
3 changed files with 17 additions and 10 deletions

View File

@@ -90,17 +90,17 @@ message Favorite {
optional string iconPackage = 16;
optional string iconResource = 17;
optional bytes icon = 18;
}
}
message Screen {
required int64 id = 1;
optional int32 rank = 2;
}
}
message Resource {
required int32 dpi = 1;
required bytes data = 2;
}
}
message Widget {
required string provider = 1;
@@ -108,4 +108,8 @@ message Widget {
optional bool configure = 3;
optional Resource icon = 4;
optional Resource preview = 5;
}
// Assume that a widget is resizable upto 2x2 if no data is available
optional int32 minSpanX = 6 [default = 2];
optional int32 minSpanY = 7 [default = 2];
}

View File

@@ -92,7 +92,7 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
LauncherClings.synchonouslyMarkFirstRunClingDismissed(this);
// TODO: Update the backup set to include rank.
if (mHelper.restoredBackupVersion <= 2) {
if (mHelper.restoredBackupVersion <= 3) {
LauncherAppState.getLauncherProvider().updateFolderItemsRank();
}
} else {

View File

@@ -19,7 +19,6 @@ import android.app.backup.BackupDataInputStream;
import android.app.backup.BackupDataOutput;
import android.app.backup.BackupHelper;
import android.app.backup.BackupManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -58,7 +57,6 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.zip.CRC32;
@@ -70,7 +68,7 @@ public class LauncherBackupHelper implements BackupHelper {
private static final boolean VERBOSE = LauncherBackupAgentHelper.VERBOSE;
private static final boolean DEBUG = LauncherBackupAgentHelper.DEBUG;
private static final int BACKUP_VERSION = 2;
private static final int BACKUP_VERSION = 3;
private static final int MAX_JOURNAL_SIZE = 1000000;
// Journal key is such that it is always smaller than any dynamically generated
@@ -171,6 +169,7 @@ public class LauncherBackupHelper implements BackupHelper {
mExistingKeys.add(keyToBackupKey(key));
}
}
restoredBackupVersion = journal.backupVersion;
}
/**
@@ -313,7 +312,6 @@ public class LauncherBackupHelper implements BackupHelper {
MessageNano.mergeFrom(journal, readCheckedBytes(mBuffer, dataSize));
applyJournal(journal);
restoreSuccessful = isBackupCompatible(journal);
restoredBackupVersion = journal.backupVersion;
return;
}
@@ -639,7 +637,7 @@ public class LauncherBackupHelper implements BackupHelper {
} else {
Log.w(TAG, "empty intent on appwidget: " + id);
}
if (mExistingKeys.contains(backupKey)) {
if (mExistingKeys.contains(backupKey) && restoredBackupVersion >= BACKUP_VERSION) {
if (DEBUG) Log.d(TAG, "already saved widget " + backupKey);
// remember that we already backed this up previously
@@ -942,6 +940,11 @@ public class LauncherBackupHelper implements BackupHelper {
widget.preview.dpi = dpi;
}
}
widget.minSpanX = (info.resizeMode & LauncherAppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0
? info.minSpanX : -1;
widget.minSpanY = (info.resizeMode & LauncherAppWidgetProviderInfo.RESIZE_VERTICAL) != 0
? info.minSpanY : -1;
return widget;
}