Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Update Android example app
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs committed Oct 18, 2019
1 parent 03e8f2e commit 2243a7c
Show file tree
Hide file tree
Showing 28 changed files with 273 additions and 55 deletions.
35 changes: 17 additions & 18 deletions android-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ buildscript {
}

plugins {
id("com.android.application") version "3.5.0"
id("com.android.application") version "3.5.1"
kotlin("android") version "1.3.50"
kotlin("android.extensions") version "1.3.50"
id("com.github.ben-manes.versions") version "0.22.0"
id("com.github.ben-manes.versions") version "0.27.0"
}

android {
Expand All @@ -22,23 +22,23 @@ android {

applicationId = "org.rewedigital.katana.android.example"
versionCode = 1
versionName = "1.8.0"
versionName = "1.8.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}

dependencies {
implementation("org.rewedigital.katana:katana-android:1.8.0")
implementation("org.rewedigital.katana:katana-androidx-viewmodel-savedstate:1.8.0-alpha03")
implementation("org.rewedigital.katana:katana-android:1.8.1")
implementation("org.rewedigital.katana:katana-androidx-viewmodel-savedstate:1.8.1-beta01")
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.3.50")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2")
implementation("org.jetbrains.anko:anko-coroutines:0.10.8")
implementation("com.squareup.retrofit2:retrofit:2.6.1")
implementation("com.squareup.retrofit2:converter-moshi:2.6.1")
implementation("com.squareup.retrofit2:retrofit:2.6.2")
implementation("com.squareup.retrofit2:converter-moshi:2.6.2")
implementation("com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2")
implementation("com.squareup.moshi:moshi:1.8.0")
implementation("com.squareup.moshi:moshi-kotlin:1.8.0") {
Expand All @@ -59,17 +59,16 @@ repositories {
}

tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
resolutionStrategy {
componentSelection {
all {
val rejected = listOf("alpha", "beta", "rc", "cr", "m", "preview", "b", "ea")
.map { qualifier -> Regex("(?i).*[.-]$qualifier[.\\d-+]*") }
.any { it.matches(candidate.version) }
if (rejected) {
reject("Release candidate")
}
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword =
listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}

rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}

160 changes: 160 additions & 0 deletions android-example/etc/launcher_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android-example/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class MainEspressoTest {

// Overwrite modules with mock implementation
Modules.modules = listOf(
testSuccessApiMockModule,
createTestRepositoryModule(repositoryIdlingResource)
TestSuccessApiMockModule,
TestRepositoryModule(repositoryIdlingResource)
)

IdlingRegistry.getInstance().register(repositoryIdlingResource)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("TestFunctionName")

package org.rewedigital.katana.android.example.main

import androidx.test.espresso.idling.CountingIdlingResource
Expand All @@ -6,14 +8,14 @@ import org.rewedigital.katana.android.example.remote.*
import org.rewedigital.katana.dsl.singleton
import org.rewedigital.katana.dsl.get

val testSuccessApiMockModule = Module("testSuccessApiMockModule") {
val TestSuccessApiMockModule = Module("TestSuccessApiMockModule") {

singleton<JsonPlaceholderApi> {
JsonPlaceholderApiSuccessMock()
}
}

val testErrorApiMockModule = Module("testErrorApiMockModule") {
val TestErrorApiMockModule = Module("TestErrorApiMockModule") {

singleton<JsonPlaceholderApi> {
JsonPlaceholderApiErrorMock()
Expand All @@ -23,7 +25,7 @@ val testErrorApiMockModule = Module("testErrorApiMockModule") {
const val TEST_REPO = "TEST_REPO"
const val TEST_IDLING_RESOURCE = "TEST_IDLING_RESOURCE"

fun createTestRepositoryModule(repositoryIdlingResource: CountingIdlingResource) =
fun TestRepositoryModule(repositoryIdlingResource: CountingIdlingResource) =
Module("testRepositoryModule") {

singleton(name = TEST_IDLING_RESOURCE) { repositoryIdlingResource }
Expand Down
12 changes: 7 additions & 5 deletions android-example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".KatanaApp"
android:allowBackup="false"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning,MissingApplicationIcon">
android:name=".KatanaApp"
android:allowBackup="false"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning,MissingApplicationIcon">

<activity android:name=".main.view.MainActivity">

Expand Down
Binary file added android-example/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import org.rewedigital.katana.Component
import org.rewedigital.katana.Katana
import org.rewedigital.katana.android.AndroidKatanaLogger
import org.rewedigital.katana.android.environment.AndroidEnvironmentContext
import org.rewedigital.katana.android.example.inject.androidModule
import org.rewedigital.katana.android.modules.createApplicationModule
import org.rewedigital.katana.android.example.inject.AndroidModule
import org.rewedigital.katana.android.modules.ApplicationModule

class KatanaApp : Application() {

Expand Down Expand Up @@ -37,8 +37,8 @@ class KatanaApp : Application() {
Katana.environmentContext = AndroidEnvironmentContext()

applicationComponent = Component(
createApplicationModule(this),
androidModule
ApplicationModule(this),
AndroidModule
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.rewedigital.katana.Component
import org.rewedigital.katana.KatanaTrait
import org.rewedigital.katana.android.example.R
import org.rewedigital.katana.android.example.fragment.fragmentActivityModule
import org.rewedigital.katana.android.modules.createActivityModule
import org.rewedigital.katana.android.modules.ActivityModule

/**
* @see FirstFragment
Expand All @@ -16,7 +16,7 @@ class FragmentActivity : AppCompatActivity(), KatanaTrait {

override val component: Component = Component(
modules = listOf(
createActivityModule(this),
ActivityModule(this),
fragmentActivityModule
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.rewedigital.katana.dsl.get
*
* @see org.rewedigital.katana.android.modules.createApplicationModule
*/
val androidModule = Module {
val AndroidModule = Module {

factory { get<Context>(APPLICATION_CONTEXT).resources }
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("FunctionName")

package org.rewedigital.katana.android.example.main

import android.content.Context
Expand All @@ -16,8 +18,8 @@ import org.rewedigital.katana.android.example.main.view.MainActivity
import org.rewedigital.katana.android.example.main.view.MainView
import org.rewedigital.katana.android.modules.ACTIVITY
import org.rewedigital.katana.android.modules.ACTIVITY_CONTEXT
import org.rewedigital.katana.dsl.singleton
import org.rewedigital.katana.dsl.get
import org.rewedigital.katana.dsl.singleton

/**
* This module demonstrates how the current [Context] can be injected safely.
Expand All @@ -28,7 +30,7 @@ import org.rewedigital.katana.dsl.get
* @see MainActivity
* @see ButtonMapper
*/
fun createMainModule(activity: MainActivity) = Module {
fun MainModule(activity: MainActivity) = Module {

singleton<ButtonMapper> { ButtonMapperImpl(get(ACTIVITY_CONTEXT)) }

Expand Down
Loading

0 comments on commit 2243a7c

Please sign in to comment.