1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-26 20:06:52 +01:00

Compare commits

..

66 Commits

Author SHA1 Message Date
Arjan Schrijver
c65f7bc19c Moyoung: Change bonding style to lazy to allow phone calls through watch 2024-11-21 16:59:19 +01:00
Arjan Schrijver
822e67c15d Moyoung: Add inactivity reminder preference 2024-11-21 16:59:19 +01:00
Arjan Schrijver
7ef3473f40 Moyoung: Add power saving mode preference 2024-11-21 16:59:19 +01:00
Arjan Schrijver
5c7d8c8fa8 Moyoung: Send volume level with music info 2024-11-21 16:59:19 +01:00
Arjan Schrijver
504faf6db0 Moyoung: Add option for letting the device follow the phone DND setting 2024-11-21 16:59:19 +01:00
Arjan Schrijver
a586a9af52 Moyoung: Support sending, receiving and deleting alarms 2024-11-21 16:59:19 +01:00
Arjan Schrijver
18768f5df3 Moyoung: Fix DND and Lift Wrist settings 2024-11-21 16:59:19 +01:00
Arjan Schrijver
7db655cd39 Moyoung: Support the Misirun C17 2024-11-21 16:59:19 +01:00
Arjan Schrijver
4106e7b3cd Moyoung: Send weather location and sunrise/sunset 2024-11-21 16:59:19 +01:00
Arjan Schrijver
cb2b216dde Moyoung: Implement sending calendar items 2024-11-21 16:59:19 +01:00
Arjan Schrijver
b5b4727564 Moyoung: Implement sending music info and state 2024-11-21 16:59:19 +01:00
Arjan Schrijver
e95892f30b Moyoung: Fix malformed notifications when sender/title contains colon 2024-11-21 16:59:19 +01:00
Arjan Schrijver
0f9c278a2e Moyoung: Implement and improve several device settings 2024-11-21 16:59:19 +01:00
Arjan Schrijver
ab882a845a Moyoung: Add music and volume control 2024-11-21 16:59:19 +01:00
Arjan Schrijver
c1ef7c6a46 Moyoung: Implement HR measurement interval setting 2024-11-21 16:59:19 +01:00
Arjan Schrijver
61ad31aa80 Moyoung: Implement language setting 2024-11-21 16:59:19 +01:00
Arjan Schrijver
1ad3500453 Moyoung: Fix HR history packet parsing and activity sample provider 2024-11-21 16:59:19 +01:00
Arjan Schrijver
9b463a8bd1 Moyoung: Send cached weather info on request 2024-11-21 16:59:19 +01:00
Arjan Schrijver
185b554980 Moyoung: Code and settings improvements 2024-11-21 16:59:19 +01:00
Arjan Schrijver
7003bb386a Moyoung: Improve notifications 2024-11-21 16:59:19 +01:00
Arjan Schrijver
a21ce4eeb3 Moyoung: Support syncing historical HR measurements 2024-11-21 16:59:19 +01:00
Arjan Schrijver
c93dc5bb09 Moyoung: Fix weather forecast being one day off 2024-11-21 16:59:19 +01:00
Arjan Schrijver
40abeea54a Moyoung: Add find my phone functionality 2024-11-21 16:59:19 +01:00
Arjan Schrijver
125b493c22 Moyoung: Make fixed MTU device-specific 2024-11-21 16:59:19 +01:00
Arjan Schrijver
d8992e104c Moyoung: Fixes for settings, sync, logging, weather, live activity 2024-11-21 16:59:19 +01:00
Arjan Schrijver
fb3ac9316a Moyoung: Improve logging 2024-11-21 16:59:19 +01:00
Arjan Schrijver
5e411b8f81 Moyoung: Persist received data in new tables 2024-11-21 16:59:19 +01:00
Arjan Schrijver
5fb78514a8 Moyoung: Split up (modernize) database tables 2024-11-21 16:59:19 +01:00
Arjan Schrijver
57cbe69138 Moyoung: Modernize classes and methods and fix compiler errors 2024-11-21 16:59:19 +01:00
Arjan Schrijver
6bf4a46f35 Rename DaFit references to Moyoung to reflect the protocol used 2024-11-21 16:59:19 +01:00
krzys-h
6a41f19e9e Da Fit: Setting alarms 2024-11-21 16:59:19 +01:00
krzys-h
56becb2ea9 Da Fit: Training data transfer 2024-11-21 16:59:18 +01:00
krzys-h
ea58fd3f0d Da Fit: Add device settings 2024-11-21 16:59:18 +01:00
krzys-h
5b0c2a9b69 Da Fit: Add weather sync 2024-11-21 16:59:18 +01:00
krzys-h
2f409f8b0a Da Fit: Add activity fetching and logging 2024-11-21 16:59:18 +01:00
krzys-h
62cc891212 Da Fit: Add handling of heart rate, blood pressure and oxidation measurements 2024-11-21 16:59:18 +01:00
krzys-h
f6b18ff680 Da Fit: Add notification support 2024-11-21 16:59:18 +01:00
krzys-h
6f8424e5d7 Da Fit: Add time sync 2024-11-21 16:59:18 +01:00
krzys-h
3aa1f7bec5 Da Fit: Add device support, reverse engineering notes and base protocol implementation 2024-11-21 16:59:18 +01:00
cdvrs
16aed1364b GBX-100: Fix notification title 2024-11-20 08:17:56 +00:00
Renato Aguiar
212289645f Add Garmin Instinct 2 2024-11-19 20:59:05 +00:00
José Rebelo
6b5c5ae0ac Garmin: Fix weather temperature conversion to celsius 2024-11-19 20:57:04 +00:00
José Rebelo
9d1a57b6c2 Fix crash in some chart pages (#4319) 2024-11-19 20:53:34 +00:00
dependency-bot
b56ed974a3 Update dependency com.android.tools:desugar_jdk_libs to v2.1.3 2024-11-19 00:15:30 +00:00
MrYoranimo
b5bd4da9b1 Xiaomi SPPv2: Catch exception thrown in onPacketReceived
When a received packet causes an exception to be thrown while
getting handled in the service's onPacketReceived method, the
message will get stuck in the queue because it is never released.
Subsequently received messages get lined up after the first message
that causes an exception, and since that message is never removed,
those newer messages are never processed.

Catching the exception thrown from within the onPacketReceived method
allows the code flow to continue and therefore remove the troubling
message from the queue.
2024-11-18 23:25:28 +01:00
José Rebelo
1d2404a4e6 Garmin: Display AGPS age 2024-11-17 19:00:00 +00:00
Martin.JM
39e7bd8c62 Huawei: Add non-P2P HR zones configuration 2024-11-17 17:57:30 +00:00
José Rebelo
5f91715c89 Realme Buds T110: Initial support 2024-11-17 17:23:23 +00:00
José Rebelo
1618fda418 Log exceptions during DBAccess async tasks 2024-11-17 00:01:40 +00:00
José Rebelo
e453855e88 Do not suppress repeated notifications if timestamp is in the future (#4327) 2024-11-16 21:46:22 +00:00
Me7c7
dc1533b4ed Huawei: Initial music managment support 2024-11-16 20:41:23 +00:00
José Rebelo
1a3a7dec05 Prevent heart rate average from using invalid samples 2024-11-16 14:08:06 +00:00
José Rebelo
87bc2e6ed7 Fix imperial unit on steps charts 2024-11-15 23:16:40 +00:00
CaptKentish
9bd828814e Add water sports icons (#4322) 2024-11-15 22:09:44 +00:00
huyz
6aa7280967 Add some workout icons 2024-11-14 23:25:28 +00:00
José Rebelo
f16e2eeabb Test device: Add dummy activities 2024-11-14 23:22:18 +00:00
Arjan Schrijver
e83555f099 Fossil/Skagen Hybrids: Fix erroneous watchface downgrade from de37e5b6f 2024-11-14 14:10:14 +01:00
José Rebelo
9b6fce566d Mi Band 9: Fix outdoor cycling parsing 2024-11-12 23:32:11 +00:00
Andreas Shimokawa
de37e5b6fd bump version, add xml changelog 2024-11-11 23:29:47 +01:00
Arjan Schrijver
cbb710abe7 Update changelog 2024-11-11 23:27:59 +01:00
mvn23
31b8fd683d Add wear sensor toggle to Bowers and Wilkins P Series 2024-11-11 02:15:41 +01:00
José Rebelo
82f221752e Compute activity average speed 2024-11-10 22:50:58 +00:00
José Rebelo
c2c1e48c85 Update changelog 2024-11-10 22:39:55 +00:00
José Rebelo
810df3055c Garmin Forerunner 55/620: Initial support 2024-11-10 22:33:48 +00:00
José Rebelo
a72de07d2a Oppo Enco Air: Initial support 2024-11-10 22:18:41 +00:00
José Rebelo
7a0e43a4de GBDevice: Do not unset firmware from dynamic state
It is not clear why this was being done, but it is the source of issues
for multiple devices, since the ensureDeviceUpToDate function will
attempt to persist the null values, in non-nullable columns.
2024-11-10 22:16:14 +00:00
106 changed files with 3917 additions and 127 deletions

View File

@ -124,6 +124,7 @@
<w>protomors</w>
<w>qhybrid</w>
<w>quallenauge</w>
<w>realme</w>
<w>rebelo</w>
<w>roidmi</w>
<w>romanization</w>

View File

@ -1,5 +1,20 @@
### Changelog
#### Next Release (WIP)
* Initial support for Bowers and Wilkins P Series
* Initial support for Garmin Fenix 6S Pro, Forerunner 55/235/620
* Initial support for Huawei Band 3 Pro
* Initial support for Oppo Enco Air
* Huawei: Display high-resolution heart rate
* Huawei: Improve activity parsing
* Huawei: Sync skin temperature
#### 0.82.1
* Huawei: Improve activity parsing
* Huawei Watch GT: Fix connection failure
* Withings: Fix crash on connection
* Improve Armenian transliterator for mixed-case words
#### 0.82.0
* Initial support for Anker Soundcore Liberty 4 NC
* Initial support for CMF Buds Pro 2 / Watch Pro 2

View File

@ -79,8 +79,8 @@ android {
minSdkVersion 21
// Note: always bump BOTH versionCode and versionName!
versionName "0.82.0"
versionCode 233
versionName "0.82.1"
versionCode 234
vectorDrawables.useSupportLibrary = true
buildConfigField "String", "GIT_HASH_SHORT", "\"${getGitHashShort()}\""
buildConfigField "boolean", "INTERNET_ACCESS", "false"
@ -198,7 +198,7 @@ android {
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.2'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation "androidx.camera:camera-core:1.4.0"

View File

@ -199,6 +199,10 @@
android:label="@string/title_activity_appmanager"
android:launchMode="singleTop"
android:parentActivityName=".activities.ControlCenterv2" />
<activity
android:name=".activities.musicmanager.MusicManagerActivity"
android:label="@string/title_activity_musicmanager"
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.AppBlacklistActivity"
android:label="@string/title_activity_notification_management"

View File

@ -97,14 +97,14 @@ public class BodyEnergyFragment extends AbstractChartFragment<BodyEnergyFragment
@Override
protected BodyEnergyData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
mDateView.setText(formattedDate);
List<? extends BodyEnergySample> samples = getBodyEnergySamples(db, device, getTSStart(), getTSEnd());
return new BodyEnergyData(samples);
}
@Override
protected void updateChartsnUIThread(BodyEnergyData bodyEnergyData) {
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
mDateView.setText(formattedDate);
List<Entry> lineEntries = new ArrayList<>();
final List<ILineDataSet> lineDataSets = new ArrayList<>();

View File

@ -126,10 +126,8 @@ public class HRVStatusFragment extends AbstractChartFragment<HRVStatusFragment.H
@Override
protected HRVStatusWeeklyData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
Calendar day = Calendar.getInstance();
Date tsEnd = getChartsHost().getEndDate();
day.setTime(tsEnd);
String formattedDate = new SimpleDateFormat("E, MMM dd").format(tsEnd);
mDateView.setText(formattedDate);
day.setTime(getEndDate());
List<HRVStatusDayData> weeklyData = getWeeklyData(db, day, device);
return new HRVStatusWeeklyData(weeklyData);
}
@ -164,6 +162,9 @@ public class HRVStatusFragment extends AbstractChartFragment<HRVStatusFragment.H
@Override
protected void updateChartsnUIThread(HRVStatusWeeklyData weeklyData) {
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
mDateView.setText(formattedDate);
mWeeklyHRVStatusChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
List<Entry> lineEntries = new ArrayList<>();
final List<ILineDataSet> lineDataSets = new ArrayList<>();

View File

@ -38,6 +38,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.HeartRateSample;
import nodomain.freeyourgadget.gadgetbridge.util.Accumulator;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDailyFragment.HeartRateData> {
@ -123,9 +124,7 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
day.add(Calendar.HOUR, 0);
int startTs = (int) (day.getTimeInMillis() / 1000);
int endTs = startTs + 24 * 60 * 60 - 1;
Date date = new Date((long) endTs * 1000);
String formattedDate = new SimpleDateFormat("E, MMM dd").format(date);
mDateView.setText(formattedDate);
List<? extends ActivitySample> samples = getActivitySamples(db, device, startTs, endTs);
int restingHeartRate = -1;
@ -211,20 +210,33 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
@Override
protected void updateChartsnUIThread(HeartRateDailyFragment.HeartRateData data) {
Calendar day = Calendar.getInstance();
day.setTime(getEndDate());
day.add(Calendar.DATE, 0);
day.set(Calendar.HOUR_OF_DAY, 0);
day.set(Calendar.MINUTE, 0);
day.set(Calendar.SECOND, 0);
day.add(Calendar.HOUR, 0);
int startTs = (int) (day.getTimeInMillis() / 1000);
int endTs = startTs + 24 * 60 * 60 - 1;
Date date = new Date((long) endTs * 1000);
String formattedDate = new SimpleDateFormat("E, MMM dd").format(date);
mDateView.setText(formattedDate);
HeartRateUtils heartRateUtilsInstance = HeartRateUtils.getInstance();
final TimestampTranslation tsTranslation = new TimestampTranslation();
final List<Entry> lineEntries = new ArrayList<>();
List<? extends ActivitySample> samples = data.samples;
int average = 0;
int minimum = 0;
int maximum = 0;
int sum = 0;
int n = 0;
final Accumulator accumulator = new Accumulator();
int lastHrSampleIndex = -1;
for (int i =0; i < samples.size(); i++) {
ActivitySample sample = samples.get(i);
int ts = tsTranslation.shorten(sample.getTimestamp());
if (sample.getKind() != ActivityKind.NOT_WORN && heartRateUtilsInstance.isValidHeartRateValue(sample.getHeartRate())) {
final ActivitySample sample = samples.get(i);
final int ts = tsTranslation.shorten(sample.getTimestamp());
if (!heartRateUtilsInstance.isValidHeartRateValue(sample.getHeartRate())) {
continue;
}
if (sample.getKind() != ActivityKind.NOT_WORN) {
if (lastHrSampleIndex > -1 && ts - lastHrSampleIndex > 1800 * HeartRateUtils.MAX_HR_MEASUREMENTS_GAP_MINUTES) {
lineEntries.add(new Entry(lastHrSampleIndex + 1, 0 ));
lineEntries.add(new Entry(ts - 1, 0));
@ -232,17 +244,7 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
lineEntries.add(new Entry(ts, sample.getHeartRate()));
lastHrSampleIndex = ts;
}
if (sample.getHeartRate() <= 0) {
continue;
}
n++;
sum += sample.getHeartRate();
if (sample.getHeartRate() > maximum) {
maximum = sample.getHeartRate();
}
if (minimum == 0 || sample.getHeartRate() < minimum) {
minimum = sample.getHeartRate();
}
accumulator.add(sample.getHeartRate());
}
LineDataSet dataSet = new LineDataSet(lineEntries, "Heart Rate");
@ -255,16 +257,15 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
dataSet.setColor(HEARTRATE_COLOR);
dataSet.setValueTextColor(CHART_TEXT_COLOR);
if (n > 0 && sum > 0) {
average = sum / n;
}
final int average = accumulator.getCount() > 0 ? (int) Math.round(accumulator.getAverage()) : -1;
final int minimum = accumulator.getCount() > 0 ? (int) Math.round(accumulator.getMin()) : -1;
final int maximum = accumulator.getCount() > 0 ? (int) Math.round(accumulator.getMax()) : -1;
hrAverage.setText(average > 0 ? getString(R.string.bpm_value_unit, average) : "-");
hrMinimum.setText(minimum > 0 ? getString(R.string.bpm_value_unit, minimum) : "-");
hrMaximum.setText(maximum > 0 ? getString(R.string.bpm_value_unit, maximum) : "-");
hrResting.setText(data.restingHeartRate > 0 ? getString(R.string.bpm_value_unit, data.restingHeartRate) : "-");
if (minimum > 0) {
hrLineChart.getAxisLeft().setAxisMinimum(Math.max(minimum - 30, 0));
hrLineChart.getAxisRight().setAxisMinimum(Math.max(minimum - 30, 0));
@ -279,7 +280,7 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
hrLineChart.getAxisLeft().removeAllLimitLines();
if (GBApplication.getPrefs().getBoolean("charts_show_average", true)) {
if (average > 0 && GBApplication.getPrefs().getBoolean("charts_show_average", true)) {
final LimitLine averageLine = new LimitLine(average);
averageLine.setLineWidth(1.5f);
averageLine.enableDashedLine(15f, 10f, 0f);

View File

@ -37,6 +37,7 @@ import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.workouts.WorkoutValueFormatter;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
@ -101,8 +102,6 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
protected StepsDailyFragment.StepsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
Calendar day = Calendar.getInstance();
day.setTime(chartsHost.getEndDate());
String formattedDate = new SimpleDateFormat("E, MMM dd").format(chartsHost.getEndDate());
mDateView.setText(formattedDate);
List<StepsDay> stepsDayList = getMyStepsDaysData(db, day, device);
final StepsDay stepsDay;
if (stepsDayList.isEmpty()) {
@ -117,6 +116,9 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
@Override
protected void updateChartsnUIThread(StepsDailyFragment.StepsData stepsData) {
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
mDateView.setText(formattedDate);
final int width = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
300,
@ -132,7 +134,9 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
));
steps.setText(String.format(String.valueOf(stepsData.todayStepsDay.steps)));
distance.setText(getString(R.string.steps_distance_unit, stepsData.todayStepsDay.distance));
final WorkoutValueFormatter valueFormatter = new WorkoutValueFormatter();
distance.setText(valueFormatter.formatValue(stepsData.todayStepsDay.distance, "km"));
// Chart
final List<LegendEntry> legendEntries = new ArrayList<>(1);

View File

@ -31,6 +31,7 @@ import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.workouts.WorkoutValueFormatter;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
@ -142,18 +143,19 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
@Override
protected StepsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
Calendar day = Calendar.getInstance();
Date to = new Date((long) this.getTSEnd() * 1000);
Date from = DateUtils.addDays(to,-(TOTAL_DAYS - 1));
String toFormattedDate = new SimpleDateFormat("E, MMM dd").format(to);
String fromFormattedDate = new SimpleDateFormat("E, MMM dd").format(from);
mDateView.setText(fromFormattedDate + " - " + toFormattedDate);
day.setTime(to);
day.setTime(getEndDate());
List<StepsDay> stepsDaysData = getMyStepsDaysData(db, day, device);
return new StepsData(stepsDaysData);
}
@Override
protected void updateChartsnUIThread(StepsData stepsData) {
Date to = new Date((long) getTSEnd() * 1000);
Date from = DateUtils.addDays(to,-(TOTAL_DAYS - 1));
String toFormattedDate = new SimpleDateFormat("E, MMM dd").format(to);
String fromFormattedDate = new SimpleDateFormat("E, MMM dd").format(from);
mDateView.setText(fromFormattedDate + " - " + toFormattedDate);
stepsChart.setData(null);
List<BarEntry> entries = new ArrayList<>();
@ -177,9 +179,10 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
}
stepsChart.setData(barData);
stepsAvg.setText(String.format(String.valueOf(stepsData.stepsDailyAvg)));
distanceAvg.setText(getString(R.string.steps_distance_unit, stepsData.distanceDailyAvg));
final WorkoutValueFormatter valueFormatter = new WorkoutValueFormatter();
distanceAvg.setText(valueFormatter.formatValue(stepsData.distanceDailyAvg, "km"));
stepsTotal.setText(String.format(String.valueOf(stepsData.totalSteps)));
distanceTotal.setText(getString(R.string.steps_distance_unit, stepsData.totalDistance));
distanceTotal.setText(valueFormatter.formatValue(stepsData.totalDistance, "km"));
}
ValueFormatter getStepsChartDayValueFormatter(StepsPeriodFragment.StepsData stepsData) {

View File

@ -118,8 +118,6 @@ public class VO2MaxFragment extends AbstractChartFragment<VO2MaxFragment.VO2MaxD
@Override
protected VO2MaxData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
mDateView.setText(formattedDate);
List<VO2MaxRecord> records = new ArrayList<>();
int tsEnd = getTSEnd();
Calendar day = Calendar.getInstance();
@ -145,7 +143,9 @@ public class VO2MaxFragment extends AbstractChartFragment<VO2MaxFragment.VO2MaxD
@Override
protected void updateChartsnUIThread(VO2MaxData vo2MaxData) {
TimestampTranslation tsTranslation = new TimestampTranslation();
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
mDateView.setText(formattedDate);
List<Entry> runningEntries = new ArrayList<>();
List<Entry> cyclingEntries = new ArrayList<>();
vo2MaxData.records.forEach((record) -> {

View File

@ -107,6 +107,7 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_DEVICE_INTENTS = "device_intents";
public static final String PREF_ACTIVE_NOISE_CANCELLING_TOGGLE = "active_noise_cancelling_toggle";
public static final String PREF_WEAR_SENSOR_TOGGLE = "wear_sensor_toggle";
public static final String PREF_BANDW_PSERIES_VPT_ENABLED = "bandw_pseries_vpt_enabled";
public static final String PREF_BANDW_PSERIES_VPT_LEVEL = "bandw_pseries_vpt_level";
public static final String PREF_BANDW_PSERIES_GUI_VPT_LEVEL = "bandw_pseries_gui_vpt_level";
@ -287,6 +288,8 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_CONTACTS = "pref_contacts";
public static final String PREF_WIDGETS = "pref_widgets";
public static final String PREF_MUSIC_MANAGEMENT = "pref_music_management";
public static final String PREF_ANTILOST_ENABLED = "pref_antilost_enabled";
public static final String PREF_HYDRATION_SWITCH = "pref_hydration_switch";
public static final String PREF_HYDRATION_PERIOD = "pref_hydration_period";

View File

@ -72,6 +72,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureWorldClocks;
import nodomain.freeyourgadget.gadgetbridge.activities.app_specific_notifications.AppSpecificNotificationSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.loyaltycards.LoyaltyCardsSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.loyaltycards.LoyaltyCardsSettingsConst;
import nodomain.freeyourgadget.gadgetbridge.activities.musicmanager.MusicManagerActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.widgets.WidgetScreensListActivity;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
@ -616,6 +617,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
addPreferenceHandlerFor(PREF_SLEEP_MODE_SMART_ENABLE);
addPreferenceHandlerFor(PREF_ACTIVE_NOISE_CANCELLING_TOGGLE);
addPreferenceHandlerFor(PREF_WEAR_SENSOR_TOGGLE);
addPreferenceHandlerFor(PREF_BANDW_PSERIES_GUI_VPT_LEVEL);
addPreferenceHandlerFor(PREF_HYBRID_HR_DRAW_WIDGET_CIRCLES);
@ -1057,6 +1059,19 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
});
}
final Preference music_management = findPreference(PREF_MUSIC_MANAGEMENT);
if (music_management != null) {
music_management.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final Intent intent = new Intent(getContext(), MusicManagerActivity.class);
intent.putExtra(GBDevice.EXTRA_DEVICE, device);
startActivity(intent);
return true;
}
});
}
final Preference widgets = findPreference(PREF_WIDGETS);
if (widgets != null) {
widgets.setOnPreferenceClickListener(preference -> {

View File

@ -0,0 +1,632 @@
package nodomain.freeyourgadget.gadgetbridge.activities.musicmanager;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.text.InputType;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.PopupMenu;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
import nodomain.freeyourgadget.gadgetbridge.adapter.MusicListAdapter;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusicPlaylist;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.GridAutoFitLayoutManager;
public class MusicManagerActivity extends AbstractGBActivity {
private static final Logger LOG = LoggerFactory.getLogger(MusicManagerActivity.class);
public static final String ACTION_MUSIC_DATA
= "nodomain.freeyourgadget.gadgetbridge.musicmanager.action.music_data";
public static final String ACTION_MUSIC_UPDATE
= "nodomain.freeyourgadget.gadgetbridge.musicmanager.action.music_update";
protected GBDevice mGBDevice = null;
private View loadingView = null;
private TextView musicDeviceInfo = null;
private final List<GBDeviceMusic> allMusic = new ArrayList<>();
private final List<GBDeviceMusic> musicList = new ArrayList<>();
private MusicListAdapter musicAdapter;
private final List<GBDeviceMusicPlaylist> playlists = new ArrayList<>();
private ArrayAdapter<GBDeviceMusicPlaylist> playlistAdapter;
private View playlistSpinnerLayout;
private Spinner playlistsSpinner;
private FloatingActionButton fabMusicUpload;
private FloatingActionButton fabMusicPlaylistAdd;
private int maxMusicCount = 0;
private int maxPlaylistCount = 0;
public GBDevice getGBDevice() {
return mGBDevice;
}
Handler loadingTimeout = new Handler();
Runnable loadingRunnable = new Runnable() {
@Override
public void run() {
GB.toast(getString(R.string.music_error), Toast.LENGTH_SHORT, GB.ERROR);
stopLoading();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_musicmanager);
Bundle extras = getIntent().getExtras();
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
}
if (mGBDevice == null) {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
fabMusicUpload = findViewById(R.id.fab_music_upload);
assert fabMusicUpload != null;
fabMusicUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("audio/*");
openAudioActivityResultLauncher.launch(intent);
}
});
fabMusicPlaylistAdd = findViewById(R.id.fab_music_playlist_add);
assert fabMusicPlaylistAdd != null;
fabMusicPlaylistAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addMusicPlaylist();
}
});
hideActionButtons();
RecyclerView musicListView = findViewById(R.id.music_songs_list);
loadingView = findViewById(R.id.music_loading);
musicDeviceInfo = findViewById(R.id.music_device_info);
musicListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
hideActionButtons();
} else if (dy < 0) {
showActionButtons();
}
}
});
musicListView.setLayoutManager(new GridAutoFitLayoutManager(this, 300));
musicAdapter = new MusicListAdapter(
musicList,
new MusicListAdapter.onItemAction() {
@Override
public void onItemClick(View view, GBDeviceMusic music) {
openPopupMenu(view, music);
}
@Override
public boolean onItemLongClick(View view, GBDeviceMusic music) {
return false;
}
}
);
musicListView.setAdapter(musicAdapter);
playlistSpinnerLayout = findViewById(R.id.music_playlists_layout);
playlistsSpinner = findViewById(R.id.music_playlists);
ImageButton renamePlaylist = findViewById(R.id.music_playlist_rename);
assert renamePlaylist != null;
renamePlaylist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
renameMusicPlaylist((GBDeviceMusicPlaylist) playlistsSpinner.getSelectedItem());
}
});
ImageButton deletePlaylist = findViewById(R.id.music_playlist_delete);
assert deletePlaylist != null;
deletePlaylist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deleteMusicPlaylist((GBDeviceMusicPlaylist) playlistsSpinner.getSelectedItem());
}
});
playlistsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
GBDeviceMusicPlaylist item = (GBDeviceMusicPlaylist) adapterView.getItemAtPosition(i);
if (item.getId() == 0) {
deletePlaylist.setVisibility(View.GONE);
renamePlaylist.setVisibility(View.GONE);
} else {
deletePlaylist.setVisibility(View.VISIBLE);
renamePlaylist.setVisibility(View.VISIBLE);
}
updateCurrentMusicList();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
playlistAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, playlists);
initPlaylists();
playlistAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
playlistsSpinner.setAdapter(playlistAdapter);
}
private void hideActionButtons() {
fabMusicUpload.hide();
fabMusicPlaylistAdd.hide();
}
private void showActionButtons() {
fabMusicUpload.show();
if(maxPlaylistCount > 0) {
fabMusicPlaylistAdd.show();
}
}
private void startLoading(long timeout) {
hideActionButtons();
loadingView.setVisibility(View.VISIBLE);
if(timeout > 0) {
loadingTimeout.postDelayed(loadingRunnable, timeout);
}
}
private void startLoading() {
startLoading(4000);
}
private void stopLoading() {
loadingTimeout.removeCallbacks(loadingRunnable);
loadingView.setVisibility(View.GONE);
showActionButtons();
}
private void updateCurrentMusicList() {
GBDeviceMusicPlaylist current = (GBDeviceMusicPlaylist) playlistsSpinner.getSelectedItem();
musicList.clear();
if (current.getId() == 0) {
musicList.addAll(allMusic);
} else {
List<GBDeviceMusic> filtered = allMusic.stream().filter(m -> current.getMusicIds().contains(m.getId())).collect(Collectors.toList());
musicList.addAll(filtered);
}
musicAdapter.notifyDataSetChanged();
}
private void initPlaylists() {
playlists.clear();
playlists.add(new GBDeviceMusicPlaylist(0,this.getString(R.string.music_all_songs),null));
}
@Override
public void onStart() {
super.onStart();
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_MUSIC_DATA);
filter.addAction(ACTION_MUSIC_UPDATE);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
// Load music data without timeout
startLoading(0);
GBApplication.deviceService(mGBDevice).onMusicListReq();
}
@Override
public void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
super.onStop();
}
ActivityResultLauncher<Intent> openAudioActivityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
Intent startIntent = new Intent(MusicManagerActivity.this, FwAppInstallerActivity.class);
startIntent.setAction(Intent.ACTION_VIEW);
startIntent.setDataAndType(result.getData().getData(), null);
startActivity(startIntent);
}
}
});
public boolean openPopupMenu(View view, GBDeviceMusic music) {
PopupMenu popupMenu = new PopupMenu(this, view);
popupMenu.getMenuInflater().inflate(R.menu.musicmanager_context, popupMenu.getMenu());
Menu menu = popupMenu.getMenu();
if (playlists.size() <= 1) {
menu.removeItem(R.id.musicmanager_add_to_playlist);
}
GBDeviceMusicPlaylist current = (GBDeviceMusicPlaylist) playlistsSpinner.getSelectedItem();
musicList.clear();
if (current.getId() == 0) {
menu.removeItem(R.id.musicmanager_delete_from_playlist);
} else {
menu.removeItem(R.id.musicmanager_delete);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onPopupItemSelected(item, music);
}
}
);
popupMenu.show();
return true;
}
private boolean onPopupItemSelected(final MenuItem item, final GBDeviceMusic music) {
final int itemId = item.getItemId();
if (itemId == R.id.musicmanager_delete || itemId == R.id.musicmanager_delete_from_playlist) {
deleteMusicConfirm(music);
return true;
} else if (itemId == R.id.musicmanager_add_to_playlist) {
addMusicSongToPlaylist(music);
return true;
}
return false;
}
private void deleteMusicConfirm(final GBDeviceMusic music) {
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.Delete)
.setMessage(this.getString(R.string.music_delete_confirm_description, music.getTitle()))
.setIcon(R.drawable.ic_warning)
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
deleteMusicFromDevice((GBDeviceMusicPlaylist) playlistsSpinner.getSelectedItem(), music);
})
.setNegativeButton(android.R.string.no, null)
.show();
}
private void addPlaylistToDevice(final String playlistName) {
startLoading();
GBApplication.deviceService(mGBDevice).onMusicOperation(0, -1, playlistName, null);
}
private void deletePlaylistFromDevice(final GBDeviceMusicPlaylist playlist) {
startLoading();
GBApplication.deviceService(mGBDevice).onMusicOperation(1, playlist.getId(), null, null);
}
private void renamePlaylistOnDevice(final GBDeviceMusicPlaylist playlist, String newPlaylistName) {
startLoading();
GBApplication.deviceService(mGBDevice).onMusicOperation(2, playlist.getId(), newPlaylistName, null);
}
private void addMusicToDevicePlaylist(GBDeviceMusicPlaylist playlist, final GBDeviceMusic music) {
startLoading();
ArrayList<Integer> list = new ArrayList<>();
list.add(music.getId());
GBApplication.deviceService(mGBDevice).onMusicOperation(3, playlist.getId(), null, list);
}
private void deleteMusicFromDevice(GBDeviceMusicPlaylist playlist, final GBDeviceMusic music) {
startLoading();
ArrayList<Integer> list = new ArrayList<>();
list.add(music.getId());
GBApplication.deviceService(mGBDevice).onMusicOperation(4, playlist.getId(), null, list);
}
private void addMusicPlaylist() {
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT);
FrameLayout container = new FrameLayout(this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
params.rightMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
input.setLayoutParams(params);
container.addView(input);
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.music_new_playlist)
.setView(container)
.setPositiveButton(android.R.string.ok, (dialog, whichButton) -> {
String playlistName = input.getText().toString();
addPlaylistToDevice(playlistName);
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
private void renameMusicPlaylist(GBDeviceMusicPlaylist playlist) {
if(playlist.getId() == 0)
return;
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setText(playlist.getName());
FrameLayout container = new FrameLayout(this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
params.rightMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
input.setLayoutParams(params);
container.addView(input);
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.music_rename_playlist)
.setView(container)
.setPositiveButton(android.R.string.ok, (dialog, whichButton) -> {
String playlistName = input.getText().toString();
renamePlaylistOnDevice(playlist, playlistName);
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
private void deleteMusicPlaylist(GBDeviceMusicPlaylist playlist) {
if(playlist.getId() == 0)
return;
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.Delete)
.setMessage(this.getString(R.string.music_delete_confirm_description, playlist.getName()))
.setIcon(R.drawable.ic_warning)
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
deletePlaylistFromDevice(playlist);
})
.setNegativeButton(android.R.string.no, null)
.show();
}
private void addMusicSongToPlaylist(final GBDeviceMusic music) {
final Spinner dPlaylists = new Spinner(this);
List<GBDeviceMusicPlaylist> dialogPlaylists = new ArrayList<>();
for (GBDeviceMusicPlaylist playlist : playlists) {
if (playlist.getId() != 0) {
dialogPlaylists.add(playlist);
}
}
ArrayAdapter<GBDeviceMusicPlaylist> dialogPlaylistAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, dialogPlaylists);
dialogPlaylistAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dPlaylists.setAdapter(dialogPlaylistAdapter);
FrameLayout container = new FrameLayout(this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
params.rightMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
dPlaylists.setLayoutParams(params);
container.addView(dPlaylists);
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.music_add_to_playlist)
.setView(container)
.setPositiveButton(android.R.string.ok, (dialog, whichButton) -> {
GBDeviceMusicPlaylist playlist = (GBDeviceMusicPlaylist) dPlaylists.getSelectedItem();
addMusicToDevicePlaylist(playlist, music);
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
private void startSyncFromDevice(Intent intent) {
String info = intent.getStringExtra("deviceInfo");
if (!TextUtils.isEmpty(info)) {
musicDeviceInfo.setText(info);
} else {
musicDeviceInfo.setVisibility(View.GONE);
}
maxMusicCount = intent.getIntExtra("maxMusicCount", 0);
maxPlaylistCount = intent.getIntExtra("maxPlaylistCount", 0);
// Hide playlist if device does not support it.
playlistSpinnerLayout.setVisibility(maxPlaylistCount>0?View.VISIBLE:View.GONE);
allMusic.clear();
musicList.clear();
initPlaylists();
}
private void musicListFromDevice(Intent intent) {
ArrayList<GBDeviceMusic> list = (ArrayList<GBDeviceMusic>) intent.getSerializableExtra("musicList");
if (list != null && !list.isEmpty()) {
allMusic.addAll(list);
}
ArrayList<GBDeviceMusicPlaylist> devicePlaylist = (ArrayList<GBDeviceMusicPlaylist>) intent.getSerializableExtra("musicPlaylist");
if (devicePlaylist != null && !devicePlaylist.isEmpty()) {
playlists.addAll(devicePlaylist);
playlistAdapter.notifyDataSetChanged();
}
}
private void musicOperationResponse(Intent intent) {
int operation = intent.getIntExtra("operation", -1);
if (operation == 0) {
int playlistIndex = intent.getIntExtra("playlistIndex", -1);
String playlistName = intent.getStringExtra("playlistName");
if (playlistIndex != -1 && !TextUtils.isEmpty(playlistName)) {
playlists.add(new GBDeviceMusicPlaylist(playlistIndex, playlistName, new ArrayList<>()));
playlistAdapter.notifyDataSetChanged();
}
} else if (operation == 1) {
int playlistIndex = intent.getIntExtra("playlistIndex", -1);
if (playlistIndex != -1) {
for (Iterator<GBDeviceMusicPlaylist> iterator = playlists.iterator(); iterator.hasNext(); ) {
GBDeviceMusicPlaylist playlist = iterator.next();
if (playlist.getId() == playlistIndex) {
iterator.remove();
}
}
playlistAdapter.notifyDataSetChanged();
}
} else if (operation == 2) {
int playlistIndex = intent.getIntExtra("playlistIndex", -1);
String playlistName = intent.getStringExtra("playlistName");
if (playlistIndex != -1 && !TextUtils.isEmpty(playlistName)) {
for (GBDeviceMusicPlaylist playlist : playlists) {
if (playlist.getId() == playlistIndex) {
playlist.setName(playlistName);
break;
}
}
playlistAdapter.notifyDataSetChanged();
}
} else if (operation == 3) {
int playlistIndex = intent.getIntExtra("playlistIndex", -1);
ArrayList<Integer> ids = (ArrayList<Integer>) intent.getSerializableExtra("musicIds");
if (playlistIndex != -1 && ids != null && !ids.isEmpty()) {
for (GBDeviceMusicPlaylist playlist : playlists) {
if (playlist.getId() == playlistIndex) {
ArrayList<Integer> currentList = playlist.getMusicIds();
for (Integer id : ids) {
if (!currentList.contains(id))
currentList.add(id);
}
playlist.setMusicIds(currentList);
break;
}
}
playlistAdapter.notifyDataSetChanged();
updateCurrentMusicList();
}
} else if (operation == 4) {
ArrayList<Integer> ids = (ArrayList<Integer>) intent.getSerializableExtra("musicIds");
int playlistIndex = intent.getIntExtra("playlistIndex", 0);
if (ids != null && !ids.isEmpty()) {
if (playlistIndex == 0) {
for (Iterator<GBDeviceMusic> iterator = musicList.iterator(); iterator.hasNext(); ) {
GBDeviceMusic music = iterator.next();
if (ids.contains(music.getId())) {
iterator.remove();
}
}
for (Iterator<GBDeviceMusic> iterator = allMusic.iterator(); iterator.hasNext(); ) {
GBDeviceMusic music = iterator.next();
if (ids.contains(music.getId())) {
iterator.remove();
}
}
} else {
for (GBDeviceMusicPlaylist playlist : playlists) {
if (playlist.getId() == playlistIndex) {
ArrayList<Integer> currentList = playlist.getMusicIds();
for (Integer id : ids) {
currentList.remove(id);
}
playlist.setMusicIds(currentList);
break;
}
}
}
playlistAdapter.notifyDataSetChanged();
updateCurrentMusicList();
}
}
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch (action) {
case ACTION_MUSIC_DATA: {
if (!intent.hasExtra("type"))
break;
int type = intent.getIntExtra("type", -1);
LOG.info("UPDATE type: {}", type);
if (type == 1) {
startSyncFromDevice(intent);
} else if (type == 2) {
LOG.info("got music list or playlist from device");
musicListFromDevice(intent);
} else if (type == 10) {
updateCurrentMusicList();
stopLoading();
}
break;
}
case ACTION_MUSIC_UPDATE: {
boolean success = intent.getBooleanExtra("success", false);
if (intent.hasExtra("operation") && success) {
musicOperationResponse(intent);
}
stopLoading();
break;
}
}
}
};
}

View File

@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities.workouts;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_CM;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_KG;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_KILOMETERS;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_METERS;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_METERS_PER_SECOND;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_SECONDS_PER_KM;
@ -106,6 +107,12 @@ public class WorkoutValueFormatter {
unit = "minutes_km";
}
break;
case UNIT_KILOMETERS:
if (units.equals(UNIT_IMPERIAL)) {
value = value * 0.621371D;
unit = "mi";
}
break;
case UNIT_METERS:
if (units.equals(UNIT_IMPERIAL)) {
value = value * 3.28084D;

View File

@ -0,0 +1,85 @@
package nodomain.freeyourgadget.gadgetbridge.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
public class MusicListAdapter extends RecyclerView.Adapter<MusicListAdapter.MusicViewHolder> {
public interface onItemAction {
void onItemClick(View view, GBDeviceMusic music);
boolean onItemLongClick(View view, GBDeviceMusic music);
}
private final List<GBDeviceMusic> musicList;
private final onItemAction callback;
public MusicListAdapter(List<GBDeviceMusic> list, onItemAction callback) {
this.musicList = list;
this.callback = callback;
}
@Override
public long getItemId(int position) {
return musicList.get(position).getId();
}
@Override
public int getItemCount() {
return musicList.size();
}
@Override
public MusicListAdapter.MusicViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_musicmanager_song, parent, false);
return new MusicViewHolder(view);
}
@Override
public void onBindViewHolder(final MusicListAdapter.MusicViewHolder holder, int position) {
final GBDeviceMusic music = musicList.get(position);
holder.musicTitle.setText(music.getTitle());
holder.musicArtist.setText(music.getArtist());
if(callback != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
callback.onItemClick(view, music);
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
return callback.onItemLongClick(view, music);
}
});
}
}
public static class MusicViewHolder extends RecyclerView.ViewHolder {
final TextView musicArtist;
final TextView musicTitle;
MusicViewHolder(View itemView) {
super(itemView);
musicArtist = itemView.findViewById(R.id.item_details);
musicTitle = itemView.findViewById(R.id.item_name);
}
}
}

View File

@ -20,11 +20,16 @@ import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
public abstract class DBAccess extends AsyncTask {
private static final Logger LOG = LoggerFactory.getLogger(DBAccess.class);
private final String mTask;
private final Context mContext;
private Exception mError;
@ -45,6 +50,7 @@ public abstract class DBAccess extends AsyncTask {
try (DBHandler db = GBApplication.acquireDB()) {
doInBackground(db);
} catch (Exception e) {
LOG.error("Error during DBAccess for {}", mTask, e);
mError = e;
}
return null;

View File

@ -0,0 +1,15 @@
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusicPlaylist;
public class GBDeviceMusicData extends GBDeviceEvent {
public int type = 0; // 1 - sync start, 2 - music list, 10 - end sync
public List<GBDeviceMusic> list = null;
public List<GBDeviceMusicPlaylist> playlists = null;
public String deviceInfo = null;
public int maxMusicCount = 0;
public int maxPlaylistCount = 0;
}

View File

@ -0,0 +1,11 @@
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
import java.util.ArrayList;
public class GBDeviceMusicUpdate extends GBDeviceEvent {
public boolean success = false;
public int operation = -1;
public int playlistIndex = -1;
public String playlistName;
public ArrayList<Integer> musicIds = null;
}

View File

@ -95,7 +95,7 @@ public interface EventHandler {
void onAppConfiguration(UUID appUuid, String config, Integer id);
void onAppReorder(UUID uuids[]);
void onAppReorder(UUID[] uuids);
void onFetchRecordedData(int dataTypes);
@ -154,4 +154,9 @@ public interface EventHandler {
void onSleepAsAndroidAction(String action, Bundle extras);
void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename);
void onMusicListReq();
void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds);
}

View File

@ -55,7 +55,8 @@ public class BandWPSeriesDeviceCoordinator extends AbstractBLEDeviceCoordinator
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[] {
R.xml.devicesettings_active_noise_cancelling_toggle,
R.xml.devicesettings_bandw_pseries
R.xml.devicesettings_bandw_pseries,
R.xml.devicesettings_wear_sensor_toggle
};
}

View File

@ -28,6 +28,7 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -36,6 +37,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpec
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.agps.GarminAgpsStatus;
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
@ -142,7 +144,10 @@ public class GarminSettingsCustomizer implements DeviceSpecificSettingsCustomize
prefUpdateTime.setTitle(R.string.pref_agps_update_time);
final long ts = prefs.getLong(GarminPreferences.agpsUpdateTime(url), 0L);
if (ts > 0) {
prefUpdateTime.setSummary(SDF.format(new Date(ts)));
prefUpdateTime.setSummary(String.format("%s (%s)",
SDF.format(new Date(ts)),
DateTimeUtils.formatDurationHoursMinutes(System.currentTimeMillis() - ts, TimeUnit.MILLISECONDS)
));
} else {
prefUpdateTime.setSummary(handler.getContext().getString(R.string.unknown));
}

View File

@ -0,0 +1,34 @@
/* Copyright (C) 2024 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.garmin.watches.forerunner;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
public class GarminForerunner55Coordinator extends GarminCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("^Forerunner 55$");
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_garmin_forerunner_55;
}
}

View File

@ -0,0 +1,34 @@
/* Copyright (C) 2024 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.garmin.watches.forerunner;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
public class GarminForerunner620Coordinator extends GarminCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("^Forerunner 620$");
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_garmin_forerunner_620;
}
}

View File

@ -0,0 +1,18 @@
package nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.instinct;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
public class GarminInstinct2Coordinator extends GarminCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("^Instinct 2$");
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_garmin_instinct_2;
}
}

View File

@ -305,6 +305,11 @@ public class HuaweiCoordinator {
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_contacts);
}
//Music
if (supportsMusicUploading() && getMusicInfoParams() != null && device.isConnected()) {
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_musicmanagement);
}
// Time
if (supportsDateFormat()) {
final List<Integer> dateTime = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DATE_TIME);
@ -448,6 +453,14 @@ public class HuaweiCoordinator {
return supportsHeartRate() || getForceOption(gbDevice, PREF_FORCE_ENABLE_HEARTRATE_SUPPORT);
}
public boolean supportsHeartRateZones() {
return supportsCommandForService(0x07, 0x13);
}
public boolean supportsExtendedHeartRateZones() {
return supportsCommandForService(0x07, 0x21);
}
public boolean supportsFitnessRestHeartRate() {
return supportsCommandForService(0x07, 0x23);
}
@ -602,8 +615,6 @@ public class HuaweiCoordinator {
return false;
}
public boolean supportsCalendar() {
if (supportsExpandCapability())
return supportsExpandCapability(171) || supportsExpandCapability(184);
@ -628,6 +639,12 @@ public class HuaweiCoordinator {
return false;
}
public boolean supportsMoreMusic() {
if (supportsExpandCapability())
return supportsExpandCapability(122);
return false;
}
public boolean supportsPromptPushMessage () {
// do not ask for capabilities under specific condition

View File

@ -7,16 +7,16 @@ import java.util.List;
public class HuaweiMusicUtils {
public static class PageStruct {
public short startIndex = 0;
public short endIndex = 0;
public short startFrame = 0;
public short endFrame = 0;
public short count = 0;
public byte[] hashCode = null;
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("PageStruct{");
sb.append("startIndex=").append(startIndex);
sb.append(", endIndex=").append(endIndex);
sb.append("startFrame=").append(startFrame);
sb.append(", endFrame=").append(endFrame);
sb.append(", count=").append(count);
sb.append(", hashCode=");
if (hashCode == null) sb.append("null");
@ -68,7 +68,6 @@ public class HuaweiMusicUtils {
public int currentMusicCount = 0; // TODO: not sure
public int unknown = 0; // TODO: not sure
public List<FormatRestrictions> formatsRestrictions = null;
public List<PageStruct> pageStruct = null;
@Override
public String toString() {
@ -80,7 +79,6 @@ public class HuaweiMusicUtils {
sb.append(", currentMusicCount=").append(currentMusicCount);
sb.append(", unknown=").append(unknown);
sb.append(", formatsRestrictions=").append(formatsRestrictions);
sb.append(", pageStruct=").append(pageStruct);
sb.append('}');
return sb.toString();
}

View File

@ -598,6 +598,14 @@ public class HuaweiPacket {
return new MusicControl.Control.Response(paramsProvider).fromPacket(this);
case MusicControl.MusicInfoParams.id:
return new MusicControl.MusicInfoParams.Response(paramsProvider).fromPacket(this);
case MusicControl.MusicList.id:
return new MusicControl.MusicList.Response(paramsProvider).fromPacket(this);
case MusicControl.MusicPlaylists.id:
return new MusicControl.MusicPlaylists.Response(paramsProvider).fromPacket(this);
case MusicControl.MusicPlaylistMusics.id:
return new MusicControl.MusicPlaylistMusics.Response(paramsProvider).fromPacket(this);
case MusicControl.MusicOperation.id:
return new MusicControl.MusicOperation.Response(paramsProvider).fromPacket(this);
case MusicControl.UploadMusicFileInfo.id:
return new MusicControl.UploadMusicFileInfo.UploadMusicFileInfoRequest(paramsProvider).fromPacket(this);
case MusicControl.ExtendedMusicInfoParams.id:

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HeartRateZonesConfig;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiReportThreshold;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiTLV;
@ -597,6 +598,71 @@ public class FitnessData {
}
}
public static class HeartRateZoneConfigPacket {
// It can use two IDs with basically the same format.
public static final byte id_simple = 0x13;
public static final byte id_extended = 0x21;
public static class Request extends HuaweiPacket {
private Request(
ParamsProvider paramsProvider,
byte id,
HeartRateZonesConfig heartRateZonesConfig
) {
super(paramsProvider);
this.serviceId = FitnessData.id;
this.commandId = id;
HuaweiTLV subTlv = new HuaweiTLV().
put(0x08, heartRateZonesConfig.getWarningEnable());
if (
heartRateZonesConfig.hasValidMHRData() &&
heartRateZonesConfig.getWarningHRLimit() > 0 &&
heartRateZonesConfig.getMaxHRThreshold() > 0
) {
subTlv
.put(0x09, (byte) heartRateZonesConfig.getWarningHRLimit())
.put(0x02, (byte) heartRateZonesConfig.getMHRWarmUp())
.put(0x03, (byte) heartRateZonesConfig.getMHRFatBurning())
.put(0x04, (byte) heartRateZonesConfig.getMHRAerobic())
.put(0x05, (byte) heartRateZonesConfig.getMHRAnaerobic())
.put(0x06, (byte) heartRateZonesConfig.getMHRExtreme())
.put(0x07, (byte) heartRateZonesConfig.getMaxHRThreshold())
.put(0x0b, (byte) heartRateZonesConfig.getMaxHRThreshold());
}
if (id == id_extended && heartRateZonesConfig.hasValidHRRData()) {
subTlv
.put(0x0d, (byte) heartRateZonesConfig.getHRRBasicAerobic())
.put(0x0e, (byte) heartRateZonesConfig.getHRRAdvancedAerobic())
.put(0x0f, (byte) heartRateZonesConfig.getHRRLactate())
.put(0x10, (byte) heartRateZonesConfig.getHRRBasicAnaerobic())
.put(0x11, (byte) heartRateZonesConfig.getHRRAdvancedAnaerobic());
}
if (id == id_extended && heartRateZonesConfig.getRestHeartRate() > 0) {
subTlv
.put(0x0a, (byte) heartRateZonesConfig.getCalculateMethod())
.put(0x0c, (byte) heartRateZonesConfig.getRestHeartRate());
}
this.tlv = new HuaweiTLV().put(0x81, subTlv);
this.complete = true;
}
public static Request requestSimple(ParamsProvider paramsProvider, HeartRateZonesConfig heartRateZonesConfig) {
return new Request(paramsProvider, id_simple, heartRateZonesConfig);
}
public static Request requestExtended(ParamsProvider paramsProvider, HeartRateZonesConfig heartRateZonesConfig) {
return new Request(paramsProvider, id_extended, heartRateZonesConfig);
}
}
}
public static class TruSleep {
public static final byte id = 0x16;

View File

@ -18,12 +18,14 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets;
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiMusicUtils.parseFormatBits;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiMusicUtils;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiTLV;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
public class MusicControl {
public static final byte id = 0x25;
@ -251,16 +253,16 @@ public class MusicControl {
public static class Response extends HuaweiPacket {
public HuaweiMusicUtils.MusicCapabilities params = new HuaweiMusicUtils.MusicCapabilities();
public int frameCount = 0;
public List<HuaweiMusicUtils.PageStruct> pageStruct = null;
public Response(ParamsProvider paramsProvider) {
super(paramsProvider);
}
@Override
public void parseTlv() throws ParseException {
//TODO: unknown TLV
// if (this.tlv.contains(0x01))
// LOG.info("Unknown: " + this.tlv.getShort(0x01));
this.frameCount = this.tlv.getAsInteger(0x01);
if (this.tlv.contains(0x02))
params.availableSpace = this.tlv.getAsInteger(0x02);
@ -274,25 +276,214 @@ public class MusicControl {
params.currentMusicCount = this.tlv.getAsInteger(0x05);
if (this.tlv.contains(0x86)) {
params.pageStruct = new ArrayList<>();
this.pageStruct = new ArrayList<>();
List<HuaweiTLV> subTlvs = this.tlv.getObject(0x86).getObjects(0x87);
for (HuaweiTLV subTlv : subTlvs) {
HuaweiMusicUtils.PageStruct pageStruct = new HuaweiMusicUtils.PageStruct();
if (subTlv.contains(0x08))
pageStruct.startIndex = subTlv.getShort(0x08);
pageStruct.startFrame = subTlv.getShort(0x08);
if (subTlv.contains(0x09))
pageStruct.endIndex = subTlv.getShort(0x09);
pageStruct.endFrame = subTlv.getShort(0x09);
if (subTlv.contains(0x0a))
pageStruct.count = subTlv.getShort(0x0a);
if (subTlv.contains(0x0b))
pageStruct.hashCode = subTlv.getBytes(0x0b);
params.pageStruct.add(pageStruct);
this.pageStruct.add(pageStruct);
}
}
}
}
}
public static class MusicList {
public static final byte id = 0x05;
public static class Request extends HuaweiPacket {
public Request(ParamsProvider paramsProvider, short startFrame, short endIndex) {
super(paramsProvider);
this.serviceId = MusicControl.id;
this.commandId = id;
this.tlv = new HuaweiTLV()
.put(0x01, startFrame)
.put(0x04, endIndex);
}
}
public static class Response extends HuaweiPacket {
public short startFrame = 0;
public short endIndex = 0;
public List<GBDeviceMusic> musicList;
public Response (ParamsProvider paramsProvider) {
super(paramsProvider);
}
@Override
public void parseTlv() throws HuaweiPacket.ParseException {
if(tlv.contains(0x1))
startFrame = tlv.getShort(0x1);
if(tlv.contains(0x4))
endIndex = tlv.getShort(0x4);
musicList = new ArrayList<>();
if(this.tlv.contains(0x82)) {
for (HuaweiTLV subTlv : this.tlv.getObject(0x82).getObjects(0x83)) {
int index = subTlv.getAsInteger(0x4);
String title = subTlv.getString(0x5);
String artist = subTlv.getString(0x6);
String fileName = subTlv.getString(0x7);
musicList.add(new GBDeviceMusic(index, title, artist, fileName));
}
}
}
}
}
public static class MusicPlaylists {
public static final byte id = 0x06;
public static class Request extends HuaweiPacket {
public Request(ParamsProvider paramsProvider) {
super(paramsProvider);
this.serviceId = MusicControl.id;
this.commandId = id;
this.tlv = new HuaweiTLV()
.put(0x01);
}
}
public static class Response extends HuaweiPacket {
public static class PlaylistData {
public int id;
public String name;
public int frameCount;
}
public List<PlaylistData> playlists = new ArrayList<>();
public Response (ParamsProvider paramsProvider) {
super(paramsProvider);
}
@Override
public void parseTlv() throws HuaweiPacket.ParseException {
if(this.tlv.contains(0x81)) {
for (HuaweiTLV subTlv : this.tlv.getObject(0x81).getObjects(0x82)) {
PlaylistData data = new PlaylistData();
data.id = subTlv.getAsInteger(0x3);
data.name = subTlv.getString(0x4);
data.frameCount = subTlv.getAsInteger(0x5);
playlists.add(data);
}
}
}
}
}
public static class MusicPlaylistMusics {
public static final byte id = 0x07;
public static class Request extends HuaweiPacket {
public Request(ParamsProvider paramsProvider, short playlist, short index) {
super(paramsProvider);
this.serviceId = MusicControl.id;
this.commandId = id;
this.tlv = new HuaweiTLV()
.put(0x01, playlist)
.put(0x02, index);
}
}
public static class Response extends HuaweiPacket {
public int id = -1;
public int index = -1;
public ArrayList<Integer> musicIds = null;
public Response (ParamsProvider paramsProvider) {
super(paramsProvider);
}
@Override
public void parseTlv() throws HuaweiPacket.ParseException {
if(this.tlv.contains(0x1))
id = tlv.getAsInteger(0x1);
if(this.tlv.contains(0x2))
index = tlv.getAsInteger(0x2);
if(this.tlv.contains(0x3)) {
musicIds = new ArrayList<>();
ByteBuffer dt = ByteBuffer.wrap(this.tlv.getBytes(0x3));
while (dt.hasRemaining())
musicIds.add((int) dt.getShort());
}
}
}
}
public static class MusicOperation {
public static final byte id = 0x08;
public static class Request extends HuaweiPacket {
public Request(ParamsProvider paramsProvider, int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
super(paramsProvider);
this.serviceId = MusicControl.id;
this.commandId = id;
this.tlv = new HuaweiTLV()
.put(0x01, (byte)operation);
if(operation == 1 || operation == 2 || operation == 3 || operation == 4) {
this.tlv.put(0x02, (short)playlistIndex);
}
if (operation == 0 || operation == 2) {
this.tlv.put(0x03, playlistName);
}
if (operation == 3 || operation == 4) {
ByteBuffer ids = ByteBuffer.allocate(musicIds.size() * 2);
for (Integer id : musicIds) {
ids.putShort(id.shortValue());
}
this.tlv.put(0x04, ids.array());
}
}
}
public static class Response extends HuaweiPacket {
public int operation = -1;
public int playlistIndex = -1;
public String playlistName;
public ArrayList<Integer> musicIds = null;
public int resultCode = -1;
public Response (ParamsProvider paramsProvider) {
super(paramsProvider);
}
@Override
public void parseTlv() throws HuaweiPacket.ParseException {
if(this.tlv.contains(0x7f))
resultCode = tlv.getInteger(0x7f);
if(this.tlv.contains(0x1))
operation = tlv.getByte(0x1);
if(this.tlv.contains(0x2))
playlistIndex = tlv.getAsInteger(0x2);
if(this.tlv.contains(0x3))
playlistName = tlv.getString(0x3);
if(this.tlv.contains(0x4)) {
musicIds = new ArrayList<>();
ByteBuffer dt = ByteBuffer.wrap(this.tlv.getBytes(0x4));
while (dt.hasRemaining())
musicIds.add((int) dt.getShort());
}
}
}
}
public static class ExtendedMusicInfoParams {
public static final byte id = 0x0d;

View File

@ -0,0 +1,75 @@
/* Copyright (C) 2024 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.oppo;
import android.util.Pair;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigSide;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigValue;
public class OppoEncoAirCoordinator extends OppoHeadphonesCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("OPPO Enco Air", Pattern.LITERAL);
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_oppo_enco_air;
}
@Override
public boolean supportsFindDevice() {
return true;
}
@Override
protected Map<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> getTouchOptions() {
return new LinkedHashMap<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>>() {{
put(Pair.create(TouchConfigSide.LEFT, TouchConfigType.TAP_2), Arrays.asList(
TouchConfigValue.OFF,
TouchConfigValue.PLAY_PAUSE,
TouchConfigValue.PREVIOUS,
TouchConfigValue.NEXT,
TouchConfigValue.VOICE_ASSISTANT
));
put(Pair.create(TouchConfigSide.LEFT, TouchConfigType.TAP_3), Arrays.asList(
TouchConfigValue.OFF,
TouchConfigValue.VOICE_ASSISTANT,
TouchConfigValue.GAME_MODE
));
put(Pair.create(TouchConfigSide.LEFT, TouchConfigType.HOLD), Arrays.asList(
TouchConfigValue.OFF,
TouchConfigValue.VOLUME_UP,
TouchConfigValue.VOLUME_DOWN
));
// Right side is the same
put(Pair.create(TouchConfigSide.RIGHT, TouchConfigType.TAP_2), get(Pair.create(TouchConfigSide.LEFT, TouchConfigType.TAP_2)));
put(Pair.create(TouchConfigSide.RIGHT, TouchConfigType.TAP_3), get(Pair.create(TouchConfigSide.LEFT, TouchConfigType.TAP_3)));
put(Pair.create(TouchConfigSide.RIGHT, TouchConfigType.HOLD), get(Pair.create(TouchConfigSide.LEFT, TouchConfigType.HOLD)));
}};
}
}

View File

@ -0,0 +1,101 @@
/* Copyright (C) 2024 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.oppo;
import android.util.Pair;
import androidx.annotation.NonNull;
import java.util.List;
import java.util.Map;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLClassicDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.OppoHeadphonesSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigSide;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigValue;
public abstract class OppoHeadphonesCoordinator extends AbstractBLClassicDeviceCoordinator {
@Override
protected void deleteDevice(@NonNull final GBDevice gbDevice, @NonNull final Device device, @NonNull final DaoSession session) throws GBException {
}
@Override
public String getManufacturer() {
return "Oppo";
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return OppoHeadphonesSupport.class;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_nothingear;
}
@Override
public int getDisabledIconResource() {
return R.drawable.ic_device_nothingear_disabled;
}
@Override
public int getBatteryCount() {
return 3;
}
@Override
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
final BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_nothing_ear_l, R.string.left_earbud);
final BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_nothing_ear_r, R.string.right_earbud);
final BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_tws_case, R.string.battery_case);
return new BatteryConfig[]{battery1, battery2, battery3};
}
@Override
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
final DeviceSpecificSettings settings = new DeviceSpecificSettings();
settings.addRootScreen(DeviceSpecificSettingsScreen.TOUCH_OPTIONS);
settings.addSubScreen(DeviceSpecificSettingsScreen.TOUCH_OPTIONS, R.xml.devicesettings_oppo_headphones_touch_options);
settings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
settings.addSubScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS, R.xml.devicesettings_headphones);
return settings;
}
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
return new OppoHeadphonesSettingsCustomizer(getTouchOptions());
}
protected abstract Map<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> getTouchOptions();
}

View File

@ -0,0 +1,33 @@
/* Copyright (C) 2024 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.oppo;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigSide;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigType;
public class OppoHeadphonesPreferences {
public static String getKey(final TouchConfigSide side, final TouchConfigType type) {
return String.format(
Locale.ROOT,
"oppo_touch__%s__%s",
side.name().toLowerCase(Locale.ROOT),
type.name().toLowerCase(Locale.ROOT)
);
}
}

View File

@ -0,0 +1,152 @@
/* Copyright (C) 2024 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.oppo;
import android.os.Parcel;
import android.util.Pair;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigSide;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigValue;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class OppoHeadphonesSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
private final Map<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> touchOptions;
public static final Creator<OppoHeadphonesSettingsCustomizer> CREATOR = new Creator<OppoHeadphonesSettingsCustomizer>() {
@Override
public OppoHeadphonesSettingsCustomizer createFromParcel(final Parcel in) {
final Map<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> touchOptions = new LinkedHashMap<>();
final int numOptions = in.readInt();
for (int i = 0; i < numOptions; i++) {
final TouchConfigSide touchConfigSide = TouchConfigSide.valueOf(in.readString());
final TouchConfigType touchConfigType = TouchConfigType.valueOf(in.readString());
final List<TouchConfigValue> values = new ArrayList<>();
in.readList(values, TouchConfigValue.class.getClassLoader());
touchOptions.put(Pair.create(touchConfigSide, touchConfigType), values);
}
return new OppoHeadphonesSettingsCustomizer(touchOptions);
}
@Override
public OppoHeadphonesSettingsCustomizer[] newArray(final int size) {
return new OppoHeadphonesSettingsCustomizer[size];
}
};
public OppoHeadphonesSettingsCustomizer(final Map<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> touchOptions) {
this.touchOptions = touchOptions;
}
@Override
public void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler) {
}
@Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Set<TouchConfigSide> knownSides = new HashSet<>();
final Set<TouchConfigType> knownTypes = new HashSet<>();
for (final Map.Entry<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> e : touchOptions.entrySet()) {
final TouchConfigSide side = e.getKey().first;
final TouchConfigType type = e.getKey().second;
final Set<TouchConfigValue> possibleValues = new HashSet<>(e.getValue());
knownSides.add(side);
knownTypes.add(type);
final String key = OppoHeadphonesPreferences.getKey(side, type);
final ListPreference pref = handler.findPreference(key);
if (pref == null) {
continue;
}
final CharSequence[] originalEntries = pref.getEntries();
final CharSequence[] originalValues = pref.getEntryValues();
final CharSequence[] entries = new CharSequence[possibleValues.size()];
final CharSequence[] values = new CharSequence[possibleValues.size()];
int j = 0;
for (int i = 0; i < originalValues.length; i++) {
if (possibleValues.contains(TouchConfigValue.valueOf(originalValues[i].toString().toUpperCase(Locale.ROOT)))) {
entries[j] = originalEntries[i];
values[j] = originalValues[i];
j++;
}
}
pref.setEntries(entries);
pref.setEntryValues(values);
handler.addPreferenceHandlerFor(key);
}
for (final TouchConfigSide side : TouchConfigSide.values()) {
if (!knownSides.contains(side)) {
// Side not configurable, hide it completely
final Preference header = handler.findPreference("oppo_touch_header_" + side.name().toLowerCase(Locale.ROOT));
if (header != null) {
header.setVisible(false);
continue;
}
}
for (final TouchConfigType type : TouchConfigType.values()) {
if (!knownTypes.contains(type)) {
final String key = OppoHeadphonesPreferences.getKey(side, type);
final Preference pref = handler.findPreference(key);
if (pref != null) {
pref.setVisible(false);
}
}
}
}
}
@Override
public Set<String> getPreferenceKeysWithSummary() {
return Collections.emptySet();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(final Parcel dest, final int flags) {
dest.writeInt(touchOptions.size());
for (final Map.Entry<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> e : touchOptions.entrySet()) {
dest.writeString(e.getKey().first.name());
dest.writeString(e.getKey().second.name());
dest.writeList(e.getValue());
}
}
}

View File

@ -0,0 +1,73 @@
/* Copyright (C) 2024 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.realme;
import android.util.Pair;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.oppo.OppoHeadphonesCoordinator;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigSide;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigValue;
public class RealmeBudsT110Coordinator extends OppoHeadphonesCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("realme Buds T110", Pattern.LITERAL);
}
@Override
public String getManufacturer() {
return "Realme";
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_realme_buds_t110;
}
@Override
protected Map<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>> getTouchOptions() {
return new LinkedHashMap<Pair<TouchConfigSide, TouchConfigType>, List<TouchConfigValue>>() {{
final List<TouchConfigValue> options = Arrays.asList(
TouchConfigValue.OFF,
TouchConfigValue.PLAY_PAUSE,
TouchConfigValue.PREVIOUS,
TouchConfigValue.NEXT,
TouchConfigValue.VOLUME_UP,
TouchConfigValue.VOLUME_DOWN,
TouchConfigValue.VOICE_ASSISTANT_REALME
);
put(Pair.create(TouchConfigSide.LEFT, TouchConfigType.TAP_2), options);
put(Pair.create(TouchConfigSide.LEFT, TouchConfigType.TAP_3), options);
put(Pair.create(TouchConfigSide.LEFT, TouchConfigType.HOLD), options);
put(Pair.create(TouchConfigSide.RIGHT, TouchConfigType.TAP_2), options);
put(Pair.create(TouchConfigSide.RIGHT, TouchConfigType.TAP_3), options);
put(Pair.create(TouchConfigSide.RIGHT, TouchConfigType.HOLD), options);
put(Pair.create(TouchConfigSide.BOTH, TouchConfigType.HOLD), Arrays.asList(
TouchConfigValue.OFF,
TouchConfigValue.GAME_MODE
));
}};
}
}

View File

@ -38,7 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.capabilities.widgets.WidgetManager;
@ -502,26 +504,26 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public int[] getSupportedDeviceSpecificSettings(final GBDevice device) {
final List<Integer> settings = new ArrayList<>();
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
settings.add(R.xml.devicesettings_header_apps);
settings.add(R.xml.devicesettings_loyalty_cards);
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_loyalty_cards);
if (getWorldClocksSlotCount() > 0) {
settings.add(R.xml.devicesettings_header_time);
settings.add(R.xml.devicesettings_world_clocks);
final List<Integer> dateTime = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DATE_TIME);
dateTime.add(R.xml.devicesettings_world_clocks);
}
if (getContactsSlotCount(device) > 0) {
settings.add(R.xml.devicesettings_header_other);
settings.add(R.xml.devicesettings_contacts);
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_contacts);
}
settings.add(R.xml.devicesettings_header_developer);
settings.add(R.xml.devicesettings_test_features);
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_test_features);
return ArrayUtils.toPrimitive(settings.toArray(new Integer[0]));
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
developer.add(R.xml.devicesettings_developer_add_test_activities);
return deviceSpecificSettings;
}
@Override

View File

@ -17,15 +17,30 @@
package nodomain.freeyourgadget.gadgetbridge.devices.test;
import android.os.Parcel;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.preference.MultiSelectListPreference;
import androidx.preference.Preference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.entities.User;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class TestDeviceSpecificSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
@ -39,20 +54,55 @@ public class TestDeviceSpecificSettingsCustomizer implements DeviceSpecificSetti
@Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference pref = handler.findPreference(TestDeviceConst.PREF_TEST_FEATURES);
if (pref == null) {
return;
if (pref != null) {
// Populate the preference directly from the enum
final CharSequence[] entries = new CharSequence[TestFeature.values().length];
final CharSequence[] values = new CharSequence[TestFeature.values().length];
for (int i = 0; i < TestFeature.values().length; i++) {
entries[i] = TestFeature.values()[i].name();
values[i] = TestFeature.values()[i].name();
}
if (pref instanceof MultiSelectListPreference) {
((MultiSelectListPreference) pref).setEntries(entries);
((MultiSelectListPreference) pref).setEntryValues(values);
}
}
// Populate the preference directly from the enum
final CharSequence[] entries = new CharSequence[TestFeature.values().length];
final CharSequence[] values = new CharSequence[TestFeature.values().length];
for (int i = 0; i < TestFeature.values().length; i++) {
entries[i] = TestFeature.values()[i].name();
values[i] = TestFeature.values()[i].name();
}
if (pref instanceof MultiSelectListPreference) {
((MultiSelectListPreference) pref).setEntries(entries);
((MultiSelectListPreference) pref).setEntryValues(values);
final Preference addTestActivities = handler.findPreference("pref_developer_add_test_activities");
if (addTestActivities != null) {
addTestActivities.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(@NonNull final Preference preference) {
try (DBHandler dbHandler = GBApplication.acquireDB()) {
final DaoSession session = dbHandler.getDaoSession();
final Device device = DBHelper.getDevice(handler.getDevice(), session);
final User user = DBHelper.getUser(session);
//final QueryBuilder<?> qb = session.getBaseActivitySummaryDao().queryBuilder();
//qb.where(BaseActivitySummaryDao.Properties.DeviceId.eq(device.getId())).buildDelete().executeDeleteWithoutDetachingEntities();
final List<BaseActivitySummary> summaries = new ArrayList<>();
for (final ActivityKind activityKind : ActivityKind.values()) {
final BaseActivitySummary summary = new BaseActivitySummary();
summary.setStartTime(new Date(System.currentTimeMillis() - new Random().nextInt(31 * 24 * 60 * 60) * 1000L));
summary.setEndTime(new Date(summary.getStartTime().getTime() + new Random().nextInt(60 * 60 * 2) * 1000L));
summary.setDevice(device);
summary.setUser(user);
summary.setActivityKind(activityKind.getCode());
// TODO data
summaries.add(summary);
}
session.getBaseActivitySummaryDao().insertOrReplaceInTx(summaries);
} catch (final Exception e) {
GB.toast(handler.getContext(), "Error saving activity summary", Toast.LENGTH_LONG, GB.ERROR, e);
return false;
}
return true;
}
});
}
}

View File

@ -455,10 +455,14 @@ public class NotificationListener extends NotificationListenerService {
mPackageLookup.add(notificationSpec.getId(), sbn.getPackageName()); // for MUTE
notificationBurstPrevention.put(source, curTime);
if (0 != notification.when) {
notificationOldRepeatPrevention.put(source, notification.when);
if (notification.when == 0) {
LOG.info("This app might show old/duplicate notifications. notification.when is 0 for {}", source);
} else if ((notification.when - System.currentTimeMillis()) > 30_000L) {
// #4327 - Some apps such as outlook send reminder notifications in the future
// If we add them to the oldRepeatPrevention, they never show up again
LOG.info("This app might show old/duplicate notifications. notification.when is in the future for {}", source);
} else {
LOG.info("This app might show old/duplicate notifications. notification.when is 0 for " + source);
notificationOldRepeatPrevention.put(source, notification.when);
}
notificationsActive.add(notificationSpec.getId());
// NOTE for future developers: this call goes to implementations of DeviceService.onNotification(NotificationSpec), like in GBDeviceService
@ -813,10 +817,11 @@ public class NotificationListener extends NotificationListenerService {
private void logNotification(StatusBarNotification sbn, boolean posted) {
LOG.debug(
"Notification {} {}: packageName={}, priority={}, category={}",
"Notification {} {}: packageName={}, when={}, priority={}, category={}",
sbn.getId(),
posted ? "posted" : "removed",
sbn.getPackageName(),
sbn.getNotification().when,
sbn.getNotification().priority,
sbn.getNotification().category
);

View File

@ -400,15 +400,12 @@ public class GBDevice implements Parcelable {
}
private void unsetDynamicState() {
setBatteryLevel(BATTERY_UNKNOWN, 0);
setBatteryLevel(BATTERY_UNKNOWN, 1);
setBatteryLevel(BATTERY_UNKNOWN, 2);
setBatteryState(UNKNOWN, 0);
setBatteryState(UNKNOWN, 1);
setBatteryState(UNKNOWN, 2);
setFirmwareVersion(null);
setFirmwareVersion2(null);
setRssi(RSSI_UNKNOWN);
resetExtraInfos();
if (mBusyTask != null) {

View File

@ -0,0 +1,33 @@
package nodomain.freeyourgadget.gadgetbridge.impl;
import java.io.Serializable;
public class GBDeviceMusic implements Serializable {
private final int id;
private final String title;
private final String artist;
private final String fileName;
public GBDeviceMusic(int id, String title, String artist, String fileName) {
this.id = id;
this.title = title;
this.artist = artist;
this.fileName = fileName;
}
public int getId() {
return id;
}
public String getTitle() {
return title;
}
public String getArtist() {
return artist;
}
public String getFileName() {
return fileName;
}
}

View File

@ -0,0 +1,41 @@
package nodomain.freeyourgadget.gadgetbridge.impl;
import java.io.Serializable;
import java.util.ArrayList;
public class GBDeviceMusicPlaylist implements Serializable {
private final int id;
private String name;
private ArrayList<Integer> musicIds;
public GBDeviceMusicPlaylist(int id, String name, ArrayList<Integer> musicIds) {
this.id = id;
this.name = name;
this.musicIds = musicIds;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ArrayList<Integer> getMusicIds() {
return musicIds;
}
public void setMusicIds(ArrayList<Integer> musicIds) {
this.musicIds = musicIds;
}
@Override
public String toString() {
return name;
}
}

View File

@ -568,4 +568,20 @@ public class GBDeviceService implements DeviceService {
intent.putExtra(EXTRA_CAMERA_FILENAME, filename);
invokeService(intent);
}
@Override
public void onMusicListReq() {
Intent intent = createIntent().setAction(ACTION_REQUEST_MUSIC_LIST);
invokeService(intent);
}
@Override
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
Intent intent = createIntent().setAction(ACTION_REQUEST_MUSIC_OPERATION);
intent.putExtra("operation", operation);
intent.putExtra("playlistIndex", playlistIndex);
intent.putExtra("playlistName", playlistName);
intent.putExtra("musicIds", musicIds);
invokeService(intent);
}
}

View File

@ -67,8 +67,8 @@ public enum ActivityKind {
HANDCYCLING_INDOOR(0x04000005, R.string.activity_type_handcycling_indoor),
TRANSITION(0x04000006, R.string.activity_type_transition),
FITNESS_EQUIPMENT(0x04000007, R.string.activity_type_fitness_equipment),
STAIR_STEPPER(0x04000008, R.string.activity_type_stair_stepper),
PILATES(0x04000009, R.string.activity_type_pilates),
STAIR_STEPPER(0x04000008, R.string.activity_type_stair_stepper, R.drawable.ic_activity_stair_stepper),
PILATES(0x04000009, R.string.activity_type_pilates, R.drawable.ic_activity_pilates),
POOL_SWIM(0x0400000a, R.string.activity_type_pool_swimming, R.drawable.ic_activity_swimming),
TENNIS(0x0400000b, R.string.activity_type_tennis),
PLATFORM_TENNIS(0x0400000c, R.string.activity_type_platform_tennis),
@ -94,23 +94,23 @@ public enum ActivityKind {
HUNTING(0x04000023, R.string.activity_type_hunting),
FISHING(0x04000024, R.string.activity_type_fishing),
INLINE_SKATING(0x04000025, R.string.activity_type_inline_skating),
ROCK_CLIMBING(0x04000026, R.string.activity_type_rock_climbing),
ROCK_CLIMBING(0x04000026, R.string.activity_type_rock_climbing, R.drawable.ic_activity_rock_climbing),
CLIMB_INDOOR(0x04000027, R.string.activity_type_climb_indoor),
BOULDERING(0x04000028, R.string.activity_type_bouldering),
SAIL_RACE(0x0400002a, R.string.activity_type_sail_race, R.drawable.ic_activity_sailing),
SAIL_EXPEDITION(0x0400002b, R.string.activity_type_sail_expedition, R.drawable.ic_activity_sailing),
ICE_SKATING(0x0400002c, R.string.activity_type_ice_skating),
ICE_SKATING(0x0400002c, R.string.activity_type_ice_skating, R.drawable.ic_activity_ice_skating),
SKY_DIVING(0x0400002d, R.string.activity_type_sky_diving),
SNOWSHOE(0x0400002e, R.string.activity_type_snowshoe),
SNOWMOBILING(0x0400002f, R.string.activity_type_snowmobiling),
STAND_UP_PADDLEBOARDING(0x04000030, R.string.activity_type_stand_up_paddleboarding),
SURFING(0x04000031, R.string.activity_type_surfing),
WAKEBOARDING(0x04000032, R.string.activity_type_wakeboarding),
WATER_SKIING(0x04000033, R.string.activity_type_water_skiing),
STAND_UP_PADDLEBOARDING(0x04000030, R.string.activity_type_stand_up_paddleboarding, R.drawable.ic_activity_sup),
SURFING(0x04000031, R.string.activity_type_surfing, R.drawable.ic_activity_surfing),
WAKEBOARDING(0x04000032, R.string.activity_type_wakeboarding, R.drawable.ic_activity_wakeboarding),
WATER_SKIING(0x04000033, R.string.activity_type_water_skiing, R.drawable.ic_activity_waterskiing),
KAYAKING(0x04000034, R.string.activity_type_kayaking, R.drawable.ic_activity_rowing),
RAFTING(0x04000035, R.string.activity_type_rafting, R.drawable.ic_activity_rowing),
WINDSURFING(0x04000036, R.string.activity_type_windsurfing),
KITESURFING(0x04000037, R.string.activity_type_kitesurfing),
WINDSURFING(0x04000036, R.string.activity_type_windsurfing, R.drawable.ic_activity_windsurfing),
KITESURFING(0x04000037, R.string.activity_type_kitesurfing, R.drawable.ic_activity_kitesurfing),
TACTICAL(0x04000038, R.string.activity_type_tactical),
JUMPMASTER(0x04000039, R.string.activity_type_jumpmaster),
BOXING(0x0400003a, R.string.activity_type_boxing),
@ -144,7 +144,7 @@ public enum ActivityKind {
HOCKEY(0x04000056, R.string.activity_type_hockey),
LACROSSE(0x04000057, R.string.activity_type_lacrosse),
VOLLEYBALL(0x04000058, R.string.activity_type_volleyball),
WATER_TUBING(0x04000059, R.string.activity_type_water_tubing),
WATER_TUBING(0x04000059, R.string.activity_type_water_tubing, R.drawable.ic_activity_watertubing),
WAKESURFING(0x0400005a, R.string.activity_type_wakesurfing),
MIXED_MARTIAL_ARTS(0x0400005b, R.string.activity_type_mixed_martial_arts), // aka MMA
DANCE(0x0400005c, R.string.activity_type_dance),
@ -194,20 +194,20 @@ public enum ActivityKind {
ROLLER_SKATING(0x04000087, R.string.activity_type_roller_skating),
MARTIAL_ARTS(0x04000088, R.string.activity_type_martial_arts),
TAI_CHI(0x04000089, R.string.activity_type_tai_chi),
HULA_HOOPING(0x0400008a, R.string.activity_type_hula_hooping),
HULA_HOOPING(0x0400008a, R.string.activity_type_hula_hooping, R.drawable.ic_activity_hula_hoop),
DISC_SPORTS(0x0400008b, R.string.activity_type_disc_sports),
DARTS(0x0400008c, R.string.activity_type_darts),
ARCHERY(0x0400008d, R.string.activity_type_archery),
ARCHERY(0x0400008d, R.string.activity_type_archery, R.drawable.ic_activity_archery),
HORSE_RIDING(0x0400008e, R.string.activity_type_horse_riding),
KITE_FLYING(0x0400008f, R.string.activity_type_kite_flying),
SWING(0x04000090, R.string.activity_type_swing),
STAIRS(0x04000091, R.string.activity_type_stairs),
STAIRS(0x04000091, R.string.activity_type_stairs, R.drawable.ic_activity_stairs),
MIND_AND_BODY(0x04000092, R.string.activity_type_mind_and_body),
WRESTLING(0x04000093, R.string.activity_type_wrestling),
KABADDI(0x04000094, R.string.activity_type_kabaddi),
KARTING(0x04000095, R.string.activity_type_karting),
BILLIARDS(0x04000096, R.string.activity_type_billiards),
BOWLING(0x04000097, R.string.activity_type_bowling),
BOWLING(0x04000097, R.string.activity_type_bowling, R.drawable.ic_activity_bowling),
SHUTTLECOCK(0x04000098, R.string.activity_type_shuttlecock),
HANDBALL(0x04000099, R.string.activity_type_handball),
DODGEBALL(0x0400009a, R.string.activity_type_dodgeball),
@ -222,14 +222,14 @@ public enum ActivityKind {
JET_SKIING(0x040000a3, R.string.activity_type_jet_skiing),
SKATING(0x040000a4, R.string.activity_type_skating),
ICE_HOCKEY(0x040000a5, R.string.activity_type_ice_hockey),
CURLING(0x040000a6, R.string.activity_type_curling),
CURLING(0x040000a6, R.string.activity_type_curling, R.drawable.ic_activity_curling),
CROSS_COUNTRY_SKIING(0x040000a8, R.string.activity_type_cross_country_skiing),
SNOW_SPORTS(0x040000a9, R.string.activity_type_snow_sports),
LUGE(0x040000ab, R.string.activity_type_luge),
SKATEBOARDING(0x040000ac, R.string.activity_type_skateboarding),
PARACHUTING(0x040000ae, R.string.activity_type_parachuting),
PARKOUR(0x040000af, R.string.activity_type_parkour),
INDOOR_RUNNING(0x040000b0, R.string.activity_type_indoor_running),
INDOOR_RUNNING(0x040000b0, R.string.activity_type_indoor_running, R.drawable.ic_activity_indoor_running),
OUTDOOR_RUNNING(0x040000b1, R.string.activity_type_outdoor_running, R.drawable.ic_activity_running),
OUTDOOR_WALKING(0x040000b2, R.string.activity_type_outdoor_walking, R.drawable.ic_activity_hiking),
OUTDOOR_CYCLING(0x040000b3, R.string.activity_type_outdoor_cycling, R.drawable.ic_activity_biking),
@ -251,13 +251,13 @@ public enum ActivityKind {
FINSWIMMING(0x040000c3, R.string.activity_type_finswimming),
FLOWRIDING(0x040000c4, R.string.activity_type_flowriding),
FOLK_DANCE(0x040000c5, R.string.activity_type_folk_dance),
FRISBEE(0x040000c6, R.string.activity_type_frisbee),
FRISBEE(0x040000c6, R.string.activity_type_frisbee, R.drawable.ic_activity_frisbee),
FUTSAL(0x040000c7, R.string.activity_type_futsal),
HACKY_SACK(0x040000c8, R.string.activity_type_hacky_sack),
HIP_HOP(0x040000c9, R.string.activity_type_hip_hop),
HULA_HOOP(0x040000ca, R.string.activity_type_hula_hoop),
HULA_HOOP(0x040000ca, R.string.activity_type_hula_hoop, R.drawable.ic_activity_hula_hoop),
INDOOR_FITNESS(0x040000cb, R.string.activity_type_indoor_fitness),
INDOOR_ICE_SKATING(0x040000cc, R.string.activity_type_indoor_ice_skating),
INDOOR_ICE_SKATING(0x040000cc, R.string.activity_type_indoor_ice_skating, R.drawable.ic_activity_ice_skating),
JAI_ALAI(0x040000cd, R.string.activity_type_jai_alai),
JUDO(0x040000ce, R.string.activity_type_judo),
JUJITSU(0x040000cf, R.string.activity_type_jujitsu),
@ -284,8 +284,8 @@ public enum ActivityKind {
BODY_COMBAT(0x040000e5, R.string.activity_type_body_combat),
PLAZA_DANCING(0x040000e6, R.string.activity_type_plaza_dancing),
LASER_TAG(0x040000e7, R.string.activity_type_laser_tag),
OBSTACLE_RACE(0x040000e8, R.string.activity_type_obstacle_race),
BILLIARD_POOL(0x040000e9, R.string.activity_type_billiard_pool),
OBSTACLE_RACE(0x040000e8, R.string.activity_type_obstacle_race, R.drawable.ic_activity_obstacle_race),
BILLIARD_POOL(0x040000e9, R.string.activity_type_billiard_pool, R.drawable.ic_activity_billiard_pool),
CANOEING(0x040000ea, R.string.activity_type_canoeing),
WATER_SCOOTER(0x040000eb, R.string.activity_type_water_scooter),
BOBSLEIGH(0x040000ec, R.string.activity_type_bobsleigh),

View File

@ -57,7 +57,7 @@ public class ActivitySummaryJsonSummary {
summary.add("baseAltitude", item.getBaseAltitude(), UNIT_METERS);
}
if (!summary.has("averageKMPaceSeconds") && !summary.has("averageSpeed") && summary.has("distanceMeters") && summary.has("activeSeconds")) {
if (!summary.has("averageSpeed") && summary.has("distanceMeters") && summary.has("activeSeconds")) {
double distance = summary.getNumber("distanceMeters", 0).doubleValue();
double duration = summary.getNumber("activeSeconds", 1).doubleValue();
summary.add("averageSpeed", distance / duration, UNIT_METERS_PER_SECOND);

View File

@ -80,6 +80,8 @@ public interface DeviceService extends EventHandler {
String ACTION_SET_LED_COLOR = PREFIX + ".action.set_led_color";
String ACTION_POWER_OFF = PREFIX + ".action.power_off";
String ACTION_CAMERA_STATUS_CHANGE = PREFIX + ".action.camera_status_change";
String ACTION_REQUEST_MUSIC_LIST = PREFIX + ".action.request_music_list";
String ACTION_REQUEST_MUSIC_OPERATION = PREFIX + ".action.request_music_operation";
String ACTION_SLEEP_AS_ANDROID = ".action.sleep_as_android";
String EXTRA_SLEEP_AS_ANDROID_ACTION = "sleepasandroid_action";

View File

@ -79,8 +79,11 @@ import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.Ga
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner255SMusicCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner265Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner265SCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner55Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner620Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner955Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner.GarminForerunner965Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.instinct.GarminInstinct2Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.instinct.GarminInstinct2SCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.instinct.GarminInstinct2SSolarCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.instinct.GarminInstinct2SolTacCoordinator;
@ -226,10 +229,12 @@ import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear1Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear2Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.EarStickCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.nut.NutCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.oppo.OppoEncoAirCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.pinetime.PineTimeJFCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.qc35.QC35Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.QHybridCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.realme.RealmeBudsT110Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.roidmi.Roidmi1Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.roidmi.Roidmi3Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.scannable.ScannableDeviceCoordinator;
@ -431,6 +436,7 @@ public enum DeviceType {
GARMIN_FENIX_7S(GarminFenix7SCoordinator.class),
GARMIN_FENIX_7_PRO(GarminFenix7ProCoordinator.class),
GARMIN_FENIX_8(GarminFenix8Coordinator.class),
GARMIN_FORERUNNER_55(GarminForerunner55Coordinator.class),
GARMIN_FORERUNNER_165(GarminForerunner165Coordinator.class),
GARMIN_FORERUNNER_235(GarminForerunner235Coordinator.class),
GARMIN_FORERUNNER_245(GarminForerunner245Coordinator.class),
@ -441,11 +447,13 @@ public enum DeviceType {
GARMIN_FORERUNNER_255S_MUSIC(GarminForerunner255SMusicCoordinator.class),
GARMIN_FORERUNNER_265(GarminForerunner265Coordinator.class),
GARMIN_FORERUNNER_265S(GarminForerunner265SCoordinator.class),
GARMIN_FORERUNNER_620(GarminForerunner620Coordinator.class),
GARMIN_FORERUNNER_955(GarminForerunner955Coordinator.class),
GARMIN_FORERUNNER_965(GarminForerunner965Coordinator.class),
GARMIN_SWIM_2(GarminSwim2Coordinator.class),
GARMIN_INSTINCT(GarminInstinctCoordinator.class),
GARMIN_INSTINCT_SOLAR(GarminInstinctSolarCoordinator.class),
GARMIN_INSTINCT_2(GarminInstinct2Coordinator.class),
GARMIN_INSTINCT_2S(GarminInstinct2SCoordinator.class),
GARMIN_INSTINCT_2S_SOLAR(GarminInstinct2SSolarCoordinator.class),
GARMIN_INSTINCT_2X_SOLAR(GarminInstinct2XSolarCoordinator.class),
@ -540,6 +548,8 @@ public enum DeviceType {
FLIPPER_ZERO(FlipperZeroCoordinator.class),
SUPER_CARS(SuperCarsCoordinator.class),
ASTEROIDOS(AsteroidOSDeviceCoordinator.class),
OPPO_ENCO_AIR(OppoEncoAirCoordinator.class),
REALME_BUDS_T110(RealmeBudsT110Coordinator.class),
SOFLOW_SO6(SoFlowCoordinator.class),
WITHINGS_STEEL_HR(WithingsSteelHRDeviceCoordinator.class),
SONY_WENA_3(SonyWena3Coordinator.class),

View File

@ -63,6 +63,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.FindPhoneActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AbstractAppManagerFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.activities.musicmanager.MusicManagerActivity;
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
import nodomain.freeyourgadget.gadgetbridge.database.DBAccess;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
@ -86,12 +87,16 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePref
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventWearState;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceMusicData;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceMusicUpdate;
import nodomain.freeyourgadget.gadgetbridge.entities.BatteryLevel;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener;
import nodomain.freeyourgadget.gadgetbridge.externalevents.opentracks.OpenTracksController;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusicPlaylist;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
@ -236,7 +241,12 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
handleGBDeviceEvent((GBDeviceEventWearState) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventSleepStateDetection) {
handleGBDeviceEvent((GBDeviceEventSleepStateDetection) deviceEvent);
} else if (deviceEvent instanceof GBDeviceMusicData) {
handleGBDeviceEvent((GBDeviceMusicData) deviceEvent);
} else if (deviceEvent instanceof GBDeviceMusicUpdate) {
handleGBDeviceEvent((GBDeviceMusicUpdate) deviceEvent);
}
}
private void handleGBDeviceEvent(GBDeviceEventSilentMode deviceEvent) {
@ -751,6 +761,53 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
handleDeviceAction(actionOnUnwear, broadcastMessage);
}
private void handleGBDeviceEvent(GBDeviceMusicData deviceEvent) {
Context context = getContext();
LOG.info("Got event for ACTION_MUSIC_DATA");
Intent intent = new Intent(MusicManagerActivity.ACTION_MUSIC_DATA);
intent.putExtra("type", deviceEvent.type);
if(deviceEvent.list != null) {
ArrayList<GBDeviceMusic> list = new ArrayList<>(deviceEvent.list);
intent.putExtra("musicList", list);
}
if(deviceEvent.playlists != null) {
ArrayList<GBDeviceMusicPlaylist> list = new ArrayList<>(deviceEvent.playlists);
intent.putExtra("musicPlaylist", list);
}
if(!TextUtils.isEmpty(deviceEvent.deviceInfo)) {
intent.putExtra("deviceInfo", deviceEvent.deviceInfo);
}
if(deviceEvent.maxMusicCount > 0) {
intent.putExtra("maxMusicCount", deviceEvent.maxMusicCount);
}
if(deviceEvent.maxPlaylistCount > 0) {
intent.putExtra("maxPlaylistCount", deviceEvent.maxPlaylistCount);
}
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
private void handleGBDeviceEvent(GBDeviceMusicUpdate deviceEvent) {
Context context = getContext();
LOG.info("Got event for ACTION_MUSIC_UPDATE");
Intent intent = new Intent(MusicManagerActivity.ACTION_MUSIC_UPDATE);
intent.putExtra("success", deviceEvent.success);
intent.putExtra("operation", deviceEvent.operation);
intent.putExtra("playlistIndex", deviceEvent.playlistIndex);
intent.putExtra("playlistName", deviceEvent.playlistName);
intent.putExtra("musicIds", deviceEvent.musicIds);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
private StoreDataTask createStoreTask(String task, Context context, GBDeviceEventBatteryInfo deviceEvent) {
return new StoreDataTask(task, context, deviceEvent);
}
@ -1233,4 +1290,10 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
@Override
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {}
@Override
public void onMusicListReq() {}
@Override
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {}
}

View File

@ -108,7 +108,6 @@ public abstract class AbstractHeadphoneDeviceSupport extends AbstractSerialDevic
@Override
public void onSendConfiguration(String config) {
LOG.warn("ONSENDCONFIGURATION");
if (PREF_SPEAK_NOTIFICATIONS_FOCUS_EXCLUSIVE.equals(config)) {
final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
gbTextToSpeech.setAudioFocus(prefs.getBoolean(PREF_SPEAK_NOTIFICATIONS_FOCUS_EXCLUSIVE, false) ?

View File

@ -87,6 +87,7 @@ import nodomain.freeyourgadget.gadgetbridge.externalevents.TinyWeatherForecastGe
import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationService;
import nodomain.freeyourgadget.gadgetbridge.externalevents.sleepasandroid.SleepAsAndroidReceiver;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
@ -1137,6 +1138,16 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
}
deviceSupport.onCameraStatusChange(event, filename);
break;
case ACTION_REQUEST_MUSIC_LIST:
deviceSupport.onMusicListReq();
break;
case ACTION_REQUEST_MUSIC_OPERATION:
int operation = intentCopy.getIntExtra("operation", -1);
int playlistIndex = intentCopy.getIntExtra("playlistIndex", -1);
String playlistName = intentCopy.getStringExtra("playlistName");
ArrayList<Integer> musics = (ArrayList<Integer>) intentCopy.getSerializableExtra("musicIds");
deviceSupport.onMusicOperation(operation, playlistIndex, playlistName, musics);
break;
}
}

View File

@ -34,6 +34,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
@ -524,4 +525,20 @@ public class ServiceDeviceSupport implements DeviceSupport {
}
delegate.onCameraStatusChange(event, filename);
}
@Override
public void onMusicListReq() {
if (checkBusy("music list request")) {
return;
}
delegate.onMusicListReq();
}
@Override
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
if (checkBusy("music operation")) {
return;
}
delegate.onMusicOperation(operation, playlistIndex, playlistName, musicIds);
}
}

View File

@ -50,6 +50,10 @@ public class BandWBLEProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
sendRequest(builder, (byte) 0x03, (byte) 0x03);
}
public void requestWearSensorEnabled(final TransactionBuilder builder) {
sendRequest(builder, (byte) 0x0a, (byte) 0x01);
}
public void setAncModeState(final TransactionBuilder builder, final boolean mode) throws IOException {
BandWPSeriesRequest req = new BandWPSeriesRequest((byte) 0x03, (byte) 0x02).addToPayload(mode ? ANC_MODE_ON : ANC_MODE_OFF);
builder.write(getCharacteristic(UUID_RPC_REQUEST_CHARACTERISTIC), req.finishAndGetBytes());
@ -65,6 +69,11 @@ public class BandWBLEProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
builder.write(getCharacteristic(UUID_RPC_REQUEST_CHARACTERISTIC), req.finishAndGetBytes());
}
public void setWearSensorEnabled(final TransactionBuilder builder, final boolean mode) throws IOException {
BandWPSeriesRequest req = new BandWPSeriesRequest((byte) 0x0a, (byte) 0x02).addToPayload(mode);
builder.write(getCharacteristic(UUID_RPC_REQUEST_CHARACTERISTIC), req.finishAndGetBytes());
}
private void sendRequest(final TransactionBuilder builder, byte namespace, byte commandID) {
BandWPSeriesRequest req;
try {

View File

@ -4,6 +4,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BANDW_PSERIES_GUI_VPT_LEVEL;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BANDW_PSERIES_VPT_ENABLED;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BANDW_PSERIES_VPT_LEVEL;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEAR_SENSOR_TOGGLE;
import static nodomain.freeyourgadget.gadgetbridge.impl.GBDevice.BATTERY_UNKNOWN;
import static nodomain.freeyourgadget.gadgetbridge.service.devices.bandwpseries.BandWBLEProfile.ANC_MODE_ON;
@ -78,6 +79,7 @@ public class BandWPSeriesDeviceSupport extends AbstractBTLEDeviceSupport {
BandWBLEProfile.requestAncModeState(builder);
BandWBLEProfile.requestVptEnabled(builder);
BandWBLEProfile.requestVptLevel(builder);
BandWBLEProfile.requestWearSensorEnabled(builder);
return builder;
}
@ -129,6 +131,12 @@ public class BandWPSeriesDeviceSupport extends AbstractBTLEDeviceSupport {
if (response.commandId == 0x17) {
return handleBatteryLevels(response);
}
} else if (response.namespace == 0x0a) {
if (response.commandId == 0x01) {
return handleGetWearSensorEnabledResponse(response);
} else if (response.commandId == 0x02) {
return getBooleanResponseStatus(response);
}
}
return true;
}
@ -168,6 +176,24 @@ public class BandWPSeriesDeviceSupport extends AbstractBTLEDeviceSupport {
return true;
}
private boolean handleGetWearSensorEnabledResponse(BandWPSeriesResponse response) {
if (!response.messageType.hasPayload) {
GB.toast("No payload in response!", Toast.LENGTH_SHORT, GB.ERROR);
return false;
}
boolean wearSensorEnabled;
try {
wearSensorEnabled = response.getPayloadBoolean();
} catch (IOException e) {
GB.toast("Failed to unpack wear sensor status from payload " + Arrays.toString(response.payload), Toast.LENGTH_SHORT, GB.ERROR);
return false;
}
Editor editor = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).edit();
editor.putBoolean(PREF_WEAR_SENSOR_TOGGLE, wearSensorEnabled);
editor.apply();
return true;
}
private boolean handleFirmwareVersionResponse(BandWPSeriesResponse response) {
String firmwareString = response.getPayloadString();
if (firmwareString == null) {
@ -249,6 +275,10 @@ public class BandWPSeriesDeviceSupport extends AbstractBTLEDeviceSupport {
BandWBLEProfile.setVptLevel(builder, level - 1);
}
break;
case PREF_WEAR_SENSOR_TOGGLE:
boolean wearSensorEnabled = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(PREF_WEAR_SENSOR_TOGGLE, true);
BandWBLEProfile.setWearSensorEnabled(builder, wearSensorEnabled);
break;
}
performImmediately(builder);
} catch (IOException e) {

View File

@ -77,4 +77,8 @@ public class BandWPSeriesResponse {
}
return values;
}
public boolean getPayloadBoolean() throws IOException{
return payloadUnpacker.unpackBoolean();
}
}

View File

@ -300,7 +300,7 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
// If not a call or email, check the sender and if null, promote the title and message preview
// as subtitle
if (showMessagePreview && icon != CasioConstants.CATEGORY_INCOMING_CALL && icon != CasioConstants.CATEGORY_EMAIL) {
if (!StringUtils.isNullOrEmpty(sender)) {
if (StringUtils.isNullOrEmpty(sender)) {
// Shift title to sender slot
sender = title;
}

View File

@ -6,6 +6,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.baseTypes
public class FieldDefinitionTemperature extends FieldDefinition {
public FieldDefinitionTemperature(int localNumber, int size, BaseType baseType, String name) {
// #4313 - We do a "wrong" conversion to celsius on purpose
super(localNumber, size, baseType, name, 1, -273);
}

View File

@ -273,7 +273,8 @@ public class WeatherHandler {
return new WeatherValue(kelvin, "KELVIN");
case "CELSIUS":
default:
return new WeatherValue(kelvin - 273.15, "CELSIUS");
// #4313 - We do a "wrong" conversion to celsius on purpose
return new WeatherValue(kelvin - 273, "CELSIUS");
}
}

View File

@ -30,6 +30,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.model.Contact;
@ -198,4 +199,14 @@ public class HuaweiBRSupport extends AbstractBTBRDeviceSupport {
public void onTestNewFunction() {
supportProvider.onTestNewFunction();
}
@Override
public void onMusicListReq() {
supportProvider.onMusicListReq();
}
@Override
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
supportProvider.onMusicOperation(operation, playlistIndex, playlistName, musicIds);
}
}

View File

@ -33,6 +33,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.model.Contact;
@ -214,4 +215,14 @@ public class HuaweiLESupport extends AbstractBTLEDeviceSupport {
public boolean getSendWriteRequestResponse() {
return false;
}
@Override
public void onMusicListReq() {
supportProvider.onMusicListReq();
}
@Override
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
supportProvider.onMusicOperation(operation, playlistIndex, playlistName, musicIds);
}
}

View File

@ -1,11 +1,28 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei;
import android.widget.Toast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceMusicData;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceMusicUpdate;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiMusicUtils;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.MusicControl;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusicPlaylist;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetMusicInfoParams;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetMusicList;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetMusicPlaylist;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetMusicPlaylistMusics;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendMusicOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendUploadMusicFileInfoResponse;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class HuaweiMusicManager {
static Logger LOG = LoggerFactory.getLogger(HuaweiMusicManager.class);
@ -125,4 +142,236 @@ public class HuaweiMusicManager {
LOG.error("Could not send sendUploadMusicFileInfoResponse", e);
}
}
private boolean syncMusicData = false;
private int frameCount = 0;
private int endFrame = 65535;
private int currentFrame = 0;
public void startSyncMusicData() {
syncMusicData = true;
try {
GetMusicInfoParams getMusicInfoParams = new GetMusicInfoParams(this.support);
getMusicInfoParams.doPerform();
} catch (IOException e) {
LOG.error("Get music info: {}", e.getMessage());
syncMusicData = false;
}
}
private void syncMusicList() {
if (!syncMusicData) {
this.currentFrame = 0;
return;
}
int count = this.frameCount;
if (support.getHuaweiCoordinator().supportsMoreMusic()) {
count = Math.min(this.frameCount, 250);
}
if (this.currentFrame < count) {
try {
GetMusicList getMusicList = new GetMusicList(this.support, this.currentFrame, this.endFrame);
getMusicList.doPerform();
} catch (IOException e) {
LOG.error("Get music list: {}", e.getMessage());
endMusicListSync();
}
} else {
endMusicListSync();
}
}
private void endMusicListSync() {
this.currentFrame = 0;
try {
GetMusicPlaylist getMusicPlaylist = new GetMusicPlaylist(this.support);
getMusicPlaylist.doPerform();
} catch (IOException e) {
LOG.error("Get music playlist: {}", e.getMessage());
endMusicPlaylistSync();
}
}
private void endMusicPlaylistSync() {
this.currentPlaylistIndex = 0;
this.currentPlaylistFrame = 0;
tempPlaylistMusic.clear();
musicPlaylistMusicSync();
}
private final List<MusicControl.MusicPlaylists.Response.PlaylistData> devicePlaylists = new ArrayList<>();
private int currentPlaylistIndex = 0;
private int currentPlaylistFrame = 0;
private final List<List<Integer>> tempPlaylistMusic = new ArrayList<>();
private void musicPlaylistMusicSync() {
if (this.currentPlaylistIndex < devicePlaylists.size()) {
MusicControl.MusicPlaylists.Response.PlaylistData playlist = devicePlaylists.get(this.currentPlaylistIndex);
syncPlaylistMusicsOne(playlist.id, playlist.frameCount);
} else {
musicPlaylistMusicDone();
}
}
private void syncPlaylistMusicsOne(int id, int frameCount) {
if (this.currentPlaylistFrame < frameCount) {
try {
GetMusicPlaylistMusics getMusicPlaylistMusics = new GetMusicPlaylistMusics(this.support, id, this.currentPlaylistFrame);
getMusicPlaylistMusics.doPerform();
} catch (IOException e) {
LOG.error("Get music playlist musics: {}", e.getMessage());
musicPlaylistMusicDone();
}
} else {
syncPlayListMusicIndexDone(id, frameCount);
}
}
public void syncNextPlaylistMusicIndex() {
this.currentPlaylistFrame++;
MusicControl.MusicPlaylists.Response.PlaylistData playlist = devicePlaylists.get(this.currentPlaylistIndex);
syncPlaylistMusicsOne(playlist.id, playlist.frameCount);
}
private void syncPlayListMusicIndexDone(int id, int frameCount) {
MusicControl.MusicPlaylists.Response.PlaylistData playlist = devicePlaylists.get(this.currentPlaylistIndex);
ArrayList<Integer> musics = new ArrayList<>();
if (this.tempPlaylistMusic.size() == frameCount) {
for (int i = 0; i < frameCount; i++) {
musics.addAll(this.tempPlaylistMusic.get(i));
}
}
GBDeviceMusicPlaylist pl = new GBDeviceMusicPlaylist(playlist.id, playlist.name, musics);
List<GBDeviceMusicPlaylist> list = new ArrayList<>();
list.add(pl);
sendMusicPlaylist(list);
this.currentPlaylistIndex++;
this.currentPlaylistFrame = 0;
this.tempPlaylistMusic.clear();
musicPlaylistMusicSync();
}
private void musicPlaylistMusicDone() {
this.currentPlaylistIndex = 0;
this.currentPlaylistFrame = 0;
this.tempPlaylistMusic.clear();
this.syncMusicData = false;
sendMusicSyncDone();
}
public void onMusicMusicInfoParams(HuaweiMusicUtils.MusicCapabilities capabilities, int frameCount, List<HuaweiMusicUtils.PageStruct> pageStruct) {
//TODO: research and use pageStruct. It may/should be used to retrieve music data from devices by pages.
// without it list can be incomplete, but I can't confirm this.
LOG.info("FrameCount: {}, pageStruct: {}", frameCount, pageStruct);
support.getHuaweiCoordinator().setMusicInfoParams(capabilities);
if(syncMusicData) {
this.frameCount = frameCount;
this.currentFrame = 0;
this.endFrame = 65535;
String formats = null;
if(capabilities.supportedFormats != null) {
formats = String.join(",", capabilities.supportedFormats);
}
int maxPlaylistCount = 0;
if(support.getCoordinator().getHuaweiCoordinator().getExtendedMusicInfoParams() != null) {
maxPlaylistCount = support.getCoordinator().getHuaweiCoordinator().getExtendedMusicInfoParams().maxPlaylistCount;
}
sendMusicSyncStart(support.getContext().getString(R.string.music_huawei_device_info, formats, capabilities.availableSpace), capabilities.maxMusicCount, maxPlaylistCount);
syncMusicList();
}
}
private void sendMusicSyncStart(final String info, int maxMusicCount, int maxPlaylistCount) {
final GBDeviceMusicData musicListCmd = new GBDeviceMusicData();
musicListCmd.type = 1;
musicListCmd.deviceInfo = info;
musicListCmd.maxMusicCount = maxMusicCount;
musicListCmd.maxPlaylistCount = maxPlaylistCount;
support.evaluateGBDeviceEvent(musicListCmd);
}
private void sendMusicList(List<GBDeviceMusic> list) {
final GBDeviceMusicData musicListCmd = new GBDeviceMusicData();
musicListCmd.type = 2;
musicListCmd.list = list;
support.evaluateGBDeviceEvent(musicListCmd);
}
private void sendMusicPlaylist(List<GBDeviceMusicPlaylist> list) {
final GBDeviceMusicData musicListCmd = new GBDeviceMusicData();
musicListCmd.type = 2;
musicListCmd.playlists = list;
support.evaluateGBDeviceEvent(musicListCmd);
}
private void sendMusicSyncDone() {
final GBDeviceMusicData musicListCmd = new GBDeviceMusicData();
musicListCmd.type = 10;
support.evaluateGBDeviceEvent(musicListCmd);
}
public void onMusicListResponse(int startFrame, int endFrame, List<GBDeviceMusic> list) {
sendMusicList(list);
if (support.getHuaweiCoordinator().supportsMoreMusic() || !(endFrame == this.endFrame || list.size() == 1)) {
if (list.size() == 2) {
this.endFrame = list.get(1).getId();
}
this.currentFrame++;
syncMusicList();
return;
}
endMusicListSync();
}
public void onMusicPlaylistResponse(List<MusicControl.MusicPlaylists.Response.PlaylistData> playlists) {
this.devicePlaylists.clear();
for(MusicControl.MusicPlaylists.Response.PlaylistData pl: playlists) {
if(pl.id != 0) {
this.devicePlaylists.add(pl);
}
}
endMusicPlaylistSync();
}
public void onMusicPlaylistMusics(int id, int index, List<Integer> musicIds) {
this.tempPlaylistMusic.add(musicIds);
syncNextPlaylistMusicIndex();
}
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
LOG.info("music operation: {}", operation);
try {
SendMusicOperation sendMusicOperation = new SendMusicOperation(this.support, operation, playlistIndex, playlistName, musicIds);
sendMusicOperation.doPerform();
} catch (IOException e) {
LOG.error("SendMusicOperation: {}", e.getMessage());
}
}
public void onMusicOperationResponse(int resultCode, int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
boolean success = true;
if (resultCode != 0x000186A0) {
GB.toast(support.getContext(), support.getContext().getString(R.string.music_error), Toast.LENGTH_SHORT, GB.ERROR);
success = false;
}
LOG.info("music operation response: {} {}", operation, success);
final GBDeviceMusicUpdate updateCmd = new GBDeviceMusicUpdate();
updateCmd.success = success;
updateCmd.operation = operation;
updateCmd.playlistIndex = playlistIndex;
updateCmd.playlistName = playlistName;
updateCmd.musicIds = musicIds;
support.evaluateGBDeviceEvent(updateCmd);
}
}

View File

@ -50,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceMusicData;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinator;
@ -124,6 +125,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.Send
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendFitnessUserInfoRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendGpsDataRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendFileUploadInfo;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendHeartRateZonesConfig;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendRunPaceConfigRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendSetContactsRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendNotifyHeartRateCapabilityRequest;
@ -833,6 +835,7 @@ public class HuaweiSupportProvider {
initRequestQueue.add(new SendFitnessUserInfoRequest(this));
initRequestQueue.add(new SendRunPaceConfigRequest(this));
initRequestQueue.add(new SendDeviceReportThreshold(this));
initRequestQueue.add(new SendHeartRateZonesConfig(this));
initRequestQueue.add(new SetMediumToStrengthThresholdRequest(this));
initRequestQueue.add(new SendFitnessGoalRequest(this));
initRequestQueue.add(new GetNotificationCapabilitiesRequest(this));
@ -2529,4 +2532,12 @@ public class HuaweiSupportProvider {
callback
), true);
}
public void onMusicListReq() {
getHuaweiMusicManager().startSyncMusicData();
}
public void onMusicOperation(int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
getHuaweiMusicManager().onMusicOperation(operation, playlistIndex, playlistName, musicIds);
}
}

View File

@ -39,6 +39,6 @@ public class GetMusicInfoParams extends Request {
throw new Request.ResponseTypeMismatchException(receivedPacket, MusicControl.MusicInfoParams.Response.class);
MusicControl.MusicInfoParams.Response resp = (MusicControl.MusicInfoParams.Response)(receivedPacket);
supportProvider.getHuaweiCoordinator().setMusicInfoParams(resp.params);
supportProvider.getHuaweiMusicManager().onMusicMusicInfoParams(resp.params, resp.frameCount, resp.pageStruct);
}
}

View File

@ -0,0 +1,45 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.MusicControl;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class GetMusicList extends Request {
private final Logger LOG = LoggerFactory.getLogger(GetMusicList.class);
private final int startFrame;
private final int endFrame;
public GetMusicList(HuaweiSupportProvider support, int startFrame, int endFrame) {
super(support);
this.serviceId = MusicControl.id;
this.commandId = MusicControl.MusicList.id;
this.startFrame = startFrame;
this.endFrame = endFrame;
}
@Override
protected List<byte[]> createRequest() throws Request.RequestCreationException {
try {
return new MusicControl.MusicList.Request(paramsProvider, (short) this.startFrame, (short) this.endFrame).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new Request.RequestCreationException(e);
}
}
@Override
protected void processResponse() throws Request.ResponseParseException {
LOG.info("MusicControl.MusicList processResponse");
if (!(receivedPacket instanceof MusicControl.MusicList.Response))
throw new Request.ResponseTypeMismatchException(receivedPacket, MusicControl.MusicList.Response.class);
MusicControl.MusicList.Response resp = (MusicControl.MusicList.Response) (receivedPacket);
supportProvider.getHuaweiMusicManager().onMusicListResponse(resp.startFrame, resp.endIndex, resp.musicList);
}
}

View File

@ -0,0 +1,39 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.MusicControl;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class GetMusicPlaylist extends Request {
private final Logger LOG = LoggerFactory.getLogger(GetMusicPlaylist.class);
public GetMusicPlaylist(HuaweiSupportProvider support) {
super(support);
this.serviceId = MusicControl.id;
this.commandId = MusicControl.MusicPlaylists.id;
}
@Override
protected List<byte[]> createRequest() throws Request.RequestCreationException {
try {
return new MusicControl.MusicPlaylists.Request(paramsProvider).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new Request.RequestCreationException(e);
}
}
@Override
protected void processResponse() throws Request.ResponseParseException {
LOG.info("MusicControl.MusicPlaylists processResponse");
if (!(receivedPacket instanceof MusicControl.MusicPlaylists.Response))
throw new Request.ResponseTypeMismatchException(receivedPacket, MusicControl.MusicPlaylists.Response.class);
MusicControl.MusicPlaylists.Response resp = (MusicControl.MusicPlaylists.Response) (receivedPacket);
supportProvider.getHuaweiMusicManager().onMusicPlaylistResponse(resp.playlists);
}
}

View File

@ -0,0 +1,44 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.MusicControl;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class GetMusicPlaylistMusics extends Request {
private final Logger LOG = LoggerFactory.getLogger(GetMusicPlaylistMusics.class);
private final int playlist;
private final int index;
public GetMusicPlaylistMusics(HuaweiSupportProvider support, int playlist, int index) {
super(support);
this.serviceId = MusicControl.id;
this.commandId = MusicControl.MusicPlaylistMusics.id;
this.playlist = playlist;
this.index = index;
}
@Override
protected List<byte[]> createRequest() throws Request.RequestCreationException {
try {
return new MusicControl.MusicPlaylistMusics.Request(paramsProvider, (short) playlist, (short) index).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new Request.RequestCreationException(e);
}
}
@Override
protected void processResponse() throws Request.ResponseParseException {
LOG.info("MusicControl.GetMusicPlaylistMusics processResponse");
if (!(receivedPacket instanceof MusicControl.MusicPlaylistMusics.Response))
throw new Request.ResponseTypeMismatchException(receivedPacket, MusicControl.MusicPlaylistMusics.Response.class);
MusicControl.MusicPlaylistMusics.Response resp = (MusicControl.MusicPlaylistMusics.Response) (receivedPacket);
supportProvider.getHuaweiMusicManager().onMusicPlaylistMusics(resp.id, resp.index, resp.musicIds);
}
}

View File

@ -0,0 +1,57 @@
/* Copyright (C) 2024 Martin.JM
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.service.devices.huawei.requests;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HeartRateZonesConfig;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.FitnessData;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class SendHeartRateZonesConfig extends Request {
public SendHeartRateZonesConfig(HuaweiSupportProvider support) {
super(support);
this.serviceId = FitnessData.id;
this.commandId = supportProvider.getHuaweiCoordinator().supportsExtendedHeartRateZones() ?
FitnessData.HeartRateZoneConfigPacket.id_extended :
FitnessData.HeartRateZoneConfigPacket.id_simple;
}
@Override
protected boolean requestSupported() {
return
!supportProvider.getHuaweiCoordinator().supportsTrack() && // In this case it uses P2P
supportProvider.getHuaweiCoordinator().supportsHeartRateZones();
}
@Override
protected List<byte[]> createRequest() throws RequestCreationException {
try {
HeartRateZonesConfig heartRateZonesConfig = new HeartRateZonesConfig(HeartRateZonesConfig.TYPE_UPRIGHT, new ActivityUser().getAge());
if (supportProvider.getHuaweiCoordinator().supportsExtendedHeartRateZones()) {
return FitnessData.HeartRateZoneConfigPacket.Request.requestExtended(paramsProvider, heartRateZonesConfig).serialize();
} else {
return FitnessData.HeartRateZoneConfigPacket.Request.requestSimple(paramsProvider, heartRateZonesConfig).serialize();
}
} catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e);
}
}
}

View File

@ -0,0 +1,51 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.MusicControl;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class SendMusicOperation extends Request {
private static final Logger LOG = LoggerFactory.getLogger(SendMusicOperation.class);
private final int operation;
private final int playlistIndex;
private final String playlistName;
private final ArrayList<Integer> musicIds;
public SendMusicOperation(HuaweiSupportProvider support, int operation, int playlistIndex, String playlistName, ArrayList<Integer> musicIds) {
super(support);
this.serviceId = MusicControl.id;
this.commandId = MusicControl.MusicOperation.id;
this.operation = operation;
this.playlistIndex = playlistIndex;
this.playlistName = playlistName;
this.musicIds = musicIds;
}
@Override
protected List<byte[]> createRequest() throws Request.RequestCreationException {
try {
return new MusicControl.MusicOperation.Request(paramsProvider, operation, playlistIndex, playlistName, musicIds).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new Request.RequestCreationException(e);
}
}
@Override
protected void processResponse() throws ResponseTypeMismatchException {
LOG.debug("handle Music Operation");
if (!(receivedPacket instanceof MusicControl.MusicOperation.Response))
throw new Request.ResponseTypeMismatchException(receivedPacket, MusicControl.MusicOperation.Response.class);
MusicControl.MusicOperation.Response resp = (MusicControl.MusicOperation.Response) (receivedPacket);
supportProvider.getHuaweiMusicManager().onMusicOperationResponse(resp.resultCode, resp.operation, resp.playlistIndex, resp.playlistName, resp.musicIds);
}
}

View File

@ -0,0 +1,75 @@
/* Copyright (C) 2024 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.service.devices.oppo;
import static nodomain.freeyourgadget.gadgetbridge.util.GB.hexdump;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.btclassic.BtClassicIoThread;
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
public class OppoHeadphonesIoThread extends BtClassicIoThread {
private static final Logger LOG = LoggerFactory.getLogger(OppoHeadphonesIoThread.class);
private final OppoHeadphonesProtocol mProtocol;
public OppoHeadphonesIoThread(final GBDevice gbDevice,
final Context context,
final OppoHeadphonesProtocol deviceProtocol,
final AbstractSerialDeviceSupport deviceSupport,
final BluetoothAdapter btAdapter) {
super(gbDevice, context, deviceProtocol, deviceSupport, btAdapter);
this.mProtocol = deviceProtocol;
}
@NonNull
@Override
protected UUID getUuidToConnect(@NonNull final ParcelUuid[] uuids) {
return UUID.fromString("0000079a-d102-11e1-9b23-00025b00a5a5");
}
@Override
protected void initialize() {
write(mProtocol.encodeFirmwareVersionReq());
write(mProtocol.encodeConfigurationReq());
write(mProtocol.encodeBatteryReq());
setUpdateState(GBDevice.State.INITIALIZED);
}
@Override
protected byte[] parseIncoming(final InputStream inStream) throws IOException {
final byte[] buffer = new byte[1048576]; //HUGE read
final int bytes = inStream.read(buffer);
// FIXME: We should buffer this and handle partial commands
LOG.debug("Read {} bytes: {}", bytes, hexdump(buffer, 0, bytes));
return Arrays.copyOf(buffer, bytes);
}
}

View File

@ -0,0 +1,355 @@
/* Copyright (C) 2024 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.service.devices.oppo;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.devices.oppo.OppoHeadphonesPreferences;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.OppoCommand;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigSide;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.oppo.commands.TouchConfigValue;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
public class OppoHeadphonesProtocol extends GBDeviceProtocol {
private static final Logger LOG = LoggerFactory.getLogger(OppoHeadphonesProtocol.class);
public static final byte CMD_PREAMBLE = (byte) 0xaa;
private int seqNum = 0;
protected OppoHeadphonesProtocol(final GBDevice device) {
super(device);
}
@Override
public GBDeviceEvent[] decodeResponse(final byte[] responseData) {
final List<GBDeviceEvent> events = new ArrayList<>();
int i = 0;
while (i < responseData.length) {
if (responseData[i] != CMD_PREAMBLE) {
LOG.warn("Unexpected preamble {}", responseData[i]);
i++;
continue;
}
final int totalLength = responseData[i + 1] & 0xff;
if (responseData.length - i < totalLength + 2) {
LOG.error("Got partial response with {} bytes, expected {}", responseData.length - i, totalLength + 2);
break;
}
final byte[] singleResponse = ArrayUtils.subarray(responseData, i, i + totalLength + 3);
events.addAll(handleSingleResponse(singleResponse));
i += totalLength + 2;
}
return events.toArray(new GBDeviceEvent[0]);
}
private static List<GBDeviceEvent> handleSingleResponse(final byte[] responseData) {
final List<GBDeviceEvent> events = new ArrayList<>();
final ByteBuffer responseBuf = ByteBuffer.wrap(responseData).order(ByteOrder.LITTLE_ENDIAN);
final byte preamble = responseBuf.get();
if (preamble != CMD_PREAMBLE) {
LOG.error("Unexpected preamble {}", preamble);
return Collections.emptyList();
}
final byte totalLength = responseBuf.get();
if (responseData.length != totalLength + 2) {
LOG.error("Invalid number of bytes {}, expected {}", responseData.length, totalLength + 2);
return Collections.emptyList();
}
final short zero = responseBuf.getShort();
if (zero != 0 && zero != 4) {
// 0 on oppo, 4 on realme?
LOG.warn("Unexpected bytes: {}, expected 0 or 4", zero);
}
final short code = responseBuf.getShort();
final OppoCommand command = OppoCommand.fromCode(code);
if (command == null) {
LOG.warn("Unknown command code {}", String.format(Locale.ROOT, "0x%04x", code));
return Collections.emptyList();
}
final int seq = responseBuf.get();
final short payloadLength = responseBuf.getShort();
final byte[] payload = new byte[payloadLength];
responseBuf.get(payload);
switch (command) {
case BATTERY_RET: {
if (payload[0] != 0) {
LOG.error("Unknown battery ret {}", payload[0]);
break;
}
events.addAll(parseBattery(payload));
break;
}
case DEVICE_INFO: {
switch (payload[0]) {
case 1: // battery
events.addAll(parseBattery(payload));
break;
case 2: // status
LOG.debug("Got status");
// TODO handle
break;
default:
LOG.warn("Unknown device info {}", payload[0]);
}
break;
}
case FIRMWARE_RET: {
if (payload[0] != 0) {
LOG.warn("Unexpected firmware ret {}", payload[0]);
break;
}
final String fwString;
if (payload[payload.length - 1] == 0) {
fwString = new String(ArrayUtils.subarray(payload, 2, payload.length - 1)).strip();
} else {
fwString = new String(ArrayUtils.subarray(payload, 2, payload.length - 2)).strip();
}
final String[] parts = fwString.split(",");
if (parts.length % 3 != 0) {
LOG.warn("Fw parts length {} from '{}' is not divisible by 3", parts.length, fwString);
break;
}
final String[] fwVersionParts = new String[3];
for (int i = 0; i < parts.length; i += 3) {
final String versionPart = parts[i];
final String versionType = parts[i + 1];
final String version = parts[i + 2];
if (!"2".equals(versionType)) {
continue; // not fw
}
switch (versionPart) {
case "1":
fwVersionParts[0] = version;
break;
case "2":
fwVersionParts[1] = version;
break;
case "3":
fwVersionParts[2] = version;
break;
default:
LOG.warn("Unknown firmware version part {}", versionPart);
}
}
final List<String> nonNullParts = new ArrayList<>(fwVersionParts.length);
for (int i = 0; i < fwVersionParts.length; i++) {
if (fwVersionParts[i] == null) {
continue;
}
nonNullParts.add(fwVersionParts[i]);
if (fwVersionParts[i].contains(".")) {
// Realme devices have the version already with the dots, repeated multiple times
break;
}
}
final String fwVersion = String.join(".", nonNullParts);
final GBDeviceEventVersionInfo eventVersionInfo = new GBDeviceEventVersionInfo();
eventVersionInfo.fwVersion = fwVersion;
eventVersionInfo.hwVersion = GBApplication.getContext().getString(R.string.n_a);
events.add(eventVersionInfo);
LOG.debug("Got fw version: {}", fwVersion);
break;
}
case FIND_DEVICE_ACK: {
LOG.debug("Got find device ack, status={}", payload[0]);
break;
}
case TOUCH_CONFIG_RET: {
if (payload[0] != 0) {
LOG.warn("Unknown config ret {}", payload[0]);
break;
}
if ((payload.length - 2) % 4 != 0) {
LOG.warn("Unexpected config ret payload size {}", payload.length);
break;
}
final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences();
for (int i = 2; i < payload.length; i += 4) {
final int sideCode = payload[i] & 0xff;
final int typeCode = BLETypeConversions.toUint16(payload, i + 1);
final int valueCode = payload[i + 3] & 0xff;
final TouchConfigSide side = TouchConfigSide.fromCode(sideCode);
final TouchConfigType type = TouchConfigType.fromCode(typeCode);
final TouchConfigValue value = TouchConfigValue.fromCode(valueCode);
if (side == null) {
LOG.warn("Unknown side code {}", sideCode);
continue;
}
if (type == null) {
LOG.warn("Unknown type code {}", typeCode);
continue;
}
if (value == null) {
LOG.warn("Unknown value code {}", valueCode);
continue;
}
LOG.debug("Got touch config for {} {} = {}", side, type, value);
eventUpdatePreferences.withPreference(
OppoHeadphonesPreferences.getKey(side, type),
value.name().toLowerCase(Locale.ROOT)
);
}
events.add(eventUpdatePreferences);
break;
}
case TOUCH_CONFIG_ACK: {
LOG.debug("Got config ack, status={}", payload[0]);
break;
}
default:
LOG.warn("Unhandled command {}", command);
}
return events;
}
private static List<GBDeviceEvent> parseBattery(final byte[] payload) {
final List<GBDeviceEvent> events = new ArrayList<>();
final int numBatteries = payload[1] & 0xff;
for (int i = 2; i < payload.length; i += 2) {
if ((payload[i] & 0xff) == 0xff) {
continue;
}
final int batteryIndex = payload[i] - 1;
if (batteryIndex < 0 || batteryIndex > 2) {
LOG.error("Unknown battery index {}", payload[i]);
break;
}
final int batteryLevel = payload[i + 1] & 0x7f;
final BatteryState batteryState = (payload[i + 1] & 0x80) != 0 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL;
LOG.debug("Got battery {}: {}%, {}", batteryIndex, batteryLevel, batteryState);
final GBDeviceEventBatteryInfo eventBatteryInfo = new GBDeviceEventBatteryInfo();
eventBatteryInfo.batteryIndex = batteryIndex;
eventBatteryInfo.level = batteryLevel;
eventBatteryInfo.state = batteryState;
events.add(eventBatteryInfo);
}
return events;
}
@Override
public byte[] encodeFirmwareVersionReq() {
return encodeMessage(OppoCommand.FIRMWARE_GET, new byte[0]);
}
@Override
public byte[] encodeFindDevice(final boolean start) {
return encodeMessage(OppoCommand.FIND_DEVICE_REQ, new byte[]{(byte) (start ? 0x01 : 0x00)});
}
@Override
public byte[] encodeSendConfiguration(final String config) {
final DevicePrefs prefs = getDevicePrefs();
if (config.startsWith("oppo_touch__")) {
final String[] parts = config.split("__");
final TouchConfigSide side = TouchConfigSide.valueOf(parts[1].toUpperCase(Locale.ROOT));
final TouchConfigType type = TouchConfigType.valueOf(parts[2].toUpperCase(Locale.ROOT));
final String valueCode = prefs.getString(OppoHeadphonesPreferences.getKey(side, type), null);
if (valueCode == null) {
LOG.warn("Failed to get touch option value for {}/{}", side, type);
return super.encodeSendConfiguration(config);
}
final TouchConfigValue value = TouchConfigValue.valueOf(valueCode.toUpperCase(Locale.ROOT));
LOG.debug("Sending {} {} = {}", side, type, value);
final ByteBuffer buf = ByteBuffer.allocate(5).order(ByteOrder.LITTLE_ENDIAN);
buf.put((byte) 0x01);
buf.put((byte) side.getCode());
buf.putShort((short) type.getCode());
buf.put((byte) value.getCode());
return encodeMessage(OppoCommand.TOUCH_CONFIG_SET, buf.array());
}
return super.encodeSendConfiguration(config);
}
public byte[] encodeBatteryReq() {
return encodeMessage(OppoCommand.BATTERY_REQ, new byte[0]);
}
public byte[] encodeConfigurationReq() {
return encodeMessage(OppoCommand.TOUCH_CONFIG_REQ, new byte[]{0x02, 0x03, 0x01});
}
private byte[] encodeMessage(final OppoCommand command, final byte[] payload) {
final ByteBuffer buf = ByteBuffer.allocate(9 + payload.length).order(ByteOrder.LITTLE_ENDIAN);
buf.put(CMD_PREAMBLE);
buf.put((byte) (buf.limit() - 2));
buf.put((byte) 0);
buf.put((byte) 0);
buf.putShort(command.getCode());
buf.put((byte) seqNum++);
buf.putShort((short) payload.length);
buf.put(payload);
return buf.array();
}
}

View File

@ -0,0 +1,44 @@
/* Copyright (C) 2024 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.service.devices.oppo;
import nodomain.freeyourgadget.gadgetbridge.service.AbstractHeadphoneDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
public class OppoHeadphonesSupport extends AbstractHeadphoneDeviceSupport {
@Override
protected GBDeviceProtocol createDeviceProtocol() {
return new OppoHeadphonesProtocol(getDevice());
}
@Override
protected GBDeviceIoThread createDeviceIOThread() {
return new OppoHeadphonesIoThread(
getDevice(),
getContext(),
(OppoHeadphonesProtocol) getDeviceProtocol(),
OppoHeadphonesSupport.this,
getBluetoothAdapter()
);
}
@Override
public boolean useAutoConnect() {
return false;
}
}

View File

@ -0,0 +1,55 @@
/* Copyright (C) 2024 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.service.devices.oppo.commands;
import androidx.annotation.Nullable;
public enum OppoCommand {
BATTERY_REQ(0x0106),
BATTERY_RET(0x8106),
DEVICE_INFO(0x0204),
FIRMWARE_GET(0x0105),
FIRMWARE_RET(0x8105),
TOUCH_CONFIG_REQ(0x0108),
TOUCH_CONFIG_SET(0x0401),
TOUCH_CONFIG_RET(0x8108),
TOUCH_CONFIG_ACK(0x8401),
FIND_DEVICE_REQ(0x0400),
FIND_DEVICE_ACK(0x8400),
;
private final short code;
OppoCommand(final int code) {
this.code = (short) code;
}
public short getCode() {
return code;
}
@Nullable
public static OppoCommand fromCode(final short code) {
for (final OppoCommand cmd : OppoCommand.values()) {
if (cmd.code == code) {
return cmd;
}
}
return null;
}
}

View File

@ -0,0 +1,47 @@
/* Copyright (C) 2024 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.service.devices.oppo.commands;
import androidx.annotation.Nullable;
public enum TouchConfigSide {
LEFT(0x01),
RIGHT(0x02),
BOTH(0x04),
;
private final int code;
TouchConfigSide(final int code) {
this.code = code;
}
public int getCode() {
return code;
}
@Nullable
public static TouchConfigSide fromCode(final int code) {
for (final TouchConfigSide param : TouchConfigSide.values()) {
if (param.code == code) {
return param;
}
}
return null;
}
}

View File

@ -0,0 +1,48 @@
/* Copyright (C) 2024 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.service.devices.oppo.commands;
import androidx.annotation.Nullable;
public enum TouchConfigType {
UNK_1(0x0101),
TAP_2(0x0201),
TAP_3(0x0301),
HOLD(0x0401),
;
private final int code;
TouchConfigType(final int code) {
this.code = code;
}
public int getCode() {
return code;
}
@Nullable
public static TouchConfigType fromCode(final int code) {
for (final TouchConfigType param : TouchConfigType.values()) {
if (param.code == code) {
return param;
}
}
return null;
}
}

View File

@ -0,0 +1,53 @@
/* Copyright (C) 2024 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.service.devices.oppo.commands;
import androidx.annotation.Nullable;
public enum TouchConfigValue {
OFF(0x00),
PLAY_PAUSE(0x01),
VOICE_ASSISTANT(0x03), // oppo
VOICE_ASSISTANT_REALME(0x04),
PREVIOUS(0x05),
NEXT(0x06),
GAME_MODE(0x11),
VOLUME_UP(0x0B),
VOLUME_DOWN(0x0C),
;
private final int code;
TouchConfigValue(final int code) {
this.code = code;
}
public int getCode() {
return code;
}
@Nullable
public static TouchConfigValue fromCode(final int code) {
for (final TouchConfigValue param : TouchConfigValue.values()) {
if (param.code == code) {
return param;
}
}
return null;
}
}

View File

@ -105,7 +105,11 @@ public class XiaomiSppProtocolV2 extends AbstractXiaomiSppProtocol {
break;
case PACKET_TYPE_DATA:
XiaomiSppPacketV2.DataPacket dataPacket = (XiaomiSppPacketV2.DataPacket) decodedPacket;
support.onPacketReceived(dataPacket.getChannel(), dataPacket.getPayloadBytes(support.getAuthService()));
try {
support.onPacketReceived(dataPacket.getChannel(), dataPacket.getPayloadBytes(support.getAuthService()));
} catch (final Exception ex) {
LOG.error("Exception while handling received packet", ex);
}
// TODO: only directly ack protobuf packets, bulk ack others
sendAck(decodedPacket.getSequenceNumber());
break;

View File

@ -454,6 +454,9 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi
case 5:
headerSize = 6;
break;
case 6:
headerSize = 7;
break;
default:
LOG.warn("Unable to parse workout summary version {}", fileId.getVersion());
return null;

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M12.5,2.75A9.75,9.75 0,0 0,2.75 12.5A9.75,9.75 0,0 0,12.5 22.25A9.75,9.75 0,0 0,22.25 12.5A9.75,9.75 0,0 0,19.963 6.229L19.43,6.762A9,9 0,0 1,21.5 12.5A9,9 0,0 1,12.5 21.5A9,9 0,0 1,3.5 12.5A9,9 0,0 1,12.5 3.5A9,9 0,0 1,18.381 5.689L18.912,5.158A9.75,9.75 0,0 0,12.5 2.75zM12.5,5.5A7,7 0,0 0,5.5 12.5A7,7 0,0 0,12.5 19.5A7,7 0,0 0,19.5 12.5A7,7 0,0 0,18.008 8.184L17.475,8.717A6.25,6.25 0,0 1,18.75 12.5A6.25,6.25 0,0 1,12.5 18.75A6.25,6.25 0,0 1,6.25 12.5A6.25,6.25 0,0 1,12.5 6.25A6.25,6.25 0,0 1,16.43 7.641L16.963,7.107A7,7 0,0 0,12.5 5.5zM12.5,8.25A4.25,4.25 0,0 0,8.25 12.5A4.25,4.25 0,0 0,12.5 16.75A4.25,4.25 0,0 0,16.75 12.5A4.25,4.25 0,0 0,16.041 10.15L15.496,10.695A3.5,3.5 0,0 1,16 12.5A3.5,3.5 0,0 1,12.5 16A3.5,3.5 0,0 1,9 12.5A3.5,3.5 0,0 1,12.5 9A3.5,3.5 0,0 1,14.465 9.605L15.002,9.068A4.25,4.25 0,0 0,12.5 8.25z"
android:strokeWidth="1.0045"
android:fillColor="#000000"/>
<path
android:pathData="m20.275,2.754 l0.239,1.175 -8.365,8.365 0.707,0.707 8.365,-8.365 1.175,0.239L24.169,3.102 22.994,2.863 23.108,2.749 22.401,2.042 22.287,2.156 22.048,0.981Z"
android:strokeWidth="1.04456"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M12.5,4A8.5,8.5 0,0 0,4 12.5A8.5,8.5 0,0 0,12.5 21A8.5,8.5 0,0 0,21 12.5A8.5,8.5 0,0 0,12.5 4zM11,7A4,4 0,0 1,15 11A4,4 0,0 1,11 15A4,4 0,0 1,7 11A4,4 0,0 1,11 7z"
android:strokeWidth="1.02129"
android:fillColor="#000000"/>
<path
android:fillColor="#FF000000"
android:pathData="m8.846,8.891q0.49,-0.49 1.046,-0.56 0.556,-0.07 1.015,0.389 0.238,0.238 0.315,0.513 0.083,0.271 0.06,0.57 -0.029,0.294 -0.117,0.592 0.345,-0.113 0.682,-0.152 0.331,-0.044 0.634,0.04 0.308,0.079 0.579,0.35 0.497,0.497 0.457,1.124 -0.041,0.616 -0.599,1.173 -0.599,0.599 -1.199,0.646 -0.605,0.041 -1.108,-0.462 -0.271,-0.271 -0.365,-0.574 -0.089,-0.308 -0.056,-0.629 0.034,-0.321 0.137,-0.624 -0.437,0.105 -0.862,0.066 -0.425,-0.05 -0.79,-0.415 -0.304,-0.304 -0.362,-0.654 -0.064,-0.356 0.076,-0.717 0.14,-0.361 0.458,-0.679zM9.233,9.289q-0.287,0.287 -0.325,0.624 -0.039,0.326 0.238,0.602 0.204,0.204 0.431,0.254 0.232,0.044 0.488,-0.013 0.25,-0.062 0.526,-0.162 0.149,-0.393 0.161,-0.746 0.016,-0.359 -0.282,-0.657 -0.276,-0.276 -0.602,-0.238 -0.332,0.033 -0.634,0.336zM11.064,12.674q0.287,0.287 0.674,0.288 0.381,-0.005 0.782,-0.406 0.381,-0.381 0.391,-0.766 0.01,-0.397 -0.294,-0.701 -0.287,-0.287 -0.689,-0.262 -0.407,0.02 -0.905,0.231l-0.117,0.05q-0.189,0.499 -0.167,0.886 0.022,0.376 0.326,0.68z"
android:strokeWidth="0.633"/>
</vector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M12.5,4C7.806,4 4,7.806 4,12.5C4,17.194 7.806,21 12.5,21C17.194,21 21,17.194 21,12.5C21,7.806 17.194,4 12.5,4zM15.871,6.604A1.5,1.5 0,0 1,17.371 8.104A1.5,1.5 0,0 1,15.871 9.604A1.5,1.5 0,0 1,14.371 8.104A1.5,1.5 0,0 1,15.871 6.604zM18.018,10.33A1.5,1.5 0,0 1,19.518 11.83A1.5,1.5 0,0 1,18.018 13.33A1.5,1.5 0,0 1,16.518 11.83A1.5,1.5 0,0 1,18.018 10.33zM14.051,10.365A1.5,1.5 0,0 1,15.551 11.865A1.5,1.5 0,0 1,14.051 13.365A1.5,1.5 0,0 1,12.551 11.865A1.5,1.5 0,0 1,14.051 10.365z"
android:strokeWidth="1.02129"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M7,12A4,4 0,0 0,3 16A4,4 0,0 0,7 20L17,20A4,4 0,0 0,21 16A4,4 0,0 0,17 12L7,12zM3.5,15L20.5,15L20.5,17L3.5,17L3.5,15z"
android:strokeWidth="1.03322"
android:fillColor="#000000"/>
<path
android:pathData="M9.202,7.542 L7.286,11.542h1.5L9.993,9.022v0.02H18.167v-1.5H10.702,9.993Z"
android:strokeWidth="1.00035"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M12.756,8.485 L16.727,6.553 16.121,5.094 12.88,6.495 10.388,6.12c-0.3,-0.5 -0.84,-0.84 -1.46,-0.84 -0.18,0 -0.34,0.03 -0.5,0.08l-5.42,1.69v5.2h1.8V8.58l2.11,-0.66 -3.91,15.33h1.8l2.87,-8.11 2.33,3.11v5h1.8V16.84L9.318,12.3 10.351,8.294M11.008,5.05c1,0 1.8,-0.8 1.8,-1.8 0,-1 -0.8,-1.8 -1.8,-1.8 -1,0 -1.8,0.8 -1.8,1.8 0,1 0.8,1.8 1.8,1.8z"
android:fillColor="#000000"/>
<path
android:pathData="M17.902,5.203a0.909,3.182 78.761,1 0,6.242 -1.24a0.909,3.182 78.761,1 0,-6.242 1.24z"
android:strokeWidth="0.816497"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:fillColor="#FF000000"
android:pathData="m12,2c-1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2 1.1,0 2,-0.9 2,-2C14,2.9 13.1,2 12,2ZM3,7v2h6v4.571c1.563,0.297 3.731,0.466 6,0.467L15,9h6L21,7ZM9,14.488L9,22h2v-6h2v6h2v-7c-2.215,-0.001 -4.352,-0.183 -6,-0.512z"/>
<path
android:pathData="m15.302,10.783v0.5a8.3,1.5 0,0 1,8.035 1.498,8.3 1.5,0 0,1 -8.301,1.5 8.3,1.5 0,0 1,-8.301 -1.5,8.3 1.5,0 0,1 1.975,-0.967v-0.449a9,2 0,0 0,-2.674 1.416,9 2,0 0,0 9,2 9,2 0,0 0,9 -2,9 2,0 0,0 -8.734,-1.998z"
android:strokeWidth="1.28533"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M13.5,5.5c1.09,0 2,-0.92 2,-2 0,-1.12 -0.91,-2 -2,-2 -1.11,0 -2,0.88 -2,2 0,1.08 0.89,2 2,2M9.89,19.38l1,-4.38L13,17v6h2v-7.5l-2.11,-2 0.61,-3C14.79,12 16.79,13 19,13v-2c-1.91,0 -3.5,-1 -4.31,-2.42l-1,-1.58c-0.4,-0.62 -1,-1 -1.69,-1 -0.31,0 -0.5,0.08 -0.81,0.08L6,8.28V13h2V9.58l1.79,-0.7L8.19,17l-4.9,-1 -0.4,2 7,1.38z"
android:fillColor="#000000"/>
<path
android:pathData="m16.248,22.074v0.977c-0.008,0.16 -0.028,0.183 -0.116,0.27 -0.081,0.071 -0.185,0.084 -0.328,0.078h-4.578v0.699H15.828c0.355,-0.003 0.665,-0.036 0.889,-0.246 0.199,-0.241 0.239,-0.411 0.231,-0.793l0.002,-0.984z"
android:strokeWidth="1.07471"
android:fillColor="#000000"/>
<path
android:pathData="M3.346,19.328 L2.393,19.115c-0.155,-0.043 -0.172,-0.067 -0.238,-0.171 -0.051,-0.094 -0.042,-0.199 -0.005,-0.337L3.146,14.139 2.463,13.986 1.462,18.478c-0.074,0.348 -0.11,0.656 0.047,0.921 0.192,0.246 0.35,0.322 0.724,0.398l0.96,0.216z"
android:strokeWidth="1.07471"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M13.5,5.5c1.09,0 2,-0.92 2,-2 0,-1.12 -0.91,-2 -2,-2 -1.11,0 -2,0.88 -2,2 0,1.08 0.89,2 2,2M9.89,19.38l1,-4.38L13,17v6h2v-7.5l-2.11,-2 0.61,-3C14.79,12 16.79,13 19,13v-2c-1.91,0 -3.5,-1 -4.31,-2.42l-1,-1.58c-0.4,-0.62 -1,-1 -1.69,-1 -0.31,0 -0.5,0.08 -0.81,0.08L6,8.28V13h2V9.58l1.79,-0.7L8.19,17l-4.9,-1 -0.4,2 7,1.38z"
android:fillColor="#000000"/>
<path
android:pathData="M21.363,7.109L21.363,8.34L17.529,8.896L17.619,9.615L19.59,9.328L21.332,20.801L19.814,20.807L16.957,22.387L2.035,22.387L2.035,23.674L23.371,23.674L23.371,22.436L23.375,22.436L23.371,22.428L23.371,22.387L23.352,22.387L22.576,20.795L22.268,20.797L20.508,9.195L21.855,9L21.973,9L21.973,7.109L21.363,7.109z"
android:strokeWidth="1.07548"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,23 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25sp"
android:height="25sp"
android:tint="#7E7E7E"
android:viewportHeight="568.82"
android:viewportWidth="568.82">
<path
android:fillColor="#000000"
android:pathData="M482.6,292.64c55.21,-67.94 49.51,-155.85 43.68,-193.76c-1.61,-10.44 -9.37,-25.13 -16.76,-32.67C471.67,27.7 442.04,11.3 424.35,4.34c-9.83,-3.86 -11.5,0.2 -5.15,8.65c11.62,15.44 27.12,45.55 30.1,98.19c3.37,59.43 -20.72,132 -33.13,164.93c-3.73,9.89 -0.51,23.47 9.02,28.04C461.35,321.48 482.6,292.64 482.6,292.64z"/>
<path
android:fillColor="#000000"
android:pathData="M349.79,1.75c-53.17,10.91 -80.2,49.88 -84.01,78.21c-0.52,3.91 0.61,10.14 2.3,13.69c4.48,9.42 14.4,25.89 29.99,27.9c3.89,0.52 9.35,-2.37 12.16,-5.1c15.54,-15.01 64.22,-59.38 111.31,-74.26C421.54,42.2 407.58,-10.1 349.79,1.75z" />
<path
android:fillColor="#000000"
android:pathData="M137.16,211.18m-38.31,0a38.31,38.31 0,1 1,76.62 0a38.31,38.31 0,1 1,-76.62 0"/>
<path
android:fillColor="#000000"
android:pathData="M93.64,257.84l-50.9,91.48c-7.88,13.96 -2.97,31.75 10.83,39.6l102.88,62.07c3.62,2.06 8.86,6.9 11.22,10.38l7.76,11.43h-0.06c-63.28,4.78 -90.19,16.43 -101.61,25.34c-4.78,3.74 -7.37,10.9 -7.37,15.74v11.81c0,4.85 2.59,12.02 7.37,15.74c11.78,9.2 45.68,24.98 140.21,27.24c4.28,0.1 8.47,0.15 12.56,0.15c96.26,0 139.49,-27.71 153.59,-39.62c2.74,-2.31 4.31,-5.75 4.31,-9.41c0,-3.68 -1.57,-7.11 -4.31,-9.41c-13.41,-11.32 -54.35,-37.82 -144.55,-39.49l-6.61,-0.13l-15.99,-31.81c-2.63,-5.28 -8.3,-12.33 -12.89,-16.05l-75.74,-61.56c-1.54,-1.25 -1.87,-3.67 -0.72,-5.3l5.39,-7.66c3.55,3.63 8.73,6.07 13.59,6.07h112.66c0.74,0 2.15,-0.05 3.55,-0.39l37.33,47.7c1.88,2.41 4.7,3.67 7.53,3.67c2.06,0 4.14,-0.66 5.88,-2.04c4.16,-3.25 4.9,-9.27 1.64,-13.42l-86.06,-109.97c-3.26,-4.16 -9.27,-4.92 -13.42,-1.63c-4.16,3.25 -4.9,9.27 -1.63,13.42l27.23,34.79c-3.11,-0.67 -6.56,-1.03 -10.35,-1.03h-61.95c-7.67,0 -17.57,-2.07 -18.48,-3.7l-19.75,-44.19c-0.03,-0.07 -2.04,-3.7 -5.67,-6.83l11.83,4.66c0.83,1.21 1.29,2.04 1.31,2.07l15.14,33.8l3.37,-4.79c2.31,-3.25 2.73,-7.76 1.21,-11.62l43.44,-20.24c4.82,-2.54 9.95,-8.59 11.68,-13.71l28.43,-76.67c3.67,-9.9 0.49,-20.2 -7.12,-22.99c-7.6,-2.8 -16.79,2.94 -20.52,12.82l-26.3,69.67c-1.4,4.4 -6.43,8.75 -11.13,9.55l-39.55,12.28l-18.77,-10.64C105.78,249.47 97.89,250.32 93.64,257.84z"/>
</vector>

View File

@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="m13.5,5.5c1.09,0 2,-0.92 2,-2 0,-1.12 -0.91,-2 -2,-2 -1.11,0 -2,0.88 -2,2 0,1.08 0.89,2 2,2m-3.61,13.88 l1,-4.38 3.246,1.091 3.258,2.97 1.242,-1.477L15.417,14.553 12.89,13.5 13.5,10.5C14.79,12 16.79,13 19,13V11C17.09,11 15.5,10 14.69,8.58L13.69,7C13.29,6.38 12.69,6 12,6 11.69,6 11.5,6.08 11.19,6.08L6,8.28V13H8V9.58L9.79,8.88 8.19,17 3.29,16 2.89,18Z"
android:fillColor="#000000"/>
<path
android:pathData="M12.045,17.311h1.856v5.985h-1.856z"
android:fillColor="#000000"/>
<path
android:pathData="M6.629,22.689h7.879v1.174h-7.879z"
android:strokeWidth="1.06034"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M14.356,9.471 L19.887,7.805 19.032,6.592 12.327,8.432 7.26,10.363c-0.595,0.345 -0.988,1.024 -0.988,1.738 0,0.56 0.226,1.071 0.595,1.429l4.393,4.405c0.369,0.369 0.845,0.595 1.44,0.595 0.75,0 1.381,-0.393 1.75,-1.012l3.136,-3.723 5.271,-3.03 -0.72,-1.764 -6.337,2.652 -2.684,2.413 -2.798,-2.762M7.105,7.815c0,-1.19 -0.952,-2.143 -2.143,-2.143 -1.19,0 -2.143,0.952 -2.143,2.143 0,1.19 0.952,2.143 2.143,2.143 1.19,0 2.143,-0.952 2.143,-2.143z"
android:strokeWidth="1.19048"
android:fillColor="#000000"/>
<path
android:pathData="M1.023,18.977h23.75v1.174h-23.75z"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="45dp"
android:height="45dp"
android:tint="#7E7E7E"
android:viewportWidth="45"
android:viewportHeight="45">
<path
android:pathData="m21.918,3.78c-1.731,0 -3.118,1.386 -3.118,3.118 0,1.731 1.386,3.118 3.118,3.118 1.731,0 3.118,-1.386 3.118,-3.118 0,-1.731 -1.386,-3.118 -3.118,-3.118zM11.349,9.781C10.536,9.81 9.822,10.151 9.594,10.921L6.551,21.933c-0.613,2.321 4.201,3.793 4.95,1.464l2.884,-11.114c0.423,-1.465 -1.485,-2.557 -3.036,-2.502zM18.317,10.41c-0.312,0 -0.589,0.052 -0.866,0.139 -1.82,0.239 -2.614,4.433 -2.614,4.433l-2.715,13.063 4.052,12.985 3.199,-1.228 -3.221,-11.5 4.826,-0.775 2.363,7.234 2.624,-1.113 -2.446,-9.626 -5.018,-0.471 1.752,-5.953 3.999,2.332 4.812,-2.895 -1.226,-2.639 -3.146,1.844L20.846,11.864c-0.519,-0.866 -1.456,-1.454 -2.529,-1.454zM38.858,29.96 L38.818,4.143 30.079,4.223 27.439,10.934 30.943,18.349 29.482,20.019 29.317,24.488 26.055,28.006 26.603,34.446 21.053,37.344 20.478,41.411L38.858,41.521Z"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="m12.112,11.742h4.88V9.942h-3.62l-2,-3.33c-0.3,-0.5 -0.84,-0.84 -1.46,-0.84 -0.18,0 -0.34,0.03 -0.5,0.08l-5.42,1.69v5.2h1.8V9.072l2.11,-0.66 -3.635,14.469h1.8l2.595,-7.249 2.444,0.042 0,3.899h1.8l-0,-5.309 -2.604,-1.472 0.73,-2.87m0.96,-4.38c1,0 1.8,-0.8 1.8,-1.8 0,-1 -0.8,-1.8 -1.8,-1.8 -1,0 -1.8,0.8 -1.8,1.8 0,1 0.8,1.8 1.8,1.8z"
android:fillColor="#000000"/>
<path
android:pathData="m17.479,16.2 l0.042,1.796 -3.415,0.009 -0.011,1.803 -3.414,-0.015 0.038,1.807L7.3,21.6v1.4l-3.4,-0v1.047h6.412v0.014H20.9v-1.06H11.502L20.9,17.508v-1.308z"
android:strokeWidth="0.863186"
android:fillColor="#000000"/>
<path
android:pathData="M19.553,7.871h0.91v15.311h-0.91z"
android:strokeWidth="1.1438"
android:fillColor="#000000"/>
<path
android:pathData="M17.489,7.5l3.74,-0.805l0.232,1.076l-3.74,0.805z"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:tint="#7E7E7E"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="m12.112,11.742h4.88V9.942h-3.62l-2,-3.33c-0.3,-0.5 -0.84,-0.84 -1.46,-0.84 -0.18,0 -0.34,0.03 -0.5,0.08l-5.42,1.69v5.2h1.8V9.072l2.11,-0.66 -3.91,15.33h1.8l2.87,-8.11 2.444,0.042 -0.038,5.038h1.8l0.038,-6.448 -2.604,-1.472 0.73,-2.87m0.96,-4.38c1,0 1.8,-0.8 1.8,-1.8 0,-1 -0.8,-1.8 -1.8,-1.8 -1,0 -1.8,0.8 -1.8,1.8 0,1 0.8,1.8 1.8,1.8z"
android:fillColor="#000000"/>
<path
android:pathData="M18.313,15.061L18.313,18.061L14.313,18.061L14.313,21.061L10.313,21.061L10.313,24.061L21.313,24.061L21.313,21.061L21.313,18.061L21.313,15.061L18.313,15.061z"
android:strokeWidth="0.918472"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25sp"
android:height="25sp"
android:tint="#7E7E7E"
android:viewportHeight="1024"
android:viewportWidth="1024">
<path android:fillColor="#000000" android:pathData="M699.5,448.9l-102.3,-52.2 -128.4,-102.3 -43.5,65.3 128.4,89.2c2.2,2.2 4.4,4.4 8.7,6.5l128.4,63.1 8.7,-69.7zM251.1,882c-4.4,0 -8.7,0 -15.2,-2.2 -21.8,-8.7 -34.8,-32.7 -26.1,-56.6l50.1,-141.5L290.2,518.5l132.8,-37 -130.6,370.1c-6.5,19.6 -23.9,30.5 -41.4,30.5z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M366.4,642.6l56.6,-161.1 -132.8,37 -19.6,102.3z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M479.6,76.6c41.4,0 76.2,34.8 76.2,76.2s-34.8,76.2 -76.2,76.2 -76.2,-34.8 -76.2,-76.2 34.8,-76.2 76.2,-76.2z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M773.3,210.5l-86.9,695.5 -43.2,-5.4 86.9,-695.5z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M736.5,947.4H584.1c13.1,-117.5 69.7,-126.3 78.4,-195.9h43.5c-4.4,69.7 37,71.8 30.5,195.9z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M925.9,816.7s-65.3,65.3 -413.6,65.3H98.7c-13.1,0 -21.8,8.7 -21.8,21.8 0,21.8 87.1,43.5 174.1,43.5h522.4c87.1,0 174.1,-87.1 174.1,-108.8 0,-13.1 -8.7,-21.8 -21.8,-21.8z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M771.3,194.2c-8.7,-15.2 -28.3,-21.8 -43.5,-13.1l-124.1,67.5 -119.7,23.9h-60.9c-30.5,0 -56.6,19.6 -67.5,47.9L292.4,512c-8.7,26.1 -2.2,52.2 15.2,69.7l117.5,119.7v137.1c0,23.9 19.6,43.5 43.5,43.5s43.5,-19.6 43.5,-43.5V686.1c0,-10.9 -4.4,-19.6 -10.9,-28.3l-76.2,-100.1v-2.2l74,-189.4c0,-2.2 2.2,-4.4 2.2,-6.5l117.5,-47.9c4.4,0 6.5,-2.2 8.7,-4.4l128.4,-71.8c17.4,-6.5 23.9,-26.1 15.2,-41.4z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M447,316.1c0,-43.5 37,-43.5 37,-43.5h-60.9c-30.5,0 -56.6,19.6 -67.5,47.9L292.4,512c-8.7,26.1 -2.2,52.2 15.2,69.7l60.9,60.9 82.7,-52.2s-26.1,-32.7 -26.1,-34.8l74,-189.4c0,-2.2 2.2,-4.4 2.2,-6.5 0,0 -54.4,8.7 -54.4,-43.5z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#000000" android:pathData="M501.4,359.6c-2.2,0 -21.8,2.2 -37,-6.5l-67.5,169.8 28.3,32.7 74,-189.4c0,-2.2 2.2,-4.4 2.2,-6.5z" android:strokeColor="#000000" android:strokeWidth="1"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25sp"
android:height="25sp"
android:tint="#7E7E7E"
android:viewportHeight="128"
android:viewportWidth="128">
<path android:fillColor="#000000" android:pathData="M120.4,120.9C64.2,103.2 20.1,83.7 10,79.1c-1,-0.4 -2.2,0 -2.6,1.1c-0.4,1 0,2.2 1.1,2.5c2.5,1.1 5,2.2 7.4,3.3l-7.9,6c-0.9,1.3 -0.5,3 0.8,3.9c1,0.7 2.4,0.6 3.4,0l13.6,-5.7c33.3,14 58.7,22.2 94.3,33.4c0.7,0.1 1.4,-0.4 1.5,-1.2C121.6,121.8 121.1,121.1 120.4,120.9z"/>
<path android:fillColor="#000000" android:pathData="M100,32c5.3,0 9.5,-4.3 9.5,-9.5c0,-5.3 -4.2,-9.5 -9.5,-9.5s-9.5,4.3 -9.5,9.5C90.4,27.7 94.7,32 100,32z"/>
<path android:fillColor="#000000" android:pathData="M34.3,84.1c1,0.1 2,-0.2 2.8,-0.6l20.9,-9.4c1.5,-0.8 2.6,-2.2 3,-4v-10.5l14.5,13l-2.7,22.1c0,0.1 0,0.3 0,0.4c-0.1,3.3 2.4,6 5.7,6.1c3.1,0.1 5.7,-2.1 6.1,-5.1l3.1,-25.2c0,-0.1 0,-0.2 0,-0.3c0.1,-1.8 -0.6,-3.4 -1.8,-4.5l-13.4,-12l20.2,-9.9l18.8,17.3c0.8,0.8 2,1.3 3.2,1.3c2.5,0 4.6,-2.1 4.5,-4.6c0,-1.4 -0.6,-2.6 -1.6,-3.4L90.9,30.2c-0.9,-0.9 -1.9,-1.6 -3.1,-2.1L66.9,20.7l-9.5,-13.8c-0.7,-1 -1.9,-1.7 -3.2,-1.9c-2.5,-0.3 -4.7,1.5 -5,4c-0.1,1 0.1,2.1 0.6,2.9L59.5,26c0.4,0.6 1,1 1.7,1.4l11.2,4.4L54,41.2c-2.6,1.5 -4.4,4 -4.9,7.1l0.1,16.9l-17.1,7.7c-1.9,0.9 -3.3,2.8 -3.4,5.1C28.6,81.2 31.1,83.9 34.3,84.1z"/>
</vector>

View File

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25sp"
android:height="25sp"
android:tint="#7E7E7E"
android:viewportHeight="310.64"
android:viewportWidth="310.64">
<path android:fillColor="#000000" android:pathData="m195.65,257c2.78,18.54 -8.98,30.61 -22.42,32.63 -14.94,2.23 -28.54,-8.32 -30.69,-22.7 -0.8,-5.33 -1.14,-7.65 -1.94,-12.97 -5.31,18.91 -4.37,15.58 -5.85,20.83 -3.97,14.13 -18.79,22.77 -33.29,18.7 -8.09,-2.27 -14.6,-8.07 -17.77,-15.98 -22.34,7.52 -36.01,15.71 -34.98,22.35 1.85,11.96 50.67,14.34 109.05,5.32s104.21,-26.03 102.36,-37.99c-1.35,-8.72 -27.67,-12.35 -64.46,-10.18z"/>
<path android:fillColor="#000000" android:pathData="m65.05,194.39l45.68,10.55 -16.42,58.49c-2.24,7.98 2.41,16.26 10.39,18.5 7.98,2.24 16.26,-2.42 18.5,-10.39l20.67,-73.62c2.31,-8.24 -2.74,-16.75 -11.07,-18.67l-59.72,-14.11c0,0 60.84,2.06 62.42,2.42 7.16,1.65 13.41,6.22 17.15,12.54 3.74,6.32 4.75,14 2.77,21.07l-6.91,24.61 5.9,39.38c1.23,8.18 8.84,13.84 17.06,12.61 8.19,-1.23 13.84,-8.86 12.61,-17.06l-13.58,-90.67c-0.88,-5.91 -5.18,-10.68 -10.87,-12.24l-44.46,-12.19 -2.57,-7.09 -4.58,2.27c-10.52,5.21 -21.37,1.36 -25.36,-2.39l-37.23,-35.02 45.45,26.27c3.5,2.03 8.02,2.26 11.81,0.38l44.75,-22.18c6.18,-3.06 8.72,-10.56 5.65,-16.75 -0,-0 -0,-0 -0,-0 -3.1,-6.25 -10.65,-8.67 -16.75,-5.65l-12.84,6.36 -25.9,12.84 -41.16,-23.79c2.27,0.63 38.12,10.51 39.93,11.01l11.41,-5.66 -24.95,-23.96c-3.59,-3.44 -11.63,-5.97 -18.84,-3.36l-31.26,11.3c-9.68,3.5 -14.69,14.18 -11.19,23.86 3.01,8.31 29.23,80.83 32.37,89.53 1.37,5.22 5.51,9.52 11.13,10.81z"/>
<path android:fillColor="#000000" android:pathData="m289.24,136.02c-46.08,-5.14 -84.47,-16.25 -110.52,-25.64l1.95,-0.61c6.59,-2.07 10.25,-9.09 8.18,-15.67 -2.07,-6.59 -9.09,-10.25 -15.67,-8.18l-8.2,2.58c3.09,8.74 1,18.6 -5.61,25.32 -1.85,1.88 -3.98,3.43 -6.34,4.63 -0.09,0.05 -0.17,0.1 -0.26,0.14l-3.57,1.77c24.34,10.43 73.53,28.35 137.82,35.53 0.38,0.04 0.75,0.06 1.12,0.06 5.03,0 9.35,-3.78 9.93,-8.89 0.61,-5.49 -3.34,-10.43 -8.83,-11.05z"/>
<path android:fillColor="#000000" android:pathData="M40.1,27.59m-27.59,0a27.59,27.59 0,1 1,55.18 0a27.59,27.59 0,1 1,-55.18 0"/>
</vector>

View File

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="25sp"
android:width="25sp"
android:tint="#7E7E7E"
android:viewportHeight="128"
android:viewportWidth="128">
<path android:fillColor="#000000" android:pathData="M75.9,107.4c0.8,-0.1 1.6,-0.2 2.4,-0.2c2.5,0 4.9,0.6 7,1.6c2.1,0.9 4.4,1.5 6.8,1.5c2.4,0 4.8,-0.6 6.9,-1.5c2.1,-1 4.5,-1.6 7,-1.6c2.5,0 4.9,0.6 7,1.6c2.1,0.9 4.4,1.5 6.8,1.5v10.3c-2.4,0 -4.8,-0.6 -6.8,-1.5c-2.1,-1 -4.5,-1.5 -7,-1.5c-2.5,0 -4.9,0.6 -7,1.5c-2.1,0.9 -4.4,1.5 -6.9,1.5c-2.4,0 -4.8,-0.6 -6.8,-1.5c-2.1,-1 -4.5,-1.5 -7,-1.5c-2.5,0 -4.9,0.6 -7,1.5c-2.1,0.9 -4.4,1.5 -6.8,1.5c-2.4,0 -4.7,-0.6 -6.8,-1.5c-2.1,-1 -4.5,-1.5 -7,-1.5c-2.5,0 -4.9,0.6 -7,1.5c-2.1,0.9 -4.4,1.5 -6.8,1.5c-2.4,0 -4.7,-0.6 -6.8,-1.5c-2.2,-1 -4.6,-1.5 -7,-1.5c-2.5,0 -4.9,0.6 -7,1.5c-2.1,0.9 -4.4,1.5 -6.8,1.5v-10.3c2.4,0 4.7,-0.6 6.8,-1.5c2.1,-1 4.5,-1.6 7,-1.6c2.5,0 4.9,0.6 7,1.6c2.1,0.9 4.4,1.5 6.8,1.5c2.4,0 4.7,-0.6 6.8,-1.5c1.2,-0.6 2.5,-1 3.8,-1.2l64.7,-11.5c2.1,-0.5 4.9,-2 5.9,-4.5c0.2,-0.5 0.9,-0.6 1.5,-0.6c1,0.1 1.8,1 1.8,2c0,1.7 -1.3,6.3 -8.3,7.7L75.9,107.4z"/>
<path android:fillColor="#000000" android:pathData="M19.8,26.2c5.2,0 9.4,-4.2 9.4,-9.4S25,7.4 19.8,7.4c-5.2,0 -9.3,4.2 -9.3,9.3S14.6,26.2 19.8,26.2"/>
<path android:fillColor="#000000" android:pathData="M47,101.8c0.5,2.1 3,4.1 5.6,4.1l0,0c3.3,0 6,-2.6 6,-6l-0.1,-1l-7.1,-30.6c-0.6,-2 -2.5,-3.8 -4.4,-4.6l-10.5,-6.3l-4.8,-20.6l29.5,-0.1c2.4,0 4.3,-1.9 4.3,-4.3c0,-2.4 -1.9,-4.4 -4.3,-4.4H18.6c-4.3,0 -6.2,3 -5.7,5.7l6,27.3c0.5,2.6 2.2,4.7 4.4,5.9l0.1,0.1L41,77.3L47,101.8z"/>
<path android:fillColor="#000000" android:pathData="M68,33.6h52.1v3.3h-52.1z"/>
</vector>

View File

@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="25sp"
android:width="25sp"
android:tint="#7E7E7E"
android:viewportHeight="285"
android:viewportWidth="285">
<path android:fillColor="#000000" android:pathData="m195.45,103.55h31.74c8.28,0 15.89,2.98 21.8,7.91l6.68,0.84c8.23,1.04 15.72,-4.79 16.76,-13.01 1.03,-8.22 -4.79,-15.72 -13.01,-16.76l-63.54,-8c-4.73,-0.59 -9.45,1.09 -12.73,4.54l-15.61,16.38 5.69,-0.76c8.58,-1.14 16.9,2.32 22.22,8.85z"/>
<path android:fillColor="#000000" android:pathData="m59.64,98.99l2.83,4.55h25.43l-4.92,-9.27 34.56,39.51c2.76,3.15 7.06,4.71 11.06,4.16l49.51,-6.58c7.32,-0.97 12.2,-8.06 10.52,-15.25 -1.48,-6.32 -7.55,-10.36 -13.81,-9.53 -0,0 -0,0 -0,0l-42.86,5.7 -31.3,-35.78 34.26,23.28 2.92,-0.39 -21.92,-35.32c-5.1,-8.21 -15.89,-10.74 -24.1,-5.64l-26.52,16.46c-8.21,5.1 -10.74,15.89 -5.64,24.1z"/>
<path android:fillColor="#000000" android:pathData="M60.91,37.99m-25.91,0a25.91,25.91 0,1 1,51.81 0a25.91,25.91 0,1 1,-51.81 0"/>
<path android:fillColor="#000000" android:pathData="m53.31,175.72h113.34c-0.24,-12.4 9.78,-22.43 21.99,-22.43h60.61v-15.68c0,-12.18 -9.88,-22.06 -22.06,-22.06h-26.49c1.92,13.56 -7.61,25.94 -21.02,27.72l-49.51,6.58c-11.05,1.47 -20.39,-5.06 -23.24,-10.43l-12.68,-23.88h-40.96c-12.18,0 -22.06,9.88 -22.06,22.06v16.05c-0,12.18 9.88,22.06 22.06,22.06z"/>
<path android:fillColor="#000000" android:pathData="m111,199.42c0,-5.52 -4.48,-10 -10,-10h-91c-5.52,0 -10,4.48 -10,10 0,5.52 4.48,10 10,10h91c5.52,0 10,-4.48 10,-10z"/>
<path android:fillColor="#000000" android:pathData="m76.82,231.42c0,5.52 4.48,10 10,10h91.18c5.52,0 10,-4.48 10,-10 0,-5.52 -4.48,-10 -10,-10h-91.18c-5.52,0 -10,4.48 -10,10z"/>
<path android:fillColor="#000000" android:pathData="m264,252.92h-229c-5.52,0 -10,4.48 -10,10 0,5.52 4.48,10 10,10h229c5.52,0 10,-4.48 10,-10 0,-5.52 -4.48,-10 -10,-10z"/>
<path android:fillColor="#000000" android:pathData="m275,165.29h-86.36c-5.52,0 -10,4.48 -10,10 0,5.52 4.48,10 10,10h86.36c5.52,0 10,-4.48 10,-10s-4.48,-10 -10,-10z"/>
</vector>

View File

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25sp"
android:height="25sp"
android:tint="#7E7E7E"
android:viewportHeight="128"
android:viewportWidth="128">
<path android:fillColor="#000000" android:pathData="M119.9,124c-2.5,0 -4.8,-0.6 -6.9,-1.5c-2.2,-1 -4.6,-1.6 -7.1,-1.6c-2.5,0 -5,0.6 -7.1,1.6c-2.1,0.9 -4.5,1.5 -7,1.5c-2.5,0 -4.8,-0.6 -6.9,-1.5c-2.2,-1 -4.6,-1.6 -7.2,-1.6c-2.5,0 -5,0.6 -7.1,1.6c-2.1,0.9 -4.5,1.5 -7,1.5c-2.5,0 -4.8,-0.6 -6.9,-1.5c-2.2,-1 -4.6,-1.6 -7.2,-1.6s-5,0.6 -7.1,1.6c-2.1,0.9 -4.5,1.5 -7,1.5c-2.5,0 -4.8,-0.6 -6.9,-1.5c-2.2,-1 -4.6,-1.6 -7.1,-1.6c-2.6,0 -5,0.6 -7.1,1.6c-2.1,0.9 -4.5,1.5 -7,1.5v-10.4c2.5,0 4.8,-0.6 7,-1.5c2.2,-1 4.6,-1.6 7.1,-1.6c2.5,0 5,0.6 7.1,1.6c2.1,0.9 4.5,1.5 6.9,1.5c2.5,0 4.8,-0.6 7,-1.5c2.2,-1 4.6,-1.6 7.1,-1.6s5,0.6 7.2,1.6c2.1,0.9 4.5,1.5 6.9,1.5c2.5,0 4.8,-0.6 7,-1.5c2.2,-1 4.6,-1.6 7.1,-1.6c2.5,0 5,0.6 7.2,1.6c2.1,0.9 4.5,1.5 6.9,1.5c2.5,0 4.8,-0.6 7,-1.5c2.2,-1 4.6,-1.6 7.1,-1.6c2.5,0 5,0.6 7.1,1.6c2.1,0.9 4.5,1.5 6.9,1.5V124z"/>
<path android:fillColor="#000000" android:pathData="M19.2,63.8c3.8,0 6.8,-3.1 6.8,-6.8c0,-3.8 -3.1,-6.8 -6.8,-6.8c-3.8,0 -6.8,3.1 -6.8,6.8C12.4,60.7 15.5,63.8 19.2,63.8"/>
<path android:fillColor="#000000" android:pathData="M49.3,94.7H29.7c-2.9,0 -5.4,-1.7 -6.5,-4.2L16,74.1c-0.1,-0.6 -0.2,-1.1 -0.2,-1.7c0,-4 3.2,-7.2 7.1,-7.2l15.9,0l10.9,-4.9c0.2,-0.1 0.6,-0.2 1.1,-0.2c1.9,0 3.4,1.5 3.4,3.4c0,1.1 -0.6,2.2 -1.5,2.8l-11.8,5.3c-0.8,0.6 -2.3,0.7 -2.3,0.7h-7.1l6,13.3h13.2c1.3,0 2.2,0.5 3,1.1L66.6,99c1.8,1.7 1.9,4.5 0.2,6.3c-1.7,1.8 -4.5,1.9 -6.4,0.2L49.3,94.7z"/>
<path android:fillColor="#000000" android:pathData="M110.1,72.4c0.3,0.4 0.9,0.6 1.4,0.6c1.1,0 2,-0.9 2,-2c0,-0.5 -0.3,-1 -0.5,-1.5c-12.2,-23.3 -45.2,-16.4 -49.2,-14.8c-0.7,0.3 -1.1,1 -1.1,1.8c0,1.1 0.9,2 2,2c0.3,0 0.5,0 0.8,-0.1C97.9,51 108.4,69.4 110.1,72.4M115.8,74.5l-41.4,26.1L36.8,4.4C70.5,8.9 113.3,35.1 115.8,74.5"/>
</vector>

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.musicmanager.MusicManagerActivity">
<TextView
android:id="@+id/music_device_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:lineSpacingMultiplier="1.1"
android:text="" />
<LinearLayout
android:id="@+id/music_playlists_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/music_device_info"
android:orientation="horizontal">
<Spinner
android:id="@+id/music_playlists"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_weight="20" />
<ImageButton
android:id="@+id/music_playlist_rename"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@null"
android:contentDescription="@string/music_rename_playlist"
app:srcCompat="@drawable/ic_edit"/>
<ImageButton
android:id="@+id/music_playlist_delete"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@null"
android:contentDescription="@string/music_delete"
app:srcCompat="@drawable/ic_delete" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/music_songs_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/music_playlists_layout"
android:layout_centerHorizontal="true"
android:divider="@null" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_music_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:contentDescription="@string/music_new_playlist"
app:srcCompat="@android:drawable/stat_sys_upload" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_music_playlist_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="90dp"
app:srcCompat="@drawable/ic_add"
/>
<RelativeLayout
android:id="@+id/music_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#95000000"
android:gravity="center">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.widget.RelativeLayout>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appmanager_item_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="?attr/cardview_background_color"
app:cardElevation="3dp"
app:contentPadding="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="60dp">
<ImageView
android:id="@+id/item_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:contentDescription="@string/candidate_item_device_image"
android:src="@drawable/ic_music"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@+id/item_image"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:scrollHorizontally="false"
android:text="Item Name"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
<TextView
android:id="@+id/item_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/musicmanager_add_to_playlist"
android:title="@string/music_add_to_playlist"/>
<item
android:id="@+id/musicmanager_delete_from_playlist"
android:title="@string/music_delete_from_playlist"/>
<item
android:id="@+id/musicmanager_delete"
android:title="@string/music_delete"/>
</menu>

View File

@ -3614,6 +3614,32 @@
<item>as_off</item>
</string-array>
<string-array name="oppo_touch_tap_names">
<!-- superset of values, unsupported are hidden by the coordinator -->
<item>@string/sony_button_mode_off</item>
<item>@string/moondrop_touch_action_play_pause</item>
<item>@string/pref_media_previous</item>
<item>@string/pref_media_next</item>
<item>@string/pref_media_volumeup</item>
<item>@string/pref_media_volumedown</item>
<item>@string/pref_title_touch_voice_assistant</item>
<item>@string/pref_title_touch_voice_assistant</item>
<item>@string/prefs_game_mode</item>
</string-array>
<string-array name="oppo_touch_tap_values">
<!-- superset of values, unsupported are hidden by the coordinator -->
<item>off</item>
<item>play_pause</item>
<item>previous</item>
<item>next</item>
<item>volume_up</item>
<item>volume_down</item>
<item>voice_assistant</item>
<item>voice_assistant_realme</item>
<item>game_mode</item>
</string-array>
<string-array name="soundcore_button_function_names">
<item>@string/pref_media_volumedown</item>
<item>@string/pref_media_volumeup</item>

View File

@ -191,6 +191,8 @@
<string name="open_fw_installer_connect_minimum_one_device">Please connect AT LEAST ONE device you want to send the file to.</string>
<string name="open_fw_installer_connect_maximum_one_device">Please connect ONLY ONE device you want to send the file to.</string>
<string name="open_fw_installer_ensure_device_connected">Make sure that the device %s is connected</string>
<!-- Strings related to MusicManager -->
<string name="title_activity_musicmanager">Music Manager</string>
<!-- Strings related to Settings -->
<string name="title_activity_settings">Settings</string>
<string name="proprietary_app_warning">This feature requires the installation of a proprietary app</string>
@ -1750,12 +1752,14 @@
<string name="devicetype_garmin_fenix_8">Garmin Fenix 8</string>
<string name="devicetype_garmin_instinct">Garmin Instinct</string>
<string name="devicetype_garmin_instinct_solar">Garmin Instinct Solar</string>
<string name="devicetype_garmin_instinct_2">Garmin Instinct 2</string>
<string name="devicetype_garmin_instinct_2s">Garmin Instinct 2S</string>
<string name="devicetype_garmin_instinct_2s_solar">Garmin Instinct 2S Solar</string>
<string name="devicetype_garmin_instinct_2x_solar">Garmin Instinct 2X Solar</string>
<string name="devicetype_garmin_instinct_2_solar">Garmin Instinct 2 Solar</string>
<string name="devicetype_garmin_instinct_2_soltac">Garmin Instinct 2 SolTac</string>
<string name="devicetype_garmin_instinct_crossover">Garmin Instinct Crossover</string>
<string name="devicetype_garmin_forerunner_55">Garmin Forerunner 55</string>
<string name="devicetype_garmin_forerunner_165">Garmin Forerunner 165</string>
<string name="devicetype_garmin_forerunner_235">Garmin Forerunner 235</string>
<string name="devicetype_garmin_forerunner_245">Garmin Forerunner 245</string>
@ -1766,6 +1770,7 @@
<string name="devicetype_garmin_forerunner_255s_music">Garmin Forerunner 255S Music</string>
<string name="devicetype_garmin_forerunner_265">Garmin Forerunner 265</string>
<string name="devicetype_garmin_forerunner_265s">Garmin Forerunner 265S</string>
<string name="devicetype_garmin_forerunner_620">Garmin Forerunner 620</string>
<string name="devicetype_garmin_forerunner_955">Garmin Forerunner 955</string>
<string name="devicetype_garmin_forerunner_965">Garmin Forerunner 965</string>
<string name="devicetype_garmin_swim_2">Garmin Swim 2</string>
@ -2491,6 +2496,8 @@
<string name="devicetype_nothing_cmf_buds_pro_2">CMF Buds Pro 2</string>
<string name="devicetype_nothing_cmf_watch_pro">CMF Watch Pro</string>
<string name="devicetype_nothing_cmf_watch_pro_2">CMF Watch Pro 2</string>
<string name="devicetype_oppo_enco_air">Oppo Enco Air</string>
<string name="devicetype_realme_buds_t110">Realme Buds T110</string>
<string name="devicetype_galaxybuds">Galaxy Buds</string>
<string name="devicetype_galaxybuds_live">Galaxy Buds Live</string>
<string name="devicetype_galaxybuds_pro">Galaxy Buds Pro</string>
@ -2585,6 +2592,8 @@
<string name="pref_header_stress">Stress</string>
<string name="pref_header_spo2">Blood Oxygen</string>
<string name="pref_header_hrv_status">HRV Status</string>
<string name="pref_wear_sensor_summary">Detect when the device is not being worn</string>
<string name="pref_wear_sensor_title">Wear Sensor</string>
<string name="body_energy">Body Energy</string>
<string name="vo2max_running">Running VO₂ Max</string>
<string name="vo2max_cycling">Cycling VO₂ Max</string>
@ -3194,6 +3203,8 @@
<string name="warning_missing_notification_permission">Could not post ongoing notification due to missing permission</string>
<string name="pref_test_features_title">Features</string>
<string name="pref_test_features_summary">Enabled features for this test device</string>
<string name="pref_developer_add_test_activities_title">Add test activities</string>
<string name="pref_developer_add_test_activities_summary">Populate the database with dummy test activities</string>
<string name="device_state_waiting_scan">Waiting for device scan</string>
<string name="auto_reconnect_ble_scan_title">Reconnect by BLE scan</string>
<string name="auto_reconnect_ble_scan_summary">Wait for device scan instead of blind connection attempts</string>
@ -3398,4 +3409,15 @@
<string name="inactivity_warnings_minimum_steps_summary">Minimum amount of steps that need to be taken during the threshold minutes</string>
<string name="prefs_hrv_monitoring_title">HRV monitoring</string>
<string name="prefs_hrv_monitoring_description">Automatically monitor heart rate variability throughout the day</string>
<string name="pref_music_management_title">Manage Music</string>
<string name="pref_music_management_summary">Manage music on the watch</string>
<string name="music_delete_confirm_description">Are you sure you want to delete \'%1$s\'?</string>
<string name="music_add_to_playlist">Add to playlist</string>
<string name="music_delete_from_playlist">Delete from playlist</string>
<string name="music_delete">Delete song</string>
<string name="music_all_songs">All songs</string>
<string name="music_new_playlist">New playlist</string>
<string name="music_rename_playlist">Rename playlist</string>
<string name="music_error">Error occurred</string>
<string name="music_huawei_device_info">Supported formats: %1$s\nWatch storage: %2$d MB</string>
</resources>

View File

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="0.82.1" versioncode="234">
<change>Huawei: Improve activity parsing</change>
<change>Huawei Watch GT: Fix connection failure</change>
<change>Withings: Fix crash on connection</change>
<change>Improve Armenian transliterator for mixed-case words</change>
</release>
<release version="0.82.0" versioncode="233">
<change>Initial support for Anker Soundcore Liberty 4 NC</change>
<change>Initial support for CMF Buds Pro 2 / Watch Pro 2</change>

Some files were not shown because too many files have changed in this diff Show More