Skip to content

Commit e20f678

Browse files
committed
Gradle: Fix build script, Examples: Added Kotlin example
1 parent d07a6fb commit e20f678

File tree

39 files changed

+566
-58
lines changed

39 files changed

+566
-58
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3+
ext.kotlin_version = '1.6.20'
34
repositories {
45
google()
56
jcenter()
67
mavenCentral()
8+
mavenLocal()
79
}
810
dependencies {
911
classpath "com.android.tools.build:gradle:4.1.2"
12+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1013

1114
// NOTE: Do not place your application dependencies here; they belong
1215
// in the individual module build.gradle files
@@ -18,6 +21,7 @@ allprojects {
1821
google()
1922
jcenter()
2023
mavenCentral()
24+
mavenLocal()
2125
}
2226
}
2327

helloandroidharness/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 30
7-
buildToolsVersion "30.0.2"
6+
compileSdkVersion 31
87

98
defaultConfig {
109
applicationId "com.jme3.helloandroidharness"
1110
minSdkVersion 22
12-
targetSdkVersion 30
11+
targetSdkVersion 31
1312
versionCode 1
1413
versionName "1.0"
1514

helloandroidharness/src/main/java/com/jme3/helloandroidharness/MainActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package com.jme3.helloandroidharness;
22

3+
import android.content.pm.ActivityInfo;
4+
import android.os.Bundle;
5+
import android.os.PersistableBundle;
6+
import android.view.Menu;
7+
8+
import androidx.annotation.Nullable;
9+
310
import com.jme3.app.AndroidHarness;
411

512
import java.util.Objects;
@@ -24,4 +31,10 @@ public MainActivity() {
2431
/*get the jme class dir*/
2532
appClass = Objects.requireNonNull(MyGame.class.getName());
2633
}
34+
35+
@Override
36+
protected void onDestroy() {
37+
super.onDestroy();
38+
System.err.println("OnDestroy invoked");
39+
}
2740
}

helloandroidui/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 30
7-
buildToolsVersion "30.0.2"
6+
compileSdkVersion 31
87

98
defaultConfig {
109
applicationId "com.jme3.helloandroidui"
1110
minSdkVersion 22
12-
targetSdkVersion 30
11+
targetSdkVersion 31
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -32,12 +31,12 @@ dependencies {
3231
implementation 'androidx.appcompat:appcompat:1.2.0'
3332
implementation 'com.google.android.material:material:1.3.0'
3433
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
35-
testImplementation 'junit:junit:'
34+
testImplementation 'junit:junit:4.13.2'
3635
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
3736
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3837

3938
/*add the JMonkeyEngine Dependencies*/
4039
implementation "org.jmonkeyengine:jme3-core:3.5.1-stable"
4140
implementation "org.jmonkeyengine:jme3-effects:3.5.1-stable"
42-
implementation "org.jmonkeyengine:jme3-android-native:3.5.1-stable"
41+
implementation "org.jmonkeyengine:jme3-android-native:3.4.0-SNAPSHOT"
4342
}

helloandroidui/src/main/java/com/jme3/helloandroidui/MainActivity.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
import android.widget.RelativeLayout;
99
import android.widget.Toast;
1010

11-
import com.jme3.app.LegacyApplication;
12-
import com.jme3.app.jmeSurfaceView.JmeSurfaceView;
13-
import com.jme3.app.jmeSurfaceView.OnExceptionThrown;
14-
import com.jme3.app.jmeSurfaceView.OnRendererCompleted;
15-
import com.jme3.system.AppSettings;
16-
1711
import androidx.appcompat.app.AppCompatActivity;
1812
import androidx.cardview.widget.CardView;
1913
import androidx.core.content.ContextCompat;
2014

15+
import com.jme3.app.LegacyApplication;
16+
import com.jme3.system.AppSettings;
17+
import com.jme3.view.surfaceview.JmeSurfaceView;
18+
import com.jme3.view.surfaceview.OnExceptionThrown;
19+
import com.jme3.view.surfaceview.OnRendererCompleted;
20+
2121
import static android.widget.Toast.LENGTH_LONG;
2222

2323
/**
@@ -34,6 +34,7 @@
3434
*/
3535
public final class MainActivity extends AppCompatActivity implements OnRendererCompleted, OnExceptionThrown {
3636

37+
private static boolean isRenderingCompleted;
3738
private JmeSurfaceView jmeSurfaceView;
3839
private CardView splashScreen;
3940

@@ -45,17 +46,24 @@ protected void onCreate(Bundle savedInstanceState) {
4546

4647
/*define the android view with it's id from xml*/
4748
jmeSurfaceView = findViewById(R.id.jmeSurfaceView);
49+
jmeSurfaceView.setDestructionPolicy(JmeSurfaceView.DestructionPolicy.KEEP_WHEN_FINISH);
50+
4851
/*display a splash screen*/
49-
splashScreen = new CardView(MainActivity.this);
50-
splashScreen.setLayoutParams(new RelativeLayout.LayoutParams(jmeSurfaceView.getLayoutParams().width, jmeSurfaceView.getLayoutParams().height));
51-
splashScreen.setBackground(ContextCompat.getDrawable(this, R.drawable.power2));
52-
jmeSurfaceView.addView(splashScreen);
52+
if (!isRenderingCompleted) {
53+
splashScreen = new CardView(MainActivity.this);
54+
splashScreen.setLayoutParams(new RelativeLayout.LayoutParams(jmeSurfaceView.getLayoutParams().width, jmeSurfaceView.getLayoutParams().height));
55+
splashScreen.setBackground(ContextCompat.getDrawable(this, R.drawable.power2));
56+
jmeSurfaceView.addView(splashScreen);
57+
} else {
58+
findViewById(R.id.webView).setVisibility(View.VISIBLE);
59+
findViewById(R.id.image).setVisibility(View.VISIBLE);
60+
}
61+
5362
/*set the jme game*/
5463
jmeSurfaceView.setLegacyApplication(new MyGame());
5564
jmeSurfaceView.setOnExceptionThrown(this);
5665
jmeSurfaceView.setOnRendererCompleted(this);
57-
/*start the game, with delay for the splashScreen*/
58-
jmeSurfaceView.startRenderer(300);
66+
jmeSurfaceView.startRenderer(500);
5967

6068
/*Handle other UI-Components parts*/
6169
final WebView webView = findViewById(R.id.webView);
@@ -98,6 +106,7 @@ public void onRenderCompletion(LegacyApplication application, AppSettings appSet
98106
/*dismiss the splash screen at the send of the animation*/
99107
jmeSurfaceView.removeView(splashScreen);
100108
}).start();
109+
isRenderingCompleted = true;
101110
}
102111

103112
/**

helloandroidui/src/main/java/com/jme3/helloandroidui/MyGame.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* To use it inside Android :
1515
* <ol>
1616
* <li>Create an instance of it inside the #{@link MainActivity}</li>
17-
* <li>Set that instance using #{@link com.jme3.app.jmeSurfaceView.JmeSurfaceView#setLegacyApplication(LegacyApplication)}</li>
18-
* <li>Start the game using #{@link com.jme3.app.jmeSurfaceView.JmeSurfaceView#startRenderer(int)}</li>
17+
* <li>Set that instance using #{@link com.jme3.view.surfaceview.JmeSurfaceView#setLegacyApplication(LegacyApplication)}</li>
18+
* <li>Start the game using #{@link com.jme3.view.surfaceview.JmeSurfaceView#startRenderer(int)}</li>
1919
* </ol>
2020
*
2121
* @author pavl_g
2222
*/
23+
2324
public final class MyGame extends SimpleApplication {
2425
@Override
2526
public void simpleInitApp() {

helloandroidui/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_height="match_parent"
77
tools:context=".MainActivity">
88

9-
<com.jme3.app.jmeSurfaceView.JmeSurfaceView
9+
<com.jme3.view.surfaceview.JmeSurfaceView
1010
android:id="@+id/jmeSurfaceView"
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"

hellofragmentharness/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 30
7-
buildToolsVersion "30.0.2"
6+
compileSdkVersion 31
87

98
defaultConfig {
109
applicationId "com.jme3.hellofragmentharness"
1110
minSdkVersion 22
12-
targetSdkVersion 30
11+
targetSdkVersion 31
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -32,12 +31,12 @@ dependencies {
3231
implementation 'androidx.appcompat:appcompat:1.2.0'
3332
implementation 'com.google.android.material:material:1.3.0'
3433
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
35-
testImplementation 'junit:junit:'
34+
testImplementation 'junit:junit:4.13.2'
3635
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
3736
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3837

3938
/*add the JMonkeyEngine Dependencies*/
4039
implementation "org.jmonkeyengine:jme3-core:3.5.1-stable"
4140
implementation "org.jmonkeyengine:jme3-effects:3.5.1-stable"
42-
implementation "org.jmonkeyengine:jme3-android-native:3.5.1-stable"
41+
implementation "org.jmonkeyengine:jme3-android-native:3.4.0-SNAPSHOT"
4342
}

hellojmesurfaceview/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 30
7-
buildToolsVersion "30.0.2"
6+
compileSdkVersion 31
87

98
defaultConfig {
109
applicationId "com.jme3.hellojmesurfaceview"
1110
minSdkVersion 22
12-
targetSdkVersion 30
11+
targetSdkVersion 31
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -37,7 +36,9 @@ dependencies {
3736
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3837

3938
/*add the JMonkeyEngine Dependencies*/
40-
implementation "org.jmonkeyengine:jme3-core:3.5.1-stable"
41-
implementation "org.jmonkeyengine:jme3-effects:3.5.1-stable"
42-
implementation "org.jmonkeyengine:jme3-android-native:3.5.1-stable"
39+
implementation "org.jmonkeyengine:jme3-core:3.4.0-SNAPSHOT"
40+
//noinspection GradleDependency
41+
implementation "org.jmonkeyengine:jme3-effects:3.4.0-SNAPSHOT"
42+
//noinspection GradleDependency
43+
implementation "org.jmonkeyengine:jme3-android-native:3.4.0-SNAPSHOT"
4344
}

hellojmesurfaceview/src/main/java/com/jme3/hellojmesurfaceview/MainActivity.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
package com.jme3.hellojmesurfaceview;
1+
package com.jme3.hellojmesurfaceview;
22

3-
import android.content.pm.ActivityInfo;
4-
import android.os.Bundle;
5-
import android.view.View;
6-
import android.view.ViewGroup;
7-
import android.widget.FrameLayout;
8-
import android.widget.RelativeLayout;
9-
import android.widget.Toast;
3+
import android.content.pm.ActivityInfo;
4+
import android.graphics.Rect;
5+
import android.os.Bundle;
6+
import android.view.TouchDelegate;
7+
import android.view.View;
8+
import android.widget.Toast;
9+
import androidx.appcompat.app.AppCompatActivity;
1010

11-
import com.jme3.app.LegacyApplication;
12-
import com.jme3.app.jmeSurfaceView.JmeSurfaceView;
13-
import com.jme3.app.jmeSurfaceView.OnExceptionThrown;
14-
import com.jme3.app.jmeSurfaceView.OnRendererCompleted;
15-
import com.jme3.system.AppSettings;
11+
import com.jme3.app.LegacyApplication;
12+
import com.jme3.system.AppSettings;
13+
import com.jme3.view.surfaceview.JmeSurfaceView;
14+
import com.jme3.view.surfaceview.OnExceptionThrown;
15+
import com.jme3.view.surfaceview.OnRendererCompleted;
1616

17-
import androidx.appcompat.app.AppCompatActivity;
18-
19-
/**
17+
/**
2018
* <b>NB: Please Open this example <u>root module</u> using Android Studio; because android build scripts are different from java builds.</b>
2119
* <br/>
2220
* An Android Example that demonstrates : How to use a simple game#{@link MyGame}
23-
* on #{@link com.jme3.app.jmeSurfaceView.JmeSurfaceView} inside an #{@link androidx.appcompat.app.AppCompatActivity}.
21+
* on #{@link com.jme3.view.surfaceview.JmeSurfaceView} inside an #{@link androidx.appcompat.app.AppCompatActivity}.
2422
* <br>
2523
* <b>Note : use #{@link AppCompatActivity#setRequestedOrientation(int)} and #{@link ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE} for LandScape mode or specify that under the <activity> activity tag xml.</b>
2624
*
@@ -31,15 +29,15 @@ public final class MainActivity extends AppCompatActivity implements OnRendererC
3129
protected void onCreate(Bundle savedInstanceState) {
3230
super.onCreate(savedInstanceState);
3331
setContentView(R.layout.activity_main);
34-
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
3532
/*define the android view with it's id from xml*/
3633
final JmeSurfaceView jmeSurfaceView = findViewById(R.id.jmeSurfaceView);
34+
jmeSurfaceView.setDestructionPolicy(JmeSurfaceView.DestructionPolicy.KEEP_WHEN_FINISH);
3735
/*set the jme game*/
3836
jmeSurfaceView.setLegacyApplication(new MyGame());
3937
jmeSurfaceView.setOnExceptionThrown(this);
4038
jmeSurfaceView.setOnRendererCompleted(this);
4139
/*start the game*/
42-
jmeSurfaceView.startRenderer(0);
40+
jmeSurfaceView.startRenderer(500);
4341
}
4442

4543
/**
@@ -51,7 +49,6 @@ protected void onCreate(Bundle savedInstanceState) {
5149
public void onExceptionThrown(Throwable e) {
5250
Toast.makeText(MainActivity.this, "User's Delay Finished w/ exception : " + e.getMessage(), Toast.LENGTH_SHORT).show();
5351
}
54-
5552
/**
5653
* Fired when the user delay in ms is up #{@link JmeSurfaceView#startRenderer(int)}.
5754
*

hellojmesurfaceview/src/main/java/com/jme3/hellojmesurfaceview/MyGame.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.jme3.app.LegacyApplication;
44
import com.jme3.app.SimpleApplication;
55
import com.jme3.asset.AssetKey;
6+
import com.jme3.input.CameraInput;
7+
import com.jme3.input.ChaseCamera;
68
import com.jme3.material.Material;
79
import com.jme3.math.ColorRGBA;
810
import com.jme3.scene.Geometry;
@@ -14,13 +16,14 @@
1416
* To use it inside Android :
1517
* <ol>
1618
* <li>Create an instance of it inside the #{@link MainActivity}</li>
17-
* <li>Set that instance using #{@link com.jme3.app.jmeSurfaceView.JmeSurfaceView#setLegacyApplication(LegacyApplication)}</li>
18-
* <li>Start the game using #{@link com.jme3.app.jmeSurfaceView.JmeSurfaceView#startRenderer(int)}</li>
19+
* <li>Set that instance using #{@link com.jme3.view.surfaceview.JmeSurfaceView#setLegacyApplication(LegacyApplication)}</li>
20+
* <li>Start the game using #{@link com.jme3.view.surfaceview.JmeSurfaceView#startRenderer(int)}</li>
1921
* </ol>
2022
*
2123
* @author pavl_g
2224
*/
2325
public final class MyGame extends SimpleApplication {
26+
2427
@Override
2528
public void simpleInitApp() {
2629
final Sphere mySphere = new Sphere(10, 50, 50);

hellojmesurfaceview/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_height="match_parent"
77
tools:context=".MainActivity">
88

9-
<com.jme3.app.jmeSurfaceView.JmeSurfaceView
9+
<com.jme3.view.surfaceview.JmeSurfaceView
1010
android:id="@+id/jmeSurfaceView"
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"

hellokotlin/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

0 commit comments

Comments
 (0)