Skip to content

Commit

Permalink
Maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuele committed Aug 11, 2021
1 parent bc36779 commit 2175ba9
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 143 deletions.
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ apply plugin: 'android-maven'
group='com.github.Paroca72'

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
minSdkVersion 15
targetSdkVersion 29
versionCode 630
versionName '3.5.4'
targetSdkVersion 30
versionCode 640
versionName '3.6.0'
}
buildTypes {
release {
Expand Down
94 changes: 0 additions & 94 deletions library/library.iml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
Expand Down
36 changes: 3 additions & 33 deletions library/src/main/java/com/sccomponents/gauges/library/ScBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;

/**
* The base class.
Expand Down Expand Up @@ -36,30 +34,6 @@ public ScBase(Context context, AttributeSet attrs, int defStyleAttr) {
}


// ***************************************************************************************
// Privates methods

/**
* Get the display metric.
* This method is used for screen measure conversion.
* @param context the current context
* @return the display metrics
*/
private DisplayMetrics getDisplayMetrics(Context context) {
// Get the window manager from the window service
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
assert wm != null;

// Create the variable holder and inject the values
DisplayMetrics displayMetrics = new DisplayMetrics();
Display display = wm.getDefaultDisplay();
display.getMetrics(displayMetrics);

// Return
return displayMetrics;
}


// ***************************************************************************************
// Public methods

Expand All @@ -70,9 +44,8 @@ private DisplayMetrics getDisplayMetrics(Context context) {
*/
@SuppressWarnings("unused")
public float dipToPixel(float dip) {
// Get the display metrics
DisplayMetrics metrics = this.getDisplayMetrics(this.getContext());
// Calc the conversion by the screen density
// Calc the conversion using the screen density
DisplayMetrics metrics = this.getResources().getDisplayMetrics();
return dip * metrics.density;
}

Expand All @@ -96,10 +69,7 @@ public static float valueRangeLimit(float value, float startValue, float endValu

// If is over the limit return the normalized value
if (value < min) return min;
if (value > max) return max;

// Else return the original value
return value;
return Math.min(value, max);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @version 3.5.0
* @since 2016-05-26
*/
@SuppressWarnings({"WeakerAccess"})
@SuppressWarnings({"FieldMayBeFinal"})
public class ScCopier extends ScFeature {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @version 3.5.0
* @since 2016-05-26
*/
@SuppressWarnings({"WeakerAccess"})
@SuppressWarnings({"FieldMayBeFinal"})
public abstract class ScFeature {

// ***************************************************************************************
Expand Down Expand Up @@ -256,7 +256,7 @@ protected int getColor(int[] colors, float ratio, boolean isSmooth) {
* @param defaultValue the default value
* @return the value
*/
@SuppressWarnings("all")
@SuppressWarnings("SameParameterValue")
protected float getValue(float[] values, float ratio, boolean isSmooth, float defaultValue) {
// Check
if (values == null)
Expand Down Expand Up @@ -983,7 +983,7 @@ public void setOnPropertyChangedListener(OnPropertyChangedListener listener) {
/**
* This is a structure to hold the feature information before draw a contour
*/
@SuppressWarnings({"unused"})
@SuppressWarnings("InnerClassMayBeStatic")
public class ContourInfo {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
* @since 2016-05-26
* -----------------------------------------------------------------------------------------------
*/
@SuppressWarnings("FieldMayBeFinal")
public abstract class ScGauge extends ScDrawer
implements ScFeature.OnPropertyChangedListener {

Expand Down Expand Up @@ -209,6 +210,7 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
// ***************************************************************************************
// Classes

@SuppressWarnings("InnerClassMayBeStatic")
class AnimationStarter implements Runnable {
private ValueAnimator animator;
private float lastValue;
Expand Down Expand Up @@ -725,7 +727,7 @@ private float[] splitToWidths(String source) {
// Cycle all token
for (int index = 0; index < tokens.length; index++) {
// Try to convert
float value = Float.valueOf(tokens[index]);
float value = Float.parseFloat(tokens[index]);
widths[index] = this.dipToPixel(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @version 3.5.0
* @since 2018-08-13
*/
@SuppressWarnings("FieldMayBeFinal")
public class ScLabeler extends ScWriter {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @version 3.6.0
* @since 2016-05-30
*/
@SuppressWarnings("FieldMayBeFinal")
public class ScNotches extends ScRepetitions {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @version 3.5.0
* @since 2016-05-26
*/
@SuppressWarnings({"WeakerAccess"})
public class ScPathMeasure extends PathMeasure {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @version 3.5.0
* @since 2016-05-26
*/
@SuppressWarnings("FieldMayBeFinal")
public class ScPointer extends ScNotches {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @since 2016-05-26
*/

@SuppressWarnings({"WeakerAccess"})
@SuppressWarnings("FieldMayBeFinal")
public abstract class ScRepetitions extends ScFeature {

// ***************************************************************************************
Expand Down Expand Up @@ -358,7 +358,10 @@ public void setEdges(Positions value) {
*/
@SuppressWarnings("unused")
public void setRepetitions(int value) {
value = value < 0 ? 0: value;
// Exclude negative numbers
value = Math.max(value, 0);

// Apply
if (this.mRepetitions != value) {
this.mSpaceBetween = 0.0f;
this.mRepetitions = value;
Expand Down Expand Up @@ -511,7 +514,7 @@ public void setOnDrawRepetitionListener(OnDrawRepetitionListener listener) {
/**
* This is a structure to hold the feature information before draw it
*/
@SuppressWarnings({"unused"})
@SuppressWarnings({"unused", "InnerClassMayBeStatic"})
public class RepetitionInfo {

// ***************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @version 3.5.0
* @since 2016-05-26
*/
@SuppressWarnings("FieldMayBeFinal")
public class ScWriter extends ScRepetitions {

// ***************************************************************************************
Expand Down Expand Up @@ -206,7 +207,7 @@ private int getTextWidth(String text) {
*/
private float getInternalLetterSpacing() {
float letterSpacing = this.getPainter().getTextSize() * this.mLetterSpacing;
return letterSpacing < 1.0f ? 1.0f: letterSpacing;
return Math.max(letterSpacing, 1.0f);
}

/**
Expand Down

0 comments on commit 2175ba9

Please sign in to comment.