diff --git a/.github/workflows/ktlint.yml b/.github/workflows/ktlint.yml new file mode 100644 index 0000000..69d1f79 --- /dev/null +++ b/.github/workflows/ktlint.yml @@ -0,0 +1,17 @@ +name: Run KtLint + +on: + push: + branches-ignore: + - 'master' + +jobs: + ktlint: + runs-on: ubuntu-latest + + steps: + - name: "checkout" + uses: actions/checkout@v2 + + - name: "ktlint" + uses: "vroy/gha-kotlin-linter@v1" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..4d73b6d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ +name: Build Submission + +on: + push: + branches-ignore: + - 'master' + - 'base' + + +jobs: + build: + + 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: Build with Gradle + run: ./gradlew build + - name: Run Unit Tests + run: ./gradlew test diff --git a/.github/workflows/prepareZip.yml b/.github/workflows/prepareZip.yml new file mode 100644 index 0000000..4e03909 --- /dev/null +++ b/.github/workflows/prepareZip.yml @@ -0,0 +1,63 @@ +name: Prepare Code Challenge Zip + +on: + push: + branches: + - 'base' + +jobs: + build: + name: Build and test + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew build + - name: Run Unit Tests + run: ./gradlew test + + zip: + name: Zip artifact + + runs-on: ubuntu-latest + + needs: build + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Prepare artifact + run: git checkout -b candidate; + git branch -D base; + git remote set-url origin git@github.com:motain/android-code-challenge-submissions.git; + + # INFO: We're archiving folder manually to keep file permissions. + # It's workaround to avoid file permissions change on artifact upload. More info: https://github.com/actions/upload-artifact/issues/38 + # After actions/upload-artifact gets fix, this step should be avoided and 'path' value for upload-artifact shuld be changed to `path: ./` + - name: Zip artifact (workaround for upload-artifact permissions bug) + run: mkdir ../artifact; + cd ..; + zip -qq -r ./artifact/android-code-challenge-submissions.zip ./android-code-challenge-submissions; + + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: android-code-challenge-submissions + path: ../artifact + + ktlint: + runs-on: ubuntu-latest + + steps: + - name: "checkout" + uses: actions/checkout@v2 + + - name: "ktlint" + uses: "vroy/gha-kotlin-linter@v1" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7bec898 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Project exclude paths +/.gradle/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..c00d67d --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +OnefootballCodingChallenge \ No newline at end of file diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..bd63510 Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..b9f8a5e --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f845854 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f347f9c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1374c14 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Android Take Home Test + +The purpose of this test is to evaluate your technical skills, communication and mindset. + +You should exemplify the :muscle: best work you can do with the provided example and perhaps :boom: surprise us with your solution. You have *one* week time to work on the test, but our expectations are that a fraction of the time is needed for the test. + +You are expected to refactor and improve the project to avoid the mistakes it has. + +## Procedure + +1. After completing the challenge, clean the project (builds, .gradle, etc). But remember: The project should still be runnable. +2. Compress project file as a ".zip" file. +3. Send the `zip` file back to the person you have been in contact with (from the recruiting team). +4. You will receive feedback for this project file which you sent us during the live interview. + +Notes : + - Meaningful commit history (git) will be a plus. + - Feel free to add some comments or provide information in `README.md` file about things you would like to improve but didn't have time for this. + - The project zip file size should't be more 15 MB. + +## Project + +In this project, you will have a news feed activity. It retrieves the data from the local JSON file. +JSON is parsed manually and elements has been created from the parsed data. + +All the logical operations are happening in `MyNewsActivity.kt` and the layout for the list items is +stored in `news_item.xml` file. There is only one data class for `News` element and it's in `model` folder. + +The Application is written in Kotlin. + +You are free to suggest and implement any library or code snippet that you think that is going to be useful +for the codebase. But please be sure to add detailed information about your suggestions and why they would be useful. + +## Questions + +Feel free to reach out to us if you have any issues or questions. You may contact the person that sent the +code challenge to you. + +![](https://media.giphy.com/media/uADx98ByhpOwcE7KhW/giphy.gif) + +:rocket: Have fun! diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..c0e8700 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,82 @@ +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..53ef58b --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,47 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.onefootball" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + kotlinOptions { + jvmTarget = "1.8" + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation("io.coil-kt:coil:0.6.1") + + implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.core:core-ktx:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/onefootball/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/onefootball/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..9e95d99 --- /dev/null +++ b/app/src/androidTest/java/com/onefootball/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.onefootball + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.assertEquals + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.onefootball", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..66f289d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/news.json b/app/src/main/assets/news.json new file mode 100644 index 0000000..5916c61 --- /dev/null +++ b/app/src/main/assets/news.json @@ -0,0 +1,74 @@ +{ + "news": [ + { + "title": "The 5 players who could be the next Messi or Ronaldo", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FFIFA-Ballon-dOr-Gala-2014-1566312341-1024x683.jpg&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/the-5-players-who-could-be-the-next-messi-or-ronaldo-en-26880141?variable=20190822" + }, + { + "title": "How will Juventus line up this season?", + "image_url": "https://oneftbl-cms.imgix.net/https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FFBL-ICC-2019-MADRID-JUVENTUS-1566054314-1024x768.jpg?crop=faces&fit=crop&h=810&q=25&w=1080&s=eecf0b15917c1c4af6bc16ecb63ccc1e", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/how-will-juventus-line-up-this-season-en-26881454?variable=20190822" + }, + { + "title": "Impact of VAR on the Premier League so far", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwww.elartedf.com%2Fwp-content%2Fuploads%2F2019%2F08%2FManchester-City-v-Tottenham-Hotspur-Premier-League-1566473944.jpg&q=25&w=1080", + "resource_name": "El Arte Del Futbol", + "resource_url": "https://filebucket.onefootball.com/2019/8/1564679170544-EADF_90.png", + "news_link": "https://onefootball.com/en/news/impact-of-var-on-the-premier-league-so-far-en-26880789?variable=20190822" + }, + { + "title": "Philippe Coutinho not ready as Bayern Munich deal with other injuries", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FFC-Bayern-Muenchen-Training-Session-1566477286-1024x768.jpg&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/philippe-coutinho-not-ready-as-bayern-munich-deal-with-other-injuries-en-26881369?variable=20190822" + }, + { + "title": "Real Madrid, Juventus, Manchester United and PSG all could have signed Dortmund's Witsel", + "image_url": "https://image-service.onefootball.com/resize?fit=max&image=https%3A%2F%2Fimages.performgroup.com%2Fdi%2Flibrary%2Fomnisport%2Fce%2Fd4%2Faxelwitsel-cropped_1e7rytc4fq9j31l3phqdnalo2v.jpg%3Ft%3D-1198856740&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/real-madrid-juventus-manchester-united-and-psg-all-could-have-signed-dortmunds-witsel-en-26879930?variable=20190822" + }, + { + "title": "Real Madrid have a huge bid for Neymar turned down", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FBrazil-v-Qatar-1566457504-1024x768.jpg&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/real-madrid-have-a-huge-bid-for-neymar-turned-down-en-26877739?variable=20190822" + }, + { + "title": "Midfielder's agent leaves door open for Bayern Munich bid", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FLevante-UD-v-RCD-Espanyol-La-Liga-1566468667-1024x768.jpg&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/midfielders-agent-leaves-door-open-for-bayern-munich-bid-en-26879600?variable=20190822" + }, + { + "title": "Transfer gossip: Mega Neymar bid? Premier League sales?", + "image_url": "https://oneftbl-cms.imgix.net/https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FFBL-FRA-LIGUE1-PSG-TRAINING-1566452758-1024x768.jpg?crop=faces&fit=crop&h=810&q=25&w=1080&s=a8aceb949a6bd84840193dc0f5b0c16a", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/transfer-gossip-mega-neymar-bid-premier-league-sales-en-26877182?variable=20190822" + }, + { + "title": "Roma sign Chelsea's Davide Zappacosta on six-month loan", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FReading-v-Chelsea-Pre-Season-Friendly-1566410136-1024x768.jpg&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/roma-sign-chelseas-davide-zappacosta-on-six-month-loan-en-26872291?variable=20190822" + }, + { + "title": "Ryan Kent looking to force through Rangers move", + "image_url": "https://image-service.onefootball.com/crop/face?h=810&image=https%3A%2F%2Fwp-images.onefootball.com%2Fwp-content%2Fuploads%2Fsites%2F10%2F2019%2F08%2FCeltic-v-Rangers-Ladbrokes-Scottish-Premiership-1566411847-1024x768.jpg&q=25&w=1080", + "resource_name": "Onefootball", + "resource_url": "https://images.onefootball.com/blogs_logos/circle_onefootball.png", + "news_link": "https://onefootball.com/en/news/ryan-kent-looking-to-force-through-rangers-move-en-26872667?variable=20190822" + } + ] +} \ No newline at end of file diff --git a/app/src/main/java/com/onefootball/MyNewsActivity.kt b/app/src/main/java/com/onefootball/MyNewsActivity.kt new file mode 100644 index 0000000..998a645 --- /dev/null +++ b/app/src/main/java/com/onefootball/MyNewsActivity.kt @@ -0,0 +1,108 @@ +package com.onefootball + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import coil.api.load +import com.onefootball.model.News +import org.json.JSONArray +import org.json.JSONObject +import java.nio.charset.Charset + +class MyNewsActivity : AppCompatActivity() { + + var jsonString: String? = null + lateinit var recyclerView: RecyclerView + lateinit var myAdapter: NewsAdapter + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + recyclerView = findViewById(R.id.newsRecyclerView) + myAdapter = NewsAdapter() + with(recyclerView) { + adapter = myAdapter + layoutManager = LinearLayoutManager(this@MyNewsActivity) + } + } + + override fun onResume() { + super.onResume() + var inputStream = assets.open("news.json") + val size = inputStream.available() + val buffer = ByteArray(size) + inputStream.read(buffer) + inputStream.close() + jsonString = buffer.toString(Charset.defaultCharset()) + + val items = parseJsonString(jsonString!!) + myAdapter.setNewsItems(items) + } + + private fun parseJsonString(jsonString: String): List { + val mainObject = JSONObject(jsonString) + val newsItems = mutableListOf() + val newsArray = mainObject.getJSONArray("news") + newsArray.forEach { newsObject -> + val title = newsObject.getString("title") + val imageURL = newsObject.getString("image_url") + val resourceName = newsObject.getString("resource_name") + val resourceURL = newsObject.getString("resource_url") + val newsLink = newsObject.getString("news_link") + + newsItems.add(News(title = title, imageURL = imageURL, resourceName = resourceName, resourceURL = resourceURL, newsLink = newsLink)) + } + return newsItems + } +} + +class NewsAdapter : RecyclerView.Adapter() { + + private val newsItems = ArrayList() + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NewsViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.news_item, parent, false) + return NewsViewHolder(view) + } + + override fun getItemCount() = newsItems.size + + override fun onBindViewHolder(holder: NewsViewHolder, position: Int) { + val news = newsItems[position] + + holder.titleView.text = news.title + holder.newsView.load(url = news.imageURL) + holder.resourceImage.load(url = news.resourceURL) + holder.resourceName.text = news.resourceName + holder.itemView.setOnClickListener { + it.context.startActivity( + Intent(Intent.ACTION_VIEW, Uri.parse(news.newsLink)) + ) + } + } + + fun setNewsItems(newListOfNewsItems: List) { + newsItems.clear() + newsItems.addAll(newListOfNewsItems) + notifyDataSetChanged() + } + + class NewsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + + var titleView: TextView = itemView.findViewById(R.id.news_title) + var newsView: ImageView = itemView.findViewById(R.id.news_view) + var resourceImage: ImageView = itemView.findViewById(R.id.resource_icon) + var resourceName: TextView = itemView.findViewById(R.id.resource_name) + } +} + +fun JSONArray.forEach(jsonObject: (JSONObject) -> Unit) { + for (index in 0 until this.length()) jsonObject(this[index] as JSONObject) +} diff --git a/app/src/main/java/com/onefootball/model/News.kt b/app/src/main/java/com/onefootball/model/News.kt new file mode 100644 index 0000000..2aa2d4c --- /dev/null +++ b/app/src/main/java/com/onefootball/model/News.kt @@ -0,0 +1,9 @@ +package com.onefootball.model + +data class News( + val title: String, + val imageURL: String, + val resourceName: String, + val resourceURL: String, + val newsLink: String +) \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..fc9bc21 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/news_item.xml b/app/src/main/res/layout/news_item.xml new file mode 100644 index 0000000..09cdf7c --- /dev/null +++ b/app/src/main/res/layout/news_item.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..898f3ed Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dffca36 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..64ba76f Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..dae5e08 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e5ed465 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..14ed0af Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d8ae031 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2c18de9 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..beed3cd Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..69b2233 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #008577 + #00574B + #D81B60 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..0fe8808 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + OnefootballCodingChallenge + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/com/onefootball/ExampleUnitTest.kt b/app/src/test/java/com/onefootball/ExampleUnitTest.kt new file mode 100644 index 0000000..84ff349 --- /dev/null +++ b/app/src/test/java/com/onefootball/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.onefootball + +import org.junit.Test + +import org.junit.Assert.assertEquals + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e0797fd --- /dev/null +++ b/build.gradle @@ -0,0 +1,28 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.72' + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..723bcad --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Aug 22 15:04:06 CEST 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/local.properties b/local.properties new file mode 100644 index 0000000..c38a30d --- /dev/null +++ b/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Wed Jun 10 15:52:18 EAT 2020 +sdk.dir=C\:\\Users\\HP PAVILLION\\AppData\\Local\\Android\\Sdk diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..c669efe --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name='OnefootballCodingChallenge'