Commit 47fb4821 authored by Newton Allen's avatar Newton Allen

Address NewApi and other Android lint warnings in src/chrome.

BUG=266140
R=aurimas@chromium.org

Review URL: https://codereview.chromium.org/965933002

Cr-Commit-Position: refs/heads/master@{#318735}
parent 97874ef0
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:orientation="horizontal" > android:orientation="horizontal" >
<!--suppress ButtonStyle -->
<Button <Button
android:id="@+id/negative_button" android:id="@+id/negative_button"
android:layout_width="0dp" android:layout_width="0dp"
...@@ -107,6 +108,7 @@ ...@@ -107,6 +108,7 @@
android:textColor="@color/light_normal_color" android:textColor="@color/light_normal_color"
android:textSize="@dimen/fre_button_text_size" /> android:textSize="@dimen/fre_button_text_size" />
<!--suppress ButtonStyle -->
<Button <Button
android:id="@+id/positive_button" android:id="@+id/positive_button"
android:layout_width="0dp" android:layout_width="0dp"
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="?android:attr/listDivider" android:src="?android:attr/listDivider"
android:scaleType="fitXY" /> android:scaleType="fitXY" />
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser; package org.chromium.chrome.browser;
import android.annotation.TargetApi;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -151,6 +152,7 @@ public class BookmarkUtils { ...@@ -151,6 +152,7 @@ public class BookmarkUtils {
return bitmap; return bitmap;
} }
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
private static Bitmap getBitmapFromResourceId(Context context, int id, int density) { private static Bitmap getBitmapFromResourceId(Context context, int id, int density) {
Drawable drawable = null; Drawable drawable = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
package org.chromium.chrome.browser; package org.chromium.chrome.browser;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener; import android.speech.tts.UtteranceProgressListener;
...@@ -12,6 +14,7 @@ import android.speech.tts.UtteranceProgressListener; ...@@ -12,6 +14,7 @@ import android.speech.tts.UtteranceProgressListener;
/** /**
* Subclass of TtsPlatformImpl for Lollipop to make use of newer APIs. * Subclass of TtsPlatformImpl for Lollipop to make use of newer APIs.
*/ */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class LollipopTtsPlatformImpl extends TtsPlatformImpl { class LollipopTtsPlatformImpl extends TtsPlatformImpl {
protected LollipopTtsPlatformImpl(long nativeTtsPlatformImplAndroid, Context context) { protected LollipopTtsPlatformImpl(long nativeTtsPlatformImplAndroid, Context context) {
super(nativeTtsPlatformImplAndroid, context); super(nativeTtsPlatformImplAndroid, context);
......
...@@ -9,6 +9,7 @@ import android.animation.AnimatorListenerAdapter; ...@@ -9,6 +9,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.annotation.TargetApi;
import android.os.Build; import android.os.Build;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
...@@ -217,6 +218,7 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener ...@@ -217,6 +218,7 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener
mTargetWrapperView.startTransition(); mTargetWrapperView.startTransition();
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mTargetWrapperView.finishTransition(); mTargetWrapperView.finishTransition();
......
...@@ -16,14 +16,12 @@ import android.preference.Preference; ...@@ -16,14 +16,12 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.provider.Settings; import android.provider.Settings;
import android.text.Editable; import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -36,6 +34,7 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge; ...@@ -36,6 +34,7 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge;
public class AddExceptionPreference extends Preference implements OnPreferenceClickListener { public class AddExceptionPreference extends Preference implements OnPreferenceClickListener {
// The callback to notify when the user adds a site. // The callback to notify when the user adds a site.
private SiteAddedCallback mSiteAddedCallback; private SiteAddedCallback mSiteAddedCallback;
private int mPrefAccentColor;
/** /**
* An interface to implement to get a callback when a site has been added. * An interface to implement to get a callback when a site has been added.
...@@ -57,20 +56,22 @@ public class AddExceptionPreference extends Preference implements OnPreferenceCl ...@@ -57,20 +56,22 @@ public class AddExceptionPreference extends Preference implements OnPreferenceCl
setKey(key); setKey(key);
Resources resources = getContext().getResources(); Resources resources = getContext().getResources();
mPrefAccentColor = resources.getColor(R.color.pref_accent_color);
Drawable plusIcon = resources.getDrawable(R.drawable.plus); Drawable plusIcon = resources.getDrawable(R.drawable.plus);
plusIcon.mutate(); plusIcon.mutate();
plusIcon.setColorFilter( plusIcon.setColorFilter(mPrefAccentColor, PorterDuff.Mode.SRC_IN);
resources.getColor(R.color.pref_accent_color),
PorterDuff.Mode.SRC_IN);
setIcon(plusIcon); setIcon(plusIcon);
SpannableString titleSpan = new SpannableString( setTitle(resources.getString(R.string.website_settings_add_site));
resources.getString( }
R.string.website_settings_add_site).toUpperCase());
titleSpan.setSpan(new ForegroundColorSpan( @Override
resources.getColor(R.color.pref_accent_color)), 0, titleSpan.length(), protected void onBindView(View view) {
Spannable.SPAN_INCLUSIVE_INCLUSIVE); super.onBindView(view);
setTitle(titleSpan); TextView titleView = (TextView) view.findViewById(android.R.id.title);
titleView.setAllCaps(true);
titleView.setTextColor(mPrefAccentColor);
} }
@Override @Override
...@@ -89,6 +90,7 @@ public class AddExceptionPreference extends Preference implements OnPreferenceCl ...@@ -89,6 +90,7 @@ public class AddExceptionPreference extends Preference implements OnPreferenceCl
final EditText input = (EditText) view.findViewById(R.id.site); final EditText input = (EditText) view.findViewById(R.id.site);
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) { public void onClick(DialogInterface dialog, int button) {
if (button == AlertDialog.BUTTON_POSITIVE) { if (button == AlertDialog.BUTTON_POSITIVE) {
String hostname = input.getText().toString().trim(); String hostname = input.getText().toString().trim();
......
...@@ -38,6 +38,7 @@ import org.chromium.chrome.R; ...@@ -38,6 +38,7 @@ import org.chromium.chrome.R;
* Note: To ensure the button's shadow is fully visible, you may need to set * Note: To ensure the button's shadow is fully visible, you may need to set
* android:clipToPadding="false" on the button's parent view. * android:clipToPadding="false" on the button's parent view.
*/ */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class ButtonCompat extends Button { public class ButtonCompat extends Button {
private static final float PRE_L_PRESSED_BRIGHTNESS = 0.85f; private static final float PRE_L_PRESSED_BRIGHTNESS = 0.85f;
......
Markdown is supported
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