Skip to content

Commit

Permalink
Fix various test and lint errors
Browse files Browse the repository at this point in the history
* Fix test and lint errors in all samples
* Update all samples to the latest Gradle plugin version
  • Loading branch information
owahltinez committed Mar 6, 2020
1 parent 3e50358 commit 60e8cf1
Show file tree
Hide file tree
Showing 29 changed files with 52 additions and 194 deletions.
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

This file was deleted.

4 changes: 3 additions & 1 deletion CameraXBasic/app/src/main/res/drawable/ic_switch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:tint="@color/selector_ic"
android:width="24dp"
android:height="24dp"
android:viewportWidth="46.0"
android:viewportHeight="46.0">
android:viewportHeight="46.0"
tools:ignore="VectorRaster">
<path android:fillAlpha="0" android:fillColor="#D8D8D8"
android:fillType="evenOdd" android:pathData="M-4,-4h54v54h-54z"
android:strokeColor="#00000000" android:strokeWidth="1"/>
Expand Down
18 changes: 6 additions & 12 deletions CameraXBasic/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +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=".MainActivity">

<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=".MainActivity"/>
7 changes: 0 additions & 7 deletions CameraXBasic/app/src/main/res/values-v28/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:immersive">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>

Expand Down
3 changes: 0 additions & 3 deletions CameraXBasic/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:immersive">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowTranslucentStatus">true</item>
Expand Down
2 changes: 1 addition & 1 deletion CameraXBasic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
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.2.1"

Expand Down
Loading

0 comments on commit 60e8cf1

Please sign in to comment.