Skip to content

Commit

Permalink
Initial project files
Browse files Browse the repository at this point in the history
  • Loading branch information
zirman committed Aug 30, 2020
1 parent 536b965 commit bdd9171
Show file tree
Hide file tree
Showing 78 changed files with 4,046 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
/*/build/
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# arcore-filament-example-app
ARCore Filament Example App
## AR Core Filament Example App

This project is an example of how to get ARCore working with Filament without the use of Sceneform
Android SDK.

This app shows detected planes and can manipulate a single model with pinch and rotate.

## Attribution
Sample GLB model with animation provided by Queenie Chan on https://poly.google.com/view/dh3af8qUMl1
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
155 changes: 155 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

apply plugin: 'androidx.navigation.safeargs.kotlin'

android {
compileSdkVersion 30
buildToolsVersion '30.0.2'
defaultConfig {
applicationId 'com.example.app'
minSdkVersion 26
targetSdkVersion 30
versionCode 13
versionName '0.0.1'
}
buildTypes {
debug {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
kotlinOptions.freeCompilerArgs = ['-Xinline-classes']
}
buildFeatures.viewBinding = true
// We use the .filamat extension for materials compiled with matc
// Telling aapt to not compress them allows to load them efficiently
aaptOptions {
noCompress 'filamat', 'ktx'
}
}
kapt {
useBuildCache = false
}
dependencies {
implementation(fileTree(dir: "libs", include: ["*.jar"]))

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.3.9-native-mt'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.9'

api 'androidx.appcompat:appcompat:1.2.0'

api 'androidx.arch.core:core-common:2.1.0'
api 'androidx.arch.core:core-runtime:2.1.0'

api 'androidx.vectordrawable:vectordrawable:1.1.0'
api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'

api 'androidx.dynamicanimation:dynamicanimation-ktx:1.0.0-alpha03'

api 'androidx.interpolator:interpolator:1.0.0'

api 'androidx.annotation:annotation:1.2.0-alpha01'

api 'androidx.palette:palette-ktx:1.0.0'

api 'androidx.savedstate:savedstate:1.1.0-alpha01'

api 'androidx.autofill:autofill:1.0.0'

api 'androidx.transition:transition:1.3.1'

api 'androidx.biometric:biometric:1.0.1'

api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
api 'androidx.lifecycle:lifecycle-common-java8:2.3.0-alpha07'
api 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.3.0-alpha07'
api 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha07'
api 'androidx.lifecycle:lifecycle-reactivestreams-ktx:2.3.0-alpha07'
api 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha07'
api 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha07'

api 'androidx.work:work-runtime-ktx:2.4.0'
api 'androidx.work:work-rxjava2:2.4.0'
api 'androidx.work:work-gcm:2.4.0'

api 'androidx.emoji:emoji:1.1.0'
api 'androidx.emoji:emoji-appcompat:1.1.0'

api 'androidx.room:room-runtime:2.2.5'
api 'androidx.room:room-rxjava2:2.2.5'
api 'androidx.room:room-ktx:2.2.5'
kapt 'androidx.room:room-compiler:2.2.5'

api 'androidx.sqlite:sqlite-ktx:2.1.0'

api 'androidx.legacy:legacy-support-v4:1.0.0'

api 'androidx.constraintlayout:constraintlayout:2.0.1'
api 'androidx.recyclerview:recyclerview:1.1.0'
api 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
api 'androidx.drawerlayout:drawerlayout:1.1.0'
api 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
api 'androidx.gridlayout:gridlayout:1.0.0'
api 'androidx.cardview:cardview:1.0.0'
api 'androidx.viewpager:viewpager:1.0.0'
api 'androidx.browser:browser:1.3.0-alpha05'

api 'androidx.core:core:1.5.0-alpha02'

api 'androidx.slice:slice-builders:1.1.0-alpha01'
api 'androidx.slice:slice-builders-ktx:1.0.0-alpha6'

api 'androidx.slice:slice-core:1.1.0-alpha01'
api 'androidx.slice:slice-view:1.1.0-alpha01'

// KTX Extensions
api 'androidx.core:core-ktx:1.3.1'

api 'androidx.activity:activity-ktx:1.2.0-alpha08'

api 'androidx.benchmark:benchmark-junit4:1.0.0'

api 'androidx.collection:collection-ktx:1.1.0'

api 'androidx.fragment:fragment-ktx:1.3.0-alpha08'

api 'androidx.navigation:navigation-runtime-ktx:2.3.0'
api 'androidx.navigation:navigation-fragment-ktx:2.3.0'
api 'androidx.navigation:navigation-ui-ktx:2.3.0'
api 'androidx.navigation:navigation-dynamic-features-fragment:2.3.0'

api 'androidx.paging:paging-common-ktx:2.1.2'
api 'androidx.paging:paging-runtime-ktx:2.1.2'
api 'androidx.paging:paging-rxjava2-ktx:2.1.2'

api 'androidx.preference:preference-ktx:1.1.1'

api 'com.google.android.play:core-ktx:1.8.1'

api 'com.google.android.material:material:1.3.0-alpha02'

api 'com.google.ar:core:1.18.0'

api 'com.google.android.filament:filament-android:1.8.1'
api 'com.google.android.filament:filament-utils-android:1.8.1'
api 'com.google.android.filament:gltfio-android:1.8.1'

// Third Party Dependencies

api 'io.arrow-kt:arrow-fx:0.10.5'

api 'io.reactivex.rxjava2:rxjava:2.2.19'
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
}
26 changes: 26 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep class com.example.app.** { *; }

# Filament
-keep class com.google.android.filament.** { *; }
46 changes: 46 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.app">

<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera" />

<uses-feature
android:glEsVersion="0x00030000"
android:required="true" />

<!-- Play Store listing only on devices that support ARCore -->
<uses-feature
android:name="android.hardware.camera.ar"
android:required="true" />

<application
android:name=".ExampleApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ExampleApp">

<activity
android:name=".aractivity.ArActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="fullSensor"
android:theme="@style/Theme.ExampleApp.Fullscreen"
android:windowSoftInputMode="adjustPan|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.ar.core"
android:value="required" />
</application>
</manifest>
Binary file added app/src/main/assets/eren-hiphop-dance.glb
Binary file not shown.
Binary file added app/src/main/assets/materials/textured.filamat
Binary file not shown.
Binary file added app/src/main/assets/materials/unlit.filamat
Binary file not shown.
56 changes: 56 additions & 0 deletions app/src/main/java/com/example/app/AutoHideSystemUi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.app

import android.app.Activity
import android.view.View
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import java.util.concurrent.TimeUnit

interface AutoHideSystemUi {
val onSystemUiFlagHideNavigationDisposable: CompositeDisposable
}

fun <T> T.onCreateAutoHideSystemUi() where T : Activity, T : AutoHideSystemUi {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_IMMERSIVE

@Suppress("DEPRECATION")
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
// immersive mode will not automatically hide the navigation bar after being revealed
if (visibility and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION == 0) {
onResumeAutoHideSystemUi()
}
}
}

fun <T> T.onResumeAutoHideSystemUi() where T : Activity, T : AutoHideSystemUi {
@Suppress("DEPRECATION")
if (window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION == 0) {
onSystemUiFlagHideNavigationDisposable.clear()

Single.just(Unit)
.delay(
resources
.getInteger(R.integer.hide_system_navigation_timeout_seconds)
.toLong(),
TimeUnit.SECONDS
)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
window.decorView.systemUiVisibility =
window.decorView.systemUiVisibility or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
},
{}
)
// Do not remove: Kotlin has a bug where it casts Boolean result of previous statement to
// Unit
.let { onSystemUiFlagHideNavigationDisposable.add(it); Unit }
}
}
28 changes: 28 additions & 0 deletions app/src/main/java/com/example/app/ExampleApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.app

import android.app.Application
import android.os.Looper
import com.google.android.filament.utils.Utils
import io.reactivex.android.plugins.RxAndroidPlugins
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.plugins.RxJavaPlugins

class ExampleApplication : Application() {
companion object {
lateinit var instance: ExampleApplication private set
}

override fun onCreate() {
super.onCreate()
instance = this

RxAndroidPlugins.setInitMainThreadSchedulerHandler {
AndroidSchedulers.from(Looper.getMainLooper(), true)
}

RxJavaPlugins.setErrorHandler {
}

Utils.init()
}
}
Loading

0 comments on commit bdd9171

Please sign in to comment.