update UI

master
Zhengyu Peng 3 years ago
parent 9759a51c41
commit ee5192138e

@ -398,20 +398,6 @@ class BluetoothService(context: Context?, handler: Handler) {
// given BluetoothDevice // given BluetoothDevice
try { try {
tmp = if (secure) { tmp = if (secure) {
// if (ActivityCompat.checkSelfPermission(
// this,
// Manifest.permission.BLUETOOTH_CONNECT
// ) != PackageManager.PERMISSION_GRANTED
// ) {
// // TODO: Consider calling
// // ActivityCompat#requestPermissions
// // here to request the missing permissions, and then overriding
// // public void onRequestPermissionsResult(int requestCode, String[] permissions,
// // int[] grantResults)
// // to handle the case where the user grants the permission. See the documentation
// // for ActivityCompat#requestPermissions for more details.
// return
// }
mmDevice.createRfcommSocketToServiceRecord( mmDevice.createRfcommSocketToServiceRecord(
MY_UUID_SECURE MY_UUID_SECURE
) )

@ -1,131 +1,176 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/grey_200"
tools:context=".MainActivity"> tools:context=".MainActivity">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:gravity="center_horizontal"
android:paddingEnd="16dp" android:orientation="vertical">
android:orientation="vertical"
android:gravity="center_horizontal"> <LinearLayout
<ImageView
android:id="@+id/hexapod_logo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:src="@drawable/hexapod_logo"
app:layout_constraintBottom_toTopOf="@id/tab"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent" android:gravity="center_horizontal"
app:layout_constraintStart_toStartOf="parent" android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/ip_input_layout" android:paddingStart="16dp"
app:layout_constraintTop_toBottomOf="@+id/hexapod_logo"> android:paddingEnd="16dp">
<com.google.android.material.tabs.TabItem
android:id="@+id/wifi_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WiFi" />
<com.google.android.material.tabs.TabItem <ImageView
android:id="@+id/bluetooth_tab" android:id="@+id/hexapod_logo"
android:layout_width="wrap_content" android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:src="@drawable/hexapod_logo"
app:layout_constraintBottom_toTopOf="@id/tab"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Bluetooth" /> app:layout_constraintBottom_toTopOf="@id/ip_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hexapod_logo">
<com.google.android.material.tabs.TabItem
android:id="@+id/wifi_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WiFi" />
</com.google.android.material.tabs.TabLayout> <com.google.android.material.tabs.TabItem
android:id="@+id/bluetooth_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bluetooth" />
<com.google.android.material.textfield.TextInputLayout </com.google.android.material.tabs.TabLayout>
android:id="@+id/ip_input_layout"
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:gravity="center_horizontal"
android:visibility="visible" android:orientation="vertical">
app:errorEnabled="true"
app:layout_constraintBottom_toTopOf="@id/port_input_layout" <com.google.android.material.card.MaterialCardView
app:layout_constraintEnd_toEndOf="parent" android:id="@+id/card"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tab">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ip_input"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:digits="0123456789." android:layout_margin="16dp"
android:hint="IP" app:cardElevation="8dp">
android:inputType="number|numberDecimal"
android:text="192.168.1.127" /> <LinearLayout
</com.google.android.material.textfield.TextInputLayout> android:layout_width="match_parent"
android:layout_height="wrap_content"
<com.google.android.material.textfield.TextInputLayout android:orientation="vertical">
android:id="@+id/port_input_layout"
android:layout_width="match_parent" <com.google.android.material.textfield.TextInputLayout
android:layout_height="wrap_content" android:id="@+id/ip_input_layout"
android:layout_marginBottom="4dp" android:layout_width="match_parent"
android:visibility="visible" android:layout_height="wrap_content"
app:errorEnabled="true" android:layout_marginBottom="4dp"
app:layout_constraintBottom_toTopOf="@id/paired_devices" android:paddingStart="16dp"
app:layout_constraintEnd_toEndOf="parent" android:paddingEnd="16dp"
app:layout_constraintStart_toStartOf="parent" android:paddingTop="16dp"
app:layout_constraintTop_toBottomOf="@id/ip_input_layout"> android:visibility="visible"
app:errorEnabled="true"
<com.google.android.material.textfield.TextInputEditText app:layout_constraintBottom_toTopOf="@id/port_input_layout"
android:id="@+id/port_input" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tab">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ip_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:hint="IP"
android:inputType="number|numberDecimal"
android:text="192.168.1.127" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/port_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_marginBottom="4dp"
android:visibility="visible"
app:errorEnabled="true"
app:layout_constraintBottom_toTopOf="@id/paired_devices"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ip_input_layout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/port_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Port"
android:inputType="number"
android:text="1234" />
</com.google.android.material.textfield.TextInputLayout>
<include
android:id="@+id/selected"
layout="@layout/selected_device"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/button_connect"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/port_input_layout" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<Button
android:id="@+id/button_connect"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Port" android:layout_marginStart="16dp"
android:inputType="number" android:layout_marginEnd="16dp"
android:text="1234" /> android:paddingTop="16dp"
android:paddingBottom="16dp"
</com.google.android.material.textfield.TextInputLayout> android:text="Connect"
app:layout_constraintBottom_toTopOf="@+id/textView_github"
<include app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/selected" app:layout_constraintStart_toStartOf="parent"
android:visibility="visible" app:layout_constraintTop_toBottomOf="@id/selected" />
layout="@layout/selected_device"
app:layout_constraintBottom_toTopOf="@+id/button_connect" <TextView
app:layout_constraintEnd_toEndOf="parent" android:id="@+id/textView_github"
app:layout_constraintStart_toStartOf="parent" android:layout_width="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/port_input_layout" /> android:layout_height="wrap_content"
android:layout_marginTop="32dp"
<Button android:layout_marginBottom="32dp"
android:id="@+id/button_connect" android:text="@string/hexapod_github"
android:layout_width="match_parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="@+id/button_connect" />
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="Connect"
app:layout_constraintBottom_toTopOf="@+id/textView_github"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/selected" />
<TextView
android:id="@+id/textView_github"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:text="@string/hexapod_github"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_connect" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

@ -7,8 +7,8 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:paddingTop="24dp" android:paddingTop="16dp"
android:paddingBottom="24dp"> android:paddingBottom="16dp">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"

Loading…
Cancel
Save