Niedzielski has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/338058 )
Change subject: Hygiene: remove superfluous @TargetApi annotations ...................................................................... Hygiene: remove superfluous @TargetApi annotations Lint now checks API conditionals Change-Id: I8c0782655b9128b64220bfd55ee16b8695cdba97 --- M app/src/main/java/org/wikipedia/WikipediaApp.java M app/src/main/java/org/wikipedia/auth/AccountUtil.java M app/src/main/java/org/wikipedia/descriptions/DescriptionEditTutorialActivity.java M app/src/main/java/org/wikipedia/drawable/AppLevelListDrawable.java M app/src/main/java/org/wikipedia/main/MainFragment.java M app/src/main/java/org/wikipedia/page/FindInPageActionProvider.java M app/src/main/java/org/wikipedia/page/PageActivity.java M app/src/main/java/org/wikipedia/views/ViewUtil.java 8 files changed, 19 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/58/338058/1 diff --git a/app/src/main/java/org/wikipedia/WikipediaApp.java b/app/src/main/java/org/wikipedia/WikipediaApp.java index e387f76..784bd53 100644 --- a/app/src/main/java/org/wikipedia/WikipediaApp.java +++ b/app/src/main/java/org/wikipedia/WikipediaApp.java @@ -1,6 +1,5 @@ package org.wikipedia; -import android.annotation.TargetApi; import android.app.Activity; import android.app.Application; import android.database.ContentObserver; @@ -581,7 +580,6 @@ }; } - @TargetApi(Build.VERSION_CODES.KITKAT) private void enableWebViewDebugging() { if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); diff --git a/app/src/main/java/org/wikipedia/auth/AccountUtil.java b/app/src/main/java/org/wikipedia/auth/AccountUtil.java index 11e0492..de10076 100644 --- a/app/src/main/java/org/wikipedia/auth/AccountUtil.java +++ b/app/src/main/java/org/wikipedia/auth/AccountUtil.java @@ -3,7 +3,6 @@ import android.accounts.Account; import android.accounts.AccountAuthenticatorResponse; import android.accounts.AccountManager; -import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; @@ -56,7 +55,6 @@ } } - @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) public static void removeAccount() { Account account = account(); if (account != null) { diff --git a/app/src/main/java/org/wikipedia/descriptions/DescriptionEditTutorialActivity.java b/app/src/main/java/org/wikipedia/descriptions/DescriptionEditTutorialActivity.java index 09e1b29..6598b78 100644 --- a/app/src/main/java/org/wikipedia/descriptions/DescriptionEditTutorialActivity.java +++ b/app/src/main/java/org/wikipedia/descriptions/DescriptionEditTutorialActivity.java @@ -1,6 +1,5 @@ package org.wikipedia.descriptions; -import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -15,18 +14,14 @@ extends SingleFragmentActivity<DescriptionEditTutorialFragment> implements DescriptionEditTutorialFragment.Callback { - public static Intent newIntent(@NonNull Context context) { + @NonNull public static Intent newIntent(@NonNull Context context) { return new Intent(context, DescriptionEditTutorialActivity.class); } - @TargetApi(18) @Override public void onCreate(Bundle savedInstanceState) { + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Setting this in the manifest will not suffice since any manifest screenOrientation - // setting is overridden by the call to ActivityUtil.requestFullUserOrientation() in the - // base ActionBarActivity's onCreate(). - setRequestedOrientation(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 - ? ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT - : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + + setPortraitOrientation(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, @@ -34,12 +29,21 @@ } } - @Override protected DescriptionEditTutorialFragment createFragment() { - return DescriptionEditTutorialFragment.newInstance(); - } - @Override public void onStartEditingClick() { setResult(RESULT_OK); finish(); } -} + + @Override protected DescriptionEditTutorialFragment createFragment() { + return DescriptionEditTutorialFragment.newInstance(); + } + + private void setPortraitOrientation() { + int orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + orientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT; + } + + setRequestedOrientation(orientation); + } +} \ No newline at end of file diff --git a/app/src/main/java/org/wikipedia/drawable/AppLevelListDrawable.java b/app/src/main/java/org/wikipedia/drawable/AppLevelListDrawable.java index 228a337..5c319f5 100644 --- a/app/src/main/java/org/wikipedia/drawable/AppLevelListDrawable.java +++ b/app/src/main/java/org/wikipedia/drawable/AppLevelListDrawable.java @@ -1,6 +1,5 @@ package org.wikipedia.drawable; -import android.annotation.TargetApi; import android.content.res.ColorStateList; import android.graphics.ColorFilter; import android.graphics.drawable.Drawable; @@ -40,7 +39,6 @@ return invalidate; } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) private boolean updateLevelTint(Drawable drawable) { boolean invalidate = false; if (drawable != null) { diff --git a/app/src/main/java/org/wikipedia/main/MainFragment.java b/app/src/main/java/org/wikipedia/main/MainFragment.java index 25d3fb6..f92450d 100644 --- a/app/src/main/java/org/wikipedia/main/MainFragment.java +++ b/app/src/main/java/org/wikipedia/main/MainFragment.java @@ -1,7 +1,6 @@ package org.wikipedia.main; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.app.Activity; import android.app.DownloadManager; import android.content.ActivityNotFoundException; @@ -183,7 +182,6 @@ } } - @TargetApi(Build.VERSION_CODES.M) public void handleIntent(Intent intent) { IntentFunnel funnel = new IntentFunnel(WikipediaApp.getInstance()); if (Intent.ACTION_SEND.equals(intent.getAction()) diff --git a/app/src/main/java/org/wikipedia/page/FindInPageActionProvider.java b/app/src/main/java/org/wikipedia/page/FindInPageActionProvider.java index 5729bff..f2aa9d2 100644 --- a/app/src/main/java/org/wikipedia/page/FindInPageActionProvider.java +++ b/app/src/main/java/org/wikipedia/page/FindInPageActionProvider.java @@ -1,6 +1,5 @@ package org.wikipedia.page; -import android.annotation.TargetApi; import android.graphics.Color; import android.os.Build; import android.support.annotation.NonNull; @@ -119,9 +118,7 @@ return fragment.getWebView() != null; } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void findInPage(String s) { - // to make it stop complaining if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { fragment.getWebView().setFindListener(new FindListener() { @Override diff --git a/app/src/main/java/org/wikipedia/page/PageActivity.java b/app/src/main/java/org/wikipedia/page/PageActivity.java index 72ee674..36d9733 100644 --- a/app/src/main/java/org/wikipedia/page/PageActivity.java +++ b/app/src/main/java/org/wikipedia/page/PageActivity.java @@ -115,7 +115,6 @@ }; @Override - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (WikipediaApp) getApplicationContext(); diff --git a/app/src/main/java/org/wikipedia/views/ViewUtil.java b/app/src/main/java/org/wikipedia/views/ViewUtil.java index ad79762..7a61176 100644 --- a/app/src/main/java/org/wikipedia/views/ViewUtil.java +++ b/app/src/main/java/org/wikipedia/views/ViewUtil.java @@ -2,7 +2,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; -import android.annotation.TargetApi; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.drawable.Drawable; @@ -26,12 +25,11 @@ import java.lang.reflect.Field; public final class ViewUtil { - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) - @SuppressWarnings("deprecation") public static void setBackgroundDrawable(View view, Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(drawable); } else { + //noinspection deprecation view.setBackgroundDrawable(drawable); } } -- To view, visit https://gerrit.wikimedia.org/r/338058 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8c0782655b9128b64220bfd55ee16b8695cdba97 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: Sniedzielski <sniedziel...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits