-
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.
[Android] virtual-device-app: Add On/Off Switch feature in App (#28550)
* virtual-device-app: Update chip device config Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add java files about chip stack id information Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add initialize api for OnOffManager Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Update parameter types about chip stack id Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add setCallback api Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Use ExampleDACProvider Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add core:ui module Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add MatterModule for provide DeviceApp library Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add OnOffManager stub Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement chip stack initialize code Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add device event callback Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add permissions about stack related Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement service managing code Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add SharedPreferences feature for managing commissioning state Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add OnOffManager repository Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Update matter repository for device event callback Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement sharedpreferences usecase Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement matter usecase Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add ignore batter optimization feature Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add SharedViewModel for managing reset popup Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement main view scenario - go to commissioned device view - reset abnormal state - start commissioning Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement qrcode view scenario - start MatterAppService - monitoring establishment started event Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement loading view scenario - monitoring commissioning complete event Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement base fragment/viewmodel for device detail view - fabric removed event - common reset menu/popup - abstract setup functions Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement common layout - on/off button layout - radio button layout - common space Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Implement onoff switch scenario - set onoff attribute - show onoff status Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Apply feature:control navGraph Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add permissions about stack related Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * Restyled by google-java-format Signed-off-by: Charles Kim <[email protected]> --------- Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> Co-authored-by: Jaehoon You <[email protected]> Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
Showing
94 changed files
with
2,342 additions
and
151 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
examples/virtual-device-app/android/App/app/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
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
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
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
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
25 changes: 25 additions & 0 deletions
25
.../android/App/core/common/src/main/java/com/matter/virtual/device/app/core/common/Event.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,25 @@ | ||
package com.matter.virtual.device.app.core.common | ||
|
||
import androidx.lifecycle.Observer | ||
|
||
open class Event<out T>(private val content: T) { | ||
var hasBeenHandled = false | ||
private set | ||
|
||
fun getContentIfNotHandled(): T? { | ||
return if (hasBeenHandled) { | ||
null | ||
} else { | ||
hasBeenHandled = true | ||
content | ||
} | ||
} | ||
|
||
fun peekContent(): T = content | ||
} | ||
|
||
class EventObserver<T>(private val onEventUnHandledContent: (T) -> Unit) : Observer<Event<T>> { | ||
override fun onChanged(event: Event<T>?) { | ||
event?.getContentIfNotHandled()?.let { value -> onEventUnHandledContent(value) } | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
.../java/com/matter/virtual/device/app/core/common/sharedpreferences/SharedPreferencesKey.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,7 @@ | ||
package com.matter.virtual.device.app.core.common.sharedpreferences | ||
|
||
object SharedPreferencesKey { | ||
const val COMMISSIONING_DEVICE_COMPLETED = "commissioningDeviceCompleted" | ||
const val COMMISSIONED_DEVICE = "commissionedDevice" | ||
const val COMMISSIONING_SEQUENCE = "commissioningSequence" | ||
} |
59 changes: 59 additions & 0 deletions
59
...a/com/matter/virtual/device/app/core/common/sharedpreferences/SharedPreferencesManager.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,59 @@ | ||
package com.matter.virtual.device.app.core.common.sharedpreferences | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
import timber.log.Timber | ||
|
||
@Singleton | ||
class SharedPreferencesManager | ||
@Inject | ||
constructor(@ApplicationContext private val context: Context) { | ||
|
||
private val sharedPreferences: SharedPreferences by lazy { | ||
context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE) | ||
} | ||
|
||
fun getString(key: String): String { | ||
val value = sharedPreferences.getString(key, DEFAULT_VALUE_STRING) | ||
return value ?: "" | ||
} | ||
|
||
fun setString(key: String, value: String) { | ||
val editor = sharedPreferences.edit() | ||
editor.putString(key, value) | ||
editor.apply() | ||
} | ||
|
||
fun getBoolean(key: String): Boolean { | ||
return sharedPreferences.getBoolean(key, DEFAULT_VALUE_BOOLEAN) | ||
} | ||
|
||
fun setBoolean(key: String, value: Boolean) { | ||
val editor = sharedPreferences.edit() | ||
editor.putBoolean(key, value) | ||
editor.apply() | ||
} | ||
|
||
fun deleteMatterSharedPreferences() { | ||
Timber.d("deleteMatterSharedPreferences()") | ||
if (!context.deleteSharedPreferences(PREFERENCES_NAME_MATTER_KEY_VALUE_STORE)) { | ||
Timber.e("delete failure($PREFERENCES_NAME_MATTER_KEY_VALUE_STORE)") | ||
} | ||
|
||
if (!context.deleteSharedPreferences(PREFERENCES_NAME_MATTER_CONFIGURATION_MANAGER)) { | ||
Timber.e("delete failure($PREFERENCES_NAME_MATTER_CONFIGURATION_MANAGER)") | ||
} | ||
} | ||
|
||
companion object { | ||
private const val PREFERENCES_NAME = "virtualdeviceapp" | ||
private const val PREFERENCES_NAME_MATTER_KEY_VALUE_STORE = "chip.platform.KeyValueStore" | ||
private const val PREFERENCES_NAME_MATTER_CONFIGURATION_MANAGER = | ||
"chip.platform.ConfigurationManager" | ||
private const val DEFAULT_VALUE_STRING = "" | ||
private const val DEFAULT_VALUE_BOOLEAN = false | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
examples/virtual-device-app/android/App/core/common/src/main/res/values/dimens.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
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
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
13 changes: 13 additions & 0 deletions
13
...data/src/main/java/com/matter/virtual/device/app/core/data/repository/MatterRepository.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 |
---|---|---|
@@ -1,9 +1,22 @@ | ||
package com.matter.virtual.device.app.core.data.repository | ||
|
||
import com.matter.virtual.device.app.core.common.MatterSettings | ||
import com.matter.virtual.device.app.core.model.Payload | ||
|
||
interface MatterRepository { | ||
fun getQrcodeString(payload: Payload): String | ||
|
||
fun getManualPairingCodeString(payload: Payload): String | ||
|
||
suspend fun startMatterAppService(matterSettings: MatterSettings) | ||
|
||
suspend fun stopMatterAppService() | ||
|
||
fun reset() | ||
|
||
suspend fun isCommissioningCompleted(): Boolean | ||
|
||
suspend fun isCommissioningSessionEstablishmentStarted(): Boolean | ||
|
||
suspend fun isFabricRemoved(): Boolean | ||
} |
Oops, something went wrong.