Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Completed/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ limitations under the License.
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
compileSdkVersion 28
defaultConfig {
applicationId "com.google.devrel.ar.codelab"
minSdkVersion 24
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -39,14 +39,14 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "com.google.ar.sceneform.ux:sceneform-ux:1.8.0"
implementation "com.google.ar.sceneform:animation:1.8.0"
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.11.0'
implementation 'com.google.ar.sceneform:animation:1.11.0'
}

apply plugin: 'com.google.ar.sceneform.plugin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package com.google.devrel.ar.codelab;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
7 changes: 5 additions & 2 deletions Completed/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ limitations under the License.
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<meta-data android:name="com.google.ar.core" android:value="required" />

<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand All @@ -38,9 +41,9 @@ limitations under the License.
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.ar.core" android:value="required" />

<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.ar.codelab.name.provider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
Binary file modified Completed/app/src/main/assets/Cabin.sfb
Binary file not shown.
Binary file modified Completed/app/src/main/assets/House.sfb
Binary file not shown.
Binary file modified Completed/app/src/main/assets/andy.sfb
Binary file not shown.
Binary file modified Completed/app/src/main/assets/andy_dance.sfb
Binary file not shown.
Binary file modified Completed/app/src/main/assets/igloo.sfb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.core.content.FileProvider;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.PixelCopy;
import android.view.SurfaceHolder;
import android.view.View;
Expand Down Expand Up @@ -80,10 +80,10 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -162,7 +162,6 @@ private void takePhoto() {
intent.setDataAndType(photoURI, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);

});
snackbar.show();
} else {
Expand Down Expand Up @@ -194,12 +193,15 @@ private void onUpdate() {
}
}
}

private boolean updateTracking() {
Frame frame = fragment.getArSceneView().getArFrame();
boolean wasTracking = isTracking;
isTracking = frame.getCamera().getTrackingState() == TrackingState.TRACKING;
isTracking = frame != null &&
frame.getCamera().getTrackingState() == TrackingState.TRACKING;
return isTracking != wasTracking;
}

private boolean updateHitTest() {
Frame frame = fragment.getArSceneView().getArFrame();
android.graphics.Point pt = getScreenCenter();
Expand All @@ -210,8 +212,8 @@ private boolean updateHitTest() {
hits = frame.hitTest(pt.x, pt.y);
for (HitResult hit : hits) {
Trackable trackable = hit.getTrackable();
if ((trackable instanceof Plane &&
((Plane) trackable).isPoseInPolygon(hit.getHitPose()))) {
if (trackable instanceof Plane &&
((Plane) trackable).isPoseInPolygon(hit.getHitPose())) {
isHitting = true;
break;
}
Expand Down Expand Up @@ -246,13 +248,14 @@ public boolean onOptionsItemSelected(MenuItem item) {

return super.onOptionsItemSelected(item);
}

private void initializeGallery() {
LinearLayout gallery = findViewById(R.id.gallery_layout);

ImageView andy = new ImageView(this);
andy.setImageResource(R.drawable.droid_thumb);
andy.setContentDescription("andy");
andy.setOnClickListener(view ->{addObject( Uri.parse("andy_dance.sfb"));});
andy.setOnClickListener(view ->{addObject(Uri.parse("andy_dance.sfb"));});
gallery.addView(andy);

ImageView cabin = new ImageView(this);
Expand Down Expand Up @@ -311,7 +314,6 @@ public void addNodeToScene(Anchor anchor, ModelRenderable renderable) {
startAnimation(node, renderable);
}


public void startAnimation(TransformableNode node, ModelRenderable renderable){
if(renderable==null || renderable.getAnimationDataCount() == 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class PointerDrawable extends Drawable {
private final Paint paint = new Paint();
private boolean enabled;

@Override
public void draw(@NonNull Canvas canvas) {
float cx = canvas.getWidth()/2;
float cy = canvas.getHeight()/2;
float cx = canvas.getWidth() / 2;
float cy = canvas.getHeight() / 2;
if (enabled) {
paint.setColor(Color.GREEN);
canvas.drawCircle(cx, cy, 10, paint);
}else {
} else {
paint.setColor(Color.GRAY);
canvas.drawText("X", cx, cy, paint);
}
Expand All @@ -51,8 +53,9 @@ public void setColorFilter(@Nullable ColorFilter colorFilter) {

@Override
public int getOpacity() {
return 0;
return PixelFormat.UNKNOWN;
}

public boolean isEnabled() {
return enabled;
}
Expand Down
12 changes: 6 additions & 6 deletions Completed/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_menu_camera" />

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
7 changes: 4 additions & 3 deletions Completed/app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -16,7 +16,8 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/gallery_layout"
app:layout_constraintVertical_chainStyle="spread"
app:layout_constraintVertical_weight="9" />
app:layout_constraintVertical_weight="9"/>

<LinearLayout
android:id="@+id/gallery_layout"
android:layout_width="match_parent"
Expand All @@ -27,4 +28,4 @@
app:layout_constraintVertical_chainStyle="spread"
app:layout_constraintVertical_weight="1"/>

</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions Completed/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.ar.sceneform:plugin:1.8.0'
classpath 'com.google.ar.sceneform:plugin:1.11.0'
}
}
allprojects {
Expand Down
7 changes: 7 additions & 0 deletions Completed/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

Binary file modified Completed/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions Completed/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 06 10:47:02 PDT 2019
#Sat Sep 07 21:33:18 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip