Skip to content

Commit

Permalink
Replace deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Oct 23, 2021
1 parent a7c558b commit 4f063dd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/woheller69/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import android.media.SoundPool;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import org.woheller69.level.Level;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
Expand Down Expand Up @@ -82,7 +84,7 @@ public class OrientationProvider implements SensorEventListener {
private static OrientationProvider provider;

public OrientationProvider() {
this.displayOrientation = Level.getContext().getWindowManager().getDefaultDisplay().getRotation();
this.displayOrientation = Level.getContext().getDisplay().getRotation();
}

public static OrientationProvider getInstance() {
Expand Down
28 changes: 15 additions & 13 deletions app/src/main/java/org/woheller69/level/painter/LevelPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import android.os.Handler;
import android.view.SurfaceHolder;

import androidx.core.content.ContextCompat;

/*
* This file is part of Level (an Android Bubble Level).
* <https://github.com/avianey/Level>
Expand Down Expand Up @@ -171,13 +173,13 @@ public LevelPainter(SurfaceHolder surfaceHolder, Context context,
this.frameRate = 1000 / context.getResources().getInteger(R.integer.frame_rate);

// drawable
this.level1D = context.getResources().getDrawable(R.drawable.level_1d);
this.level2D = context.getResources().getDrawable(R.drawable.level_2d);
this.bubble1D = context.getResources().getDrawable(R.drawable.bubble_1d);
this.bubble2D = context.getResources().getDrawable(R.drawable.bubble_2d);
this.marker1D = context.getResources().getDrawable(R.drawable.marker_1d);
this.marker2D = context.getResources().getDrawable(R.drawable.marker_2d);
this.display = context.getResources().getDrawable(R.drawable.display);
this.level1D = ContextCompat.getDrawable(context, R.drawable.level_1d);
this.level2D = ContextCompat.getDrawable(context, R.drawable.level_2d);
this.bubble1D = ContextCompat.getDrawable(context, R.drawable.bubble_1d);
this.bubble2D = ContextCompat.getDrawable(context, R.drawable.bubble_2d);
this.marker1D = ContextCompat.getDrawable(context, R.drawable.marker_1d);
this.marker2D = ContextCompat.getDrawable(context, R.drawable.marker_2d);
this.display = ContextCompat.getDrawable(context, R.drawable.display);

// vitesse de la bulle
this.viscosity = viscosity;
Expand All @@ -189,7 +191,7 @@ public LevelPainter(SurfaceHolder surfaceHolder, Context context,
this.angleType = angleType;

// colors
this.backgroundColor = context.getResources().getColor(R.color.silver);
this.backgroundColor = ContextCompat.getColor(context, R.color.silver);

// strings
this.infoText = context.getString(R.string.calibrate_info);
Expand All @@ -200,35 +202,35 @@ public LevelPainter(SurfaceHolder surfaceHolder, Context context,

// paint
this.infoPaint = new Paint();
this.infoPaint.setColor(context.getResources().getColor(R.color.black));
this.infoPaint.setColor(ContextCompat.getColor(context, R.color.black));
this.infoPaint.setAntiAlias(true);
this.infoPaint.setTextSize(context.getResources().getDimensionPixelSize(R.dimen.info_text));
this.infoPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL));
this.infoPaint.setTextAlign(Paint.Align.CENTER);

this.lcdForegroundPaint = new Paint();
this.lcdForegroundPaint.setColor(context.getResources().getColor(R.color.lcd_front));
this.lcdForegroundPaint.setColor(ContextCompat.getColor(context, R.color.lcd_front));
this.lcdForegroundPaint.setAntiAlias(true);
this.lcdForegroundPaint.setTextSize(context.getResources().getDimensionPixelSize(R.dimen.lcd_text));
this.lcdForegroundPaint.setTypeface(lcd);
this.lcdForegroundPaint.setTextAlign(Paint.Align.CENTER);

this.lcdBackgroundPaint = new Paint();
this.lcdBackgroundPaint.setColor(context.getResources().getColor(R.color.lcd_back));
this.lcdBackgroundPaint.setColor(ContextCompat.getColor(context, R.color.lcd_back));
this.lcdBackgroundPaint.setAntiAlias(true);
this.lcdBackgroundPaint.setTextSize(context.getResources().getDimensionPixelSize(R.dimen.lcd_text));
this.lcdBackgroundPaint.setTypeface(lcd);
this.lcdBackgroundPaint.setTextAlign(Paint.Align.CENTER);

this.lockForegroundPaint = new Paint();
this.lockForegroundPaint.setColor(context.getResources().getColor(R.color.lock_front));
this.lockForegroundPaint.setColor(ContextCompat.getColor(context, R.color.lcd_front));
this.lockForegroundPaint.setAntiAlias(true);
this.lockForegroundPaint.setTextSize(context.getResources().getDimensionPixelSize(R.dimen.lock_text));
this.lockForegroundPaint.setTypeface(lcd);
this.lockForegroundPaint.setTextAlign(Paint.Align.CENTER);

this.lockBackgroundPaint = new Paint();
this.lockBackgroundPaint.setColor(context.getResources().getColor(R.color.lock_back));
this.lockBackgroundPaint.setColor(ContextCompat.getColor(context, R.color.lcd_back));
this.lockBackgroundPaint.setAntiAlias(true);
this.lockBackgroundPaint.setTextSize(context.getResources().getDimensionPixelSize(R.dimen.lock_text));
this.lockBackgroundPaint.setTypeface(lcd);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/woheller69/level/view/LevelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ allprojects {
google()
jcenter()
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}

task clean(type: Delete) {
Expand Down

0 comments on commit 4f063dd

Please sign in to comment.