mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
CMF Buds 2a: Initial support
This commit is contained in:
+7
-1
@@ -82,5 +82,11 @@ public abstract class AbstractEarCoordinator extends AbstractBLClassicDeviceCoor
|
||||
|
||||
public abstract boolean incrementCounter();
|
||||
|
||||
public abstract boolean supportsLightAncAndTransparency();
|
||||
public boolean supportsInEarDetection() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract boolean supportsLightAnc();
|
||||
|
||||
public abstract boolean supportsTransparency();
|
||||
}
|
||||
|
||||
+6
-1
@@ -37,7 +37,12 @@ public class CmfBuds2Coordinator extends AbstractEarCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAncAndTransparency() {
|
||||
public boolean supportsLightAnc() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/* Copyright (C) 2026 José Rebelo
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.nothing;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
|
||||
public class CmfBuds2aCoordinator extends AbstractEarCoordinator {
|
||||
@Override
|
||||
public boolean isExperimental() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pattern getSupportedDeviceName() {
|
||||
return Pattern.compile("^CMF Buds 2a$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeviceNameResource() {
|
||||
return R.string.devicetype_nothing_cmf_buds_2a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementCounter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsInEarDetection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAnc() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -37,7 +37,12 @@ public class CmfBudsPro2Coordinator extends AbstractEarCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAncAndTransparency() {
|
||||
public boolean supportsLightAnc() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -38,7 +38,12 @@ public class Ear1Coordinator extends AbstractEarCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAncAndTransparency() {
|
||||
public boolean supportsLightAnc() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -37,7 +37,12 @@ public class Ear2Coordinator extends AbstractEarCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAncAndTransparency() {
|
||||
public boolean supportsLightAnc() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -37,7 +37,12 @@ public class EarACoordinator extends AbstractEarCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAncAndTransparency() {
|
||||
public boolean supportsLightAnc() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-3
@@ -52,7 +52,14 @@ public class EarSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
|
||||
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
|
||||
final AbstractEarCoordinator earCoordinator = (AbstractEarCoordinator) handler.getDevice().getDeviceCoordinator();
|
||||
|
||||
if (!earCoordinator.supportsLightAncAndTransparency()) {
|
||||
if (!earCoordinator.supportsInEarDetection()) {
|
||||
final Preference inEarPreference = handler.findPreference(DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_INEAR);
|
||||
if (inEarPreference != null) {
|
||||
inEarPreference.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!earCoordinator.supportsLightAnc() || !earCoordinator.supportsTransparency()) {
|
||||
// If light anc and transparency is not supported, remove the values from the preference
|
||||
final Preference audioModePref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_AUDIOMODE);
|
||||
|
||||
@@ -64,11 +71,15 @@ public class EarSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
|
||||
final List<CharSequence> entryValues = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < originalEntries.length; i++) {
|
||||
if ("anc".equals(originalEntryValues[i].toString()) || "off".equals(originalEntryValues[i].toString())) {
|
||||
if ("anclight".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsLightAnc()) {
|
||||
continue;
|
||||
}
|
||||
if ("transparency".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsTransparency()) {
|
||||
continue;
|
||||
}
|
||||
entries.add(originalEntries[i]);
|
||||
entryValues.add(originalEntryValues[i]);
|
||||
}
|
||||
}
|
||||
|
||||
((ListPreference) audioModePref).setEntries(entries.toArray(new CharSequence[0]));
|
||||
((ListPreference) audioModePref).setEntryValues(entryValues.toArray(new CharSequence[0]));
|
||||
|
||||
+6
-1
@@ -37,7 +37,12 @@ public class EarStickCoordinator extends AbstractEarCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLightAncAndTransparency() {
|
||||
public boolean supportsLightAnc() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTransparency() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,6 +353,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.ViranC29Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.ZL02DCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.no1f1.No1F1Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.CmfBuds2Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.CmfBuds2aCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.CmfBudsPro2Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear1Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear2Coordinator;
|
||||
@@ -761,6 +762,7 @@ public enum DeviceType {
|
||||
NOTHING_EAR_A(EarACoordinator.class),
|
||||
NOTHING_EAR_STICK(EarStickCoordinator.class),
|
||||
NOTHING_CMF_BUDS_2(CmfBuds2Coordinator.class),
|
||||
NOTHING_CMF_BUDS_2A(CmfBuds2aCoordinator.class),
|
||||
NOTHING_CMF_BUDS_PRO_2(CmfBudsPro2Coordinator.class),
|
||||
NOTHING_CMF_WATCH_PRO(CmfWatchProCoordinator.class),
|
||||
NOTHING_CMF_WATCH_PRO_2(CmfWatchPro2Coordinator.class),
|
||||
|
||||
@@ -3150,6 +3150,7 @@
|
||||
<string name="devicetype_nothing_ear_a" translatable="false">Nothing Ear (a)</string>
|
||||
<string name="devicetype_nothingearstick" translatable="false">Nothing Ear (Stick)</string>
|
||||
<string name="devicetype_nothing_cmf_buds_2" translatable="false">CMF Buds 2</string>
|
||||
<string name="devicetype_nothing_cmf_buds_2a" translatable="false">CMF Buds 2a</string>
|
||||
<string name="devicetype_nothing_cmf_buds_pro_2" translatable="false">CMF Buds Pro 2</string>
|
||||
<string name="devicetype_nothing_cmf_watch_pro" translatable="false">CMF Watch Pro</string>
|
||||
<string name="devicetype_nothing_cmf_watch_pro_2" translatable="false">CMF Watch Pro 2</string>
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ public class AbstractDeviceCoordinatorTest extends TestBase {
|
||||
put("Xiaomi Band 9 Active AB01", DeviceType.MIBAND9ACTIVE);
|
||||
put("vívoactive 6", DeviceType.GARMIN_VIVOACTIVE_6);
|
||||
put("CMF Buds 2", DeviceType.NOTHING_CMF_BUDS_2); // #5579
|
||||
put("CMF Buds 2a", DeviceType.NOTHING_CMF_BUDS_2A); // #6028
|
||||
put("HC96", DeviceType.HC96);
|
||||
put("P8", DeviceType.WASPOS); // from wasp-os source
|
||||
put("P8DFU", DeviceType.WASPOS); // from wasp-os source
|
||||
|
||||
Reference in New Issue
Block a user