summaryrefslogtreecommitdiffstats
path: root/Common/NativeApp/Android
diff options
context:
space:
mode:
authorEgor <egor.yusov@gmail.com>2018-02-16 07:14:40 +0000
committerEgor <egor.yusov@gmail.com>2018-02-16 07:14:40 +0000
commitfb135a4f329865103594bfb73c073296c52c4d98 (patch)
treea1757579b0fe9f14dc060ed1e4de9f45bfa33de1 /Common/NativeApp/Android
parentUpdated tools submodule (diff)
downloadDiligentEngine-fb135a4f329865103594bfb73c073296c52c4d98.tar.gz
DiligentEngine-fb135a4f329865103594bfb73c073296c52c4d98.zip
Unified Android build
Diffstat (limited to 'Common/NativeApp/Android')
-rw-r--r--Common/NativeApp/Android/.gitignore3
-rw-r--r--Common/NativeApp/Android/build.gradle54
-rw-r--r--Common/NativeApp/Android/src/main/AndroidManifest.xml2
-rw-r--r--Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/DiligentApplicationBase.java40
-rw-r--r--Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/NativeActivityBase.java156
-rw-r--r--Common/NativeApp/Android/src/main/res/layout/widgets.xml17
-rw-r--r--Common/NativeApp/Android/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 6332 bytes
-rw-r--r--Common/NativeApp/Android/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 3611 bytes
-rw-r--r--Common/NativeApp/Android/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 9400 bytes
-rw-r--r--Common/NativeApp/Android/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 16510 bytes
-rw-r--r--Common/NativeApp/Android/src/main/res/values-v11/styles.xml11
-rw-r--r--Common/NativeApp/Android/src/main/res/values-v14/styles.xml12
-rw-r--r--Common/NativeApp/Android/src/main/res/values/strings.xml5
-rw-r--r--Common/NativeApp/Android/src/main/res/values/styles.xml20
14 files changed, 320 insertions, 0 deletions
diff --git a/Common/NativeApp/Android/.gitignore b/Common/NativeApp/Android/.gitignore
new file mode 100644
index 0000000..4a06e40
--- /dev/null
+++ b/Common/NativeApp/Android/.gitignore
@@ -0,0 +1,3 @@
+/build
+/.externalNativeBuild
+*.iml
diff --git a/Common/NativeApp/Android/build.gradle b/Common/NativeApp/Android/build.gradle
new file mode 100644
index 0000000..e70da43
--- /dev/null
+++ b/Common/NativeApp/Android/build.gradle
@@ -0,0 +1,54 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion=27
+
+ defaultConfig {
+ minSdkVersion 21
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ ndk {
+ abiFilters 'armeabi-v7a'//, 'armeabi', 'arm64-v8a','x86', 'x86_64'
+ }
+ externalNativeBuild {
+ cmake {
+ arguments '-DANDROID_PLATFORM=android-21',
+ '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
+ }
+ }
+ }
+
+ externalNativeBuild {
+ cmake {
+ path '../../../CMakeLists.txt'
+ }
+ }
+
+ sourceSets {
+ main {
+ java.srcDirs = ['src/main/java', '../../../DiligentCore/External/Android/ndk_helper/src/java']
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+buildDir './build'
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+ implementation 'com.android.support:appcompat-v7:25.1.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.1'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+}
diff --git a/Common/NativeApp/Android/src/main/AndroidManifest.xml b/Common/NativeApp/Android/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..467f1c7
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.diligentengine.android.common" />
diff --git a/Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/DiligentApplicationBase.java b/Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/DiligentApplicationBase.java
new file mode 100644
index 0000000..2342e46
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/DiligentApplicationBase.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.diligentengine.android.common;
+
+import android.app.Application;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.util.Log;
+import android.widget.Toast;
+
+public class DiligentApplicationBase extends Application {
+ public void onCreate(){
+ Log.w("native-activity", "onCreate");
+
+ final PackageManager pm = getApplicationContext().getPackageManager();
+ ApplicationInfo ai;
+ try {
+ ai = pm.getApplicationInfo( this.getPackageName(), 0);
+ } catch (final NameNotFoundException e) {
+ ai = null;
+ }
+ final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");
+ Toast.makeText(this, applicationName, Toast.LENGTH_SHORT).show();
+ }
+}
diff --git a/Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/NativeActivityBase.java b/Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/NativeActivityBase.java
new file mode 100644
index 0000000..396aa7a
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/java/com/diligentengine/android/common/NativeActivityBase.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.diligentengine.android.common;
+
+import android.app.NativeActivity;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup.MarginLayoutParams;
+import android.view.WindowManager.LayoutParams;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+import android.util.Log;
+
+public class NativeActivityBase extends NativeActivity {
+
+ static
+ {
+ try{
+ System.loadLibrary("GraphicsEngineOpenGL");
+ Log.i("native-activity", "Loaded GraphicsEngineOpenGL library.\n");
+ } catch (UnsatisfiedLinkError e) {
+ Log.e("native-activity", "Failed to load GraphicsEngineOpenGL library.\n" + e);
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ //Hide toolbar
+ int SDK_INT = android.os.Build.VERSION.SDK_INT;
+ if(SDK_INT >= 19)
+ {
+ setImmersiveSticky();
+
+ View decorView = getWindow().getDecorView();
+ decorView.setOnSystemUiVisibilityChangeListener
+ (new View.OnSystemUiVisibilityChangeListener() {
+ @Override
+ public void onSystemUiVisibilityChange(int visibility) {
+ setImmersiveSticky();
+ }
+ });
+ }
+
+ }
+
+ protected void onResume() {
+ super.onResume();
+
+ //Hide toolbar
+ int SDK_INT = android.os.Build.VERSION.SDK_INT;
+ if(SDK_INT >= 11 && SDK_INT < 14)
+ {
+ getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
+ }
+ else if(SDK_INT >= 14 && SDK_INT < 19)
+ {
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ }
+ else if(SDK_INT >= 19)
+ {
+ setImmersiveSticky();
+ }
+
+ }
+ // Our popup window, you will call it from your C/C++ code later
+
+ void setImmersiveSticky() {
+ View decorView = getWindow().getDecorView();
+ decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ }
+
+ NativeActivityBase _activity;
+ PopupWindow _popupWindow;
+ TextView _label;
+
+ public void showUI()
+ {
+ if( _popupWindow != null )
+ return;
+
+ _activity = this;
+
+ this.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ LayoutInflater layoutInflater
+ = (LayoutInflater)getBaseContext()
+ .getSystemService(LAYOUT_INFLATER_SERVICE);
+ View popupView = layoutInflater.inflate(R.layout.widgets, null);
+ _popupWindow = new PopupWindow(
+ popupView,
+ LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT);
+
+ LinearLayout mainLayout = new LinearLayout(_activity);
+ MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ params.setMargins(0, 0, 0, 0);
+ _activity.setContentView(mainLayout, params);
+
+ // Show our UI over NativeActivity window
+ _popupWindow.showAtLocation(mainLayout, Gravity.TOP | Gravity.LEFT, 10, 10);
+ _popupWindow.update();
+
+ _label = (TextView)popupView.findViewById(R.id.textViewFPS);
+
+ }});
+ }
+
+ protected void onPause()
+ {
+ super.onPause();
+ if (_popupWindow != null) {
+ _popupWindow.dismiss();
+ _popupWindow = null;
+ }
+ }
+
+ public void updateFPS(final float fFPS)
+ {
+ if( _label == null )
+ return;
+
+ _activity = this;
+ this.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ _label.setText(String.format("%2.2f FPS", fFPS));
+
+ }});
+ }
+}
+
+
diff --git a/Common/NativeApp/Android/src/main/res/layout/widgets.xml b/Common/NativeApp/Android/src/main/res/layout/widgets.xml
new file mode 100644
index 0000000..b6e86e6
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/layout/widgets.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="top"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/textViewFPS"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:text="@string/fps"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@android:color/white" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/Common/NativeApp/Android/src/main/res/mipmap-hdpi/ic_launcher.png b/Common/NativeApp/Android/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..5a261ea
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/Common/NativeApp/Android/src/main/res/mipmap-mdpi/ic_launcher.png b/Common/NativeApp/Android/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..74263d9
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/Common/NativeApp/Android/src/main/res/mipmap-xhdpi/ic_launcher.png b/Common/NativeApp/Android/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..da6a331
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/Common/NativeApp/Android/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Common/NativeApp/Android/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..e587387
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/Common/NativeApp/Android/src/main/res/values-v11/styles.xml b/Common/NativeApp/Android/src/main/res/values-v11/styles.xml
new file mode 100644
index 0000000..541752f
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/Common/NativeApp/Android/src/main/res/values-v14/styles.xml b/Common/NativeApp/Android/src/main/res/values-v14/styles.xml
new file mode 100644
index 0000000..f20e015
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/Common/NativeApp/Android/src/main/res/values/strings.xml b/Common/NativeApp/Android/src/main/res/values/strings.xml
new file mode 100644
index 0000000..a06980b
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/values/strings.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <string name="fps">0.0 FPS</string>
+
+</resources> \ No newline at end of file
diff --git a/Common/NativeApp/Android/src/main/res/values/styles.xml b/Common/NativeApp/Android/src/main/res/values/styles.xml
new file mode 100644
index 0000000..4a10ca4
--- /dev/null
+++ b/Common/NativeApp/Android/src/main/res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources> \ No newline at end of file