Skip to content
This repository was archived by the owner on Jun 5, 2023. It is now read-only.

Commit 55ba2df

Browse files
committed
Update gesture sample to be consistent with other samples (not act as a library).
Unify gradle/build tools version across samples and reconfigure Camera/Card samples as composites. Change-Id: Id62f42c7a54620669f579755994ce7d6cbc7bc3f
1 parent d835cd3 commit 55ba2df

30 files changed

+300
-355
lines changed

Camera2Sample/app/build.gradle

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 Google Inc. All rights reserved.
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,15 +26,11 @@ android {
2626
versionName "1.0"
2727
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2828
}
29-
buildTypes {
30-
release {
31-
minifyEnabled false
32-
}
33-
}
3429
}
3530

3631
dependencies {
37-
implementation fileTree(dir: 'libs', include: ['*.aar'])
32+
implementation 'com.example.glass.ui:gesture-lib-sample:0.1.0-SNAPSHOT'
33+
3834
implementation 'com.android.support:appcompat-v7:28.0.0'
3935
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
4036
}

Camera2Sample/app/src/main/java/com/example/glass/camera2sample/BaseActivity.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import android.support.v7.app.AppCompatActivity;
2323
import android.view.MotionEvent;
2424
import android.view.View;
25-
import com.example.glass.camera2sample.GlassGestureDetector.Gesture;
26-
import com.example.glass.camera2sample.GlassGestureDetector.OnGestureListener;
25+
import com.example.glass.ui.GlassGestureDetector;
2726

2827
/**
2928
* Base activity for all activities in application for Glass. It hides the UI, making application
3029
* full screen and sets {@link GlassGestureDetector}.
3130
*/
32-
public abstract class BaseActivity extends AppCompatActivity implements OnGestureListener {
31+
public abstract class BaseActivity extends AppCompatActivity
32+
implements GlassGestureDetector.OnGestureListener {
3333

3434
private View decorView;
3535
private GlassGestureDetector glassGestureDetector;
@@ -65,7 +65,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
6565
}
6666

6767
@Override
68-
public boolean onGesture(Gesture gesture) {
68+
public boolean onGesture(GlassGestureDetector.Gesture gesture) {
6969
switch (gesture) {
7070
case SWIPE_DOWN:
7171
finish();

Camera2Sample/app/src/main/java/com/example/glass/camera2sample/CameraFragment.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
import android.view.ViewGroup.LayoutParams;
3838
import android.widget.FrameLayout;
3939
import android.widget.ImageView;
40-
import com.example.glass.camera2sample.GlassGestureDetector.Gesture;
41-
import com.example.glass.camera2sample.GlassGestureDetector.OnGestureListener;
4240
import com.example.glass.camera2sample.CameraActionHandler.CameraActionHandlerCallback;
4341
import com.example.glass.camera2sample.CameraActionHandler.CameraMode;
42+
import com.example.glass.ui.GlassGestureDetector;
43+
4444
import java.util.Objects;
4545

4646
/**
4747
* Fragment responsible for displaying the camera preview and handling camera actions.
4848
*/
4949
public class CameraFragment extends Fragment
50-
implements OnRequestPermissionsResultCallback, OnGestureListener, CameraActionHandlerCallback {
50+
implements OnRequestPermissionsResultCallback, GlassGestureDetector.OnGestureListener, CameraActionHandlerCallback {
5151

5252
private static final String TAG = CameraFragment.class.getSimpleName();
5353

@@ -191,7 +191,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
191191
}
192192

193193
@Override
194-
public boolean onGesture(Gesture gesture) {
194+
public boolean onGesture(GlassGestureDetector.Gesture gesture) {
195195
switch (gesture) {
196196
case TAP:
197197
cameraActionHandler.performTapAction();

Camera2Sample/app/src/main/java/com/example/glass/camera2sample/GlassGestureDetector.java

-153
This file was deleted.

Camera2Sample/app/src/main/java/com/example/glass/camera2sample/MainActivity.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
package com.example.glass.camera2sample;
1818

1919
import android.os.Bundle;
20-
import com.example.glass.camera2sample.GlassGestureDetector.Gesture;
2120
import android.view.KeyEvent;
2221

22+
import com.example.glass.ui.GlassGestureDetector;
23+
2324
/**
2425
* Main activity of the application. It creates instance of {@link CameraFragment} and passes
2526
* gestures to it.
@@ -37,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
3738
}
3839

3940
@Override
40-
public boolean onGesture(Gesture gesture) {
41+
public boolean onGesture(GlassGestureDetector.Gesture gesture) {
4142
return cameraFragment.onGesture(gesture) || super.onGesture(gesture);
4243
}
4344

Camera2Sample/settings.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 Google Inc. All rights reserved.
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,3 +15,9 @@
1515
*/
1616

1717
include ':app'
18+
19+
includeBuild('../GestureLibrarySample') {
20+
dependencySubstitution {
21+
substitute module('com.example.glass.ui:gesture-lib-sample') with project(':main')
22+
}
23+
}

CardSample/app/build.gradle

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
apply plugin: 'com.android.application'
218

319
android {
@@ -12,12 +28,15 @@ android {
1228
}
1329

1430
dependencies {
15-
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
31+
implementation 'com.example.glass.ui:gesture-lib-sample:0.1.0-SNAPSHOT'
32+
1633
implementation 'com.android.support:appcompat-v7:28.0.0'
1734
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
1835
implementation 'com.android.support:recyclerview-v7:28.0.0'
36+
1937
testImplementation 'junit:junit:4.12'
2038
testImplementation 'org.robolectric:robolectric:4.1'
39+
2140
androidTestImplementation 'com.android.support.test:runner:1.0.2'
2241
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
2342
}

CardSample/app/src/main/java/com/example/android/glass/cardsample/menu/GlassMenuItem.java

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import android.support.annotation.NonNull;
2121
import android.support.v7.util.DiffUtil;
2222

23+
import java.util.Objects;
24+
2325
/**
2426
* Represents the single menu item object.
2527
*/
@@ -71,4 +73,18 @@ Drawable getIcon() {
7173
String getText() {
7274
return text;
7375
}
76+
77+
@Override
78+
public boolean equals(Object o) {
79+
if (this == o) return true;
80+
if (o == null || getClass() != o.getClass()) return false;
81+
GlassMenuItem that = (GlassMenuItem) o;
82+
return Objects.equals(icon, that.icon) &&
83+
Objects.equals(text, that.text);
84+
}
85+
86+
@Override
87+
public int hashCode() {
88+
return Objects.hash(icon, text);
89+
}
7490
}

CardSample/build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.2.1'
11-
10+
classpath 'com.android.tools.build:gradle:3.5.1'
1211

1312
// NOTE: Do not place your application dependencies here; they belong
1413
// in the individual module build.gradle files
861 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
distributionBase=GRADLE_USER_HOME
216
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
17+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
418
zipStoreBase=GRADLE_USER_HOME
519
zipStorePath=wrapper/dists

CardSample/gradlew

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ APP_NAME="Gradle"
2828
APP_BASE_NAME=`basename "$0"`
2929

3030
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
31+
DEFAULT_JVM_OPTS='"-Xmx64m"'
3232

3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"

0 commit comments

Comments
 (0)