Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kuring-73 멀티 모듈 Feature 에서 화면 Navigate 하는 레퍼런스 추가 #67

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions Common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.ku_stacks.common'
compileSdk 33

defaultConfig {
minSdk 24
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Empty file added Common/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions Common/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ku_stacks.common

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* 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.ku_stacks.common.test", appContext.packageName)
}
}
5 changes: 5 additions & 0 deletions Common/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
7 changes: 7 additions & 0 deletions Common/src/main/java/com/ku_stacks/common/FeatureNavigator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ku_stacks.common

import android.app.Activity

interface FeatureNavigator {
fun navigateToTestFeature(activity: Activity)
}
17 changes: 17 additions & 0 deletions Common/src/test/java/com/ku_stacks/common/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ku_stacks.common

import org.junit.Test

import org.junit.Assert.*

/**
* 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)
}
}
1 change: 1 addition & 0 deletions TestFeature/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions TestFeature/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.ku_stacks.testfeature'
compileSdk 33

defaultConfig {
minSdk 24
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Empty file added TestFeature/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions TestFeature/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ku_stacks.testfeature

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* 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.ku_stacks.testfeature.test", appContext.packageName)
}
}
12 changes: 12 additions & 0 deletions TestFeature/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".TestFeatureActivity"
android:exported="false"
/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ku_stacks.testfeature

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class TestFeatureActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_testfeature)
}

companion object {
fun start(activity: Activity) {
val intent = Intent(activity, TestFeatureActivity::class.java)
activity.startActivity(intent)
}
}
}
19 changes: 19 additions & 0 deletions TestFeature/src/main/res/layout/activity_testfeature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestFeatureActivity"
>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hi"
android:textSize="60dp"
android:gravity="center"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions TestFeature/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<resources></resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ku_stacks.testfeature

import org.junit.Test

import org.junit.Assert.*

/**
* 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)
}
}
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ dependencies {
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-messaging-ktx:21.0.1'
implementation project(path: ':Common')
implementation project(path: ':TestFeature')

// dagger hilt
kapt "androidx.hilt:hilt-compiler:1.0.0"
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/ku_stacks/ku_ring/di/NavigatorModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.ku_stacks.ku_ring.di

import com.ku_stacks.common.FeatureNavigator
import com.ku_stacks.ku_ring.util.FeatureNavigatorImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@InstallIn(SingletonComponent::class)
@Module
abstract class NavigatorModule {

@Binds
abstract fun bindsFeatureNavigator(
impl: FeatureNavigatorImpl
) : FeatureNavigator
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.databinding.DataBindingUtil
import com.ku_stacks.common.FeatureNavigator
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.databinding.ActivityEditSubscriptionBinding
import com.ku_stacks.ku_ring.ui.edit_subscription.compose.Subscriptions
import com.ku_stacks.ku_ring.ui.compose.theme.KuringTheme
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import javax.inject.Inject

@AndroidEntryPoint
class EditSubscriptionActivity : AppCompatActivity() {

private lateinit var binding: ActivityEditSubscriptionBinding
private val viewModel by viewModels<EditSubscriptionViewModel>()

@Inject
lateinit var navigator: FeatureNavigator

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -48,12 +53,15 @@ class EditSubscriptionActivity : AppCompatActivity() {
}
binding.startBt.setOnClickListener {
Timber.d("Init status = ${viewModel.isInitialLoadDone}")
if (viewModel.isInitialLoadDone) {
viewModel.saveSubscribe()
setResult(RESULT_OK)
finish()
overridePendingTransition(R.anim.anim_slide_left_enter, R.anim.anim_slide_left_exit)
}

navigator.navigateToTestFeature(this)

// if (viewModel.isInitialLoadDone) {
// viewModel.saveSubscribe()
// setResult(RESULT_OK)
// finish()
// overridePendingTransition(R.anim.anim_slide_left_enter, R.anim.anim_slide_left_exit)
// }
}
}

Expand Down Expand Up @@ -94,4 +102,4 @@ class EditSubscriptionActivity : AppCompatActivity() {
companion object {
const val FIRST_RUN_FLAG = "firstRunFlag"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ku_stacks.ku_ring.util

import android.app.Activity
import com.ku_stacks.common.FeatureNavigator
import com.ku_stacks.testfeature.TestFeatureActivity
import javax.inject.Inject

class FeatureNavigatorImpl @Inject constructor() : FeatureNavigator {
override fun navigateToTestFeature(activity: Activity) {
TestFeatureActivity.start(activity)
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ buildscript {

task clean(type: Delete) {
delete rootProject.buildDir
}
}
Loading
Loading