Skip to content

Commit

Permalink
merge with master to get pass the check
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLiuZhuoCheng committed Nov 4, 2021
1 parent 800ae7b commit 651c293
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 195 deletions.
9 changes: 0 additions & 9 deletions src/android/CHIPTool/.idea/misc.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,80 +61,30 @@ class ClusterDetailFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
<<<<<<< HEAD
<<<<<<< HEAD
clusterMap = ClusterInfoMapping().clusterMap
devicePtr = checkNotNull(requireArguments().getLong(DEVICE_PTR_KEY))
endpointId = checkNotNull(requireArguments().getInt(ENDPOINT_ID_KEY))
=======
clusterMap =
checkNotNull(requireArguments().getSerializable(CLUSTER_MAP_INFO)) as HashMap<String, ClusterInfo>
devicePtr = checkNotNull(requireArguments().getLong(DEVICE_PTR))
>>>>>>> 7c783e227 (add back class description)
return inflater.inflate(R.layout.cluster_detail_fragment, container, false).apply {
deviceController.setCompletionListener(GenericChipDeviceListener())
<<<<<<< HEAD
commandAutoCompleteTv.visibility = View.GONE
clusterAutoCompleteSetup(clusterAutoCompleteTv, commandAutoCompleteTv, parameterList)
commandAutoCompleteSetup(commandAutoCompleteTv, inflater, parameterList, callbackList)
=======
commandAutoComplete.visibility = View.GONE
clusterAutoCompleteSetup(clusterAutoComplete, commandAutoComplete, parameterList)
commandAutoCompleteSetup(commandAutoComplete, inflater, parameterList, callbackList)
>>>>>>> d3d83a0bc (select different cluster, command will remove previous displayed parameter)
=======
clusterMap = ClusterInfoMapping().clusterMap
devicePtr = checkNotNull(requireArguments().getLong(DEVICE_PTR_KEY))
endpointId = checkNotNull(requireArguments().getInt(ENDPOINT_ID_KEY))
return inflater.inflate(R.layout.cluster_detail_fragment, container, false).apply {
deviceController.setCompletionListener(GenericChipDeviceListener())
commandAutoCompleteTv.visibility = View.GONE
clusterAutoCompleteSetup(clusterAutoCompleteTv, commandAutoCompleteTv, parameterList)
commandAutoCompleteSetup(commandAutoCompleteTv, inflater, parameterList, callbackList)
>>>>>>> cd1c99028 (resolve comments)
invokeCommand.setOnClickListener {
val commandArguments = HashMap<String, Any>()
parameterList.forEach {
val type =
<<<<<<< HEAD
<<<<<<< HEAD
selectedCommandInfo.commandParameters[it.clusterParameterNameTv.text.toString()]!!.type
val data = castStringToType(it.clusterParameterData.text.toString(), type)!!
=======
selectedCommandInfo.commandParameters[it.parameterName.text.toString()]!!.type!!
val data = castCorrectType(type, it.parameterData.text.toString())!!
commandArguments[it.parameterName.text.toString()] = data
}
>>>>>>> d3d83a0bc (select different cluster, command will remove previous displayed parameter)

<<<<<<< HEAD
commandArguments[it.clusterParameterNameTv.text.toString()] = data
}
=======
>>>>>>> 7c783e227 (add back class description)
=======
selectedCommandInfo.commandParameters[it.clusterParameterNameTv.text.toString()]!!.type
val data = castStringToType(it.clusterParameterData.text.toString(), type)!!

commandArguments[it.clusterParameterNameTv.text.toString()] = data
}
>>>>>>> cd1c99028 (resolve comments)
selectedCommandInfo.getCommandFunction()
.invokeCommand(selectedCluster, selectedCommandCallback, commandArguments)
}
}
}

<<<<<<< HEAD
<<<<<<< HEAD
private fun castStringToType(data: String, type: Class<*>): Any? {
=======
private fun castCorrectType(type: Class<*>, data: String): Any? {

>>>>>>> 7c783e227 (add back class description)
=======
private fun castStringToType(data: String, type: Class<*>): Any? {
>>>>>>> cd1c99028 (resolve comments)
return when (type) {
Int::class.java -> data.toInt()
String::class.java -> data
Expand Down Expand Up @@ -184,22 +134,8 @@ class ClusterDetailFragment : Fragment() {
selectedCommandInfo = selectedClusterInfo.commands[selectedCommand]!!
selectedCommandCallback = selectedCommandInfo.commandCallbackSupplier.get()
populateCommandParameter(inflater, parameterList)
<<<<<<< HEAD
<<<<<<< HEAD
selectedCommandCallback.setCallbackDelegate(object : ClusterCommandCallback {
override fun onSuccess(responseValues: Map<CommandResponseInfo, Any>) {
=======
selectedCommandCallback!!.setCallbackDelegate(object : ClusterCommandCallback {
<<<<<<< HEAD
override fun onSuccess(responseValues: Map<String, Any>) {
>>>>>>> d3d83a0bc (select different cluster, command will remove previous displayed parameter)
=======
override fun onSuccess(responseValues: Map<ResponseValueInfo, Any>) {
>>>>>>> 7a1c5d850 (add responseValueInfo class instead of string split)
=======
selectedCommandCallback.setCallbackDelegate(object : ClusterCommandCallback {
override fun onSuccess(responseValues: Map<CommandResponseInfo, Any>) {
>>>>>>> cd1c99028 (resolve comments)
showMessage("Command success")
// Populate UI based on response values. We know the types from CommandInfo.getCommandResponses().
requireActivity().runOnUiThread {
Expand All @@ -222,103 +158,38 @@ class ClusterDetailFragment : Fragment() {

private fun populateCommandParameter(inflater: LayoutInflater, parameterList: LinearLayout) {
selectedCommandInfo.commandParameters.forEach { (paramName, paramInfo) ->
<<<<<<< HEAD
<<<<<<< HEAD
val param = inflater.inflate(R.layout.cluster_parameter_item, null, false) as ConstraintLayout
param.clusterParameterNameTv.text = "${paramName}"
param.clusterParameterTypeTv.text = "${paramInfo.type}"
=======
val param = inflater.inflate(R.layout.parameter_item, null, false) as ConstraintLayout
param.parameterName.text = "${paramName}"
param.parameterType.text = "${paramInfo.type}"
>>>>>>> 78cf954d9 (fix parameter response ui alignment issue)
=======
val param = inflater.inflate(R.layout.cluster_parameter_item, null, false) as ConstraintLayout
param.clusterParameterNameTv.text = "${paramName}"
param.clusterParameterTypeTv.text = "${paramInfo.type}"
>>>>>>> cd1c99028 (resolve comments)
parameterList.addView(param)
}
}

private fun populateCallbackResult(
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
responseValues: Map<CommandResponseInfo, Any>,
=======
responseValues: Map<String, Any>,
>>>>>>> 7c783e227 (add back class description)
=======
responseValues: Map<ResponseValueInfo, Any>,
>>>>>>> 7a1c5d850 (add responseValueInfo class instead of string split)
=======
responseValues: Map<CommandResponseInfo, Any>,
>>>>>>> cd1c99028 (resolve comments)
inflater: LayoutInflater,
callbackList: LinearLayout
) {
responseValues.forEach { (variableNameType, response) ->
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> cd1c99028 (resolve comments)
val callback =
inflater.inflate(R.layout.cluster_callback_item, null, false) as ConstraintLayout
callback.clusterCallbackNameTv.text = variableNameType.name
callback.clusterCallbackDataTv.text = response.toString()
callback.clusterCallbackTypeTv.text = variableNameType.type
<<<<<<< HEAD
=======
val callback = inflater.inflate(R.layout.callback_item, null, false) as LinearLayout
=======
val callback = inflater.inflate(R.layout.callback_item, null, false) as ConstraintLayout
>>>>>>> 78cf954d9 (fix parameter response ui alignment issue)
callback.callbackName.text = variableNameType.name
callback.callbackData.text = response.toString()
callback.callbackType.text = variableNameType.type
>>>>>>> 7a1c5d850 (add responseValueInfo class instead of string split)
=======
>>>>>>> cd1c99028 (resolve comments)
callbackList.addView(callback)
}
}

<<<<<<< HEAD
<<<<<<< HEAD
private fun getCommandOptions(
=======
private fun getCommand(
>>>>>>> 7c783e227 (add back class description)
=======
private fun getCommandOptions(
>>>>>>> d3d83a0bc (select different cluster, command will remove previous displayed parameter)
clusterName: String
): ArrayAdapter<String> {
selectedClusterInfo = clusterMap[clusterName]!!
val commandNameList = constructHint(selectedClusterInfo.commands)
return ArrayAdapter(requireContext(), android.R.layout.simple_list_item_1, commandNameList)
}

<<<<<<< HEAD
<<<<<<< HEAD
private fun constructHint(clusterMap: Map<String, *>): Array<String> {
return clusterMap.keys.toTypedArray()
<<<<<<< HEAD
=======
private fun constructHint(clusterMap: HashMap<String, *>): Array<String> {
=======
private fun constructHint(clusterMap: Map<String, *>): Array<String> {
>>>>>>> cd1c99028 (resolve comments)
val clusterName = mutableListOf<String>()
for ((name, info) in clusterMap) {
clusterName.add(name)
}
return clusterName.toTypedArray()
>>>>>>> d3d83a0bc (select different cluster, command will remove previous displayed parameter)
=======
>>>>>>> d419b4060 (resolve comments)
}

override fun onStop() {
Expand All @@ -328,49 +199,17 @@ class ClusterDetailFragment : Fragment() {

companion object {
private const val TAG = "ClusterDetailFragment"
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
private const val ENDPOINT_ID_KEY = "endpoint_id"
private const val DEVICE_PTR_KEY = "device_ptr"

fun newInstance(
deviceId: Long,
endpointId: Int
=======
private const val CLUSTER_MAP_INFO = "cluster_map_info"
private const val DEVICE_PTR = "device_ptr"
fun newInstance(
clusterMap: HashMap<String, ClusterInfo>,
deviceId: Long
>>>>>>> 7c783e227 (add back class description)
): ClusterDetailFragment {
return ClusterDetailFragment().apply {
arguments = Bundle(2).apply {
putLong(DEVICE_PTR_KEY, deviceId)
putInt(ENDPOINT_ID_KEY, endpointId)
=======
private const val ENDPOINT_ID = "endpoint_id"
private const val DEVICE_PTR = "device_ptr"
=======
private const val ENDPOINT_ID_KEY = "endpoint_id"
private const val DEVICE_PTR_KEY = "device_ptr"

>>>>>>> d419b4060 (resolve comments)
fun newInstance(
deviceId: Long,
endpointId: Int
): ClusterDetailFragment {
return ClusterDetailFragment().apply {
arguments = Bundle(2).apply {
<<<<<<< HEAD
putLong(DEVICE_PTR, deviceId)
putInt(ENDPOINT_ID, endpointId)
>>>>>>> cd1c99028 (resolve comments)
=======
putLong(DEVICE_PTR_KEY, deviceId)
putInt(ENDPOINT_ID_KEY, endpointId)
>>>>>>> d419b4060 (resolve comments)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import chip.devicecontroller.ChipDeviceController
import chip.devicecontroller.ClusterInfoMapping
import com.google.chip.chiptool.ChipClient
import com.google.chip.chiptool.GenericChipDeviceListener
import com.google.chip.chiptool.R
<<<<<<< HEAD
=======
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
>>>>>>> cd1c99028 (resolve comments)
import com.google.chip.chiptool.clusterclient.AddressUpdateFragment
import kotlinx.android.synthetic.main.cluster_interaction_fragment.view.endpointList
import kotlinx.android.synthetic.main.cluster_interaction_fragment.view.getEndpointListBtn
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

class ClusterInteractionFragment : Fragment() {
Expand Down Expand Up @@ -71,29 +66,9 @@ class ClusterInteractionFragment : Fragment() {
}
}

<<<<<<< HEAD
inner class ChipControllerCallback : GenericChipDeviceListener() {
override fun onConnectDeviceComplete() {}

override fun onCommissioningComplete(nodeId: Long, errorCode: Int) {
}

override fun onNotifyChipConnectionClosed() {
Log.d(TAG, "onNotifyChipConnectionClosed")
}

override fun onCloseBleComplete() {
Log.d(TAG, "onCloseBleComplete")
}

override fun onError(error: Throwable?) {
Log.d(TAG, "onError: $error")
}
=======
override fun onStop() {
super.onStop()
scope.cancel()
>>>>>>> d3d83a0bc (select different cluster, command will remove previous displayed parameter)
}

companion object {
Expand Down

0 comments on commit 651c293

Please sign in to comment.