Commit 845a9f4e authored by Simon Xu's avatar Simon Xu
Browse files

enforce at least one emoji per sticker

WhatsApp is trying to improve sticker search capability, part of this involves using the associated emoji to figure out the search term. Sticker apps can help improve overall user experience by associating emojis to sticekrs. Therefore, we are asking all developers to be diligent and associate 1-3 emojis to each sticker.
parent ce202c7d
......@@ -64,9 +64,9 @@ You must also modify the contents.json file in SampleStickerApp/app/src/main/ass
* `image_data_version` : an overall representation of the version of the stickers and tray icon. When you update stickers or tray icon in your pack, please update this string, this will tell WhatsApp that the pack has new content and update the stickers on WhatsApp side.
* `avoid_cache` : this tells WhatsApp that the stickers from your pack should not be cached. By default, you should keep it false. Exception is that if your app updates stickers without user actions, you can keep it true, for example: your app provides clock sticker that updates stickers every minute.
* `android_play_store_link` and `ios_app_store_link` (optional fields): here you can put the URL to your sticker app in the Google Play Store and Apple App Store (if you have an iOS version of your sticker app). If you provide these URLs, users who receive a sticker from your app in WhatsApp can tap on it to view your sticker app in the respective App Stores. On Android, the URL follows the format https://play.google.com/store/apps/details?id=com.example where "com.example" is your app's package name.
* `emojis` (optional): add up to a maximum of three emoji for each sticker file. Select emoji that best describe or represent that sticker file. For example, if the sticker is portraying love, you may choose to add a heart emoji like 💕. If your sticker portrays pizza, you may want to add the pizza slice emoji 🍕. In the future, WhatsApp will support a search function for stickers and tagging your sticker files with emoji will enable that. The sticker picker/tray in WhatsApp today already categorizes stickers into emotion categories (love, happy, sad, and angry) and it does this based on the emoji you tag your stickers with.
* `emojis` (required): add up to 1-3 emojis for each sticker file. Select emoji that best describe or represent that sticker file. For example, if the sticker is portraying love, you may choose to add a heart emoji like 💕. If your sticker portrays pizza, you may want to add the pizza slice emoji 🍕. In the future, WhatsApp will support a search function for stickers and tagging your sticker files with emoji will enable that. The sticker picker/tray in WhatsApp today already categorizes stickers into emotion categories (love, happy, sad, and angry) and it does this based on the emoji you tag your stickers with.
The following fields are optional: `ios_app_store_link`, `android_play_store_link`, `publisher_website`, `privacy_policy_website`, `license_agreement_website`, `emoji`
The following fields are optional: `ios_app_store_link`, `android_play_store_link`, `publisher_website`, `privacy_policy_website`, `license_agreement_website`
All the links need to start with either "http" or "https"
If your app has more than 1 sticker pack, you will need to reference it in contents.json. Simply create a second array within the "sticker_packs" section of the JSON and include all the metadata (name, identifier, etc) along with all the references to the sticker files.
......
......@@ -21,8 +21,6 @@ import java.util.List;
class ContentFileParser {
private static final int LIMIT_EMOJI_COUNT = 3;
@NonNull
static List<StickerPack> parseStickerPacks(@NonNull InputStream contentsInputStream) throws IOException, IllegalStateException {
try (JsonReader reader = new JsonReader(new InputStreamReader(contentsInputStream))) {
......@@ -153,7 +151,7 @@ class ContentFileParser {
while (reader.hasNext()) {
reader.beginObject();
String imageFile = null;
List<String> emojis = new ArrayList<>(LIMIT_EMOJI_COUNT);
List<String> emojis = new ArrayList<>(StickerPackValidator.EMOJI_MAX_LIMIT);
while (reader.hasNext()) {
final String key = reader.nextName();
if ("image_file".equals(key)) {
......@@ -162,7 +160,9 @@ class ContentFileParser {
reader.beginArray();
while (reader.hasNext()) {
String emoji = reader.nextString();
emojis.add(emoji);
if (!TextUtils.isEmpty(emoji)) {
emojis.add(emoji);
}
}
reader.endArray();
} else {
......
......@@ -14,6 +14,7 @@ import android.database.Cursor;
import android.net.Uri;
import androidx.annotation.NonNull;
import android.text.TextUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
......@@ -125,7 +126,11 @@ class StickerPackLoader {
do {
final String name = cursor.getString(cursor.getColumnIndexOrThrow(STICKER_FILE_NAME_IN_QUERY));
final String emojisConcatenated = cursor.getString(cursor.getColumnIndexOrThrow(STICKER_FILE_EMOJI_IN_QUERY));
stickers.add(new Sticker(name, Arrays.asList(emojisConcatenated.split(","))));
List<String> emojis = new ArrayList<>(StickerPackValidator.EMOJI_MAX_LIMIT);
if (!TextUtils.isEmpty(emojisConcatenated)) {
emojis = Arrays.asList(emojisConcatenated.split(","));
}
stickers.add(new Sticker(name, emojis));
} while (cursor.moveToNext());
}
if (cursor != null) {
......
......@@ -27,7 +27,8 @@ import java.util.List;
class StickerPackValidator {
private static final int STICKER_FILE_SIZE_LIMIT_KB = 100;
private static final int EMOJI_LIMIT = 3;
static final int EMOJI_MAX_LIMIT = 3;
private static final int EMOJI_MIN_LIMIT = 1;
private static final int IMAGE_HEIGHT = 512;
private static final int IMAGE_WIDTH = 512;
private static final int STICKER_SIZE_MIN = 3;
......@@ -116,9 +117,12 @@ class StickerPackValidator {
}
private static void validateSticker(@NonNull Context context, @NonNull final String identifier, @NonNull final Sticker sticker) throws IllegalStateException {
if (sticker.emojis.size() > EMOJI_LIMIT) {
if (sticker.emojis.size() > EMOJI_MAX_LIMIT) {
throw new IllegalStateException("emoji count exceed limit, sticker pack identifier:" + identifier + ", filename:" + sticker.imageFileName);
}
if (sticker.emojis.size() < EMOJI_MIN_LIMIT) {
throw new IllegalStateException("To provide best user experience, please associate at least 1 emoji to this sticker, sticker pack identifier:" + identifier + ", filename:" + sticker.imageFileName);
}
if (TextUtils.isEmpty(sticker.imageFileName)) {
throw new IllegalStateException("no file path for sticker, sticker pack identifier:" + identifier);
}
......
Markdown is supported
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