From cb8471a7a0fb65c57c4985b6b3dd143741ea105b Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:04:12 -0600 Subject: [PATCH 1/8] fix: fixes security warnings by sonarcloud --- app/build.gradle | 9 +++++ app/src/main/AndroidManifest.xml | 10 ++++-- .../main/res/xml/data_extraction_rules.xml | 36 +++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/xml/data_extraction_rules.xml diff --git a/app/build.gradle b/app/build.gradle index 08cc377..3c60123 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,17 @@ android { compileSdkVersion 33 defaultConfig { applicationId "com.android.nikhil.memorygame" +<<<<<<< Updated upstream minSdkVersion 15 +<<<<<<< Updated upstream targetSdkVersion 33 +======= + targetSdkVersion 29 +======= + minSdkVersion 23 + targetSdkVersion 33 +>>>>>>> Stashed changes +>>>>>>> Stashed changes versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 39c5851..a45c157 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,15 +3,19 @@ xmlns:tools="http://schemas.android.com/tools"> + tools:ignore="GoogleAppIndexingWarning" + android:fullBackupContent="false" + android:dataExtractionRules="@xml/data_extraction_rules"> - + diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000..8b570f1 --- /dev/null +++ b/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,36 @@ + + + + + + + + \ No newline at end of file From c8387d983cf17e1192d03787d34df23d0eb2805d Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:07:39 -0600 Subject: [PATCH 2/8] fix: makes gradlew executable in cicd --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 794be99..b53e400 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,8 @@ jobs: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle + - name: Make gradlew executable + run: chmod +x ./gradlew - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From 62ad5a343f5d7d69a9809b3a6f0ab98bf909ade6 Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:10:25 -0600 Subject: [PATCH 3/8] fix: fixes merge conflicts --- app/build.gradle | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3c60123..dbfb921 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,17 +7,8 @@ android { compileSdkVersion 33 defaultConfig { applicationId "com.android.nikhil.memorygame" -<<<<<<< Updated upstream - minSdkVersion 15 -<<<<<<< Updated upstream - targetSdkVersion 33 -======= - targetSdkVersion 29 -======= minSdkVersion 23 targetSdkVersion 33 ->>>>>>> Stashed changes ->>>>>>> Stashed changes versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 468def568cc612f8a2a22827211aff6c4871b378 Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:30:54 -0600 Subject: [PATCH 4/8] feat: upgrades EasyFlipView library to 3.x --- app/build.gradle | 8 ++++++-- .../android/nikhil/memorygame/CardAdapter.kt | 17 ++++++++--------- .../com/android/nikhil/memorygame/GameDialog.kt | 7 ++++--- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index dbfb921..95ca576 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' apply plugin: 'org.sonarqube' android { @@ -19,6 +18,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + buildFeatures { + viewBinding = true + } + namespace 'com.android.nikhil.memorygame' } @@ -28,7 +31,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.cardview:cardview:1.0.0' - implementation "com.wajahatkarim3.EasyFlipView:EasyFlipView:$easy_flip_view" +// implementation "com.wajahatkarim3.EasyFlipView:EasyFlipView:$easy_flip_view" + implementation 'com.wajahatkarim:EasyFlipView:3.0.3' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/app/src/main/java/com/android/nikhil/memorygame/CardAdapter.kt b/app/src/main/java/com/android/nikhil/memorygame/CardAdapter.kt index 0f57344..ad567fd 100644 --- a/app/src/main/java/com/android/nikhil/memorygame/CardAdapter.kt +++ b/app/src/main/java/com/android/nikhil/memorygame/CardAdapter.kt @@ -1,19 +1,18 @@ package com.android.nikhil.memorygame +import android.annotation.SuppressLint import android.content.Context -import androidx.recyclerview.widget.RecyclerView +import android.os.Handler import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.RelativeLayout import android.widget.TextView -import android.os.Handler +import androidx.recyclerview.widget.RecyclerView import com.android.nikhil.memorygame.R.string +import com.android.nikhil.memorygame.databinding.CardItemBinding import com.wajahatkarim3.easyflipview.EasyFlipView -import kotlinx.android.synthetic.main.card_front.view.cardViewTextView - -import java.util.ArrayList /** * Created by NIKHIL on 08-01-2018. @@ -38,12 +37,12 @@ class CardAdapter( parent: ViewGroup, viewType: Int ): CardViewHolder { - return CardViewHolder(LayoutInflater.from(context).inflate(R.layout.card_item, parent, false)) + return CardViewHolder(CardItemBinding.inflate(LayoutInflater.from(context)).root) } override fun onBindViewHolder( - holder: CardViewHolder, - position: Int + holder: CardViewHolder, + @SuppressLint("RecyclerView") position: Int ) { cardList[position].flipView = holder.flipView holder.textView.text = context.getString(string.question_mark) @@ -107,7 +106,7 @@ class CardAdapter( } inner class CardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val textView = itemView.cardViewTextView as TextView + val textView = itemView.findViewById(R.id.cardViewTextView) as TextView val rootLayout = itemView.findViewById(R.id.cardViewRootLayout) as RelativeLayout val flipView = itemView.findViewById(R.id.flipView) as EasyFlipView val cardImageView = itemView.findViewById(R.id.cardImageView) as ImageView diff --git a/app/src/main/java/com/android/nikhil/memorygame/GameDialog.kt b/app/src/main/java/com/android/nikhil/memorygame/GameDialog.kt index fb6914a..df9c117 100644 --- a/app/src/main/java/com/android/nikhil/memorygame/GameDialog.kt +++ b/app/src/main/java/com/android/nikhil/memorygame/GameDialog.kt @@ -6,7 +6,7 @@ import android.content.DialogInterface import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.os.Bundle -import kotlinx.android.synthetic.main.dialog_game.view.* +import com.android.nikhil.memorygame.databinding.DialogGameBinding class GameDialog : DialogFragment() { @@ -35,9 +35,10 @@ class GameDialog : DialogFragment() { @Deprecated("Deprecated in Java") override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val view = activity.layoutInflater.inflate(R.layout.dialog_game, null) + val binding = DialogGameBinding.inflate(activity.layoutInflater) + val view = binding.root val message = arguments.getString("message") - message?.let { view.message.text = it } + message?.let { binding.message.text = it } val dialog = super.onCreateDialog(savedInstanceState) dialog.setContentView(view) dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) From d3ed6a870eee2332a5d162dd25a3fd0e5f9cc42b Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:38:02 -0600 Subject: [PATCH 5/8] fix: updates sonar task name & adds badge --- README.md | 2 ++ app/build.gradle | 3 +-- build.gradle | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e91502..2bf5415 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Memory-Game Memory Game for Android. The game consists of some cards which are randomly arranged. The user has to flip the cards to get the correct pairs. +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=subbramanil_Memory-Game&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=subbramanil_Memory-Game) + ## Screenshots ### Home diff --git a/app/build.gradle b/app/build.gradle index 95ca576..b7de42d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,6 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.cardview:cardview:1.0.0' -// implementation "com.wajahatkarim3.EasyFlipView:EasyFlipView:$easy_flip_view" implementation 'com.wajahatkarim:EasyFlipView:3.0.3' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' @@ -40,7 +39,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } -sonarqube { +sonar { properties { property "sonar.projectKey", "subbramanil_Memory-Game" property "sonar.organization", "subbramanil" diff --git a/build.gradle b/build.gradle index 2c18118..4e52899 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,6 @@ plugins { } ext { - easy_flip_view = "2.1.0" support_version = "27.1.1" constraint_version = "1.1.3" } From 854f7152eaf6010dbaeda8958494af0d5e9d3344 Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:46:13 -0600 Subject: [PATCH 6/8] fix: updates task name in cicd build & configures variant --- .github/workflows/build.yml | 2 +- app/build.gradle | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b53e400..f16fe63 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,4 +36,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew build sonarqube --info \ No newline at end of file + run: ./gradlew build sonar --info \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index b7de42d..17f5de0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,7 +39,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } -sonar { +sonarqube { + androidVariant 'debug' properties { property "sonar.projectKey", "subbramanil_Memory-Game" property "sonar.organization", "subbramanil" From d4233f37f70c6176cd88d5ce7789aa48aeb0d15c Mon Sep 17 00:00:00 2001 From: Subbu Lakshmanan Date: Fri, 24 Feb 2023 20:48:39 -0600 Subject: [PATCH 7/8] fix: removes todo that will never get done --- app/src/main/res/xml/data_extraction_rules.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml index 8b570f1..9dd0bbc 100644 --- a/app/src/main/res/xml/data_extraction_rules.xml +++ b/app/src/main/res/xml/data_extraction_rules.xml @@ -7,7 +7,6 @@