Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #54 from googlesamples/release-zeno
Browse files Browse the repository at this point in the history
Release zeno
  • Loading branch information
jguomoto committed Oct 29, 2015
2 parents 892cdcd + 2788a3b commit 228f306
Show file tree
Hide file tree
Showing 41 changed files with 2,480 additions and 37 deletions.
43 changes: 43 additions & 0 deletions plane-fitting-jni-example/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.projecttango.experiments.nativeplanefitting"
minSdkVersion 19
targetSdkVersion 19
}

sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
abortOnError false
}
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}

task ndkBuild(type: Exec) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkbuild = properties.getProperty('ndk.dir', null) + "/ndk-build"
commandLine ndkbuild, '-C', file('src/main/jni').absolutePath
}

dependencies {
compile 'com.android.support:support-v4:22.1.1'
}
30 changes: 30 additions & 0 deletions plane-fitting-jni-example/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.projecttango.experiments.nativeplanefitting"
android:versionCode="0"
android:versionName="0">
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="false"
android:theme="@style/AppTheme">
<uses-library
android:name="com.projecttango.libtango_device"
android:required="true" />
<activity
android:name=".MainActivity"
android:label="@string/menu_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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.projecttango.experiments.nativeplanefitting;

import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;

// Custom drawer extends from DrawerLayout but passes touch events.
public class CustomDrawerLayout extends DrawerLayout {
private static final int DRAWER_BAR_TOUCH_SIZE = 30;

public CustomDrawerLayout(Context context) {
super(context);
}

public CustomDrawerLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}

public CustomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);

if (event.getX() > DRAWER_BAR_TOUCH_SIZE && event.getAction() == MotionEvent.ACTION_DOWN){
return isDrawerOpen(Gravity.START) || isDrawerVisible(Gravity.START);
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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.projecttango.experiments.nativeplanefitting;

import android.opengl.GLSurfaceView;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

/**
* Renders graphic content.
*/
public class GLSurfaceRenderer implements GLSurfaceView.Renderer {
private MainActivity mMainActivity;

public GLSurfaceRenderer(MainActivity mainActivity) {
mMainActivity = mainActivity;
}

// Render loop of the GL context.
public void onDrawFrame(GL10 gl) {
JNIInterface.render();
}

// Called when the surface size changes.
public void onSurfaceChanged(GL10 gl, int width, int height) {
JNIInterface.setViewPort(width, height);
}

// Called when the surface is created or recreated.
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
mMainActivity.surfaceCreated();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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.projecttango.experiments.nativeplanefitting;

import android.app.Activity;

/**
* Interfaces between native C++ code and Java code.
*/
public class JNIInterface {
static {
System.loadLibrary("plane_fitting_jni_example");
}

// Initialize the Tango Service, this function starts the communication
// between the application and the Tango Service. The activity object is
// used for checking if the API version is outdated.
public static native int tangoInitialize(Activity activity);

// Set up the configuration, callbacks, and connect to the Tango Service.
public static native int tangoSetupAndConnect();

// Disconnect from the Tango Service, release all the resources that
// the app is holding from the Tango Service.
public static native void tangoDisconnect();

// Allocate OpenGL resources for rendering and register the color
// camera texture.
public static native int initializeGLContent();

// Release all the OpenGL resources that are allocated.
public static native void freeGLContent();

// Display debug colors on point cloud.
public static native void setRenderDebugPointCloud(boolean debugRender);

// Setup the view port width and height.
public static native void setViewPort(int width, int height);

// Main render loop.
public static native void render();

// Respond to a touch event.
public static native void onTouchEvent(float x, float y);
}
Loading

0 comments on commit 228f306

Please sign in to comment.