From fd69477e6c70636bfeb8967a3a2a38e840ea3c6a Mon Sep 17 00:00:00 2001 From: Unrud Date: Tue, 18 Jul 2017 17:41:57 +0200 Subject: [PATCH] Remove TargetApi annotations They are not used correctly and suppress important linter warnings. (e.g. ea8621cfc37349997f1c5b5ee250b42423c4c26a) --- .../nutomic/syncthingandroid/activities/MainActivity.java | 5 ++--- .../nutomic/syncthingandroid/receiver/AppConfigReceiver.java | 2 -- .../nutomic/syncthingandroid/service/DeviceStateHolder.java | 3 --- .../nutomic/syncthingandroid/service/SyncthingService.java | 2 -- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java index bc7b1ebf..62aa677e 100644 --- a/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java @@ -1,7 +1,6 @@ package com.nutomic.syncthingandroid.activities; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -131,13 +130,13 @@ public class MainActivity extends SyncthingActivity } } - @TargetApi(23) private void showBatteryOptimizationDialogIfNecessary() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) + return; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); boolean dontShowAgain = sp.getBoolean("battery_optimization_dont_show_again", false); if (dontShowAgain || mBatteryOptimizationsDialog != null || - Build.VERSION.SDK_INT < Build.VERSION_CODES.M || pm.isIgnoringBatteryOptimizations(getPackageName()) || mBatteryOptimizationDialogDismissed) { return; diff --git a/src/main/java/com/nutomic/syncthingandroid/receiver/AppConfigReceiver.java b/src/main/java/com/nutomic/syncthingandroid/receiver/AppConfigReceiver.java index 12315eaf..81e1311c 100644 --- a/src/main/java/com/nutomic/syncthingandroid/receiver/AppConfigReceiver.java +++ b/src/main/java/com/nutomic/syncthingandroid/receiver/AppConfigReceiver.java @@ -1,6 +1,5 @@ package com.nutomic.syncthingandroid.receiver; -import android.annotation.TargetApi; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -35,7 +34,6 @@ public class AppConfigReceiver extends BroadcastReceiver { public static final String ACTION_STOP = "com.nutomic.syncthingandroid.action.STOP"; @Override - @TargetApi(21) public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case ACTION_START: diff --git a/src/main/java/com/nutomic/syncthingandroid/service/DeviceStateHolder.java b/src/main/java/com/nutomic/syncthingandroid/service/DeviceStateHolder.java index 913278c4..81b791a8 100644 --- a/src/main/java/com/nutomic/syncthingandroid/service/DeviceStateHolder.java +++ b/src/main/java/com/nutomic/syncthingandroid/service/DeviceStateHolder.java @@ -1,6 +1,5 @@ package com.nutomic.syncthingandroid.service; -import android.annotation.TargetApi; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -49,7 +48,6 @@ public class DeviceStateHolder extends BroadcastReceiver { private boolean mIsCharging = false; - @TargetApi(16) public DeviceStateHolder(Context context) { mContext = context; ConnectivityManager cm = (ConnectivityManager) @@ -111,7 +109,6 @@ public class DeviceStateHolder extends BroadcastReceiver { /** * Determines if Syncthing should currently run. */ - @TargetApi(21) public boolean shouldRun() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); diff --git a/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java index 5952030c..c36d6fe4 100644 --- a/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java @@ -1,6 +1,5 @@ package com.nutomic.syncthingandroid.service; -import android.annotation.TargetApi; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; @@ -305,7 +304,6 @@ public class SyncthingService extends Service implements * Starts the native binary. */ @Override - @TargetApi(21) public void onCreate() { super.onCreate(); PRNGFixes.apply();