mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Made scan results a bit more detailed by displaying special cases
This commit is contained in:
parent
637a7d5d07
commit
2ba6b88ff9
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.adapter;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -26,9 +27,12 @@ import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
/**
|
||||
@ -47,22 +51,37 @@ public class DeviceCandidateAdapter extends ArrayAdapter<GBDeviceCandidate> {
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
GBDeviceCandidate device = getItem(position);
|
||||
|
||||
if (view == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.item_with_details, parent, false);
|
||||
}
|
||||
ImageView deviceImageView = (ImageView) view.findViewById(R.id.item_image);
|
||||
TextView deviceNameLabel = (TextView) view.findViewById(R.id.item_name);
|
||||
TextView deviceAddressLabel = (TextView) view.findViewById(R.id.item_details);
|
||||
ImageView deviceImageView = view.findViewById(R.id.item_image);
|
||||
TextView deviceNameLabel = view.findViewById(R.id.item_name);
|
||||
TextView deviceAddressLabel = view.findViewById(R.id.item_details);
|
||||
TextView deviceStatus = view.findViewById(R.id.item_status);
|
||||
|
||||
String name = formatDeviceCandidate(device);
|
||||
deviceNameLabel.setText(name);
|
||||
deviceAddressLabel.setText(device.getMacAddress());
|
||||
deviceImageView.setImageResource(device.getDeviceType().getIcon());
|
||||
|
||||
String status = "";
|
||||
if (device.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {
|
||||
status += getContext().getString(R.string.device_is_currently_bonded);
|
||||
if (!GBApplication.getPrefs().getBoolean("ignore_bonded_devices", true)) { // This could be passed to the constructor instead
|
||||
deviceImageView.setImageResource(device.getDeviceType().getDisabledIcon());
|
||||
}
|
||||
}
|
||||
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
||||
if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_REQUIRE_KEY) {
|
||||
if (device.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {
|
||||
status += "\n";
|
||||
}
|
||||
status += getContext().getString(R.string.device_requires_key);
|
||||
}
|
||||
|
||||
deviceStatus.setText(status);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -25,17 +25,32 @@
|
||||
android:id="@+id/item_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:scrollHorizontally="false"
|
||||
style="@style/Base.TextAppearance.AppCompat.SearchResult.Title"
|
||||
android:text="Item Name"
|
||||
android:maxLines="1" />
|
||||
android:text="Item Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_details"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Base.TextAppearance.AppCompat.SearchResult"
|
||||
android:text="Item Description" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_details"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:text="Item Description" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="end"
|
||||
android:text=""
|
||||
android:textColor="@color/design_default_color_error" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -888,6 +888,8 @@
|
||||
<string name="error_version_check_extreme_caution">CAUTION: Error when checking version information! You should not continue! Saw version name \"%s\"</string>
|
||||
<string name="error_background_service">Failed to start background service</string>
|
||||
<string name="error_background_service_reason_truncated">Starting the background service failed because…</string>
|
||||
<string name="device_is_currently_bonded">ALREADY BONDED</string>
|
||||
<string name="device_requires_key">KEY REQUIRED</string>
|
||||
<string name="error_background_service_reason">Starting the background service failed because of an exception. Error: </string>
|
||||
<string name="pref_check_permission_status">Check permission status</string>
|
||||
<string name="pref_check_permission_status_summary">Check and ask for missing permissions even when they might not be instantly needed. Enable this only if your devices actually doesn\'t support any of these features. Not granting a permission might cause issues!</string>
|
||||
|
Loading…
Reference in New Issue
Block a user