Skip to content

Commit

Permalink
[Android CHIPTool] Add placeholders for qr code payload elements afte… (
Browse files Browse the repository at this point in the history
#1271)

* [Android CHIPTool] Add placeholders for qr code payload elements after scan

Placeholders for relevant info after qr code parsing
Back button to go back to home scren

* Restyled by google-java-format

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
randyrossi and restyled-commits authored Jun 25, 2020
1 parent 9267c5b commit 9e861ce
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TableLayout;
import android.widget.TextView;
import androidx.annotation.RequiresPermission;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -143,14 +145,50 @@ public static class BarcodeResultsFragment extends Fragment {
// Just a test for now...
String result = CHIPNativeBridge.getInstance().base41Encode();
Log.e(TAG, "Called into native bridge: got " + result);

// Display CHIP qr code info to user for manual connect to soft AP
}

@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.xml.barcode_results_fragment, container, false);
View inflated = inflater.inflate(R.xml.barcode_results_fragment, container, false);

// Display CHIP qr code info to user for manual connect to soft AP
TextView textView;

textView = (TextView) inflated.findViewById(R.id.version);
textView.setText("VERSION"); // TODO

textView = (TextView) inflated.findViewById(R.id.vendorID);
textView.setText("VENDORID"); // TODO

textView = (TextView) inflated.findViewById(R.id.productID);
textView.setText("PRODUCTID"); // TODO

textView = (TextView) inflated.findViewById(R.id.setUpPINCode);
textView.setText("PIN"); // TODO

TableLayout tableLayout = (TableLayout) inflated.findViewById(R.id.qrcode_table);

// TODO : Extract vendor tags for IP and SOFT AP SSID and display them here
int vendorTags[] = {1, 2};
for (int i : vendorTags) {
View row = inflater.inflate(R.xml.barcode_vendor_tag, tableLayout, false);
textView = (TextView) row.findViewById(R.id.label);
textView.setText("Vendor Tag Label");
textView = (TextView) row.findViewById(R.id.value);
textView.setText("Vendor Tag Value");
tableLayout.addView(row);
}

inflated
.findViewById(R.id.back)
.setOnClickListener(
new View.OnClickListener() {
public void onClick(View v) {
activity.finish();
}
});
return inflated;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,99 @@
android:layout_height="match_parent">

<TextView
android:id="@+id/title"
android:text="QR Code Payload Contents"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>

<TextView
android:id="@+id/info_line1"
android:text="Please manually pair with this device's soft AP using the information below."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>

<TextView
android:id="@+id/info_line2"
android:layout_width="wrap_content"
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/qrcode_table"
android:layout_marginLeft="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
android:stretchColumns="1">

<TextView
android:id="@+id/info_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TableRow>
<TextView
android:text="Version:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</TableRow>

<TableRow>
<TextView
android:text="VendorID:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TextView
android:id="@+id/vendorID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</TableRow>


<TableRow>
<TextView
android:text="ProductID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TextView
android:id="@+id/productID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</TableRow>

<TableRow>
<TextView
android:text="PIN:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TextView
android:id="@+id/setUpPINCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</TableRow>

</TableLayout>

<Button
android:id="@+id/back"
android:layout_marginLeft="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Back To Home Screen" />
</LinearLayout>
16 changes: 16 additions & 0 deletions src/android/CHIPTool/app/src/main/res/xml/barcode_vendor_tag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<TableRow xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</TableRow>

0 comments on commit 9e861ce

Please sign in to comment.