From 852e3a9bd94d396b53a50fe3b0af7e474ca022f6 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Wed, 19 Feb 2020 12:22:05 +0100 Subject: [PATCH 1/3] Android Studio 3.5.3 --- .../app/build.gradle | 20 +++++++++++++------ InteractiveSliceProviderKotlin/build.gradle | 8 +++----- .../gradle/wrapper/gradle-wrapper.properties | 4 ++-- SliceViewerKotlin/app/build.gradle | 17 +++++++++------- SliceViewerKotlin/build.gradle | 8 ++++---- .../gradle/wrapper/gradle-wrapper.properties | 4 ++-- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/InteractiveSliceProviderKotlin/app/build.gradle b/InteractiveSliceProviderKotlin/app/build.gradle index 9d7340076..8053f13ac 100644 --- a/InteractiveSliceProviderKotlin/app/build.gradle +++ b/InteractiveSliceProviderKotlin/app/build.gradle @@ -13,6 +13,14 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + } } buildTypes { release { @@ -25,8 +33,8 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "androidx.appcompat:appcompat:1.0.2" - implementation "androidx.core:core-ktx:1.0.1" + implementation "androidx.appcompat:appcompat:1.1.0" + implementation "androidx.core:core-ktx:1.2.0" // The slice builder ktx library has a number of dependencies. For reference, since this is a // slice sample, below are a list of the slice dependencies: @@ -35,10 +43,10 @@ dependencies { implementation "androidx.slice:slice-builders-ktx:1.0.0-alpha6" implementation "androidx.constraintlayout:constraintlayout:1.1.3" - implementation "com.google.firebase:firebase-appindexing:17.1.0" - testImplementation "junit:junit:4.12" - androidTestImplementation "androidx.test:runner:1.1.1" - androidTestImplementation "androidx.test.espresso:espresso-core:3.1.1" + implementation "com.google.firebase:firebase-appindexing:19.1.0" + testImplementation "junit:junit:4.13" + androidTestImplementation "androidx.test:runner:1.2.0" + androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" } apply plugin: "com.google.gms.google-services" diff --git a/InteractiveSliceProviderKotlin/build.gradle b/InteractiveSliceProviderKotlin/build.gradle index 20acdf270..dff13383e 100644 --- a/InteractiveSliceProviderKotlin/build.gradle +++ b/InteractiveSliceProviderKotlin/build.gradle @@ -1,17 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.0' + ext.kotlin_version = '1.3.61' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.5.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.gms:google-services:4.2.0' - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.google.gms:google-services:4.3.3' } } diff --git a/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties b/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties index f3e238e39..6d59a2db2 100644 --- a/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties +++ b/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu May 24 23:16:35 PDT 2018 +#Wed Feb 19 12:27:54 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip diff --git a/SliceViewerKotlin/app/build.gradle b/SliceViewerKotlin/app/build.gradle index bd4c1ed9a..2dbed614b 100644 --- a/SliceViewerKotlin/app/build.gradle +++ b/SliceViewerKotlin/app/build.gradle @@ -8,14 +8,14 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "androidx.lifecycle:lifecycle-runtime:2.0.0" - implementation "androidx.lifecycle:lifecycle-extensions:2.0.0" - implementation "androidx.lifecycle:lifecycle-common:2.0.0" + implementation "androidx.lifecycle:lifecycle-runtime:2.2.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation "androidx.lifecycle:lifecycle-common:2.2.0" implementation "androidx.slice:slice-view:1.1.0-alpha01" implementation "androidx.slice:slice-builders-ktx:1.0.0-alpha6" - implementation "androidx.appcompat:appcompat:1.0.0" + implementation "androidx.appcompat:appcompat:1.1.0" implementation "androidx.cardview:cardview:1.0.0" - implementation "androidx.core:core-ktx:1.0.0" + implementation "androidx.core:core-ktx:1.2.0" implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } @@ -31,7 +31,10 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 } } diff --git a/SliceViewerKotlin/build.gradle b/SliceViewerKotlin/build.gradle index b9c6c7048..0103e8819 100644 --- a/SliceViewerKotlin/build.gradle +++ b/SliceViewerKotlin/build.gradle @@ -1,19 +1,19 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.61' repositories { - jcenter() google() + jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:3.5.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { - jcenter() google() + jcenter() } } \ No newline at end of file diff --git a/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties b/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties index fd6b29dfb..4d26b5ad8 100644 --- a/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties +++ b/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jun 12 10:02:08 PDT 2018 +#Wed Feb 19 12:20:02 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip From d38e307a0f3376f7cae5357c7bc86724bf5750dd Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Mon, 23 Mar 2020 08:13:30 +0100 Subject: [PATCH 2/3] Android Studio 3.6.1 --- InteractiveSliceProviderKotlin/app/.gitignore | 1 - InteractiveSliceProviderKotlin/app/build.gradle | 1 - InteractiveSliceProviderKotlin/build.gradle | 6 ++---- .../gradle/wrapper/gradle-wrapper.properties | 2 +- SliceViewerKotlin/build.gradle | 5 ++--- SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties | 4 ++-- 6 files changed, 7 insertions(+), 12 deletions(-) delete mode 100644 InteractiveSliceProviderKotlin/app/.gitignore diff --git a/InteractiveSliceProviderKotlin/app/.gitignore b/InteractiveSliceProviderKotlin/app/.gitignore deleted file mode 100644 index 796b96d1c..000000000 --- a/InteractiveSliceProviderKotlin/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/InteractiveSliceProviderKotlin/app/build.gradle b/InteractiveSliceProviderKotlin/app/build.gradle index 8053f13ac..c02056697 100644 --- a/InteractiveSliceProviderKotlin/app/build.gradle +++ b/InteractiveSliceProviderKotlin/app/build.gradle @@ -31,7 +31,6 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "androidx.appcompat:appcompat:1.1.0" implementation "androidx.core:core-ktx:1.2.0" diff --git a/InteractiveSliceProviderKotlin/build.gradle b/InteractiveSliceProviderKotlin/build.gradle index dff13383e..44cf0df3b 100644 --- a/InteractiveSliceProviderKotlin/build.gradle +++ b/InteractiveSliceProviderKotlin/build.gradle @@ -1,13 +1,11 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.70' repositories { google() 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 'com.google.gms:google-services:4.3.3' } diff --git a/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties b/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties index 6d59a2db2..3cf51e2f3 100644 --- a/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties +++ b/InteractiveSliceProviderKotlin/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip diff --git a/SliceViewerKotlin/build.gradle b/SliceViewerKotlin/build.gradle index 0103e8819..11412df59 100644 --- a/SliceViewerKotlin/build.gradle +++ b/SliceViewerKotlin/build.gradle @@ -1,12 +1,11 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.70' repositories { google() 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" } } diff --git a/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties b/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties index 4d26b5ad8..4609175a7 100644 --- a/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties +++ b/SliceViewerKotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Feb 19 12:20:02 CET 2020 +#Mon Mar 23 08:09:41 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip From 27b28e3d099b44c96e6fd6aea5b827bdcb2cc8ea Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Mon, 23 Mar 2020 08:51:19 +0100 Subject: [PATCH 3/3] fix some lint warnings --- .../android/sliceviewer/util/SliceViewKtx.kt | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/SliceViewerKotlin/app/src/main/java/com/example/android/sliceviewer/util/SliceViewKtx.kt b/SliceViewerKotlin/app/src/main/java/com/example/android/sliceviewer/util/SliceViewKtx.kt index 78e6f6a11..142427ff0 100644 --- a/SliceViewerKotlin/app/src/main/java/com/example/android/sliceviewer/util/SliceViewKtx.kt +++ b/SliceViewerKotlin/app/src/main/java/com/example/android/sliceviewer/util/SliceViewKtx.kt @@ -30,21 +30,20 @@ import androidx.slice.core.SliceHints import androidx.slice.widget.SliceLiveData import androidx.slice.widget.SliceView import androidx.slice.widget.SliceView.OnSliceActionListener -import com.example.android.sliceviewer.ui.list.SliceViewerActivity import com.example.android.sliceviewer.ui.list.SliceViewerActivity.Companion.TAG fun SliceView.bind( - context: Context, - lifecycleOwner: LifecycleOwner, - uri: Uri, - onSliceActionListener: OnSliceActionListener = OnSliceActionListener { _, _ -> }, - onClickListener: OnClickListener = OnClickListener { }, - onLongClickListener: OnLongClickListener = OnLongClickListener { false }, - scrollable: Boolean = false + context: Context, + lifecycleOwner: LifecycleOwner, + uri: Uri, + onSliceActionListener: OnSliceActionListener = OnSliceActionListener { _, _ -> }, + onClickListener: OnClickListener = OnClickListener { }, + onLongClickListener: OnLongClickListener = OnLongClickListener { false }, + scrollable: Boolean = false ) { setOnSliceActionListener(onSliceActionListener) setOnClickListener(onClickListener) - setScrollable(scrollable) + isScrollable = scrollable setOnLongClickListener(onLongClickListener) if (uri.scheme == null) { Log.w(TAG, "Scheme is null for URI $uri") @@ -52,40 +51,36 @@ fun SliceView.bind( } // If someone accidentally prepends the "slice-" prefix to their scheme, let's remove it. val scheme = - if (uri.scheme.startsWith("slice-")) { - uri.scheme.replace("slice-", "") - } - else { - uri.scheme - } + if (uri.scheme.startsWith("slice-")) { + uri.scheme.replace("slice-", "") + } else { + uri.scheme + } if (scheme == ContentResolver.SCHEME_CONTENT || - scheme.equals("https", true) || - scheme.equals("http", true) + scheme.equals("https", true) || + scheme.equals("http", true) ) { val intent = Intent(Intent.ACTION_VIEW, uri) val sliceLiveData = SliceLiveData.fromIntent(context, intent) - sliceLiveData?.removeObservers(lifecycleOwner) + sliceLiveData.removeObservers(lifecycleOwner) try { - sliceLiveData?.observe(lifecycleOwner, Observer { updatedSlice -> + sliceLiveData.observe(lifecycleOwner, Observer { updatedSlice -> if (updatedSlice == null) return@Observer slice = updatedSlice val expiry = SliceMetadata.from(context, updatedSlice).expiry if (expiry != SliceHints.INFINITY) { // Shows the updated text after the TTL expires. postDelayed( - { slice = updatedSlice }, - expiry - System.currentTimeMillis() + 15 + { slice = updatedSlice }, + expiry - System.currentTimeMillis() + 15 ) } - Log.d(SliceViewerActivity.TAG, "Update Slice: $updatedSlice") + Log.d(TAG, "Update Slice: $updatedSlice") }) } catch (e: Exception) { - Log.e( - SliceViewerActivity.TAG, - "Failed to find a valid ContentProvider for authority: $uri" - ) + Log.e(TAG, "Failed to find a valid ContentProvider for authority: $uri") } } else { - Log.w(SliceViewerActivity.TAG, "Invalid uri, skipping slice: $uri") + Log.w(TAG, "Invalid uri, skipping slice: $uri") } } \ No newline at end of file