From ae6a328fe1ed948504230a88b7756a78a44ee098 Mon Sep 17 00:00:00 2001 From: Madalin Valceleanu Date: Mon, 19 Aug 2019 17:49:40 +0200 Subject: [PATCH 1/4] Fix several project lint warnings --- app/build.gradle | 5 + app/src/main/AndroidManifest.xml | 2 +- .../apps/sunflower/PlantDetailFragment.kt | 35 ++--- .../res/drawable/ic_launcher_background.xml | 129 ------------------ app/src/main/res/layout/nav_header.xml | 3 +- app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values/styles.xml | 4 + build.gradle | 14 +- 8 files changed, 37 insertions(+), 156 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml diff --git a/app/build.gradle b/app/build.gradle index 271e28198..7d8c807d5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,6 +48,11 @@ android { kotlinOptions { jvmTarget = "1.8" } + lintOptions { + disable 'GoogleAppIndexingWarning' + disable 'IconLauncherShape' + warningsAsErrors true + } } dependencies { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 88987f83f..6a9f28bc6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,7 +22,7 @@ { - val shareIntent = ShareCompat.IntentBuilder.from(activity) - .setText(shareText) - .setType("text/plain") - .createChooserIntent() - .apply { - // https://android-developers.googleblog.com/2012/02/share-with-intents.html - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - // If we're on Lollipop, we can open the intent as a document - addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK) - } else { - // Else, we will use the old CLEAR_WHEN_TASK_RESET flag - addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) - } - } - startActivity(shareIntent) - return true + activity?.let { + val shareIntent = ShareCompat.IntentBuilder.from(it) + .setText(shareText) + .setType("text/plain") + .createChooserIntent() + .apply { + // https://android-developers.googleblog.com/2012/02/share-with-intents.html + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + // If we're on Lollipop, we can open the intent as a document + addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK) + } else { + // Else, we will use the old CLEAR_WHEN_TASK_RESET flag + addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) + } + } + startActivity(shareIntent) + return true + } + return false } else -> super.onOptionsItemSelected(item) } diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 05983e01f..000000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/nav_header.xml b/app/src/main/res/layout/nav_header.xml index ac5f40311..b2e0a254a 100644 --- a/app/src/main/res/layout/nav_header.xml +++ b/app/src/main/res/layout/nav_header.xml @@ -19,11 +19,10 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="@dimen/navigation_drawer_header_height" - android:background="?attr/colorPrimaryDark" android:gravity="bottom" android:orientation="vertical" android:padding="@dimen/navigation_drawer_header_padding" - android:theme="@style/ThemeOverlay.AppCompat.Dark"> + style="@style/NavigationHeaderAppearance"> - Sunflower Filtra per zona di crescita Immagine della pianta Il mio giardino diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 71d0a5cb6..32b100194 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -35,4 +35,8 @@ + diff --git a/build.gradle b/build.gradle index 1d526c809..6748c47d5 100644 --- a/build.gradle +++ b/build.gradle @@ -23,29 +23,29 @@ buildscript { targetSdkVersion = 28 // App dependencies - appCompatVersion = '1.1.0-beta01' - constraintLayoutVersion = '2.0.0-beta1' + appCompatVersion = '1.1.0-rc01' + constraintLayoutVersion = '2.0.0-beta2' coreTestingVersion = '2.0.0' coroutinesVersion = "1.3.0-M2" espressoVersion = '3.1.1' - fragmentVersion = '1.1.0-alpha09' + fragmentVersion = '1.2.0-alpha02' glideVersion = '4.9.0' gradleVersion = '3.4.1' gsonVersion = '2.8.2' junitVersion = '4.12' kotlinVersion = '1.3.41' ktlintVersion = '0.30.0' - ktxVersion = '1.0.2' - lifecycleVersion = '2.2.0-alpha01' + ktxVersion = '1.2.0-alpha03' + lifecycleVersion = '2.2.0-alpha03' materialVersion = '1.0.0' navigationVersion = '2.0.0' - recyclerViewVersion = '1.1.0-alpha05' + recyclerViewVersion = '1.1.0-beta03' roomVersion = '2.1.0' runnerVersion = '1.0.1' truthVersion = '0.42' testExtJunit = '1.1.0' uiAutomatorVersion = '2.2.0' - workVersion = '2.1.0' + workVersion = '2.2.0' } repositories { From aa2e914f74d0ae5254fbef3ee5a0c9de5fa72f75 Mon Sep 17 00:00:00 2001 From: Madalin Valceleanu Date: Wed, 21 Aug 2019 22:00:22 +0200 Subject: [PATCH 2/4] PR comment obtain activity directly for fragment --- .../apps/sunflower/PlantDetailFragment.kt | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/google/samples/apps/sunflower/PlantDetailFragment.kt b/app/src/main/java/com/google/samples/apps/sunflower/PlantDetailFragment.kt index 02d65e5d2..fe082ca69 100644 --- a/app/src/main/java/com/google/samples/apps/sunflower/PlantDetailFragment.kt +++ b/app/src/main/java/com/google/samples/apps/sunflower/PlantDetailFragment.kt @@ -85,25 +85,22 @@ class PlantDetailFragment : Fragment() { override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { R.id.action_share -> { - activity?.let { - val shareIntent = ShareCompat.IntentBuilder.from(it) - .setText(shareText) - .setType("text/plain") - .createChooserIntent() - .apply { - // https://android-developers.googleblog.com/2012/02/share-with-intents.html - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - // If we're on Lollipop, we can open the intent as a document - addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK) - } else { - // Else, we will use the old CLEAR_WHEN_TASK_RESET flag - addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) - } + val shareIntent = ShareCompat.IntentBuilder.from(requireActivity()) + .setText(shareText) + .setType("text/plain") + .createChooserIntent() + .apply { + // https://android-developers.googleblog.com/2012/02/share-with-intents.html + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + // If we're on Lollipop, we can open the intent as a document + addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK) + } else { + // Else, we will use the old CLEAR_WHEN_TASK_RESET flag + addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) } - startActivity(shareIntent) - return true - } - return false + } + startActivity(shareIntent) + return true } else -> super.onOptionsItemSelected(item) } From f55c544995aef96f4b2adc4466c8700749a2214f Mon Sep 17 00:00:00 2001 From: Madalin Valceleanu Date: Mon, 9 Sep 2019 15:33:37 +0200 Subject: [PATCH 3/4] Compile project after `master` branch merge --- app/src/main/res/values/styles.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 7df7500f5..7a26903b7 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -41,8 +41,4 @@ ?attr/colorOnSurface - - From 626f6cea3f6073140ca8506844f21634b735d110 Mon Sep 17 00:00:00 2001 From: Madalin Valceleanu Date: Mon, 9 Sep 2019 16:13:34 +0200 Subject: [PATCH 4/4] Remove new warnings after merge with `master` branch --- .../apps/sunflower/views/MaskedCardView.kt | 7 ++++--- .../main/res/layout/fragment_plant_detail.xml | 3 ++- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values-ja/strings.xml | 1 - app/src/main/res/values-tr-rTR/strings.xml | 1 - app/src/main/res/values-zh-rCN/strings.xml | 1 - app/src/main/res/values-zh-rTW/strings.xml | 1 - app/src/main/res/values/dimens.xml | 1 - app/src/main/res/values/strings.xml | 1 - build.gradle | 16 ++++++++-------- gradle/wrapper/gradle-wrapper.properties | 2 +- 13 files changed, 15 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/google/samples/apps/sunflower/views/MaskedCardView.kt b/app/src/main/java/com/google/samples/apps/sunflower/views/MaskedCardView.kt index e19d11186..41262b575 100644 --- a/app/src/main/java/com/google/samples/apps/sunflower/views/MaskedCardView.kt +++ b/app/src/main/java/com/google/samples/apps/sunflower/views/MaskedCardView.kt @@ -21,11 +21,11 @@ import android.graphics.Canvas import android.util.AttributeSet import com.google.android.material.R import com.google.android.material.card.MaterialCardView -import com.google.android.material.shape.ShapeAppearanceModel import com.google.android.material.shape.ShapeAppearancePathProvider import android.annotation.SuppressLint import android.graphics.Path import android.graphics.RectF +import com.google.android.material.shape.ShapeAppearanceModel /** * A Card view that clips the content of any shape, this should be done upstream in card, @@ -39,8 +39,9 @@ class MaskedCardView @JvmOverloads constructor( @SuppressLint("RestrictedApi") private val pathProvider = ShapeAppearancePathProvider() private val path: Path = Path() - private val shapeAppearance: ShapeAppearanceModel = - ShapeAppearanceModel(context, attrs, defStyle, R.style.Widget_MaterialComponents_CardView) + private val shapeAppearance: ShapeAppearanceModel = ShapeAppearanceModel + .builder(context, attrs, defStyle, R.style.Widget_MaterialComponents_CardView) + .build() private val rectF = RectF(0f, 0f, 0f, 0f) override fun onDraw(canvas: Canvas) { diff --git a/app/src/main/res/layout/fragment_plant_detail.xml b/app/src/main/res/layout/fragment_plant_detail.xml index f7a315bdf..bf940e539 100644 --- a/app/src/main/res/layout/fragment_plant_detail.xml +++ b/app/src/main/res/layout/fragment_plant_detail.xml @@ -44,7 +44,8 @@ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:stateListAnimator="@animator/show_toolbar" android:background="?attr/colorSurface" - android:animateLayoutChanges="true"> + android:animateLayoutChanges="true" + tools:targetApi="lollipop"> Bild der Pflanze Mein Garten Pflanzenliste - Verfügbare Pflanzen Details zur Pflanze Pflanze hinzufügen Pflanze wurde zum Garten hinzugefügt diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 069e4db99..30c9e5d6c 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -19,7 +19,6 @@ Mon jardin Image de plante Liste des plantes - (translate me) Available Plants Détails sur la plante (translate me) Add plant Plante ajoutée à votre jardin diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 80afaa82e..f1af9045f 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -19,7 +19,6 @@ Immagine della pianta Il mio giardino Lista delle piante - (translate me) Available Plants Dettagli della pianta Condividi (translate me) Planted diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 6ec693e7f..d9f23767e 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -19,7 +19,6 @@ 植物のイメージ 私の庭 植物のリスト - (translate me) Available Plants 植物の詳細 (translate me) Add plant 植物が庭に追加されました diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index f15402fc4..2bbe120ee 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -19,7 +19,6 @@ Bitkinin görüntüsü Bahçem Bitki listesi - (translate me) Available Plants Bitki detayları (translate me) Add plant Bitki bahçeye eklendi diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 0d8a71496..582f5acd3 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -19,7 +19,6 @@ 植物图片 我的花园 植物目录 - 植物品种 植物介绍 添加植物 添加了新植物 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 2b805ca81..872d728e2 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -19,7 +19,6 @@ 植物圖片 我的花園 植物目錄 - 植物品種 植物介紹 添加植物 添加了新植物 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index fd5cfa81f..5cd82bc23 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -28,7 +28,6 @@ 16dp 8dp - 4dp 95dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1cbc497b6..b04f243a1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,7 +24,6 @@ Image of plant My garden Plant list - Available Plants Plant details Add plant Added plant to garden diff --git a/build.gradle b/build.gradle index 0b457e52c..188b05fe8 100644 --- a/build.gradle +++ b/build.gradle @@ -23,29 +23,29 @@ buildscript { targetSdkVersion = 28 // App dependencies - appCompatVersion = '1.1.0-rc01' + appCompatVersion = '1.1.0' constraintLayoutVersion = '2.0.0-beta2' coreTestingVersion = '2.0.0' coroutinesVersion = "1.3.0-M2" espressoVersion = '3.1.1' - fragmentVersion = '1.2.0-alpha02' + fragmentVersion = '1.2.0-alpha03' glideVersion = '4.9.0' gradleVersion = '3.5.0' gsonVersion = '2.8.2' junitVersion = '4.12' kotlinVersion = '1.3.41' ktlintVersion = '0.33.0' - ktxVersion = '1.2.0-alpha03' - lifecycleVersion = '2.2.0-alpha03' - materialVersion = '1.1.0-alpha09' - navigationVersion = '2.0.0' - recyclerViewVersion = '1.1.0-beta03' + ktxVersion = '1.2.0-alpha04' + lifecycleVersion = '2.2.0-alpha04' + materialVersion = '1.1.0-alpha10' + navigationVersion = '2.1.0' + recyclerViewVersion = '1.1.0-beta04' roomVersion = '2.1.0' runnerVersion = '1.0.1' truthVersion = '0.42' testExtJunit = '1.1.0' uiAutomatorVersion = '2.2.0' - viewPagerVersion = '1.0.0-beta03' + viewPagerVersion = '1.0.0-beta04' workVersion = '2.2.0' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 234a2fd29..3374d054c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -16,6 +16,6 @@ #Thu Aug 22 10:20:57 PDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists