Browse Source

Cleaning up lint warnings caused by appcompat upgrade

master
anthony restaino 8 years ago
parent
commit
3e6c228bba
  1. 1
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 14
      app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java
  3. 14
      app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java
  4. 25
      app/src/main/java/acr/browser/lightning/utils/ThemeUtils.java
  5. 4
      app/src/main/java/acr/browser/lightning/view/SearchView.java

1
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -81,7 +81,6 @@ import android.widget.TextView.OnEditorActionListener;
import android.widget.VideoView; import android.widget.VideoView;
import com.anthonycr.bonsai.Completable; import com.anthonycr.bonsai.Completable;
import com.anthonycr.bonsai.Observable;
import com.anthonycr.bonsai.Schedulers; import com.anthonycr.bonsai.Schedulers;
import com.anthonycr.grant.PermissionsManager; import com.anthonycr.grant.PermissionsManager;
import com.anthonycr.progress.AnimatedProgressBar; import com.anthonycr.progress.AnimatedProgressBar;

14
app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java

@ -15,7 +15,8 @@
*/ */
package acr.browser.lightning.fragment.anim; package acr.browser.lightning.fragment.anim;
import android.support.v4.animation.AnimatorCompatHelper; import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat; import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener; import android.support.v4.view.ViewPropertyAnimatorListener;
@ -54,6 +55,8 @@ public class HorizontalItemAnimator extends SimpleItemAnimator {
private final ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>(); private final ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>();
private final ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>(); private final ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>();
private TimeInterpolator mDefaultInterpolator;
private static class MoveInfo { private static class MoveInfo {
public final ViewHolder holder; public final ViewHolder holder;
public final int fromX; public final int fromX;
@ -544,10 +547,17 @@ public class HorizontalItemAnimator extends SimpleItemAnimator {
} }
private void resetAnimation(ViewHolder holder) { private void resetAnimation(ViewHolder holder) {
AnimatorCompatHelper.clearInterpolator(holder.itemView); clearInterpolator(holder.itemView);
endAnimation(holder); endAnimation(holder);
} }
private void clearInterpolator(View view) {
if (mDefaultInterpolator == null) {
mDefaultInterpolator = new ValueAnimator().getInterpolator();
}
view.animate().setInterpolator(mDefaultInterpolator);
}
@Override @Override
public boolean isRunning() { public boolean isRunning() {
return (!mPendingAdditions.isEmpty() || return (!mPendingAdditions.isEmpty() ||

14
app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java

@ -15,7 +15,8 @@
*/ */
package acr.browser.lightning.fragment.anim; package acr.browser.lightning.fragment.anim;
import android.support.v4.animation.AnimatorCompatHelper; import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat; import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener; import android.support.v4.view.ViewPropertyAnimatorListener;
@ -54,6 +55,8 @@ public class VerticalItemAnimator extends SimpleItemAnimator {
private final ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>(); private final ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>();
private final ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>(); private final ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>();
private TimeInterpolator mDefaultInterpolator;
private static class MoveInfo { private static class MoveInfo {
public final ViewHolder holder; public final ViewHolder holder;
public final int fromX; public final int fromX;
@ -543,10 +546,17 @@ public class VerticalItemAnimator extends SimpleItemAnimator {
} }
private void resetAnimation(ViewHolder holder) { private void resetAnimation(ViewHolder holder) {
AnimatorCompatHelper.clearInterpolator(holder.itemView); clearInterpolator(holder.itemView);
endAnimation(holder); endAnimation(holder);
} }
private void clearInterpolator(View view) {
if (mDefaultInterpolator == null) {
mDefaultInterpolator = new ValueAnimator().getInterpolator();
}
view.animate().setInterpolator(mDefaultInterpolator);
}
@Override @Override
public boolean isRunning() { public boolean isRunning() {
return (!mPendingAdditions.isEmpty() || return (!mPendingAdditions.isEmpty() ||

25
app/src/main/java/acr/browser/lightning/utils/ThemeUtils.java

@ -12,13 +12,14 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.annotation.AttrRes; import android.support.annotation.AttrRes;
import android.support.annotation.ColorInt; import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.AppCompatDrawableManager;
import android.util.TypedValue; import android.util.TypedValue;
import android.widget.ImageView; import android.widget.ImageView;
@ -69,7 +70,15 @@ public class ThemeUtils {
@NonNull @NonNull
private static Drawable getVectorDrawable(@NonNull Context context, int drawableId) { private static Drawable getVectorDrawable(@NonNull Context context, int drawableId) {
Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId); Drawable drawable;
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
drawable = context.getDrawable(drawableId);
} else {
drawable = context.getResources().getDrawable(drawableId);
}
Preconditions.checkNonNull(drawable);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = (DrawableCompat.wrap(drawable)).mutate(); drawable = (DrawableCompat.wrap(drawable)).mutate();
} }
@ -81,8 +90,8 @@ public class ThemeUtils {
private static Bitmap getBitmapFromVectorDrawable(@NonNull Context context, int drawableId) { private static Bitmap getBitmapFromVectorDrawable(@NonNull Context context, int drawableId) {
Drawable drawable = getVectorDrawable(context, drawableId); Drawable drawable = getVectorDrawable(context, drawableId);
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas); drawable.draw(canvas);
@ -94,7 +103,8 @@ public class ThemeUtils {
public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) { public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) {
int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context); int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);
Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res); Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res);
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(), Bitmap.Config.ARGB_8888); Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Paint p = new Paint(); Paint p = new Paint();
ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN); ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
p.setColorFilter(filter); p.setColorFilter(filter);
@ -115,8 +125,9 @@ public class ThemeUtils {
@NonNull @NonNull
public static ColorDrawable getSelectedBackground(@NonNull Context context, boolean dark) { public static ColorDrawable getSelectedBackground(@NonNull Context context, boolean dark) {
@ColorInt final int color = (dark) ? ContextCompat.getColor(context, R.color.selected_dark) : @ColorInt final int color =
ContextCompat.getColor(context, R.color.selected_light); (dark) ? ContextCompat.getColor(context, R.color.selected_dark) : ContextCompat.getColor(
context, R.color.selected_light);
return new ColorDrawable(color); return new ColorDrawable(color);
} }

4
app/src/main/java/acr/browser/lightning/view/SearchView.java

@ -2,12 +2,12 @@ package acr.browser.lightning.view;
import android.content.Context; import android.content.Context;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatAutoCompleteTextView;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
import android.widget.AutoCompleteTextView;
public class SearchView extends AutoCompleteTextView { public class SearchView extends AppCompatAutoCompleteTextView {
public interface PreFocusListener { public interface PreFocusListener {
void onPreFocus(); void onPreFocus();

Loading…
Cancel
Save