1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-09 06:38:01 +02:00

Improve discovery activity internationalization

This commit is contained in:
José Rebelo 2022-01-09 13:45:21 +00:00
parent 4bc2032a55
commit 8a54f5dd1c
3 changed files with 12 additions and 10 deletions

View File

@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.adapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -25,6 +26,7 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -65,27 +67,24 @@ public class DeviceCandidateAdapter extends ArrayAdapter<GBDeviceCandidate> {
deviceAddressLabel.setText(device.getMacAddress());
deviceImageView.setImageResource(device.getDeviceType().getIcon());
String status = "";
final List<String> statusLines = new ArrayList<>();
if (device.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {
status += getContext().getString(R.string.device_is_currently_bonded);
statusLines.add(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());
}
}
if (!device.getDeviceType().isSupported()) {
status += " UNSUPPORTED";
statusLines.add(getContext().getString(R.string.device_unsupported));
}
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);
statusLines.add(getContext().getString(R.string.device_requires_key));
}
deviceStatus.setText(status);
deviceStatus.setText(TextUtils.join("\n", statusLines));
return view;
}

View File

@ -29,7 +29,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bluetooth scan:" />
android:text="@string/discovery_bluetooth_scan" />
<ProgressBar
android:id="@+id/discovery_progressbar"
@ -50,7 +50,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bluetooth LE scan:" />
android:text="@string/discovery_bluetooth_le_scan" />
<ProgressBar
android:id="@+id/discovery_ble_progressbar"

View File

@ -379,6 +379,8 @@
<string name="title_activity_discovery">Device discovery</string>
<string name="discovery_stop_scanning">Stop scanning</string>
<string name="discovery_start_scanning">Start discovery</string>
<string name="discovery_bluetooth_scan">Bluetooth scan:</string>
<string name="discovery_bluetooth_le_scan">Bluetooth LE scan:</string>
<string name="action_discover">Connect new device</string>
<string name="device_with_rssi">%1$s (%2$s)</string>
<string name="title_activity_android_pairing">Pair device</string>
@ -1102,6 +1104,7 @@
<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="device_unsupported">UNSUPPORTED</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. Disable this only if your devices actually doesn\'t support any of these features. Not granting a permission might cause issues!</string>