0031619: Samples - update JNI sample to use Android Studio
authorkgv <kgv@opencascade.com>
Fri, 19 Jun 2020 23:14:51 +0000 (02:14 +0300)
committerkgv <kgv@opencascade.com>
Mon, 22 Jun 2020 06:19:06 +0000 (09:19 +0300)
Project structure and project files have been updated to use Android Studio 4.0, gradle and CMake.
Redundant OcctJni_Window has been replaced by Aspect_NeutralWindow.
SD Card permissions are not dynamically requested for compatibility with Android API level 26+.

50 files changed:
samples/java/jniviewer/.classpath [deleted file]
samples/java/jniviewer/.externalToolBuilders/C++ Builder.launch [deleted file]
samples/java/jniviewer/.gitattributes [new file with mode: 0644]
samples/java/jniviewer/.gitignore
samples/java/jniviewer/.project [deleted file]
samples/java/jniviewer/.settings/org.eclipse.jdt.core.prefs [deleted file]
samples/java/jniviewer/ReadMe.md
samples/java/jniviewer/app/build.gradle [new file with mode: 0644]
samples/java/jniviewer/app/src/main/AndroidManifest.xml [moved from samples/java/jniviewer/AndroidManifest.xml with 97% similarity]
samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniActivity.java [moved from samples/java/jniviewer/src/com/opencascade/jnisample/OcctJniActivity.java with 87% similarity]
samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniFileDialog.java [moved from samples/java/jniviewer/src/com/opencascade/jnisample/OcctJniFileDialog.java with 100% similarity]
samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniLogger.java [moved from samples/java/jniviewer/src/com/opencascade/jnisample/OcctJniLogger.java with 100% similarity]
samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniRenderer.java [moved from samples/java/jniviewer/src/com/opencascade/jnisample/OcctJniRenderer.java with 100% similarity]
samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniView.java [moved from samples/java/jniviewer/src/com/opencascade/jnisample/OcctJniView.java with 100% similarity]
samples/java/jniviewer/app/src/main/jni/CMakeLists.txt [new file with mode: 0644]
samples/java/jniviewer/app/src/main/jni/OcctJni_MsgPrinter.cxx [moved from samples/java/jniviewer/jni/OcctJni_MsgPrinter.cxx with 98% similarity]
samples/java/jniviewer/app/src/main/jni/OcctJni_MsgPrinter.hxx [moved from samples/java/jniviewer/jni/OcctJni_MsgPrinter.hxx with 95% similarity]
samples/java/jniviewer/app/src/main/jni/OcctJni_Viewer.cxx [moved from samples/java/jniviewer/jni/OcctJni_Viewer.cxx with 96% similarity]
samples/java/jniviewer/app/src/main/jni/OcctJni_Viewer.hxx [moved from samples/java/jniviewer/jni/OcctJni_Viewer.hxx with 98% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/close_l.png [moved from samples/java/jniviewer/res/drawable-hdpi/close_l.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/close_p.png [moved from samples/java/jniviewer/res/drawable-hdpi/close_p.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/fit.png [moved from samples/java/jniviewer/res/drawable-hdpi/fit.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/ic_launcher.png [moved from samples/java/jniviewer/res/drawable-hdpi/ic_launcher.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/info.png [moved from samples/java/jniviewer/res/drawable-hdpi/info.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/info_image.png [moved from samples/java/jniviewer/res/drawable-hdpi/info_image.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/message.png [moved from samples/java/jniviewer/res/drawable-hdpi/message.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/open.png [moved from samples/java/jniviewer/res/drawable-hdpi/open.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/open_l.png [moved from samples/java/jniviewer/res/drawable-hdpi/open_l.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/open_p.png [moved from samples/java/jniviewer/res/drawable-hdpi/open_p.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/proj_back.png [moved from samples/java/jniviewer/res/drawable-hdpi/proj_back.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/proj_bottom.png [moved from samples/java/jniviewer/res/drawable-hdpi/proj_bottom.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/proj_front.png [moved from samples/java/jniviewer/res/drawable-hdpi/proj_front.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/proj_left.png [moved from samples/java/jniviewer/res/drawable-hdpi/proj_left.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/proj_right.png [moved from samples/java/jniviewer/res/drawable-hdpi/proj_right.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/proj_top.png [moved from samples/java/jniviewer/res/drawable-hdpi/proj_top.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-hdpi/view.png [moved from samples/java/jniviewer/res/drawable-hdpi/view.png with 100% similarity]
samples/java/jniviewer/app/src/main/res/drawable-mdpi/ic_launcher.png [moved from samples/java/jniviewer/res/drawable-mdpi/ic_launcher.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-xhdpi/ic_launcher.png [moved from samples/java/jniviewer/res/drawable-xhdpi/ic_launcher.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/drawable-xxhdpi/ic_launcher.png [moved from samples/java/jniviewer/res/drawable-xxhdpi/ic_launcher.png with 100% similarity, mode: 0644]
samples/java/jniviewer/app/src/main/res/layout/activity_main.xml [moved from samples/java/jniviewer/res/layout/activity_main.xml with 100% similarity]
samples/java/jniviewer/app/src/main/res/values/id.xml [moved from samples/java/jniviewer/res/values/id.xml with 100% similarity]
samples/java/jniviewer/app/src/main/res/values/strings.xml [moved from samples/java/jniviewer/res/values/strings.xml with 100% similarity]
samples/java/jniviewer/build.gradle [new file with mode: 0644]
samples/java/jniviewer/gradle.properties.template [new file with mode: 0644]
samples/java/jniviewer/jni/Android.mk [deleted file]
samples/java/jniviewer/jni/Application.mk [deleted file]
samples/java/jniviewer/jni/OcctJni_Window.cxx [deleted file]
samples/java/jniviewer/jni/OcctJni_Window.hxx [deleted file]
samples/java/jniviewer/project.properties [deleted file]
samples/java/jniviewer/settings.gradle [new file with mode: 0644]

diff --git a/samples/java/jniviewer/.classpath b/samples/java/jniviewer/.classpath
deleted file mode 100644 (file)
index 5176974..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
-       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
-       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="src" path="gen"/>
-       <classpathentry kind="output" path="bin/classes"/>
-</classpath>
diff --git a/samples/java/jniviewer/.externalToolBuilders/C++ Builder.launch b/samples/java/jniviewer/.externalToolBuilders/C++ Builder.launch
deleted file mode 100644 (file)
index cbe7a12..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
-<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/occtJniActivity/libs&quot; type=&quot;2&quot;/&gt;&#10;&lt;/resources&gt;}"/>
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/occtJniActivity/jni&quot; type=&quot;2&quot;/&gt;&#10;&lt;/resources&gt;}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="~/develop/android-ndk-r10/ndk-build"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="V=1 jniall"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/occtJniActivity/jni}"/>
-</launchConfiguration>
diff --git a/samples/java/jniviewer/.gitattributes b/samples/java/jniviewer/.gitattributes
new file mode 100644 (file)
index 0000000..c275dc2
--- /dev/null
@@ -0,0 +1 @@
+*.gradle eol=lf
index 890072f..3328b0f 100644 (file)
@@ -1,4 +1,10 @@
-/assets
-/bin
-/gen
-/libs
+/.gradle
+/.idea
+/build
+/gradle
+gradlew
+gradlew.bat
+/app/.cxx
+/app/build
+gradle.properties
+local.properties
diff --git a/samples/java/jniviewer/.project b/samples/java/jniviewer/.project
deleted file mode 100644 (file)
index c258add..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>occtJniActivity</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
-                       <triggers>auto,full,incremental,</triggers>
-                       <arguments>
-                               <dictionary>
-                                       <key>LaunchConfigHandle</key>
-                                       <value>&lt;project&gt;/.externalToolBuilders/C++ Builder.launch</value>
-                               </dictionary>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>com.android.ide.eclipse.adt.ApkBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/samples/java/jniviewer/.settings/org.eclipse.jdt.core.prefs b/samples/java/jniviewer/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index b080d2d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
index c1dd21d..4019016 100644 (file)
@@ -11,36 +11,22 @@ This sample demonstrates indirect method of wrapping C++ to Java using manually
 Alternative method is available, wrapping individual OCCT classes to Java equivalents so that their full API is available to Java user
 and the code can be programmed on Java level similarly to C++ one.
 See description of OCCT Java Wrapper in Advanced Samples and Tools on OCCT web site at 
-http://www.opencascade.org/support/products/advsamples
+https://www.opencascade.com/content/advanced-samples-and-tools
 
-Run Eclipse from ADT (Android Developer Tools) for building the sample. To import sample project perform
-~~~~
-  File -> Import... -> Android -> Existing Android code into Workspace
-~~~~
-and specify this directory. The project re-build will be started immediately right after importation if "Build automatically" option is turned on (default in Eclipse).  
-Proxy library compilation and packaging is performed by NDK build script, called by "C++ Builder" configured within Eclipse project.
-The path to "ndk-build" tool from Android NDK (Native Development Kit) should be specified in Eclipse project properties:
-~~~~
-  Project -> Properties -> Builders -> C++ Builder -> Edit -> Location
-~~~~
+Install Android Studio 4.0+ and install building tools (check Tools -> SDK Manager):
+- Android SDK (API level 21 or higher).
+- Android SDK build tools.
+- Android NDK r16 or higher (coming with CMake toolchain).
+  Using NDK r18 or newer will require changing ANDROID_STL in project settings.
+- CMake 3.10+.
 
-Now paths to OCCT C++ libraries and additional components should be specified in "jni/Android.mk" file:
-~~~~
-OCCT_ROOT := $(LOCAL_PATH)/../../../..
-
-FREETYPE_INC  := $(OCCT_ROOT)/../freetype/include/freetype2
-FREETYPE_LIBS := $(OCCT_ROOT)/../freetype/libs
+Specify this folder location in Android Studio for opening project.
+You might need re-entering Android SDK explicitly in File -> Project Structure -> SDK Location settings (SDK, NDK, JDK locations).
 
-FREEIMAGE_INC  := $(OCCT_ROOT)/../FreeImage/include
-FREEIMAGE_LIBS := $(OCCT_ROOT)/../FreeImage/libs
-
-OCCT_INC  := $(OCCT_ROOT)/inc
-OCCT_LIBS := $(OCCT_ROOT)/and/libs
-~~~~
-The list of extra components (Freetype, FreeImage) depends on OCCT configuration.
-Variable $(TARGET_ARCH_ABI) is used within this script to refer to active architecture.
-E.g. for 32-bit ARM build (see variable *APP_ABI* in "jni/Application.mk")
-the folder *OCCT_LIBS* should contain sub-folder "armeabi-v7a" with OCCT libraries.
+This sample expects OCCT to be already build - please refer to appropriate CMake building instructions in OCCT documentation.
+The following variables should be added into file gradle.properties (see gradle.properties.template as template):
+- `OCCT_ROOT` - path to OCCT installation folder.
+- `FREETYPE_ROOT` - path to FreeType installation folder.
 
 FreeImage is optional and does not required for this sample, however you should include all extra libraries used for OCCT building
 and load the explicitly from Java code within OcctJniActivity::loadNatives() method, including toolkits from OCCT itself in proper order:
@@ -49,10 +35,8 @@ and load the explicitly from Java code within OcctJniActivity::loadNatives() met
      || !loadLibVerbose ("TKMath",  aLoaded, aFailed)
      || !loadLibVerbose ("TKG2d",   aLoaded, aFailed)
 ~~~~
-Note that C++ STL library is not part of Android system.
-Thus application must package this library as well as extra component.
-"gnustl_shared" STL implementation is expected within this sample.
+Note that C++ STL library is not part of Android system, and application must package this library as well as extra component ("gnustl_shared" by default - see also `ANDROID_STL`).
 
-After successful build, the application can be packaged to Android:
-- Deploy and run application on connected device or emulator directly from Eclipse using adb interface by menu items "Run" and "Debug". This would sign package with debug certificate.
-- Prepare signed end-user package using wizard File -> Export -> Android -> Export Android Application.
+After successful build via Build -> Rebuild Project, the application can be packaged to Android:
+- Deploy and run application on connected device or emulator directly from Android Studio using adb interface by menu items "Run" and "Debug". This would sign package with debug certificate.
+- Prepare signed end-user package using wizard Build -> Generate signed APK.
diff --git a/samples/java/jniviewer/app/build.gradle b/samples/java/jniviewer/app/build.gradle
new file mode 100644 (file)
index 0000000..10014ce
--- /dev/null
@@ -0,0 +1,48 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 21
+    buildToolsVersion "30.0.0"
+
+    defaultConfig {
+        applicationId "com.opencascade.jnisample"
+        minSdkVersion 21
+        targetSdkVersion 26
+
+        ndk {
+            abiFilters "arm64-v8a"
+        }
+
+        externalNativeBuild {
+            cmake {
+                arguments "-DOCCT_ROOT=" + OCCT_ROOT,
+                        "-DFREETYPE_ROOT=" + FREETYPE_ROOT,
+                        "-DANDROID_STL=gnustl_shared"
+            }
+        }
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+    }
+
+    sourceSets {
+        main {
+            manifest.srcFile 'src/main/AndroidManifest.xml'
+            assets.srcDirs = [OCCT_ROOT + "/src"]
+        }
+    }
+
+    externalNativeBuild {
+        cmake {
+            path "src/main/jni/CMakeLists.txt"
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: 'java/com/opencascade/jnisample', include: ['*.jar'])
+}
@@ -31,6 +31,5 @@
         </activity>
     </application>
     <uses-feature android:glEsVersion="0x00020000"/>
-    <uses-sdk android:minSdkVersion="15"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 </manifest>
@@ -110,11 +110,8 @@ public class OcctJniActivity extends Activity implements OnClickListener
 
     // copy OCCT resources
     String aResFolder = getFilesDir().getAbsolutePath();
-    copyAssetFolder (getAssets(), "Shaders",   aResFolder + "/Shaders");
-    copyAssetFolder (getAssets(), "SHMessage", aResFolder + "/SHMessage");
-    copyAssetFolder (getAssets(), "XSMessage", aResFolder + "/XSMessage");
-    copyAssetFolder (getAssets(), "TObj",      aResFolder + "/TObj");
-    copyAssetFolder (getAssets(), "UnitsAPI",  aResFolder + "/UnitsAPI");
+    copyAssetFolder (getAssets(), "src/SHMessage", aResFolder + "/SHMessage");
+    copyAssetFolder (getAssets(), "src/XSMessage", aResFolder + "/XSMessage");
 
     // C++ runtime
     loadLibVerbose ("gnustl_shared", aLoaded, aFailed);
@@ -204,6 +201,9 @@ public class OcctJniActivity extends Activity implements OnClickListener
     String aDataPath = aDataUrl != null ? aDataUrl.getPath() : "";
     myOcctView.open (aDataPath);
     myLastPath = aDataPath;
+
+    myContext = new android.content.ContextWrapper (this);
+    myContext.getExternalFilesDir (null);
   }
 
   //! Handle scroll events
@@ -513,6 +513,9 @@ public class OcctJniActivity extends Activity implements OnClickListener
         aClickedBtn.setBackgroundColor (getResources().getColor(R.color.pressedBtnColor));
         if (myFileOpenDialog == null)
         {
+          // should be requested on runtime since API level 26 (Android 8)
+          askUserPermission (android.Manifest.permission.WRITE_EXTERNAL_STORAGE, null); // for accessing SD card
+
           myFileOpenDialog = new OcctJniFileDialog (this, aPath);
           myFileOpenDialog.setFileEndsWith (".brep");
           myFileOpenDialog.setFileEndsWith (".rle");
@@ -760,6 +763,88 @@ public class OcctJniActivity extends Activity implements OnClickListener
     return aResultSize;
   }
 
+  //! Request user permission.
+  private void askUserPermission (String thePermission, String theRationale)
+  {
+    // Dynamically load methods introduced by API level 23.
+    // On older system this permission is granted by user during application installation.
+    java.lang.reflect.Method aMetPtrCheckSelfPermission, aMetPtrRequestPermissions, aMetPtrShouldShowRequestPermissionRationale;
+    try
+    {
+      aMetPtrCheckSelfPermission = myContext.getClass().getMethod ("checkSelfPermission", String.class);
+      aMetPtrRequestPermissions = getClass().getMethod ("requestPermissions", String[].class, int.class);
+      aMetPtrShouldShowRequestPermissionRationale = getClass().getMethod ("shouldShowRequestPermissionRationale", String.class);
+    }
+    catch (SecurityException theError)
+    {
+      postMessage ("Unable to find permission methods:\n" + theError.getMessage(), Message_Trace);
+      return;
+    }
+    catch (NoSuchMethodException theError)
+    {
+      postMessage ("Unable to find permission methods:\n" + theError.getMessage(), Message_Trace);
+      return;
+    }
+
+    try
+    {
+      int isAlreadyGranted = (Integer )aMetPtrCheckSelfPermission.invoke (myContext, thePermission);
+      if (isAlreadyGranted == android.content.pm.PackageManager.PERMISSION_GRANTED)
+      {
+        return;
+      }
+
+      boolean toShowInfo = theRationale != null && (Boolean )aMetPtrShouldShowRequestPermissionRationale.invoke (this, thePermission);
+      if (toShowInfo)
+      {
+        postMessage (theRationale, Message_Info);
+      }
+
+      // show dialog to user
+      aMetPtrRequestPermissions.invoke (this, new String[]{thePermission}, 0);
+    }
+    catch (IllegalArgumentException theError)
+    {
+      postMessage ("Internal error: Unable to call permission method:\n" + theError.getMessage(), Message_Fail);
+      return;
+    }
+    catch (IllegalAccessException theError)
+    {
+      postMessage ("Internal error: Unable to call permission method:\n" + theError.getMessage(), Message_Fail);
+      return;
+    }
+    catch (java.lang.reflect.InvocationTargetException theError)
+    {
+      postMessage ("Internal error: Unable to call permission method:\n" + theError.getMessage(), Message_Fail);
+      return;
+    }
+  }
+
+  //! Message gravity.
+  private static final int Message_Trace   = 0;
+  private static final int Message_Info    = 1;
+  private static final int Message_Warning = 2;
+  private static final int Message_Alarm   = 3;
+  private static final int Message_Fail    = 4;
+
+  //! Auxiliary method to show info message.
+  public void postMessage (String theMessage, int theGravity)
+  {
+    if (theGravity == Message_Trace)
+    {
+      return;
+    }
+
+    final String  aText = theMessage;
+    final Context aCtx  = this;
+    this.runOnUiThread (new Runnable() { public void run() {
+      android.app.AlertDialog.Builder aBuilder = new android.app.AlertDialog.Builder (aCtx);
+      aBuilder.setMessage (aText).setNegativeButton ("OK", null);
+      android.app.AlertDialog aDialog = aBuilder.create();
+      aDialog.show();
+    }});
+  }
+
   //! OCCT major version
   private native long cppOcctMajorVersion();
 
@@ -772,6 +857,7 @@ public class OcctJniActivity extends Activity implements OnClickListener
   private OcctJniView       myOcctView;
   private TextView          myMessageTextView;
   private String            myLastPath;
+  private android.content.ContextWrapper myContext = null;
   private OcctJniFileDialog myFileOpenDialog;
   private int               myButtonPreferSize = 65;
 
diff --git a/samples/java/jniviewer/app/src/main/jni/CMakeLists.txt b/samples/java/jniviewer/app/src/main/jni/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4862495
--- /dev/null
@@ -0,0 +1,43 @@
+cmake_minimum_required(VERSION 3.4.1)
+
+set(HEADER_FILES OcctJni_MsgPrinter.hxx OcctJni_Viewer.hxx)
+set(SOURCE_FILES OcctJni_MsgPrinter.cxx OcctJni_Viewer.cxx)
+
+set (anOcctLibs
+  TKernel TKMath TKG2d TKG3d TKGeomBase TKBRep TKGeomAlgo TKTopAlgo TKShHealing TKMesh
+  # exchange
+  TKPrim TKBO TKBool TKFillet TKOffset
+  TKXSBase
+  TKIGES
+  TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP
+  # OCCT Visualization
+  TKService TKHLR TKV3d TKOpenGl
+)
+
+set(aLibDeps "")
+
+# OCCT libraries
+include_directories(${OCCT_ROOT}/inc)
+foreach(anOcctLib ${anOcctLibs})
+  add_library(lib_${anOcctLib} SHARED IMPORTED)
+  set_target_properties(lib_${anOcctLib} PROPERTIES IMPORTED_LOCATION ${OCCT_ROOT}/libs/${ANDROID_ABI}/lib${anOcctLib}.so)
+  list(APPEND aLibDeps lib_${anOcctLib})
+endforeach()
+
+# FreeType
+add_library(lib_FreeType SHARED IMPORTED)
+set_target_properties(lib_FreeType PROPERTIES IMPORTED_LOCATION ${FREETYPE_ROOT}/libs/${ANDROID_ABI}/libfreetype.so)
+list(APPEND aLibDeps lib_FreeType)
+
+# FreeImage - uncomment, if OCCT was built with FreeImage
+#add_library(lib_FreeImage SHARED IMPORTED)
+#set_target_properties(lib_FreeImage PROPERTIES IMPORTED_LOCATION ${FREETYPE_ROOT}/libs/${ANDROID_ABI}/libfreeimage.so)
+#list(APPEND aLibDeps lib_FreeImage)
+
+# system libraries
+list(APPEND aLibDeps EGL GLESv2 log android)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -frtti -fexceptions -fpermissive")
+
+add_library(TKJniSample SHARED ${SOURCE_FILES})
+target_link_libraries(TKJniSample ${aLibDeps})
@@ -11,7 +11,7 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <OcctJni_MsgPrinter.hxx>
+#include "OcctJni_MsgPrinter.hxx"
 
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
@@ -34,7 +34,7 @@ protected:
 
   //! Main printing method
   virtual void send (const TCollection_AsciiString& theString,
-                     const Message_Gravity theGravity) const;
+                     const Message_Gravity theGravity) const override;
 
 private:
 
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <OcctJni_Viewer.hxx>
-#include <OcctJni_MsgPrinter.hxx>
+#include "OcctJni_Viewer.hxx"
+#include "OcctJni_MsgPrinter.hxx"
 
 #include <AIS_Shape.hxx>
+#include <Aspect_NeutralWindow.hxx>
 #include <Image_AlienPixMap.hxx>
 #include <BRepTools.hxx>
 #include <Message_Messenger.hxx>
 #include <Message_MsgFile.hxx>
+#include <Message_PrinterSystemLog.hxx>
 #include <OpenGl_GraphicDriver.hxx>
 #include <OSD_Environment.hxx>
 #include <OSD_Timer.hxx>
@@ -107,16 +109,19 @@ Standard_Boolean setResourceEnv (const TCollection_AsciiString& theVarName,
 // =======================================================================
 OcctJni_Viewer::OcctJni_Viewer()
 {
+#ifndef NDEBUG
+  // Register printer for logging messages into global Android log.
+  // Should never be used in production (or specify higher gravity for logging only failures).
+  Handle(Message_Messenger) aMsgMgr = Message::DefaultMessenger();
+  aMsgMgr->RemovePrinters (STANDARD_TYPE (Message_PrinterSystemLog));
+  aMsgMgr->AddPrinter (new Message_PrinterSystemLog ("OcctJni_Viewer"));
+#endif
+
   // prepare necessary environment
   TCollection_AsciiString aResRoot = "/data/data/com.opencascade.jnisample/files";
 
-  setResourceEnv ("CSF_ShadersDirectory", aResRoot + "/Shaders",   "Declarations.glsl", Standard_False);
-  setResourceEnv ("CSF_XSMessage",        aResRoot + "/XSMessage", "XSTEP.us",          Standard_False);
-  setResourceEnv ("CSF_SHMessage",        aResRoot + "/XSMessage", "SHAPE.us",          Standard_False);
-  //setResourceEnv ("CSF_PluginDefaults",   "Plugin",            Standard_False);
-
-  // make sure OCCT loads the dictionary
-  //UnitsAPI::SetLocalSystem (UnitsAPI_SI);
+  setResourceEnv ("CSF_XSMessage", aResRoot + "/XSMessage", "XSTEP.us", Standard_False);
+  setResourceEnv ("CSF_SHMessage", aResRoot + "/XSMessage", "SHAPE.us", Standard_False);
 }
 
 // =======================================================================
@@ -164,7 +169,7 @@ bool OcctJni_Viewer::init()
   if (!myViewer.IsNull())
   {
     Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
-    Handle(OcctJni_Window)       aWindow = Handle(OcctJni_Window)::DownCast (myView->Window());
+    Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast (myView->Window());
     if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
     {
       Message::DefaultMessenger()->Send ("Error: OpenGl_GraphicDriver can not be initialized!", Message_Fail);
@@ -198,7 +203,8 @@ bool OcctJni_Viewer::init()
   //myContext->SetDisplayMode (AIS_WireFrame, false);
   myContext->SetDisplayMode (AIS_Shaded, false);
 
-  Handle(OcctJni_Window) aWindow = new OcctJni_Window (aWidth, aHeight);
+  Handle(Aspect_NeutralWindow) aWindow = new Aspect_NeutralWindow();
+  aWindow->SetSize (aWidth, aHeight);
   myView = myViewer->CreateView();
 
   myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
@@ -233,7 +239,7 @@ void OcctJni_Viewer::resize (int theWidth,
   }
 
   Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
-  Handle(OcctJni_Window)       aWindow = Handle(OcctJni_Window)::DownCast (myView->Window());
+  Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast (myView->Window());
   aWindow->SetSize (theWidth, theHeight);
   //myView->MustBeResized(); // can be used instead of SetWindow() when EGLsurface has not been changed
 
@@ -11,8 +11,6 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <OcctJni_Window.hxx>
-
 #include <AIS_InteractiveContext.hxx>
 #include <TopoDS_Shape.hxx>
 #include <V3d_Viewer.hxx>
diff --git a/samples/java/jniviewer/build.gradle b/samples/java/jniviewer/build.gradle
new file mode 100644 (file)
index 0000000..da2f7cd
--- /dev/null
@@ -0,0 +1,17 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+    repositories {
+        jcenter()
+        google()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:4.0.0'
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+        google()
+    }
+}
diff --git a/samples/java/jniviewer/gradle.properties.template b/samples/java/jniviewer/gradle.properties.template
new file mode 100644 (file)
index 0000000..2cf7323
--- /dev/null
@@ -0,0 +1,5 @@
+# customized paths
+OCCT_ROOT=c\:/android/occt-dev-android
+FREETYPE_ROOT=c\:/android/freetype-2.7.1-android
+# in case if OCCT was built with FreeImage
+#FREEIMAGE_ROOT=c\:/android/freeimage-3.17-android
diff --git a/samples/java/jniviewer/jni/Android.mk b/samples/java/jniviewer/jni/Android.mk
deleted file mode 100644 (file)
index 83547a2..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-STL_INC := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/include $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include
-#STL_LIB := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libgnustl_static.a
-STL_LIB := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libgnustl_shared.so
-
-OCCT_ROOT := $(LOCAL_PATH)/../../../..
-
-FREETYPE_INC  := $(OCCT_ROOT)/../freetype/include/freetype2
-FREETYPE_LIBS := $(OCCT_ROOT)/../freetype/libs
-
-FREEIMAGE_INC  := $(OCCT_ROOT)/../FreeImage/include
-FREEIMAGE_LIBS := $(OCCT_ROOT)/../FreeImage/libs
-
-OCCT_INC  := $(OCCT_ROOT)/inc
-OCCT_LIBS := $(OCCT_ROOT)/and/libs
-
-ASSETDIR := $(LOCAL_PATH)/../assets
-
-$(ASSETDIR)/Shaders: $(ASSETDIR)
-       -mkdir -p $(ASSETDIR)
-       -mkdir -p $(ASSETDIR)/Shaders
-       cp -f -r $(OCCT_ROOT)/src/Shaders/*.* $(ASSETDIR)/Shaders
-
-$(ASSETDIR)/SHMessage: $(ASSETDIR)
-       -mkdir -p $(ASSETDIR)
-       -mkdir -p $(ASSETDIR)/SHMessage
-       cp -f -r $(OCCT_ROOT)/src/SHMessage/*.* $(ASSETDIR)/SHMessage
-
-$(ASSETDIR)/XSMessage: $(ASSETDIR)
-       -mkdir -p $(ASSETDIR)
-       -mkdir -p $(ASSETDIR)/XSMessage
-       cp -f -r $(OCCT_ROOT)/src/XSMessage/*.* $(ASSETDIR)/XSMessage
-
-pre_all: $(ASSETDIR)/Shaders $(ASSETDIR)/SHMessage $(ASSETDIR)/XSMessage
-
-jniall: pre_all all
-
-# STL libs
-include $(CLEAR_VARS)
-LOCAL_MODULE := SharedStl
-LOCAL_EXPORT_C_INCLUDES := $(STL_INC)
-LOCAL_SRC_FILES := $(STL_LIB)
-include $(PREBUILT_SHARED_LIBRARY)
-
-# 3rd-parties used in OCCT
-include $(CLEAR_VARS)
-LOCAL_MODULE := FreeType
-LOCAL_EXPORT_C_INCLUDES := $(FREETYPE_INC)
-LOCAL_SRC_FILES := $(FREETYPE_LIBS)/$(TARGET_ARCH_ABI)/libfreetype.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-#include $(CLEAR_VARS)
-#LOCAL_MODULE := FreeImage
-#LOCAL_EXPORT_C_INCLUDES := $(FREEIMAGE_INC)
-#LOCAL_SRC_FILES := $(FREEIMAGE_LIBS)/$(TARGET_ARCH_ABI)/libfreeimage.so
-#include $(PREBUILT_SHARED_LIBRARY)
-
-# OCCT core
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKernel
-LOCAL_EXPORT_C_INCLUDES := $(OCCT_INC)
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKernel.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKMath
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKMath.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKG2d
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKG2d.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKG3d
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKG3d.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKGeomBase
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKGeomBase.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKBRep
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKBRep.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKGeomAlgo
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKGeomAlgo.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKTopAlgo
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKTopAlgo.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKShHealing
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKShHealing.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKMesh
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKMesh.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-# OCCT Exchange
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKPrim
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKPrim.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKBO
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKBO.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKBool
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKBool.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKFillet
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKFillet.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKOffset
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKOffset.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKXSBase
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKXSBase.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKIGES
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKIGES.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKSTEPBase
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEPBase.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKSTEPAttr
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEPAttr.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKSTEP209
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEP209.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKSTEP
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEP.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-# OCCT visualization
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKService
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKService.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKHLR
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKHLR.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKV3d
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKV3d.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OcctTKOpenGl
-LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKOpenGl.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-# our sample
-include $(CLEAR_VARS)
-LOCAL_MODULE           := libTKJniSample
-LOCAL_C_INCLUDES       := $(STL_INC)
-#LOCAL_STATIC_LIBRARIES := $(STL_LIB) does not work
-LOCAL_CFLAGS           := -Wall -std=c++11
-LOCAL_CPP_EXTENSION    := .cxx .cpp
-LOCAL_CPP_FEATURES     := rtti exceptions
-LOCAL_SRC_FILES        := OcctJni_Viewer.cxx OcctJni_Window.cxx OcctJni_MsgPrinter.cxx
-LOCAL_SHARED_LIBRARIES := OcctTKernel OcctTKMath OcctTKG2d OcctTKG3d OcctTKGeomBase OcctTKBRep OcctTKGeomAlgo OcctTKTopAlgo OcctTKShHealing OcctTKMesh OcctTKPrim
-LOCAL_SHARED_LIBRARIES += OcctTKIGES OcctTKSTEP OcctTKXSBase
-LOCAL_SHARED_LIBRARIES += OcctTKService OcctTKHLR OcctTKV3d OcctTKOpenGl
-LOCAL_SHARED_LIBRARIES += SharedStl
-LOCAL_LDLIBS           := -llog -lGLESv2 -lEGL
-
-#LOCAL_LDLIBS += $(STL_LIB)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/samples/java/jniviewer/jni/Application.mk b/samples/java/jniviewer/jni/Application.mk
deleted file mode 100644 (file)
index 1d6b633..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-NDK_TOOLCHAIN_VERSION := 4.8
-APP_PLATFORM := android-15
-
-APP_ABI := armeabi-v7a
-#APP_ABI := all
-
-#APP_STL := gnustl_static
-#APP_STL := stlport_static
diff --git a/samples/java/jniviewer/jni/OcctJni_Window.cxx b/samples/java/jniviewer/jni/OcctJni_Window.cxx
deleted file mode 100644 (file)
index 9202411..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <OcctJni_Window.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(OcctJni_Window, Aspect_Window)
diff --git a/samples/java/jniviewer/jni/OcctJni_Window.hxx b/samples/java/jniviewer/jni/OcctJni_Window.hxx
deleted file mode 100644 (file)
index d6b731b..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef OcctJni_Window_H
-#define OcctJni_Window_H
-
-#include <Aspect_Window.hxx>
-
-//! This class defines dummy window
-class OcctJni_Window : public Aspect_Window
-{
-
-public:
-
-  //! Creates a wrapper over existing Window handle
-  OcctJni_Window (const int theWidth, const int theHeight)
-  : myWidth (theWidth), myHeight(theHeight) {}
-
-  //! Returns native Window handle
-  virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE { return 0; }
-
-  //! Returns parent of native Window handle
-  virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
-
-  //! Returns nothing on Android
-  virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return 0; }
-
-  virtual void Destroy() {}
-
-  //! Opens the window <me>
-  virtual void Map() const Standard_OVERRIDE {}
-
-  //! Closes the window <me>
-  virtual void Unmap() const Standard_OVERRIDE {}
-
-  //! Applies the resizing to the window <me>
-  virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
-
-  //! Apply the mapping change to the window <me>
-  virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
-
-  //! Returns True if the window <me> is opened
-  virtual Standard_Boolean IsMapped() const Standard_OVERRIDE { return Standard_True; }
-
-  //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
-  virtual Standard_Real Ratio() const Standard_OVERRIDE { return 1.0; }
-
-  //! Returns The Window POSITION in PIXEL
-  virtual void Position (Standard_Integer& theX1,
-                         Standard_Integer& theY1,
-                         Standard_Integer& theX2,
-                         Standard_Integer& theY2) const Standard_OVERRIDE
-  {
-    theX1 = 0;
-    theX2 = myWidth;
-    theY1 = 0;
-    theY2 = myHeight;
-  }
-
-  //! Set The Window POSITION in PIXEL
-  void SetPosition (const Standard_Integer theX1,
-                    const Standard_Integer theY1,
-                    const Standard_Integer theX2,
-                    const Standard_Integer theY2)
-  {
-    myWidth  = theX2 - theX1;
-    myHeight = theY2 - theY1;
-  }
-
-  //! Returns The Window SIZE in PIXEL
-  virtual void Size (Standard_Integer& theWidth,
-                     Standard_Integer& theHeight) const Standard_OVERRIDE
-  {
-    theWidth  = myWidth;
-    theHeight = myHeight;
-  }
-
-  //! Set The Window SIZE in PIXEL
-  void SetSize (const Standard_Integer theWidth,
-                const Standard_Integer theHeight)
-  {
-    myWidth  = theWidth;
-    myHeight = theHeight;
-  }
-
-private:
-
-  int myWidth;
-  int myHeight;
-
-public:
-
-  DEFINE_STANDARD_RTTIEXT(OcctJni_Window,Aspect_Window)
-
-};
-
-DEFINE_STANDARD_HANDLE(OcctJni_Window, Aspect_Window)
-
-#endif // OcctJni_Window_H
diff --git a/samples/java/jniviewer/project.properties b/samples/java/jniviewer/project.properties
deleted file mode 100644 (file)
index 0840b4a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-15
diff --git a/samples/java/jniviewer/settings.gradle b/samples/java/jniviewer/settings.gradle
new file mode 100644 (file)
index 0000000..e7b4def
--- /dev/null
@@ -0,0 +1 @@
+include ':app'