Skip to content

Commit

Permalink
Bumping and refactoring dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
arazabishov committed Sep 26, 2021
1 parent cacf0b3 commit d23ff96
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 99 deletions.
97 changes: 62 additions & 35 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.abishov.hexocat.buildsrc.AndroidSdk
import com.abishov.hexocat.buildsrc.Libraries
import com.abishov.hexocat.buildsrc.AndroidX
import com.abishov.hexocat.buildsrc.Jetpack

plugins {
id("com.android.application")
Expand All @@ -22,12 +24,18 @@ object Version {
get() = "${versionMajor}.${versionMinor}.${versionPatch}"
}

kotlin {
sourceSets.all {
languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
}
}

android {
compileSdkVersion(AndroidSdk.Version.compile)
compileSdk = AndroidSdk.Version.compile

defaultConfig {
targetSdkVersion(AndroidSdk.Version.compile)
minSdkVersion(AndroidSdk.Version.min)
targetSdk = AndroidSdk.Version.compile
minSdk = AndroidSdk.Version.min

applicationId = "com.abishov.hexocat.android"
versionCode = Version.code
Expand All @@ -42,7 +50,7 @@ android {

composeOptions {
kotlinCompilerVersion = Libraries.kotlin
kotlinCompilerExtensionVersion = Libraries.compose
kotlinCompilerExtensionVersion = Jetpack.Compose.version
}

compileOptions {
Expand All @@ -55,6 +63,10 @@ android {
useIR = true
}

testCoverage {
jacocoVersion = "0.8.7"
}

buildTypes {
getByName("debug") {
isTestCoverageEnabled = true
Expand All @@ -66,11 +78,17 @@ android {
}

packagingOptions {
exclude("**/attach_hotspot_windows.dll")
exclude("META-INF/AL2.0")
exclude("META-INF/LGPL2.1")
exclude("META-INF/LICENSE")
exclude("META-INF/licenses/ASM")
resources {
excludes.addAll(
setOf(
"**/attach_hotspot_windows.dll",
"META-INF/AL2.0",
"META-INF/LGPL2.1",
"META-INF/LICENSE",
"META-INF/licenses/ASM",
)
)
}
}

testOptions {
Expand All @@ -90,26 +108,47 @@ paperwork {
)
}

fun DependencyHandlerScope.androidx() {
implementation(AndroidX.Lifecycle.viewmodel)
implementation(AndroidX.Lifecycle.livedata)

implementation(AndroidX.annotation)
implementation(AndroidX.appcompat)

testImplementation(AndroidX.Test.androidJUnit)
testImplementation(AndroidX.Test.archCoreTesting)

androidTestUtil(AndroidX.Test.orchestrator)
androidTestImplementation(AndroidX.Test.rules)
androidTestImplementation(AndroidX.Test.Espresso.core)
androidTestImplementation(AndroidX.Test.Espresso.intents)
androidTestImplementation(AndroidX.Test.Espresso.contrib)
androidTestImplementation(AndroidX.Test.Espresso.idlingResource)
}

fun DependencyHandlerScope.jetpack() {
implementation(Jetpack.material)
implementation(Jetpack.Compose.ui)
implementation(Jetpack.Compose.uiTooling)
implementation(Jetpack.Compose.foundation)
implementation(Jetpack.Compose.material)
implementation(Jetpack.Compose.icons)

androidTestImplementation(Jetpack.Compose.Test.uiTest)
androidTestImplementation(Jetpack.Compose.Test.uiTestJUnit)
}

dependencies {
implementation(project(":shared"))

androidx()
jetpack()

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Libraries.kotlin}")
implementation("hu.supercluster:paperwork:${Libraries.paperwork}")

implementation("com.google.android.material:material:${Libraries.material}")
implementation("androidx.appcompat:appcompat:${Libraries.appcompat}")
implementation("androidx.annotation:annotation:${Libraries.annotation}")

implementation("androidx.compose.ui:ui:${Libraries.compose}")
implementation("androidx.compose.ui:ui-tooling:${Libraries.compose}")
implementation("androidx.compose.foundation:foundation:${Libraries.compose}")
implementation("androidx.compose.material:material-icons-extended:${Libraries.compose}")
implementation("androidx.compose.material:material:${Libraries.compose}")
implementation("dev.chrisbanes.accompanist:accompanist-coil:${Libraries.accompanist}")

implementation("androidx.lifecycle:lifecycle-extensions:${Libraries.lifecycle}")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:${Libraries.lifecycle}")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:${Libraries.lifecycle}")
implementation(Libraries.coil)
implementation(Libraries.flowlayout)

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:${Libraries.coroutines}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Libraries.coroutines}")
Expand Down Expand Up @@ -137,20 +176,8 @@ dependencies {
testImplementation("com.willowtreeapps.assertk:assertk:${Libraries.assertk}")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:${Libraries.mockitok}")
testImplementation("org.robolectric:robolectric:${Libraries.roboelectric}")
testImplementation("androidx.test.ext:junit:${Libraries.androidJunit}")
testImplementation("android.arch.core:core-testing:${Libraries.archTesting}")
testImplementation("com.apollographql.apollo:apollo-api:${Libraries.apollo}")

androidTestUtil("androidx.test:orchestrator:${Libraries.orchestrator}")
androidTestImplementation("androidx.test:rules:${Libraries.testRules}")

androidTestImplementation("androidx.compose.ui:ui-test:${Libraries.compose}")
androidTestImplementation("androidx.test.espresso:espresso-idling-resource:${Libraries.espresso}")
androidTestImplementation("androidx.test.espresso:espresso-core:${Libraries.espresso}")
androidTestImplementation("androidx.test.espresso:espresso-intents:${Libraries.espresso}")
androidTestImplementation("androidx.test.espresso:espresso-contrib:${Libraries.espresso}")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:${Libraries.compose}")

androidTestImplementation("com.github.andrzejchm.RESTMock:android:${Libraries.restmock}")
androidTestImplementation("com.squareup.okhttp3:mockwebserver:${Libraries.okhttp}")
androidTestImplementation("org.mockito:mockito-android:${Libraries.mockito}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object BottomNavigationViewMatcher {
}

override fun matchesSafely(item: BottomNavigationItemView): Boolean {
return isChecked.matches(item.itemData.isChecked)
return isChecked.matches(item.itemData?.isChecked)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.abishov.hexocat.android.home.trending

import android.content.Context
import androidx.compose.ui.test.*
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
Expand Down Expand Up @@ -45,8 +48,11 @@ class TrendingRobot(
}

fun errorMessage(error: String) {
composeTestRule.onNode(hasSubstring(error), useUnmergedTree = true)
.assertIsDisplayed()
composeTestRule.onNodeWithText(
text = error,
substring = true,
useUnmergedTree = true
).assertIsDisplayed()
}

fun retryButtonIsVisible() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.abishov.hexocat.android.common.theme

import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.font.font
import androidx.compose.ui.text.font.fontFamily
import androidx.compose.ui.unit.sp
import com.abishov.hexocat.android.R

private val RobotoMonoFontFamily = fontFamily(
font(R.font.robotomono_light, FontWeight.Light),
font(R.font.robotomono_medium, FontWeight.Medium),
font(R.font.robotomono_regular, FontWeight.Normal),
private val RobotoMonoFontFamily = FontFamily(
Font(R.font.robotomono_light, FontWeight.Light),
Font(R.font.robotomono_medium, FontWeight.Medium),
Font(R.font.robotomono_regular, FontWeight.Normal),
)

val HexocatTypography = Typography(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import dev.chrisbanes.accompanist.coil.CoilImage

val AvatarCornerSize = 4.dp

@Composable
fun Avatar(url: Uri, modifier: Modifier, cornerRadius: Dp) {
CoilImage(
data = url,
fadeIn = true,
RemoteImage(
url = url,
contentDescription = "",
contentScale = ContentScale.Fit,
modifier = modifier.then(
Modifier.clip(RoundedCornerShape(cornerRadius))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.google.accompanist.flowlayout.FlowRow

private val contributorAvatarSize = 28.dp

Expand All @@ -31,7 +32,7 @@ data class ContributorViewModel(val id: String, val avatarUrl: Uri)
fun Contributor(contributor: ContributorViewModel) {
Avatar(
url = contributor.avatarUrl,
Modifier.preferredSize(contributorAvatarSize),
Modifier.size(contributorAvatarSize),
AvatarCornerSize
)
}
Expand All @@ -46,7 +47,7 @@ fun ContributorOverflow(contributorsOverflow: Int) {
modifier: Modifier,
content: @Composable BoxScope.() -> Unit
) {
val contributorCornerRadius = with(AmbientDensity.current) {
val contributorCornerRadius = with(LocalDensity.current) {
val avatarSizePx = contributorAvatarSize.toPx()
val avatarSize = Size(avatarSizePx, avatarSizePx)
val cornerSize = CornerSize(avatarCornerSize).toPx(avatarSize, this)
Expand All @@ -56,7 +57,7 @@ fun ContributorOverflow(contributorsOverflow: Int) {

Box(
modifier = modifier.then(
Modifier.preferredSize(contributorAvatarSize)
Modifier.size(contributorAvatarSize)
), contentAlignment = Alignment.Center
) {
Canvas(modifier = modifier, onDraw = {
Expand All @@ -73,7 +74,7 @@ fun ContributorOverflow(contributorsOverflow: Int) {
ContributorOutline(
MaterialTheme.colors.onSurface,
AvatarCornerSize,
Modifier.preferredSize(contributorAvatarSize)
Modifier.size(contributorAvatarSize)
) {
val overflow = if (contributorsOverflow > 99)
99 else contributorsOverflow
Expand All @@ -87,7 +88,6 @@ fun ContributorOverflow(contributorsOverflow: Int) {
}

@Composable
@OptIn(ExperimentalLayout::class)
fun Contributors(owner: OwnerViewModel, users: MentionableUsersViewModel, modifier: Modifier) {
val topContributors = users.contributors
val isOwnerTheOnlyContributor = topContributors.size == 1 &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.abishov.hexocat.android.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
Expand Down Expand Up @@ -33,7 +30,7 @@ fun LanguageColor(languageColor: String?, modifier: Modifier = Modifier) {
modifier = modifier.then(
Modifier
.clip(CircleShape)
.preferredSize(10.dp)
.size(10.dp)
.background(color)
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.abishov.hexocat.android.components

import android.net.Uri
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import coil.annotation.ExperimentalCoilApi
import coil.compose.rememberImagePainter

@Composable
@OptIn(ExperimentalCoilApi::class)
fun RemoteImage(
url: Uri,
contentDescription: String,
contentScale: ContentScale,
modifier: Modifier
) {
Image(
painter = rememberImagePainter(data = url,
builder = {
crossfade(true)
}),
contentDescription = contentDescription,
contentScale = contentScale,
modifier = modifier
)
}
Loading

0 comments on commit d23ff96

Please sign in to comment.