Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sridatta Gorugantula
Stickers
Commits
9a4bb5cc
Commit
9a4bb5cc
authored
Aug 29, 2019
by
Simon Xu
Browse files
add version number
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Blame Revision:
parent
49b7062d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Android/app/src/main/assets/contents.json
View file @
9a4bb5cc
...
...
@@ -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"
:
""
,
...
...
Android/app/src/main/java/com/example/samplestickerapp/ContentFileParser.java
View file @
9a4bb5cc
...
...
@@ -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
;
}
...
...
Android/app/src/main/java/com/example/samplestickerapp/StickerContentProvider.java
View file @
9a4bb5cc
...
...
@@ -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
;
...
...
Android/app/src/main/java/com/example/samplestickerapp/StickerPack.java
View file @
9a4bb5cc
...
...
@@ -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
));
}
}
Android/app/src/main/java/com/example/samplestickerapp/StickerPackLoader.java
View file @
9a4bb5cc
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment