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 {
applicationId "dummydomain.yetanothercallblocker"
minSdkVersion 14
//noinspection OldTargetApi: required for call blocking
targetSdkVersion 28
versionCode 4030
versionName "0.4.3"

View File

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

View File

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

View File

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

View File

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

View File

@ -165,7 +165,7 @@ public class NotificationHelper {
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context, CHANNEL_ID_BLOCKED_INFO)
.setSmallIcon(R.drawable.ic_brick_24dp)
.setColor(context.getResources().getColor(R.color.rateNegative))
.setColor(UiUtils.getColorInt(context, R.color.rateNegative))
.setContentTitle(title)
.setContentText(text)
.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="rateNeutral">#ffb300</color>
<color name="rateNegative">#d40000</color>
<color name="rateUnknown">#999999</color>
<color name="notFound">#999999</color>
</resources>