forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for account login cluster for content apps. (project-chip…
…#24628) * Add support for account login cluster for content apps. * Use JniUtfString. Co-authored-by: chrisdecenzo <[email protected]>
- Loading branch information
1 parent
7572261
commit 9bf6ffa
Showing
11 changed files
with
473 additions
and
125 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
60 changes: 60 additions & 0 deletions
60
...p/android/App/content-app/src/main/java/com/example/contentapp/CommandResponseHolder.java
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,60 @@ | ||
package com.example.contentapp; | ||
|
||
import android.util.Log; | ||
import com.matter.tv.app.api.Clusters; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** Class to hold attribute values to help test attribute read and subscribe use cases. */ | ||
public class CommandResponseHolder { | ||
private Map<Long, Map<Long, String>> responseValues = new HashMap<>(); | ||
private static final String TAG = "CommandResponseHolder"; | ||
private static final Long DEFAULT_COMMAND = -1L; | ||
|
||
private static CommandResponseHolder instance = new CommandResponseHolder(); | ||
|
||
private CommandResponseHolder() { | ||
// Setting up responses | ||
setResponseValue( | ||
Clusters.ContentLauncher.Id, | ||
DEFAULT_COMMAND, | ||
"{\"0\":0, \"1\":\"custom response from content app for content launcher\"}"); | ||
setResponseValue( | ||
Clusters.TargetNavigator.Id, | ||
DEFAULT_COMMAND, | ||
"{\"0\":0, \"1\":\"custom response from content app for target navigator\"}"); | ||
setResponseValue( | ||
Clusters.MediaPlayback.Id, | ||
DEFAULT_COMMAND, | ||
"{\"0\":0, \"1\":\"custom response from content app for media playback\"}"); | ||
setResponseValue( | ||
Clusters.AccountLogin.Id, | ||
Clusters.AccountLogin.Commands.GetSetupPIN.ID, | ||
"{\"0\":\"12345678\"}"); | ||
}; | ||
|
||
public static CommandResponseHolder getInstance() { | ||
return instance; | ||
} | ||
|
||
public void setResponseValue(long clusterId, long commandId, String value) { | ||
if (value == null) { | ||
Log.d(TAG, "Setting null for cluster " + clusterId + " command " + commandId); | ||
} | ||
Map<Long, String> responses = responseValues.get(clusterId); | ||
if (responses == null) { | ||
responses = new HashMap<>(); | ||
responseValues.put(clusterId, responses); | ||
} | ||
responses.put(commandId, value); | ||
} | ||
|
||
public String getCommandResponse(long clusterId, long commandId) { | ||
Map<Long, String> responses = responseValues.get(clusterId); | ||
String response = responses.get(commandId); | ||
if (response == null) { | ||
response = responses.get(DEFAULT_COMMAND); | ||
} | ||
return response; | ||
} | ||
} |
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
115 changes: 71 additions & 44 deletions
115
examples/tv-app/android/App/content-app/src/main/res/layout/activity_main.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 |
---|---|---|
@@ -1,55 +1,82 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<FrameLayout 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" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:id="@+id/helloTextView" | ||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
android:textSize="10pt" | ||
app:layout_constraintBottom_toTopOf="@+id/commandTextView" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
android:gravity="left" | ||
android:orientation="vertical" | ||
android:padding="10sp"> | ||
|
||
<TextView | ||
android:id="@+id/commandTextView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_toEndOf="@id/helloTextView" | ||
android:textSize="10pt" | ||
android:text="No Command!!" | ||
app:layout_constraintBottom_toTopOf="@+id/sendMessageButton" | ||
app:layout_constraintTop_toBottomOf="@+id/helloTextView" /> | ||
|
||
<Spinner | ||
android:id="@+id/spinnerAttribute" | ||
android:layout_width="239dp" | ||
android:layout_height="40dp" | ||
android:background="@android:drawable/btn_dropdown" | ||
android:spinnerMode="dropdown" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/sendMessageButton" | ||
app:layout_constraintTop_toBottomOf="@+id/commandTextView" /> | ||
|
||
|
||
<Button | ||
android:id="@+id/sendMessageButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_toEndOf="@id/helloTextView" | ||
android:text="Update" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/spinnerAttribute" | ||
app:layout_constraintTop_toBottomOf="@+id/commandTextView" /> | ||
|
||
<androidx.constraintlayout.widget.Group | ||
android:id="@+id/group" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:constraint_referenced_ids="spinnerAttribute,sendMessageButton" /> | ||
<TextView | ||
android:id="@+id/helloTextView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Large" | ||
app:layout_constraintBottom_toTopOf="@+id/commandTextView" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/commandTextView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_toEndOf="@id/helloTextView" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Large" | ||
android:text="No Command!!" | ||
app:layout_constraintBottom_toTopOf="@+id/updateAttributeButton" | ||
app:layout_constraintTop_toBottomOf="@+id/helloTextView" /> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:padding="10sp"> | ||
|
||
<Spinner | ||
android:layout_width="20mm" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/spinnerAttribute" | ||
android:background="@android:drawable/btn_dropdown" | ||
android:spinnerMode="dropdown" /> | ||
|
||
|
||
<Button | ||
android:id="@+id/updateAttributeButton" | ||
android:layout_width="20mm" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="388dp" | ||
android:layout_toEndOf="@id/helloTextView" | ||
android:text="Update Attribute" /> | ||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:padding="10sp"> | ||
|
||
<EditText | ||
android:inputType="number" | ||
android:id="@+id/setupPINText" | ||
android:layout_width="20mm" | ||
android:layout_height="wrap_content" | ||
android:text="20202021" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> | ||
|
||
<Button | ||
android:id="@+id/setupPINButton" | ||
android:layout_width="20mm" | ||
android:layout_height="wrap_content" | ||
android:text="Update PIN" /> | ||
|
||
</LinearLayout> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</LinearLayout> | ||
</FrameLayout> |
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.