large code refactoring, regular, VR, and wallpaper apps work · processing/processing-android@53b4cfe · GitHub
Skip to content

Commit 53b4cfe

Browse files
committed
large code refactoring, regular, VR, and wallpaper apps work
1 parent 283191e commit 53b4cfe

26 files changed

Lines changed: 421 additions & 1276 deletions

core/src/processing/android/PFragment.java

Lines changed: 4 additions & 19 deletions

core/src/processing/android/PWallpaper.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import android.view.WindowManager;
2929
import processing.core.PApplet;
3030
import android.util.DisplayMetrics;
31-
import android.os.Build;
3231
import android.view.Display;
3332
import android.graphics.Point;
3433
import android.graphics.Rect;
@@ -42,36 +41,22 @@ public class PWallpaper extends WallpaperService implements AppComponent {
4241
public void initDimensions() {
4342
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
4443
Display display = wm.getDefaultDisplay();
45-
metrics = new DisplayMetrics();
46-
display.getMetrics(metrics);
4744

48-
// display.getRealMetrics(metrics); // API 17 or higher
49-
// display.getRealSize(size);
45+
metrics = new DisplayMetrics();
46+
display.getRealMetrics(metrics);
5047

5148
size = new Point();
52-
if (Build.VERSION.SDK_INT >= 17) {
53-
display.getRealSize(size);
54-
} else if (Build.VERSION.SDK_INT >= 14) {
55-
// Use undocumented methods getRawWidth, getRawHeight
56-
try {
57-
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
58-
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
59-
} catch (Exception e) {
60-
display.getSize(size);
61-
}
62-
}
49+
display.getRealSize(size);
6350
}
6451

6552

6653
public int getDisplayWidth() {
6754
return size.x;
68-
// return metrics.widthPixels;
6955
}
7056

7157

7258
public int getDisplayHeight() {
7359
return size.y;
74-
// return metrics.heightPixels;
7560
}
7661

7762

core/src/processing/android/PWatchFaceCanvas.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import android.graphics.Canvas;
2828
import android.graphics.Point;
29-
import android.os.Build;
3029
import android.os.Bundle;
3130
import android.graphics.Rect;
3231
import android.support.wearable.complications.ComplicationData;
@@ -52,36 +51,22 @@ public class PWatchFaceCanvas extends CanvasWatchFaceService implements AppCompo
5251
public void initDimensions() {
5352
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
5453
Display display = wm.getDefaultDisplay();
55-
metrics = new DisplayMetrics();
56-
display.getMetrics(metrics);
5754

58-
// display.getRealMetrics(metrics); // API 17 or higher
59-
// display.getRealSize(size);
55+
metrics = new DisplayMetrics();
56+
display.getRealMetrics(metrics);
6057

6158
size = new Point();
62-
if (Build.VERSION.SDK_INT >= 17) {
63-
display.getRealSize(size);
64-
} else if (Build.VERSION.SDK_INT >= 14) {
65-
// Use undocumented methods getRawWidth, getRawHeight
66-
try {
67-
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
68-
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
69-
} catch (Exception e) {
70-
display.getSize(size);
71-
}
72-
}
59+
display.getRealSize(size);
7360
}
7461

7562

7663
public int getDisplayWidth() {
7764
return size.x;
78-
// return metrics.widthPixels;
7965
}
8066

8167

8268
public int getDisplayHeight() {
8369
return size.y;
84-
// return metrics.heightPixels;
8570
}
8671

8772

core/src/processing/android/PWatchFaceGLES.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package processing.android;
2424

2525
import android.graphics.Point;
26-
import android.os.Build;
2726
import android.os.Bundle;
2827
import android.view.Display;
2928
import android.view.WindowInsets;
@@ -50,36 +49,22 @@ public class PWatchFaceGLES extends Gles2WatchFaceService implements AppComponen
5049
public void initDimensions() {
5150
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
5251
Display display = wm.getDefaultDisplay();
53-
metrics = new DisplayMetrics();
54-
display.getMetrics(metrics);
5552

56-
// display.getRealMetrics(metrics); // API 17 or higher
57-
// display.getRealSize(size);
53+
metrics = new DisplayMetrics();
54+
display.getRealMetrics(metrics);
5855

5956
size = new Point();
60-
if (Build.VERSION.SDK_INT >= 17) {
61-
display.getRealSize(size);
62-
} else if (Build.VERSION.SDK_INT >= 14) {
63-
// Use undocumented methods getRawWidth, getRawHeight
64-
try {
65-
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
66-
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
67-
} catch (Exception e) {
68-
display.getSize(size);
69-
}
70-
}
57+
display.getRealSize(size);
7158
}
7259

7360

7461
public int getDisplayWidth() {
7562
return size.x;
76-
// return metrics.widthPixels;
7763
}
7864

7965

8066
public int getDisplayHeight() {
8167
return size.y;
82-
// return metrics.heightPixels;
8368
}
8469

8570

src/processing/mode/android/AVD.java

Lines changed: 6 additions & 6 deletions

0 commit comments

Comments
 (0)