1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 05:16:51 +01:00

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
This commit is contained in:
Andreas Shimokawa 2023-12-16 19:37:40 +01:00
parent c58d45423e
commit ea0817f7b6
10 changed files with 26 additions and 14 deletions

View File

@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
@ -219,7 +220,7 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragmentCompa
translatedEntries.add(entries[i].toString()); translatedEntries.add(entries[i].toString());
} }
} }
summary = String.join(", ", translatedEntries); summary = TextUtils.join(", ", translatedEntries);
} }
} else { } else {
summary = prefs.getString(key, preference.getSummary() != null ? preference.getSummary().toString() : ""); summary = prefs.getString(key, preference.getSummary() != null ? preference.getSummary().toString() : "");

View File

@ -33,6 +33,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast; import android.widget.Toast;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
@ -230,7 +231,7 @@ public class LoyaltyCardsSettingsFragment extends AbstractPreferenceFragment {
} }
} }
values.removeAll(toRemove); values.removeAll(toRemove);
syncGroups.setSummary(String.join(", ", values)); syncGroups.setSummary(TextUtils.join(", ", values));
} }
} }

View File

@ -17,6 +17,7 @@
package nodomain.freeyourgadget.gadgetbridge.activities.widgets; package nodomain.freeyourgadget.gadgetbridge.activities.widgets;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -94,7 +95,7 @@ public class WidgetScreenListAdapter extends RecyclerView.Adapter<WidgetScreenLi
} }
if (!widgetNames.isEmpty()) { if (!widgetNames.isEmpty()) {
holder.widgetScreenDescription.setText(String.join(", ", widgetNames)); holder.widgetScreenDescription.setText(TextUtils.join(", ", widgetNames));
} else { } else {
holder.widgetScreenDescription.setText(R.string.unknown); holder.widgetScreenDescription.setText(R.string.unknown);
} }

View File

@ -32,6 +32,7 @@ import android.location.Location;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.telephony.SmsManager; import android.telephony.SmsManager;
import android.text.TextUtils;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
@ -553,7 +554,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
return; return;
} }
LOG.debug("Handing device actions: {}", String.join(",", actions)); LOG.debug("Handing device actions: {}", TextUtils.join(",", actions));
final String actionBroadcast = getContext().getString(R.string.pref_device_action_broadcast_value); final String actionBroadcast = getContext().getString(R.string.pref_device_action_broadcast_value);
final String actionFitnessControlStart = getContext().getString(R.string.pref_device_action_fitness_app_control_start_value); final String actionFitnessControlStart = getContext().getString(R.string.pref_device_action_fitness_app_control_start_value);

View File

@ -20,6 +20,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils;
import android.widget.Toast; import android.widget.Toast;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -386,7 +387,7 @@ public class ZeppOsAlexaService extends AbstractZeppOsService {
final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences() final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences()
.withPreference(PREF_VOICE_SERVICE_LANGUAGE, currentLanguage.replace("-", "_")) .withPreference(PREF_VOICE_SERVICE_LANGUAGE, currentLanguage.replace("-", "_"))
.withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(PREF_VOICE_SERVICE_LANGUAGE), String.join(",", allLanguages).replace("-", "_")); .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(PREF_VOICE_SERVICE_LANGUAGE), TextUtils.join(",", allLanguages).replace("-", "_"));
getSupport().evaluateGBDeviceEvent(evt); getSupport().evaluateGBDeviceEvent(evt);
} }

View File

@ -25,6 +25,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PR
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_END; import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_END;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_START; import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_START;
import android.text.TextUtils;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -1149,7 +1150,7 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
if (includesConstraints) { if (includesConstraints) {
prefs.put( prefs.put(
DeviceSettingsUtils.getPrefPossibleValuesKey(configArg.getPrefKey()), DeviceSettingsUtils.getPrefPossibleValuesKey(configArg.getPrefKey()),
String.join(",", decodeByteValues(possibleValues, decoder)) TextUtils.join(",", decodeByteValues(possibleValues, decoder))
); );
} }
} }
@ -1184,7 +1185,7 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
possibleLanguages.add(languageByteToLocale(possibleValue)); possibleLanguages.add(languageByteToLocale(possibleValue));
} }
possibleLanguages.removeAll(Collections.singleton(null)); possibleLanguages.removeAll(Collections.singleton(null));
prefs.put(DeviceSettingsUtils.getPrefPossibleValuesKey(configArg.getPrefKey()), String.join(",", possibleLanguages)); prefs.put(DeviceSettingsUtils.getPrefPossibleValuesKey(configArg.getPrefKey()), TextUtils.join(",", possibleLanguages));
} }
} }
decoder = null; decoder = null;
@ -1241,7 +1242,7 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
if (includesConstraints) { if (includesConstraints) {
prefs.put( prefs.put(
DeviceSettingsUtils.getPrefPossibleValuesKey(configArg.getPrefKey()), DeviceSettingsUtils.getPrefPossibleValuesKey(configArg.getPrefKey()),
String.join(",", decodeByteValues(possibleValues, decoder)) TextUtils.join(",", decodeByteValues(possibleValues, decoder))
); );
} }
} }
@ -1276,7 +1277,7 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
if (decoded.isEmpty()) { if (decoded.isEmpty()) {
return null; return null;
} }
return String.join(",", decoded); return TextUtils.join(",", decoded);
} }
private Map<String, Object> singletonMap(final String key, final Object value) { private Map<String, Object> singletonMap(final String key, final Object value) {

View File

@ -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 static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.SHORTCUT_CARDS_SORTABLE;
import android.text.TextUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -218,8 +220,8 @@ public class ZeppOsShortcutCardsService extends AbstractZeppOsService {
} }
final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences() final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences()
.withPreference(SHORTCUT_CARDS_SORTABLE, String.join(",", enabledCards)) .withPreference(SHORTCUT_CARDS_SORTABLE, TextUtils.join(",", enabledCards))
.withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(SHORTCUT_CARDS_SORTABLE), String.join(",", allCards)); .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(SHORTCUT_CARDS_SORTABLE), TextUtils.join(",", allCards));
getSupport().evaluateGBDeviceEvent(evt); getSupport().evaluateGBDeviceEvent(evt);
} }

View File

@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.servic
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -229,7 +230,7 @@ public class ZeppOsWatchfaceService extends AbstractZeppOsService {
// TODO broadcast something to update app manager // TODO broadcast something to update app manager
final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences() final GBDeviceEventUpdatePreferences evt = new GBDeviceEventUpdatePreferences()
.withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(PREF_WATCHFACE), String.join(",", watchfacePrefValues)); .withPreference(DeviceSettingsUtils.getPrefPossibleValuesKey(PREF_WATCHFACE), TextUtils.join(",", watchfacePrefValues));
getSupport().evaluateGBDeviceEvent(evt); getSupport().evaluateGBDeviceEvent(evt);
} }

View File

@ -17,6 +17,7 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.withingssteelhr.communication.conversation; package nodomain.freeyourgadget.gadgetbridge.service.devices.withingssteelhr.communication.conversation;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.text.TextUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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(); GBDevice device = support.getDevice();
final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()); final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(device.getAddress());
prefs.edit().putString("workout_activity_types_sortable", workoutActivityTypes).apply(); prefs.edit().putString("workout_activity_types_sortable", workoutActivityTypes).apply();

View File

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.services; package nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.services;
import android.text.TextUtils;
import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.InvalidProtocolBufferException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -625,7 +627,7 @@ public class XiaomiSystemService extends AbstractXiaomiService implements Xiaomi
} }
final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences() final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences()
.withPreference(XiaomiPreferences.PREF_WORKOUT_TYPES, String.join(",", codes)); .withPreference(XiaomiPreferences.PREF_WORKOUT_TYPES, TextUtils.join(",", codes));
getSupport().evaluateGBDeviceEvent(eventUpdatePreferences); getSupport().evaluateGBDeviceEvent(eventUpdatePreferences);
} }