-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
virtual-device-app: Add closure module and base code (#29941)
Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]>
- Loading branch information
1 parent
2a7d893
commit 497dfb3
Showing
11 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
70 changes: 70 additions & 0 deletions
70
examples/virtual-device-app/android/App/feature/closure/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import com.matter.buildsrc.Deps | ||
import com.matter.buildsrc.Versions | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
id("com.google.dagger.hilt.android") | ||
id("androidx.navigation.safeargs.kotlin") | ||
kotlin("kapt") | ||
} | ||
|
||
android { | ||
namespace = "com.matter.virtual.device.app.feature.closure" | ||
compileSdk = Versions.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdk = Versions.minSdkVersion | ||
targetSdk = Versions.targetSdkVersion | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = 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" | ||
} | ||
buildFeatures { | ||
viewBinding = true | ||
dataBinding = true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(project(":core:common")) | ||
implementation(project(":core:domain")) | ||
implementation(project(":core:ui")) | ||
|
||
implementation(Deps.AndroidX.core) | ||
implementation(Deps.AndroidX.appcompat) | ||
implementation(Deps.AndroidX.fragment) | ||
implementation(Deps.AndroidX.Lifecycle.viewmodel) | ||
|
||
implementation(Deps.Kotlin.serialization) | ||
|
||
implementation(Deps.Navigation.fragment) | ||
implementation(Deps.Navigation.ui) | ||
|
||
implementation(Deps.Dagger.hiltAndroid) | ||
kapt(Deps.Dagger.hiltAndroidCompiler) | ||
|
||
implementation(Deps.timber) | ||
|
||
testImplementation(Deps.Test.junit) | ||
androidTestImplementation(Deps.Test.junitExt) | ||
androidTestImplementation(Deps.Test.espresso) | ||
} |
21 changes: 21 additions & 0 deletions
21
examples/virtual-device-app/android/App/feature/closure/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
...androidTest/java/com/matter/virtual/device/app/feature/closure/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.matter.virtual.device.app.feature.closure | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* 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.matter.virtual.device.app.feature.closure.test", appContext.packageName) | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/virtual-device-app/android/App/feature/closure/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
41 changes: 41 additions & 0 deletions
41
...e/closure/src/main/java/com/matter/virtual/device/app/feature/closure/DoorLockFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.matter.virtual.device.app.feature.closure | ||
|
||
import androidx.fragment.app.viewModels | ||
import androidx.navigation.fragment.navArgs | ||
import com.matter.virtual.device.app.core.ui.BaseFragment | ||
import com.matter.virtual.device.app.core.ui.databinding.LayoutAppbarBinding | ||
import com.matter.virtual.device.app.feature.closure.databinding.FragmentDoorLockBinding | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.json.Json | ||
import timber.log.Timber | ||
|
||
@AndroidEntryPoint | ||
class DoorLockFragment : | ||
BaseFragment<FragmentDoorLockBinding, DoorLockViewModel>(R.layout.fragment_door_lock) { | ||
|
||
override val viewModel: DoorLockViewModel by viewModels() | ||
|
||
@OptIn(ExperimentalSerializationApi::class) | ||
override fun setupNavArgs() { | ||
val args: DoorLockFragmentArgs by navArgs() | ||
matterSettings = Json.decodeFromString(args.setting) | ||
} | ||
|
||
override fun setupAppbar(): LayoutAppbarBinding = binding.appbar | ||
|
||
override fun setupUi() {} | ||
|
||
override fun setupObservers() {} | ||
|
||
override fun onResume() { | ||
Timber.d("onResume()") | ||
super.onResume() | ||
} | ||
|
||
override fun onDestroy() { | ||
Timber.d("onDestroy()") | ||
super.onDestroy() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../closure/src/main/java/com/matter/virtual/device/app/feature/closure/DoorLockViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.matter.virtual.device.app.feature.closure | ||
|
||
import androidx.lifecycle.SavedStateHandle | ||
import com.matter.virtual.device.app.core.ui.BaseViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import javax.inject.Inject | ||
import timber.log.Timber | ||
|
||
@HiltViewModel | ||
class DoorLockViewModel @Inject constructor(savedStateHandle: SavedStateHandle) : | ||
BaseViewModel(savedStateHandle) { | ||
|
||
override fun onCleared() { | ||
Timber.d("onCleared()") | ||
super.onCleared() | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...virtual-device-app/android/App/feature/closure/src/main/res/layout/fragment_door_lock.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<!-- appbar --> | ||
<include | ||
android:id="@+id/appbar" | ||
layout="@layout/layout_appbar" /> | ||
<!-- appbar --> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginTop="?attr/actionBarSize"> | ||
|
||
</ScrollView> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
16 changes: 16 additions & 0 deletions
16
...tual-device-app/android/App/feature/closure/src/main/res/navigation/closure_nav_graph.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<navigation 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:id="@+id/closure_nav_graph"> | ||
<fragment | ||
android:id="@+id/doorLockFragment" | ||
android:name="com.matter.virtual.device.app.feature.closure.DoorLockFragment" | ||
android:label="DoorLockFragment" | ||
tools:layout="@layout/fragment_door_lock"> | ||
<argument | ||
android:name="setting" | ||
app:argType="string" /> | ||
<deepLink app:uri="android-app://com.matter.virtual.device.app.feature.closure/doorLockFragment/{setting}" /> | ||
</fragment> | ||
</navigation> |
16 changes: 16 additions & 0 deletions
16
...re/closure/src/test/java/com/matter/virtual/device/app/feature/closure/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.matter.virtual.device.app.feature.closure | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
/** | ||
* 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters