From ea0817f7b68c009f791ad87e37cf71866985b0ee Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 16 Dec 2023 19:37:40 +0100 Subject: [PATCH] Use TextUtils.join intead of String.join, to make at least the linter happy It is not clear to me if this would get desugarized anyway, but linter says needs API 26 --- .../activities/AbstractPreferenceFragment.java | 3 ++- .../loyaltycards/LoyaltyCardsSettingsFragment.java | 3 ++- .../activities/widgets/WidgetScreenListAdapter.java | 3 ++- .../gadgetbridge/service/AbstractDeviceSupport.java | 3 ++- .../huami/zeppos/services/ZeppOsAlexaService.java | 3 ++- .../huami/zeppos/services/ZeppOsConfigService.java | 9 +++++---- .../zeppos/services/ZeppOsShortcutCardsService.java | 6 ++++-- .../huami/zeppos/services/ZeppOsWatchfaceService.java | 3 ++- .../conversation/WorkoutScreenListHandler.java | 3 ++- .../devices/xiaomi/services/XiaomiSystemService.java | 4 +++- 10 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractPreferenceFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractPreferenceFragment.java index 5c4c15e6d..01e34b6b5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractPreferenceFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractPreferenceFragment.java @@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities; import android.content.SharedPreferences; import android.os.Bundle; +import android.text.TextUtils; import androidx.fragment.app.DialogFragment; import androidx.preference.EditTextPreference; @@ -219,7 +220,7 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragmentCompa translatedEntries.add(entries[i].toString()); } } - summary = String.join(", ", translatedEntries); + summary = TextUtils.join(", ", translatedEntries); } } else { summary = prefs.getString(key, preference.getSummary() != null ? preference.getSummary().toString() : ""); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/loyaltycards/LoyaltyCardsSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/loyaltycards/LoyaltyCardsSettingsFragment.java index a0f7d6e10..dcc8a7dca 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/loyaltycards/LoyaltyCardsSettingsFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/loyaltycards/LoyaltyCardsSettingsFragment.java @@ -33,6 +33,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; +import android.text.TextUtils; import android.widget.Toast; import androidx.core.app.ActivityCompat; @@ -230,7 +231,7 @@ public class LoyaltyCardsSettingsFragment extends AbstractPreferenceFragment { } } values.removeAll(toRemove); - syncGroups.setSummary(String.join(", ", values)); + syncGroups.setSummary(TextUtils.join(", ", values)); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/widgets/WidgetScreenListAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/widgets/WidgetScreenListAdapter.java index 18403ec8c..d2278dfe1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/widgets/WidgetScreenListAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/widgets/WidgetScreenListAdapter.java @@ -17,6 +17,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities.widgets; import android.content.Context; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -94,7 +95,7 @@ public class WidgetScreenListAdapter extends RecyclerView.Adapter singletonMap(final String key, final Object value) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsShortcutCardsService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsShortcutCardsService.java index b963ae783..920ea6542 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsShortcutCardsService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsShortcutCardsService.java @@ -18,6 +18,8 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.servic import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.SHORTCUT_CARDS_SORTABLE; +import android.text.TextUtils; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -218,8 +220,8 @@ public class ZeppOsShortcutCardsService extends AbstractZeppOsService { } final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences() - .withPreference(SHORTCUT_CARDS_SORTABLE, String.join(",", enabledCards)) - .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(SHORTCUT_CARDS_SORTABLE), String.join(",", allCards)); + .withPreference(SHORTCUT_CARDS_SORTABLE, TextUtils.join(",", enabledCards)) + .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(SHORTCUT_CARDS_SORTABLE), TextUtils.join(",", allCards)); getSupport().evaluateGBDeviceEvent(evt); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java index d7a7c79ed..73a126e09 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java @@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.servic import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE; import android.content.Context; +import android.text.TextUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -229,7 +230,7 @@ public class ZeppOsWatchfaceService extends AbstractZeppOsService { // TODO broadcast something to update app manager final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences() - .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(PREF_WATCHFACE), String.join(",", watchfacePrefValues)); + .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(PREF_WATCHFACE), TextUtils.join(",", watchfacePrefValues)); getSupport().evaluateGBDeviceEvent(evt); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/conversation/WorkoutScreenListHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/conversation/WorkoutScreenListHandler.java index fad7ad734..76372895c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/conversation/WorkoutScreenListHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/conversation/WorkoutScreenListHandler.java @@ -17,6 +17,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.withingssteelhr.communication.conversation; import android.content.SharedPreferences; +import android.text.TextUtils; import java.util.ArrayList; import java.util.List; @@ -56,7 +57,7 @@ public class WorkoutScreenListHandler extends AbstractResponseHandler { } } - String workoutActivityTypes = String.join(",", prefValues); + String workoutActivityTypes = TextUtils.join(",", prefValues); GBDevice device = support.getDevice(); final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()); prefs.edit().putString("workout_activity_types_sortable", workoutActivityTypes).apply(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java index 558bf9e22..5b3b153b4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java @@ -16,6 +16,8 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.services; +import android.text.TextUtils; + import com.google.protobuf.InvalidProtocolBufferException; import org.slf4j.Logger; @@ -625,7 +627,7 @@ public class XiaomiSystemService extends AbstractXiaomiService implements Xiaomi } final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences() - .withPreference(XiaomiPreferences.PREF_WORKOUT_TYPES, String.join(",", codes)); + .withPreference(XiaomiPreferences.PREF_WORKOUT_TYPES, TextUtils.join(",", codes)); getSupport().evaluateGBDeviceEvent(eventUpdatePreferences); }