Commit 78bcffe9 authored by ar-arvind's avatar ar-arvind Committed by Simon Xu
Browse files

Fixed lint warnings.

parent 2f9b0743
......@@ -56,7 +56,7 @@ task checkDebug {
doLast {
println("checkDebug")
if (android.defaultConfig.applicationId.startsWith("com.whatsapp")) {
throw new GradleException("applicationId in defaultConfig cannot start with com.whatsapp, please change your applicationId in app/build.gradle");
throw new GradleException("applicationId in defaultConfig cannot start with com.whatsapp, please change your applicationId in app/build.gradle")
}
checkApplicationIdInDebug()
}
......@@ -67,8 +67,8 @@ private void checkApplicationIdInDebug() {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ignoreApplicationIdCheck = properties.getProperty('ignoreApplicationIdCheck')
if (ignoreApplicationIdCheck == null) {
if (android.defaultConfig.applicationId.equals("com.example.samplestickerapp")) {
throw new GradleException("Your applicationId is currently com.example.samplestickerapp, please change your applicationId to a different string in app/build.gradle in line 10");
if (android.defaultConfig.applicationId == "com.example.samplestickerapp") {
throw new GradleException("Your applicationId is currently com.example.samplestickerapp, please change your applicationId to a different string in app/build.gradle in line 10")
}
} else {
println("application id check ignored")
......@@ -80,7 +80,7 @@ task checkRelease {
doLast {
println("checkRelease")
if (android.defaultConfig.applicationId.startsWith("com.example")) {
throw new GradleException("applicationId in defaultConfig cannot start with com.example, please change your applicationId in app/build.gradle");
throw new GradleException("applicationId in defaultConfig cannot start with com.example, please change your applicationId in app/build.gradle")
}
}
}
......
......@@ -28,7 +28,7 @@ public abstract class BaseActivity extends AppCompatActivity {
private static final String ARG_TITLE_ID = "title_id";
private static final String ARG_MESSAGE = "message";
public static DialogFragment newInstance(@StringRes int titleId, String message) {
static DialogFragment newInstance(@StringRes int titleId, String message) {
DialogFragment fragment = new MessageDialogFragment();
Bundle arguments = new Bundle();
arguments.putInt(ARG_TITLE_ID, titleId);
......
......@@ -23,7 +23,7 @@ class Sticker implements Parcelable {
this.emojis = emojis;
}
protected Sticker(Parcel in) {
private Sticker(Parcel in) {
imageFileName = in.readString();
emojis = in.createStringArrayList();
size = in.readLong();
......
......@@ -84,19 +84,19 @@ class StickerPack implements Parcelable {
}
}
public void setAndroidPlayStoreLink(String androidPlayStoreLink) {
void setAndroidPlayStoreLink(String androidPlayStoreLink) {
this.androidPlayStoreLink = androidPlayStoreLink;
}
public void setIosAppStoreLink(String iosAppStoreLink) {
void setIosAppStoreLink(String iosAppStoreLink) {
this.iosAppStoreLink = iosAppStoreLink;
}
public List<Sticker> getStickers() {
List<Sticker> getStickers() {
return stickers;
}
public long getTotalSize() {
long getTotalSize() {
return totalSize;
}
......
......@@ -47,7 +47,7 @@ public class StickerPackListActivity extends AddStickerPackActivity {
protected void onResume() {
super.onResume();
whiteListCheckAsyncTask = new WhiteListCheckAsyncTask(this);
whiteListCheckAsyncTask.execute(stickerPackList.toArray(new StickerPack[stickerPackList.size()]));
whiteListCheckAsyncTask.execute(stickerPackList.toArray(new StickerPack[0]));
}
@Override
......@@ -62,7 +62,7 @@ public class StickerPackListActivity extends AddStickerPackActivity {
allStickerPacksListAdapter = new StickerPackListAdapter(stickerPackList, onAddButtonClickedListener);
packRecyclerView.setAdapter(allStickerPacksListAdapter);
packLayoutManager = new LinearLayoutManager(this);
packLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
packLayoutManager.setOrientation(RecyclerView.VERTICAL);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
packRecyclerView.getContext(),
packLayoutManager.getOrientation()
......@@ -73,9 +73,8 @@ public class StickerPackListActivity extends AddStickerPackActivity {
}
private final StickerPackListAdapter.OnAddButtonClickedListener onAddButtonClickedListener = pack -> {
addStickerPackToWhatsApp(pack.identifier, pack.name);
};
private final StickerPackListAdapter.OnAddButtonClickedListener onAddButtonClickedListener = pack -> addStickerPackToWhatsApp(pack.identifier, pack.name);
private void recalculateColumnCount() {
final int previewSize = getResources().getDimensionPixelSize(R.dimen.sticker_pack_list_item_preview_image_size);
......
......@@ -116,7 +116,7 @@ public class StickerPackListAdapter extends RecyclerView.Adapter<StickerPackList
}
}
public void setStickerPackList(List<StickerPack> stickerPackList) {
void setStickerPackList(List<StickerPack> stickerPackList) {
this.stickerPacks = stickerPackList;
}
......
......@@ -15,7 +15,7 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
public class StickerPackListItemViewHolder extends RecyclerView.ViewHolder {
class StickerPackListItemViewHolder extends RecyclerView.ViewHolder {
View container;
TextView titleView;
......
......@@ -36,13 +36,13 @@ import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_I
import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_NAME_IN_QUERY;
import static com.example.samplestickerapp.StickerContentProvider.STICKER_PACK_PUBLISHER_IN_QUERY;
public class StickerPackLoader {
class StickerPackLoader {
/**
* Get the list of sticker packs for the sticker content provider
*/
@NonNull
public static ArrayList<StickerPack> fetchStickerPacks(Context context) throws IllegalStateException {
static ArrayList<StickerPack> fetchStickerPacks(Context context) throws IllegalStateException {
final Cursor cursor = context.getContentResolver().query(StickerContentProvider.AUTHORITY_URI, null, null, null, null);
if (cursor == null) {
throw new IllegalStateException("could not fetch from content provider, " + BuildConfig.CONTENT_PROVIDER_AUTHORITY);
......@@ -130,7 +130,7 @@ public class StickerPackLoader {
return stickers;
}
public static byte[] fetchStickerAsset(@NonNull final String identifier, @NonNull final String name, ContentResolver contentResolver) throws IOException {
static byte[] fetchStickerAsset(@NonNull final String identifier, @NonNull final String name, ContentResolver contentResolver) throws IOException {
try (final InputStream inputStream = contentResolver.openInputStream(getStickerAssetUri(identifier, name));
final ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
if (inputStream == null) {
......@@ -150,7 +150,7 @@ public class StickerPackLoader {
return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(BuildConfig.CONTENT_PROVIDER_AUTHORITY).appendPath(StickerContentProvider.STICKERS).appendPath(identifier).build();
}
public static Uri getStickerAssetUri(String identifier, String stickerName) {
static Uri getStickerAssetUri(String identifier, String stickerName) {
return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(BuildConfig.CONTENT_PROVIDER_AUTHORITY).appendPath(StickerContentProvider.STICKERS_ASSET).appendPath(identifier).appendPath(stickerName).build();
}
}
......@@ -25,7 +25,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
public class StickerPackValidator {
class StickerPackValidator {
private static final int STICKER_FILE_SIZE_LIMIT_KB = 100;
private static final int EMOJI_LIMIT = 3;
private static final int IMAGE_HEIGHT = 512;
......
......@@ -14,9 +14,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.facebook.drawee.view.SimpleDraweeView;
public class StickerPreviewViewHolder extends RecyclerView.ViewHolder {
class StickerPreviewViewHolder extends RecyclerView.ViewHolder {
public SimpleDraweeView stickerPreviewView;
final SimpleDraweeView stickerPreviewView;
StickerPreviewViewHolder(final View itemView) {
super(itemView);
......
......@@ -19,12 +19,12 @@ import android.net.Uri;
import androidx.annotation.NonNull;
@SuppressWarnings("FieldCanBeLocal")
public class WhitelistCheck {
class WhitelistCheck {
private static final String AUTHORITY_QUERY_PARAM = "authority";
private static final String IDENTIFIER_QUERY_PARAM = "identifier";
private static String STICKER_APP_AUTHORITY = BuildConfig.CONTENT_PROVIDER_AUTHORITY;
public static String CONSUMER_WHATSAPP_PACKAGE_NAME = "com.whatsapp";
public static String SMB_WHATSAPP_PACKAGE_NAME = "com.whatsapp.w4b";
static final String CONSUMER_WHATSAPP_PACKAGE_NAME = "com.whatsapp";
static final String SMB_WHATSAPP_PACKAGE_NAME = "com.whatsapp.w4b";
private static String CONTENT_PROVIDER = ".provider.sticker_whitelist_check";
private static String QUERY_PATH = "is_whitelisted";
private static String QUERY_RESULT_COLUMN_NAME = "result";
......@@ -79,19 +79,19 @@ public class WhitelistCheck {
}
}
public static boolean isWhatsAppConsumerAppInstalled(PackageManager packageManager) {
static boolean isWhatsAppConsumerAppInstalled(PackageManager packageManager) {
return WhitelistCheck.isPackageInstalled(CONSUMER_WHATSAPP_PACKAGE_NAME, packageManager);
}
public static boolean isWhatsAppSmbAppInstalled(PackageManager packageManager) {
static boolean isWhatsAppSmbAppInstalled(PackageManager packageManager) {
return WhitelistCheck.isPackageInstalled(SMB_WHATSAPP_PACKAGE_NAME, packageManager);
}
public static boolean isStickerPackWhitelistedInWhatsAppConsumer(@NonNull Context context, @NonNull String identifier) {
static boolean isStickerPackWhitelistedInWhatsAppConsumer(@NonNull Context context, @NonNull String identifier) {
return isWhitelistedFromProvider(context, identifier, CONSUMER_WHATSAPP_PACKAGE_NAME);
}
public static boolean isStickerPackWhitelistedInWhatsAppSmb(@NonNull Context context, @NonNull String identifier) {
static boolean isStickerPackWhitelistedInWhatsAppSmb(@NonNull Context context, @NonNull String identifier) {
return isWhitelistedFromProvider(context, identifier, SMB_WHATSAPP_PACKAGE_NAME);
}
}
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