Fix some lint issues

This commit is contained in:
xynngh
2020-06-02 16:36:45 +04:00
parent 751472d27c
commit 322f8def76
8 changed files with 24 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ android {
defaultConfig { defaultConfig {
applicationId "dummydomain.yetanothercallblocker" applicationId "dummydomain.yetanothercallblocker"
minSdkVersion 14 minSdkVersion 14
//noinspection OldTargetApi: required for call blocking
targetSdkVersion 28 targetSdkVersion 28
versionCode 4030 versionCode 4030
versionName "0.4.3" versionName "0.4.3"

View File

@@ -95,6 +95,7 @@ public class CallReceiver extends BroadcastReceiver {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try { try {
@SuppressLint("DiscouragedPrivateApi") // no choice
Method m = tm.getClass().getDeclaredMethod("getITelephony"); Method m = tm.getClass().getDeclaredMethod("getITelephony");
m.setAccessible(true); m.setAccessible(true);
ITelephony telephony = (ITelephony)m.invoke(tm); ITelephony telephony = (ITelephony)m.invoke(tm);

View File

@@ -68,7 +68,7 @@ public class DebugActivity extends AppCompatActivity {
FeaturedDatabaseItem featuredItem = DatabaseSingleton.getFeaturedDatabase() FeaturedDatabaseItem featuredItem = DatabaseSingleton.getFeaturedDatabase()
.getDbItemByNumber(getNumber()); .getDbItemByNumber(getNumber());
return new Pair(item, featuredItem); return new Pair<>(item, featuredItem);
} }
@Override @Override

View File

@@ -1,5 +1,6 @@
package dummydomain.yetanothercallblocker; package dummydomain.yetanothercallblocker;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@@ -12,6 +13,7 @@ public class EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(EventHandler.class); private static final Logger LOG = LoggerFactory.getLogger(EventHandler.class);
@SuppressLint("StaticFieldLeak") // same lifecycle
private static EventHandler instance; private static EventHandler instance;
private Context context; private Context context;

View File

@@ -8,7 +8,6 @@ import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.widget.ImageViewCompat; import androidx.core.widget.ImageViewCompat;
import dummydomain.yetanothercallblocker.data.NumberInfo; import dummydomain.yetanothercallblocker.data.NumberInfo;
@@ -34,7 +33,7 @@ class IconAndColor {
@ColorInt @ColorInt
int getColorInt(@NonNull Context context) { int getColorInt(@NonNull Context context) {
return ResourcesCompat.getColor(context.getResources(), colorResId, context.getTheme()); return UiUtils.getColorInt(context, colorResId);
} }
void setOnImageView(AppCompatImageView imageView) { void setOnImageView(AppCompatImageView imageView) {

View File

@@ -165,7 +165,7 @@ public class NotificationHelper {
NotificationCompat.Builder builder = new NotificationCompat.Builder( NotificationCompat.Builder builder = new NotificationCompat.Builder(
context, CHANNEL_ID_BLOCKED_INFO) context, CHANNEL_ID_BLOCKED_INFO)
.setSmallIcon(R.drawable.ic_brick_24dp) .setSmallIcon(R.drawable.ic_brick_24dp)
.setColor(context.getResources().getColor(R.color.rateNegative)) .setColor(UiUtils.getColorInt(context, R.color.rateNegative))
.setContentTitle(title) .setContentTitle(title)
.setContentText(text) .setContentText(text)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)

View File

@@ -0,0 +1,17 @@
package dummydomain.yetanothercallblocker;
import android.content.Context;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
public class UiUtils {
@ColorInt
public static int getColorInt(@NonNull Context context, @ColorRes int colorResId) {
return ResourcesCompat.getColor(context.getResources(), colorResId, context.getTheme());
}
}

View File

@@ -7,6 +7,5 @@
<color name="ratePositive">#679f41</color> <color name="ratePositive">#679f41</color>
<color name="rateNeutral">#ffb300</color> <color name="rateNeutral">#ffb300</color>
<color name="rateNegative">#d40000</color> <color name="rateNegative">#d40000</color>
<color name="rateUnknown">#999999</color>
<color name="notFound">#999999</color> <color name="notFound">#999999</color>
</resources> </resources>