mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Casio2C2D: Reminders have no hour or minute
This commit is contained in:
parent
e92baf69d1
commit
e0741d4a13
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 2021-2024 Arjan Schrijver, Daniel Dakhno, José Rebelo
|
/* Copyright (C) 2021-2024 Arjan Schrijver, Daniel Dakhno, José Rebelo,
|
||||||
|
Johannes Krude
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
This file is part of Gadgetbridge.
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -64,7 +66,7 @@ public class ConfigureReminders extends AbstractGBActivity {
|
|||||||
private static final int REQ_CONFIGURE_REMINDER = 1;
|
private static final int REQ_CONFIGURE_REMINDER = 1;
|
||||||
|
|
||||||
private GBReminderListAdapter mGBReminderListAdapter;
|
private GBReminderListAdapter mGBReminderListAdapter;
|
||||||
private GBDevice gbDevice;
|
public GBDevice gbDevice;
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@ -154,7 +156,13 @@ public class ConfigureReminders extends AbstractGBActivity {
|
|||||||
private Reminder createDefaultReminder(@NonNull Device device, @NonNull User user) {
|
private Reminder createDefaultReminder(@NonNull Device device, @NonNull User user) {
|
||||||
final Reminder reminder = new Reminder();
|
final Reminder reminder = new Reminder();
|
||||||
reminder.setRepetition(Reminder.ONCE);
|
reminder.setRepetition(Reminder.ONCE);
|
||||||
|
if (gbDevice.getDeviceCoordinator().getRemindersHaveTime()) {
|
||||||
reminder.setDate(Calendar.getInstance().getTime());
|
reminder.setDate(Calendar.getInstance().getTime());
|
||||||
|
} else {
|
||||||
|
Calendar noonGMT = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
|
noonGMT.set(noonGMT.get(Calendar.YEAR), noonGMT.get(Calendar.MONTH), noonGMT.get(Calendar.DAY_OF_MONTH), 12, 0);
|
||||||
|
reminder.setDate(noonGMT.getTime());
|
||||||
|
}
|
||||||
reminder.setMessage("");
|
reminder.setMessage("");
|
||||||
reminder.setDeviceId(device.getId());
|
reminder.setDeviceId(device.getId());
|
||||||
reminder.setUserId(user.getId());
|
reminder.setUserId(user.getId());
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 2021-2024 Arjan Schrijver, Daniel Dakhno, José Rebelo
|
/* Copyright (C) 2021-2024 Arjan Schrijver, Daniel Dakhno, José Rebelo,
|
||||||
|
Johannes Krude
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
This file is part of Gadgetbridge.
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
|
|||||||
});
|
});
|
||||||
|
|
||||||
final View cardTime = findViewById(R.id.card_time);
|
final View cardTime = findViewById(R.id.card_time);
|
||||||
|
if (coordinator.getRemindersHaveTime()) {
|
||||||
cardTime.setOnClickListener(new View.OnClickListener() {
|
cardTime.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -133,6 +135,9 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
|
|||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
cardTime.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
reminderText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(coordinator.getMaximumReminderMessageLength())});
|
reminderText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(coordinator.getMaximumReminderMessageLength())});
|
||||||
reminderText.addTextChangedListener(new TextWatcher() {
|
reminderText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2021-2024 Arjan Schrijver, José Rebelo
|
/* Copyright (C) 2021-2024 Arjan Schrijver, José Rebelo, Johannes Krude
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
This file is part of Gadgetbridge.
|
||||||
|
|
||||||
@ -100,7 +100,12 @@ public class GBReminderListAdapter extends RecyclerView.Adapter<GBReminderListAd
|
|||||||
holder.reminderMessage.setText(reminder.getMessage());
|
holder.reminderMessage.setText(reminder.getMessage());
|
||||||
|
|
||||||
final Date time = reminder.getDate();
|
final Date time = reminder.getDate();
|
||||||
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
|
SimpleDateFormat format;
|
||||||
|
if (((ConfigureReminders) mContext).gbDevice.getDeviceCoordinator().getRemindersHaveTime()) {
|
||||||
|
format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
|
||||||
|
} else {
|
||||||
|
format = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||||
|
}
|
||||||
|
|
||||||
int stringResId = 0;
|
int stringResId = 0;
|
||||||
|
|
||||||
|
@ -566,6 +566,11 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getRemindersHaveTime() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getReserveReminderSlotsForCalendar() {
|
public boolean getReserveReminderSlotsForCalendar() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -586,6 +586,11 @@ public interface DeviceCoordinator {
|
|||||||
*/
|
*/
|
||||||
int getReminderSlotCount(GBDevice device);
|
int getReminderSlotCount(GBDevice device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether reminders have a time of day.
|
||||||
|
*/
|
||||||
|
boolean getRemindersHaveTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether some reminder slots are used for calendar events.
|
* Indicates whether some reminder slots are used for calendar events.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
/* Copyright (C) 2024 Johannes Krude
|
||||||
|
|
||||||
|
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/>. */
|
||||||
|
/* Based on code from BlueWatcher, https://github.com/masterjc/bluewatcher */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.casio;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class Casio2C2DDeviceCoordinator extends CasioDeviceCoordinator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getRemindersHaveTime() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,7 +34,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBException;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioDeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.casio.Casio2C2DDeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySampleDao;
|
import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySampleDao;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||||
@ -43,7 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport;
|
||||||
|
|
||||||
public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator {
|
public class CasioGBX100DeviceCoordinator extends Casio2C2DDeviceCoordinator {
|
||||||
/** CASIO brand identifier in GB Device name */
|
/** CASIO brand identifier in GB Device name */
|
||||||
public static final String CASIO_IDENTIFIER = "CASIO";
|
public static final String CASIO_IDENTIFIER = "CASIO";
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioDeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.casio.Casio2C2DDeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600DeviceSupport;
|
||||||
|
|
||||||
public class CasioGWB5600DeviceCoordinator extends CasioDeviceCoordinator {
|
public class CasioGWB5600DeviceCoordinator extends Casio2C2DDeviceCoordinator {
|
||||||
@Override
|
@Override
|
||||||
protected Pattern getSupportedDeviceName() {
|
protected Pattern getSupportedDeviceName() {
|
||||||
return Pattern.compile("CASIO GW-B5600");
|
return Pattern.compile("CASIO GW-B5600");
|
||||||
|
@ -642,7 +642,7 @@ public abstract class Casio2C2DSupport extends CasioSupport {
|
|||||||
System.arraycopy(message, 0, data[2*pos], 2, Math.min(message.length, 18));
|
System.arraycopy(message, 0, data[2*pos], 2, Math.min(message.length, 18));
|
||||||
Arrays.fill(data[2*pos], 2+message.length, 20, (byte) 0);
|
Arrays.fill(data[2*pos], 2+message.length, 20, (byte) 0);
|
||||||
|
|
||||||
LocalDate start = LocalDate.ofInstant(reminder.getDate().toInstant(), ZoneId.systemDefault());
|
LocalDate start = LocalDate.ofInstant(reminder.getDate().toInstant(), ZoneId.of("GMT"));
|
||||||
if (start.getYear() < 2000) {
|
if (start.getYear() < 2000) {
|
||||||
if (reminder.getRepetition() == Reminder.EVERY_WEEK) {
|
if (reminder.getRepetition() == Reminder.EVERY_WEEK) {
|
||||||
final LocalDate first = LocalDate.of(2000, 1, 1);
|
final LocalDate first = LocalDate.of(2000, 1, 1);
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
|
android:visibility="visible"
|
||||||
app:cardBackgroundColor="?attr/cardview_background_color"
|
app:cardBackgroundColor="?attr/cardview_background_color"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/card_date"
|
app:layout_constraintStart_toEndOf="@id/card_date"
|
||||||
@ -134,7 +135,7 @@
|
|||||||
app:cardBackgroundColor="?attr/cardview_background_color"
|
app:cardBackgroundColor="?attr/cardview_background_color"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_time"
|
app:layout_constraintTop_toBottomOf="@id/card_date"
|
||||||
card_view:cardElevation="3dp"
|
card_view:cardElevation="3dp"
|
||||||
card_view:contentPadding="4dp">
|
card_view:contentPadding="4dp">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user