Skip to content

Commit

Permalink
virtual-device-app: Add closure module and base code (#29941)
Browse files Browse the repository at this point in the history
Signed-off-by: Jaehoon You <jaehoon.you@samsung.com>
Signed-off-by: Charles Kim <chulspro.kim@samsung.com>
  • Loading branch information
Jaehoon-You authored Oct 31, 2023
1 parent 7b0b5b7 commit a9769a8
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 0 deletions.
Empty file.
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)
}
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,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)
}
}
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>
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()
}
}
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()
}
}
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>
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>
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include(":core:matter")
include(":core:model")
include(":core:ui")
include(":feature:control")
include(":feature:closure")
include(":feature:main")
include(":feature:qrcode")
include(":feature:setup")

0 comments on commit a9769a8

Please sign in to comment.