Skip to content

Commit

Permalink
add info textview
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianWessel committed Oct 12, 2021
1 parent b92391d commit e82c61d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
23 changes: 22 additions & 1 deletion org.envirocar.app/res/layout/activity_obd_selection_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
android:text="@string/obd_selection_paired_devices"
android:textColor="@color/blue_dark_cario"
android:textSize="14sp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="16dp" />

Expand All @@ -55,6 +54,17 @@
app:layout_constraintTop_toBottomOf="@+id/activity_obd_selection_layout_paired_devices_text"
tools:layout_editor_absoluteX="16dp" />

<TextView
android:id="@+id/activity_obd_selection_layout_paired_devices_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="@string/obd_selection_no_paired_devices"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintTop_toBottomOf="@+id/activity_obd_selection_layout_paired_devices_text"
tools:layout_editor_absoluteX="26dp" />

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
Expand Down Expand Up @@ -102,6 +112,17 @@
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
tools:layout_editor_absoluteX="16dp" />

<TextView
android:id="@+id/activity_obd_selection_layout_available_devices_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="@string/obd_selection_no_available_devices"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
tools:layout_editor_absoluteX="26dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
Expand Down
9 changes: 6 additions & 3 deletions org.envirocar.app/res/values-de/strings_obd_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
<string name="obd_selection_discovery_started">Suche gestartet!</string>
<string name="obd_selection_is_selected_template">%s ausgewählt.</string>

<string name="obd_selection_paired_devices">Gepaarte Geräte</string>
<string name="obd_selection_no_paired_devices">Keine gekoppelten Bluetooth-Geräte.</string>
<string name="obd_selection_no_available_devices">Keine Bluetooth-Geräte gefunden.</string>

<string name="obd_selection_paired_devices">Gekoppelte Geräte</string>
<string name="obd_selection_avaiable_devices">Verfügbare Geräte</string>

<string name="obd_selection_dialog_pairing_title">Mit Gerät koppeln</string>
<string name="obd_selection_dialog_pairing_title">Gerät koppeln</string>
<string name="obd_selection_dialog_pairing_content_template">Möchten Sie ihr Gerät mit %s koppeln?</string>
<string name="obd_selection_dialog_delete_pairing_title">Paarung löschen?</string>
<string name="obd_selection_dialog_delete_pairing_title">Gerät entkoppeln?</string>
<string name="obd_selection_dialog_delete_pairing_content_template">Möchten Sie die Kopplung mit \"%s\" löschen?</string>

<string name="obd_selection_device_unpaired_template">%s wurde entkoppelt.</string>
Expand Down
7 changes: 5 additions & 2 deletions org.envirocar.app/res/values/strings_obd_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
<string name="obd_selection_discovery_started">Bluetooth discovery started.</string>
<string name="obd_selection_is_selected_template">%s selected.</string>

<string name="obd_selection_no_paired_devices">No paired Bluetooth devices</string>
<string name="obd_selection_no_available_devices">No Bluetooth devices found</string>

<string name="obd_selection_paired_devices">Paired Devices</string>
<string name="obd_selection_avaiable_devices">Available</string>
<string name="obd_selection_avaiable_devices">Available Devices</string>

<string name="obd_selection_dialog_pairing_title">Pair Device</string>
<string name="obd_selection_dialog_pairing_content_template">Do you want to pair with %s?</string>
<string name="obd_selection_dialog_delete_pairing_title">Delete Pairing?</string>
<string name="obd_selection_dialog_delete_pairing_title">Unpair device?</string>
<string name="obd_selection_dialog_delete_pairing_content_template">Do you want to remove the pairing with "%s"?</string>

<string name="obd_selection_device_unpaired_template">%s has been unpaired.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ public interface ShowSnackbarListener {
@BindView(R.id.activity_obd_selection_layout_rescan_bluetooth)
protected ImageView mRescanImageView;

// @BindView(R.id.activity_obd_selection_layout_available_devices_info)
// protected TextView mNewDevicesInfoTextView;
@BindView(R.id.activity_obd_selection_layout_paired_devices_info)
protected TextView mPairedDevicesInfoTextView;
@BindView(R.id.activity_obd_selection_layout_available_devices_info)
protected TextView mNewDevicesInfoTextView;

// ArrayAdapter for the two different list views.
private OBDDeviceListAdapter mNewDevicesArrayAdapter;
Expand Down Expand Up @@ -345,6 +347,9 @@ public void onComplete() {
mProgressBar.setVisibility(View.GONE);
mRescanImageView.setVisibility(View.VISIBLE);
showSnackbar("Discovery Finished!");
if(mNewDevicesArrayAdapter.isEmpty()){
mNewDevicesInfoTextView.setVisibility(View.VISIBLE);
}

}

Expand All @@ -363,6 +368,7 @@ public void onNext(BluetoothDevice device) {
// add it to the list and add an entry to the array adapter.
if (!mPairedDevicesAdapter.contains(device) &&
!mNewDevicesArrayAdapter.contains(device)) {
mNewDevicesInfoTextView.setVisibility(View.GONE);
mNewDevicesArrayAdapter.add(device);
}
}
Expand Down Expand Up @@ -446,7 +452,8 @@ public void onDeviceUnpaired(BluetoothDevice device) {
device.getName() + " (" + device.getAddress() + ")"));
mPairedDevicesAdapter.remove(device);
if (mPairedDevicesAdapter.getCount() == 0 ){
mPairedDevicesTextView.setVisibility(View.GONE);
mPairedDevicesInfoTextView.setVisibility(View.VISIBLE);
//mPairedDevicesTextView.setVisibility(View.GONE);
}
updatePairedDevicesList();
}
Expand Down Expand Up @@ -474,7 +481,8 @@ private void updatePairedDevicesList() {

// Make the paired devices textview visible if there are paired devices
if (!pairedDevices.isEmpty()) {
mPairedDevicesTextView.setVisibility(View.VISIBLE);
mPairedDevicesInfoTextView.setVisibility(View.GONE);
//mPairedDevicesTextView.setVisibility(View.VISIBLE);
}
}

Expand Down Expand Up @@ -519,7 +527,8 @@ public void onDevicePaired(BluetoothDevice device) {
device.getName()));
mNewDevicesArrayAdapter.remove(device);
mPairedDevicesAdapter.add(device);
mPairedDevicesTextView.setVisibility(View.VISIBLE);
mPairedDevicesInfoTextView.setVisibility(View.GONE);
//mPairedDevicesTextView.setVisibility(View.VISIBLE);

// Post an event to all registered handlers.
mBus.post(new BluetoothPairingChangedEvent(device, true));
Expand Down

0 comments on commit e82c61d

Please sign in to comment.