Skip to content

Commit 0509290

Browse files
committed
Reduce Android deprecation warnings
1 parent cd68f25 commit 0509290

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

jme3-android/src/main/java/com/jme3/app/AndroidHarness.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.DialogInterface;
66
import android.graphics.drawable.Drawable;
77
import android.graphics.drawable.NinePatchDrawable;
8+
import android.graphics.Point;
89
import android.opengl.GLSurfaceView;
910
import android.os.Bundle;
1011
import android.util.Log;
@@ -216,7 +217,9 @@ public void onCreate(Bundle savedInstanceState) {
216217
//TODO try to find a better way to get a hand on the resolution
217218
WindowManager wind = this.getWindowManager();
218219
Display disp = wind.getDefaultDisplay();
219-
Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight());
220+
Point displaySize = new Point();
221+
disp.getSize(displaySize);
222+
Log.d("AndroidHarness", "Resolution from Window, width:" + displaySize.x + ", height: " + displaySize.y);
220223

221224
// Create Settings
222225
logger.log(Level.FINE, "Creating settings");
@@ -232,7 +235,7 @@ public void onCreate(Bundle savedInstanceState) {
232235
settings.setSamples(eglSamples);
233236
settings.setStencilBits(eglStencilBits);
234237

235-
settings.setResolution(disp.getWidth(), disp.getHeight());
238+
settings.setResolution(displaySize.x, displaySize.y);
236239
settings.setAudioRenderer(audioRendererType);
237240

238241
settings.setFrameRate(frameRate);
@@ -410,9 +413,9 @@ public void layoutDisplay() {
410413
frameLayout = new FrameLayout(this);
411414
splashImageView = new ImageView(this);
412415

413-
Drawable drawable = this.getResources().getDrawable(splashPicID);
416+
Drawable drawable = splashImageView.getContext().getDrawable(splashPicID);
414417
if (drawable instanceof NinePatchDrawable) {
415-
splashImageView.setBackgroundDrawable(drawable);
418+
splashImageView.setBackground(drawable);
416419
} else {
417420
splashImageView.setImageResource(splashPicID);
418421
}

jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
*
7171
* @author iwgeric
7272
*/
73+
@SuppressWarnings("deprecation")
7374
public class AndroidHarnessFragment extends Fragment implements
7475
TouchListener, DialogInterface.OnClickListener, View.OnLayoutChangeListener, SystemListener {
7576
private static final Logger logger = Logger.getLogger(AndroidHarnessFragment.class.getName());
@@ -494,9 +495,9 @@ public void createLayout() {
494495
if (splashPicID != 0) {
495496
splashImageView = new ImageView(getActivity());
496497

497-
Drawable drawable = getResources().getDrawable(splashPicID);
498+
Drawable drawable = splashImageView.getContext().getDrawable(splashPicID);
498499
if (drawable instanceof NinePatchDrawable) {
499-
splashImageView.setBackgroundDrawable(drawable);
500+
splashImageView.setBackground(drawable);
500501
} else {
501502
splashImageView.setImageResource(splashPicID);
502503
}

jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void writeImageFile(OutputStream outStream, String format, ByteBuffer ima
7575

7676

7777
@Override
78+
@SuppressWarnings("deprecation")
7879
public JmeContext newContext(AppSettings settings, Type contextType) {
7980
if (settings.getAudioRenderer() == null) {
8081
audioRendererType = null;

jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ public void requestDialog(
493493
public void run() {
494494
final FrameLayout layoutTextDialogInput = new FrameLayout(view.getContext());
495495
final EditText editTextDialogInput = new EditText(view.getContext());
496-
editTextDialogInput.setWidth(LayoutParams.FILL_PARENT);
497-
editTextDialogInput.setHeight(LayoutParams.FILL_PARENT);
496+
editTextDialogInput.setWidth(LayoutParams.MATCH_PARENT);
497+
editTextDialogInput.setHeight(LayoutParams.MATCH_PARENT);
498498
editTextDialogInput.setPadding(20, 20, 20, 20);
499499
editTextDialogInput.setGravity(Gravity.FILL_HORIZONTAL);
500500
//editTextDialogInput.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

0 commit comments

Comments
 (0)