-
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.
* basic code generation template, but not able to import to tool app create new public class under chip/clusterinfo * change package * no error code generation * new design solution * need to wait for cast-helper * callback generation done * on/off commands working * revert .idea changes * one more .idea change revert * remove outline.java * Restyled by whitespace * Restyled by google-java-format * Restyled by gn * Restyled by google-java-format * fix merge * merge conflict * fix comments * Restyled by gn * resolve type, nullable and format comments * resolve build issues * Restyled by gn * update zap generated file * add descriptive documentation on each new class * Restyled by google-java-format * modify description of each new added class * Restyled by google-java-format * add . at the end of class description * Restyled by google-java-format * add recycler view to display endpoint * recycler view for endpoint display and test cluster detail screen done * change number of hard-coded enpoint to 2 * endpoint first draft done * resolve conflict * remove duplicate todo * fix comments * Restyled by whitespace * resolve comments * fix comments Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
Showing
11 changed files
with
195 additions
and
221 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
53 changes: 53 additions & 0 deletions
53
...n/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.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,53 @@ | ||
package com.google.chip.chiptool.clusterclient.clusterinteraction | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.fragment.app.Fragment | ||
import chip.devicecontroller.ChipDeviceController | ||
import com.google.chip.chiptool.ChipClient | ||
import com.google.chip.chiptool.GenericChipDeviceListener | ||
import com.google.chip.chiptool.R | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.Job | ||
import kotlinx.coroutines.cancel | ||
|
||
/** | ||
* ClusterDetailFragment allows user to pick cluster, command, specify parameters and see | ||
* the callback result. | ||
*/ | ||
class ClusterDetailFragment : Fragment(){ | ||
private val deviceController: ChipDeviceController | ||
get() = ChipClient.getDeviceController(requireContext()) | ||
|
||
private val scope = CoroutineScope(Dispatchers.Main + Job()) | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
return inflater.inflate(R.layout.cluster_detail_fragment, container, false).apply { | ||
deviceController.setCompletionListener(GenericChipDeviceListener()) | ||
} | ||
} | ||
|
||
private fun showMessage(msg: String) { | ||
requireActivity().runOnUiThread { | ||
Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
|
||
override fun onStop() { | ||
super.onStop() | ||
scope.cancel() | ||
} | ||
|
||
companion object { | ||
private const val TAG = "ClusterDetailFragment" | ||
fun newInstance(): ClusterDetailFragment = ClusterDetailFragment() | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
...rc/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/EndpointAdapter.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,52 @@ | ||
package com.google.chip.chiptool.clusterclient.clusterinteraction | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.google.chip.chiptool.R | ||
|
||
/** | ||
* EndpointAdapter implements the endpointList(RecycleView) Adapter and associates different | ||
* endpoint with the same onClick function provided in [ClusterInteractionFragment.EndpointListener] | ||
*/ | ||
class EndpointAdapter( | ||
private val endpointList: List<EndpointItem>, | ||
private val listener: OnItemClickListener | ||
) : RecyclerView.Adapter<EndpointAdapter.EndpointViewHolder>() { | ||
|
||
inner class EndpointViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), | ||
View.OnClickListener { | ||
val endpointId: TextView = itemView.findViewById(R.id.endpointTv) | ||
|
||
init { | ||
itemView.setOnClickListener(this) | ||
} | ||
|
||
override fun onClick(endpointItem: View) { | ||
val position = this.adapterPosition | ||
if (position != RecyclerView.NO_POSITION) { | ||
listener.onItemClick(position) | ||
} | ||
} | ||
} | ||
|
||
interface OnItemClickListener { | ||
fun onItemClick(position: Int) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EndpointViewHolder { | ||
val itemView = | ||
LayoutInflater.from(parent.context).inflate(R.layout.endpoint_item, parent, false) | ||
return EndpointViewHolder(itemView) | ||
} | ||
|
||
override fun onBindViewHolder(holder: EndpointViewHolder, position: Int) { | ||
holder.endpointId.text = endpointList[position].endpointId.toString() | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return endpointList.size | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...p/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/endpointItem.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,3 @@ | ||
package com.google.chip.chiptool.clusterclient.clusterinteraction | ||
|
||
data class EndpointItem(val endpointId: Int) |
8 changes: 8 additions & 0 deletions
8
src/android/CHIPTool/app/src/main/res/layout/cluster_detail_fragment.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,8 @@ | ||
<?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"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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
30 changes: 30 additions & 0 deletions
30
src/android/CHIPTool/app/src/main/res/layout/endpoint_item.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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.cardview.widget.CardView 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="wrap_content"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="8dp" | ||
android:layout_margin="4dp"> | ||
|
||
<TextView | ||
android:id="@+id/endpointTv" | ||
android:textStyle="bold" | ||
android:width="100dp" | ||
android:height="70dp" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:textColor="@android:color/black" | ||
android:textSize="18sp" | ||
android:background="@color/cardview_shadow_start_color" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.cardview.widget.CardView> |
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
Oops, something went wrong.