Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed api compatibility issues: #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions Library/src/org/codeandmagic/android/gauge/GaugeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,12 @@
*******************************************************************************/
package org.codeandmagic.android.gauge;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ComposeShader;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.*;
import android.graphics.Paint.Align;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.RadialGradient;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
Expand Down Expand Up @@ -235,8 +221,8 @@ private void readAttrs(final Context context, final AttributeSet attrs, final in

private void readRanges(final Resources res, final int rangesId, final int colorsId) {
if (rangesId > 0 && colorsId > 0) {
final String[] ranges = res.getStringArray(R.array.ranges);
final String[] colors = res.getStringArray(R.array.rangeColors);
final String[] ranges = res.getStringArray(rangesId);
final String[] colors = res.getStringArray(colorsId);
if (ranges.length != colors.length) {
throw new IllegalArgumentException(
"The ranges and colors arrays must have the same length.");
Expand All @@ -255,13 +241,12 @@ private void readRanges(final Resources res, final int rangesId, final int color
}
}

@TargetApi(11)
private void init() {
// TODO Why isn't this working with HA layer?
// The needle is not displayed although the onDraw() is being triggered by invalidate()
// calls.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (Build.VERSION.SDK_INT >=11) { //Build.VERSION_CODES.HONEYCOMB=11 wasn't added until api level 11
setLayerType(1, null); //View.LAYER_TYPE_SOFTWARE=1 wasn't added until api level 11
}

initDrawingRects();
Expand Down