Commit 9a4bb5cc authored by Simon Xu's avatar Simon Xu
Browse files

add version number

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Blame Revision:
parent 49b7062d
......@@ -7,6 +7,8 @@
"name": "Cuppy",
"publisher": "Jane Doe",
"tray_image_file": "tray_Cuppy.png",
"image_data_version":"1",
"avoid_cache":false,
"publisher_email":"",
"publisher_website": "",
"privacy_policy_website": "",
......
......@@ -75,6 +75,8 @@ class ContentFileParser {
String publisherWebsite = null;
String privacyPolicyWebsite = null;
String licenseAgreementWebsite = null;
String imageDataVersion = "";
boolean avoidCache = false;
List<Sticker> stickerList = null;
while (reader.hasNext()) {
String key = reader.nextName();
......@@ -106,6 +108,12 @@ class ContentFileParser {
case "stickers":
stickerList = readStickers(reader);
break;
case "image_data_version":
imageDataVersion = reader.nextString();
break;
case "avoid_cache":
avoidCache = reader.nextBoolean();
break;
default:
reader.skipValue();
}
......@@ -128,8 +136,11 @@ class ContentFileParser {
if (identifier.contains("..") || identifier.contains("/")) {
throw new IllegalStateException("identifier should not contain .. or / to prevent directory traversal");
}
if (TextUtils.isEmpty(imageDataVersion)) {
throw new IllegalStateException("image_data_version should not be empty");
}
reader.endObject();
final StickerPack stickerPack = new StickerPack(identifier, name, publisher, trayImageFile, publisherEmail, publisherWebsite, privacyPolicyWebsite, licenseAgreementWebsite);
final StickerPack stickerPack = new StickerPack(identifier, name, publisher, trayImageFile, publisherEmail, publisherWebsite, privacyPolicyWebsite, licenseAgreementWebsite, imageDataVersion, avoidCache);
stickerPack.setStickers(stickerList);
return stickerPack;
}
......
......@@ -46,6 +46,8 @@ public class StickerContentProvider extends ContentProvider {
public static final String PUBLISHER_WEBSITE = "sticker_pack_publisher_website";
public static final String PRIVACY_POLICY_WEBSITE = "sticker_pack_privacy_policy_website";
public static final String LICENSE_AGREENMENT_WEBSITE = "sticker_pack_license_agreement_website";
public static final String IMAGE_DATA_VERSION = "image_data_version";
public static final String AVOID_CACHE = "whatsapp_will_not_cache_stickers";
public static final String STICKER_FILE_NAME_IN_QUERY = "sticker_file_name";
public static final String STICKER_FILE_EMOJI_IN_QUERY = "sticker_emoji";
......@@ -186,7 +188,9 @@ public class StickerContentProvider extends ContentProvider {
PUBLISHER_EMAIL,
PUBLISHER_WEBSITE,
PRIVACY_POLICY_WEBSITE,
LICENSE_AGREENMENT_WEBSITE
LICENSE_AGREENMENT_WEBSITE,
IMAGE_DATA_VERSION,
AVOID_CACHE,
});
for (StickerPack stickerPack : stickerPackList) {
MatrixCursor.RowBuilder builder = cursor.newRow();
......@@ -200,6 +204,8 @@ public class StickerContentProvider extends ContentProvider {
builder.add(stickerPack.publisherWebsite);
builder.add(stickerPack.privacyPolicyWebsite);
builder.add(stickerPack.licenseAgreementWebsite);
builder.add(stickerPack.imageDataVersion);
builder.add(stickerPack.avoidCache ? 1 : 0);
}
cursor.setNotificationUri(Objects.requireNonNull(getContext()).getContentResolver(), uri);
return cursor;
......
......@@ -22,6 +22,8 @@ class StickerPack implements Parcelable {
final String publisherWebsite;
final String privacyPolicyWebsite;
final String licenseAgreementWebsite;
final String imageDataVersion;
final boolean avoidCache;
String iosAppStoreLink;
private List<Sticker> stickers;
......@@ -29,7 +31,7 @@ class StickerPack implements Parcelable {
String androidPlayStoreLink;
private boolean isWhitelisted;
StickerPack(String identifier, String name, String publisher, String trayImageFile, String publisherEmail, String publisherWebsite, String privacyPolicyWebsite, String licenseAgreementWebsite) {
StickerPack(String identifier, String name, String publisher, String trayImageFile, String publisherEmail, String publisherWebsite, String privacyPolicyWebsite, String licenseAgreementWebsite, String imageDataVersion, boolean avoidCache) {
this.identifier = identifier;
this.name = name;
this.publisher = publisher;
......@@ -38,6 +40,8 @@ class StickerPack implements Parcelable {
this.publisherWebsite = publisherWebsite;
this.privacyPolicyWebsite = privacyPolicyWebsite;
this.licenseAgreementWebsite = licenseAgreementWebsite;
this.imageDataVersion = imageDataVersion;
this.avoidCache = avoidCache;
}
void setIsWhitelisted(boolean isWhitelisted) {
......@@ -62,6 +66,8 @@ class StickerPack implements Parcelable {
totalSize = in.readLong();
androidPlayStoreLink = in.readString();
isWhitelisted = in.readByte() != 0;
imageDataVersion = in.readString();
avoidCache = in.readByte() != 0;
}
public static final Creator<StickerPack> CREATOR = new Creator<StickerPack>() {
......@@ -120,5 +126,7 @@ class StickerPack implements Parcelable {
dest.writeLong(totalSize);
dest.writeString(androidPlayStoreLink);
dest.writeByte((byte) (isWhitelisted ? 1 : 0));
dest.writeString(imageDataVersion);
dest.writeByte((byte) (avoidCache ? 1 : 0));
}
}
......@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.List;
import static com.example.samplestickerapp.StickerContentProvider.ANDROID_APP_DOWNLOAD_LINK_IN_QUERY;
import static com.example.samplestickerapp.StickerContentProvider.AVOID_CACHE;
import static com.example.samplestickerapp.StickerContentProvider.IOS_APP_DOWNLOAD_LINK_IN_QUERY;
import static com.example.samplestickerapp.StickerContentProvider.LICENSE_AGREENMENT_WEBSITE;
import static com.example.samplestickerapp.StickerContentProvider.PRIVACY_POLICY_WEBSITE;
......@@ -35,6 +36,7 @@ import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_I
import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_IDENTIFIER_IN_QUERY;
import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_NAME_IN_QUERY;
import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_PUBLISHER_IN_QUERY;
import static com.example.samplestickerapp.StickerContentProvider.IMAGE_DATA_VERSION;
class StickerPackLoader {
......@@ -101,7 +103,9 @@ class StickerPackLoader {
final String publisherWebsite = cursor.getString(cursor.getColumnIndexOrThrow(PUBLISHER_WEBSITE));
final String privacyPolicyWebsite = cursor.getString(cursor.getColumnIndexOrThrow(PRIVACY_POLICY_WEBSITE));
final String licenseAgreementWebsite = cursor.getString(cursor.getColumnIndexOrThrow(LICENSE_AGREENMENT_WEBSITE));
final StickerPack stickerPack = new StickerPack(identifier, name, publisher, trayImage, publisherEmail, publisherWebsite, privacyPolicyWebsite, licenseAgreementWebsite);
final String imageDataVersion = cursor.getString(cursor.getColumnIndexOrThrow(IMAGE_DATA_VERSION));
final boolean avoidCache = cursor.getShort(cursor.getColumnIndexOrThrow(AVOID_CACHE)) > 0;
final StickerPack stickerPack = new StickerPack(identifier, name, publisher, trayImage, publisherEmail, publisherWebsite, privacyPolicyWebsite, licenseAgreementWebsite, imageDataVersion, avoidCache);
stickerPack.setAndroidPlayStoreLink(androidPlayStoreLink);
stickerPack.setIosAppStoreLink(iosAppLink);
stickerPackList.add(stickerPack);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment