Skip to content

Commit c7d0480

Browse files
authored
Merge pull request #13 from mrtry/develop
Ver 1.0.0
2 parents e1e933a + e7b9385 commit c7d0480

File tree

78 files changed

+1567
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1567
-259
lines changed

.github/workflows/deploy_to_deploy_gate.yml

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ jobs:
1919
with:
2020
java-version: 1.8
2121

22+
# google-service.jsonをデコードする
23+
# see:https://qiita.com/sudo5in5k/items/5b6da5dbba3fc2514319
24+
- name: decode google-service
25+
env:
26+
GOOGLE_SERVICE: ${{ secrets.GOOGLE_SERVICE_JSON }}
27+
run: echo $GOOGLE_SERVICE | base64 --decode --ignore-garbage > ./app/google-services.json
28+
2229
- name: Run unit test
2330
run: ./gradlew testDebugUnitTest
2431

.github/workflows/run_test.yml

+5
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ jobs:
1919
with:
2020
java-version: 1.8
2121

22+
- name: decode google-service
23+
env:
24+
GOOGLE_SERVICE: ${{ secrets.GOOGLE_SERVICE_JSON }}
25+
run: echo $GOOGLE_SERVICE | base64 --decode --ignore-garbage > ./app/google-services.json
26+
2227
- name: Run unit test
2328
run: ./gradlew testDebugUnitTest

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ lint/tmp/
8686

8787
# Android Profiling
8888
*.hprof
89+
90+
app/google-services.json
91+
.DS_Store

.idea/codeStyles/Project.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/saveactions_settings.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+72-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
4+
apply plugin: 'com.google.gms.google-services'
5+
apply plugin: 'kotlin-kapt'
46
apply plugin: 'deploygate'
57

68
android {
79
compileSdkVersion 30
810
buildToolsVersion "30.0.0"
911

1012
defaultConfig {
11-
applicationId "io.github.mrtry.todolists"
13+
applicationId "io.github.mrtry.todolist"
1214
minSdkVersion 23
1315
targetSdkVersion 30
1416
versionCode 1
@@ -23,18 +25,82 @@ android {
2325
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2426
}
2527
}
28+
29+
buildFeatures {
30+
dataBinding true
31+
}
32+
33+
viewBinding {
34+
enabled = true
35+
}
36+
37+
packagingOptions {
38+
exclude 'META-INF/AL2.0'
39+
exclude 'META-INF/LGPL2.1'
40+
}
41+
42+
kapt {
43+
javacOptions {
44+
option("-Xmaxerrs", 5000)
45+
}
46+
}
47+
48+
testOptions {
49+
unitTests {
50+
includeAndroidResources = true
51+
}
52+
53+
unitTests.all {
54+
testLogging {
55+
events 'started', 'passed', 'skipped', 'failed'
56+
}
57+
}
58+
}
2659
}
2760

2861
dependencies {
2962
implementation fileTree(dir: "libs", include: ["*.jar"])
3063
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
31-
implementation 'androidx.core:core-ktx:1.3.1'
64+
implementation 'androidx.core:core-ktx:1.3.2'
3265
implementation 'androidx.appcompat:appcompat:1.2.0'
33-
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
66+
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
67+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
68+
implementation 'com.google.android.material:material:1.2.1'
69+
70+
// dagger
71+
def dagger_version = "2.29.1"
72+
implementation "com.google.dagger:dagger:$dagger_version"
73+
kapt "com.google.dagger:dagger-compiler:$dagger_version"
74+
75+
// coroutine
76+
def coroutine_version = "1.3.9"
77+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
78+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutine_version"
79+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutine_version"
80+
81+
// deploy gate
82+
implementation 'com.deploygate:sdk:4.1.0'
83+
84+
// Firebase
85+
implementation 'com.google.firebase:firebase-analytics:17.5.0'
86+
implementation 'com.google.firebase:firebase-auth:19.4.0'
87+
implementation 'com.google.firebase:firebase-firestore:21.7.0'
88+
implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
89+
90+
// test
3491
testImplementation 'junit:junit:4.12'
92+
testImplementation 'org.robolectric:robolectric:4.4'
93+
testImplementation 'androidx.test:core:1.3.0'
94+
testImplementation "androidx.arch.core:core-testing:2.1.0"
95+
testImplementation 'org.mockito:mockito-core:3.3.3'
96+
testImplementation 'org.mockito:mockito-android:3.3.3'
97+
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
98+
testImplementation "com.google.truth:truth:1.0.1"
99+
testImplementation 'androidx.test.ext:junit:1.1.2'
35100
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
36101
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
102+
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
37103

38-
// deploy gate
39-
implementation 'com.deploygate:sdk:4.1.0'
40-
}
104+
// other
105+
implementation 'com.jakewharton.timber:timber:4.7.1'
106+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
package io.github.mrtry.todolists
1+
package io.github.mrtry.todolist
22

3-
import androidx.test.platform.app.InstrumentationRegistry
43
import androidx.test.ext.junit.runners.AndroidJUnit4
5-
4+
import androidx.test.platform.app.InstrumentationRegistry
5+
import org.junit.Assert.assertEquals
66
import org.junit.Test
77
import org.junit.runner.RunWith
88

9-
import org.junit.Assert.*
10-
119
/**
1210
* Instrumented test, which will execute on an Android device.
1311
*
@@ -19,6 +17,6 @@ class ExampleInstrumentedTest {
1917
fun useAppContext() {
2018
// Context of the app under test.
2119
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22-
assertEquals("io.github.mrtry.todolists", appContext.packageName)
20+
assertEquals("io.github.mrtry.todolist", appContext.packageName)
2321
}
2422
}

app/src/main/AndroidManifest.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="io.github.mrtry.todolists">
3+
package="io.github.mrtry.todolist">
44

55
<application
6+
android:name=".MainApplication"
67
android:allowBackup="true"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
9-
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
12+
<activity android:name="io.github.mrtry.todolist.app.splash.ui.SplashActivity">
1313
<intent-filter>
1414
<action android:name="android.intent.action.MAIN" />
1515

1616
<category android:name="android.intent.category.LAUNCHER" />
1717
</intent-filter>
1818
</activity>
19+
20+
<activity android:name=".app.todo.ui.ToDoActivity" />
1921
</application>
2022

2123
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.github.mrtry.todolist
2+
3+
import android.app.Application
4+
import android.content.Context
5+
import io.github.mrtry.todolist.di.component.AppComponent
6+
import io.github.mrtry.todolist.di.component.DaggerAppComponent
7+
import timber.log.Timber
8+
9+
10+
class MainApplication : Application() {
11+
companion object {
12+
fun getComponent(context: Context): AppComponent {
13+
return (context.applicationContext as MainApplication).appComponent
14+
}
15+
}
16+
17+
private val appComponent: AppComponent by lazy {
18+
DaggerAppComponent.builder().build().also {
19+
it.inject(this)
20+
}
21+
}
22+
23+
override fun onCreate() {
24+
super.onCreate()
25+
Timber.plant(Timber.DebugTree())
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.github.mrtry.todolist.app.splash.ui
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import androidx.appcompat.app.AppCompatActivity
6+
import androidx.databinding.DataBindingUtil
7+
import io.github.mrtry.todolist.MainApplication
8+
import io.github.mrtry.todolist.R
9+
import io.github.mrtry.todolist.app.splash.ui.navigator.SplashNavigator
10+
import io.github.mrtry.todolist.app.splash.ui.result.SplashActivityResult
11+
import io.github.mrtry.todolist.app.splash.viewmodel.SplashViewModel
12+
import io.github.mrtry.todolist.databinding.ActivitySplashBinding
13+
import io.github.mrtry.todolist.di.Injectable
14+
import io.github.mrtry.todolist.di.component.LoginComponent
15+
import io.github.mrtry.todolist.di.module.ActivityModule
16+
import io.github.mrtry.todolist.misc.ui.binding.Bindable
17+
import javax.inject.Inject
18+
19+
class SplashActivity : AppCompatActivity(), Injectable<LoginComponent>, Bindable<ActivitySplashBinding> {
20+
21+
@Inject
22+
internal lateinit var viewModel: SplashViewModel
23+
24+
@Inject
25+
internal lateinit var navigator: SplashNavigator
26+
27+
override val viewBinding: ActivitySplashBinding by lazy {
28+
DataBindingUtil.setContentView<ActivitySplashBinding>(this, R.layout.activity_splash)
29+
}
30+
31+
override val component: LoginComponent by lazy {
32+
MainApplication.getComponent(this)
33+
.plusLoginComponent(ActivityModule(this))
34+
}
35+
36+
override fun onCreate(savedInstanceState: Bundle?) {
37+
super.onCreate(savedInstanceState)
38+
component.inject(this)
39+
viewBinding
40+
}
41+
42+
override fun onResume() {
43+
super.onResume()
44+
viewModel.ensuredLoggedIn()
45+
}
46+
47+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
48+
super.onActivityResult(requestCode, resultCode, data)
49+
SplashActivityResult
50+
.valueOf(requestCode)
51+
.getResultHandler(component)
52+
.handleResult(resultCode, data)
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.github.mrtry.todolist.app.splash.ui.navigator
2+
3+
import android.app.Activity
4+
import com.firebase.ui.auth.AuthUI
5+
import io.github.mrtry.todolist.app.splash.ui.result.SplashActivityResult
6+
import io.github.mrtry.todolist.app.todo.ui.ToDoActivity
7+
import io.github.mrtry.todolist.di.scope.ActivityScope
8+
import io.github.mrtry.todolist.misc.ui.navigator.AbsNavigator
9+
import javax.inject.Inject
10+
11+
@ActivityScope
12+
class SplashNavigator
13+
@Inject constructor(
14+
private val activity: Activity
15+
) : AbsNavigator(activity) {
16+
fun navigateToToDo() {
17+
val intent = ToDoActivity.createIntent(activity)
18+
activity.startActivity(intent)
19+
finishCurrentActivity()
20+
}
21+
22+
fun navigateToAuthentication() {
23+
val providers = arrayListOf(
24+
AuthUI.IdpConfig.EmailBuilder().build()
25+
)
26+
27+
val intent = AuthUI.getInstance()
28+
.createSignInIntentBuilder()
29+
.setAvailableProviders(providers)
30+
.build()
31+
32+
activity.startActivityForResult(intent, SplashActivityResult.AUTH.requestCode)
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.github.mrtry.todolist.app.splash.ui.result
2+
3+
import android.app.Activity
4+
import android.content.Intent
5+
import io.github.mrtry.todolist.app.splash.ui.navigator.SplashNavigator
6+
import io.github.mrtry.todolist.di.scope.ActivityScope
7+
import javax.inject.Inject
8+
9+
@ActivityScope
10+
class AuthResultHandler
11+
@Inject constructor(
12+
private val navigator: SplashNavigator
13+
) : SplashResultHandler {
14+
override fun handleResult(resultCode: Int, data: Intent?) {
15+
// Firebase-UIの戻り値
16+
// see: https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md#response-codes
17+
when (resultCode == Activity.RESULT_OK) {
18+
true -> navigator.navigateToToDo()
19+
false -> navigator.finishApplication()
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.github.mrtry.todolist.app.splash.ui.result
2+
3+
import io.github.mrtry.todolist.di.component.LoginComponent
4+
import io.github.mrtry.todolist.misc.ui.result.ActivityResult
5+
6+
enum class SplashActivityResult(
7+
override val requestCode: Int
8+
) : ActivityResult<SplashResultHandler, LoginComponent> {
9+
AUTH(0) {
10+
override fun getResultHandler(component: LoginComponent): SplashResultHandler =
11+
component.authResultHandler
12+
};
13+
14+
companion object {
15+
fun valueOf(requestCode: Int): SplashActivityResult =
16+
values().first { it.requestCode == requestCode }
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.github.mrtry.todolist.app.splash.ui.result
2+
3+
import io.github.mrtry.todolist.misc.ui.result.ResultHandler
4+
5+
interface SplashResultHandler : ResultHandler

0 commit comments

Comments
 (0)