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
10 changes: 10 additions & 0 deletions .github/scripts/gradlew_recursive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -xe

# Crawl all gradlew files which indicate an Android project
# You may edit this if your repo has a different project structure
for GRADLEW in `find . -name "gradlew"` ; do
SAMPLE=$(dirname "${GRADLEW}")
# Tell Gradle that this is a CI environment and disable parallel compilation
bash "$GRADLEW" -p "$SAMPLE" -Pci --no-parallel --stacktrace $@
done
73 changes: 73 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Android CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

test:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 9
- name: Run unit tests
run: .github/scripts/gradlew_recursive.sh test
- name: Zip reports
if: always()
run: zip -r reports.zip . -i '**/reports/*.xml' '**/reports/*.html'
- name: Upload reports
if: always()
uses: actions/upload-artifact@v1
with:
name: unit_test_reports
path: reports.zip

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run linter
run: .github/scripts/gradlew_recursive.sh lint
- name: Zip reports
if: always()
run: zip -r reports.zip . -i '**/reports/*.xml' '**/reports/*.html'
- name: Upload reports
if: always()
uses: actions/upload-artifact@v1
with:
name: lint_reports
path: reports.zip

build:
name: Build
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build project
run: .github/scripts/gradlew_recursive.sh assembleDebug
- name: Zip artifacts
run: zip -r assemble.zip . -i '**/build/*.apk' '**/build/*.aab' '**/build/*.aar' '**/build/*.so'
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: assemble
path: assemble.zip
19 changes: 4 additions & 15 deletions Camera2Basic/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ android {
}
}

// Set the source of tests to same for both Unit and Instrumented tests
sourceSets {
String sharedTestDir = 'src/test/java'
test {
java.srcDir sharedTestDir
}
androidTest {
java.srcDir sharedTestDir
}
}

// Necessary for Robolectric (Unit tests)
testOptions.unitTests.includeAndroidResources = true
}
Expand All @@ -66,17 +55,17 @@ dependencies {
implementation project(':common')

// Kotlin lang
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

// App compat and UI things
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-rc03'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
implementation "androidx.viewpager2:viewpager2:1.0.0"

// Navigation library
def nav_version = "2.1.0"
def nav_version = '2.2.1'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

Expand All @@ -92,7 +81,7 @@ dependencies {
testImplementation 'androidx.test:rules:1.2.0'
testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation "org.robolectric:robolectric:4.3.1"
testImplementation 'org.robolectric:robolectric:4.3.1'

// Instrumented testing
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CameraFragment : Fragment() {

// Used to rotate the output media to match device orientation
relativeOrientation = OrientationLiveData(requireContext(), characteristics).apply {
observe(this@CameraFragment, Observer {
observe(viewLifecycleOwner, Observer {
orientation -> Log.d(TAG, "Orientation changed: $orientation")
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.example.android.camera2.basic

import android.Manifest
import android.content.Context
import android.os.Build
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
Expand All @@ -27,6 +28,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith


@RunWith(AndroidJUnit4::class)
class MainInstrumentedTest {

Expand Down
4 changes: 2 additions & 2 deletions Camera2Basic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions Camera2Basic/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 27 14:00:11 AEST 2019
#Thu Mar 05 15:31:27 EST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
8 changes: 4 additions & 4 deletions Camera2SlowMotion/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ dependencies {
implementation project(':common')

// Kotlin lang
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

// App compat and UI things
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-rc03'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'

// Navigation library
def nav_version = "2.1.0"
def nav_version = "2.2.1"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

Expand Down
2 changes: 1 addition & 1 deletion Camera2SlowMotion/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
tools:ignore="GoogleAppIndexingWarning">
tools:ignore="AllowBackup,GoogleAppIndexingWarning">

<activity
android:name="com.example.android.camera2.slowmo.CameraActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class CameraFragment : Fragment() {

// Used to rotate the output media to match device orientation
relativeOrientation = OrientationLiveData(requireContext(), characteristics).apply {
observe(this@CameraFragment, Observer {
observe(viewLifecycleOwner, Observer {
orientation -> Log.d(TAG, "Orientation changed: $orientation")
})
}
Expand Down
25 changes: 0 additions & 25 deletions Camera2SlowMotion/app/src/main/res/drawable/ic_photo.xml

This file was deleted.

17 changes: 6 additions & 11 deletions Camera2SlowMotion/app/src/main/res/layout/activity_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<FrameLayout
<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
tools:context=".CameraActivity">

<fragment
android:id="@+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_graph" />
</FrameLayout>
app:defaultNavHost="true"
app:navGraph="@navigation/nav_graph"
tools:context=".CameraActivity" />
4 changes: 2 additions & 2 deletions Camera2SlowMotion/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions Camera2SlowMotion/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 27 14:00:11 AEST 2019
#Thu Mar 05 16:15:48 EST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
2 changes: 1 addition & 1 deletion Camera2VideoJava/Application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.6.1'
}
}

Expand Down
3 changes: 2 additions & 1 deletion Camera2VideoJava/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Fri Mar 06 10:33:53 EST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
2 changes: 1 addition & 1 deletion Camera2VideoKotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
3 changes: 2 additions & 1 deletion Camera2VideoKotlin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Fri Mar 06 10:32:20 EST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
15 changes: 2 additions & 13 deletions CameraXBasic/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ android {
}
}

// Set the source of tests to same for both Unit and Instrumented tests
sourceSets {
String sharedTestDir = 'src/test/java'
test {
java.srcDir sharedTestDir
}
androidTest {
java.srcDir sharedTestDir
}
}

// Necessary for Robolectric (Unit tests)
testOptions {
unitTests {
Expand Down Expand Up @@ -100,14 +89,14 @@ dependencies {

// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.10.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'

// Unit testing
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test:rules:1.2.0'
testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation "org.robolectric:robolectric:4.3.1"
testImplementation 'org.robolectric:robolectric:4.3.1'

// Instrumented testing
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
Expand Down
4 changes: 2 additions & 2 deletions CameraXBasic/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<application
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:name=".CameraXBasic"
android:label="@string/app_name"
android:allowBackup="true">
android:allowBackup="true"
tools:ignore="AllowBackup">

<activity
android:name=".MainActivity"
Expand Down
Loading