1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-08 19:27:04 +01:00

Casio2C2D: Reminders have no hour or minute

This commit is contained in:
Johannes Krude 2024-08-29 16:41:30 +02:00 committed by José Rebelo
parent e92baf69d1
commit e0741d4a13
10 changed files with 81 additions and 24 deletions

View File

@ -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.
@ -37,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
@ -64,7 +66,7 @@ public class ConfigureReminders extends AbstractGBActivity {
private static final int REQ_CONFIGURE_REMINDER = 1;
private GBReminderListAdapter mGBReminderListAdapter;
private GBDevice gbDevice;
public GBDevice gbDevice;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
@ -154,7 +156,13 @@ public class ConfigureReminders extends AbstractGBActivity {
private Reminder createDefaultReminder(@NonNull Device device, @NonNull User user) {
final Reminder reminder = new Reminder();
reminder.setRepetition(Reminder.ONCE);
if (gbDevice.getDeviceCoordinator().getRemindersHaveTime()) {
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.setDeviceId(device.getId());
reminder.setUserId(user.getId());

View File

@ -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.
@ -121,6 +122,7 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
});
final View cardTime = findViewById(R.id.card_time);
if (coordinator.getRemindersHaveTime()) {
cardTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -133,6 +135,9 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
).show();
}
});
} else {
cardTime.setVisibility(View.GONE);
}
reminderText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(coordinator.getMaximumReminderMessageLength())});
reminderText.addTextChangedListener(new TextWatcher() {

View File

@ -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.
@ -100,7 +100,12 @@ public class GBReminderListAdapter extends RecyclerView.Adapter<GBReminderListAd
holder.reminderMessage.setText(reminder.getMessage());
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;

View File

@ -566,6 +566,11 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
return 0;
}
@Override
public boolean getRemindersHaveTime() {
return true;
}
@Override
public boolean getReserveReminderSlotsForCalendar() {
return false;

View File

@ -586,6 +586,11 @@ public interface DeviceCoordinator {
*/
int getReminderSlotCount(GBDevice device);
/**
* Indicates whether reminders have a time of day.
*/
boolean getRemindersHaveTime();
/**
* Indicates whether some reminder slots are used for calendar events.
*/

View File

@ -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;
}
}

View File

@ -34,7 +34,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
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.DaoSession;
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.devices.casio.gbx100.CasioGBX100DeviceSupport;
public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator {
public class CasioGBX100DeviceCoordinator extends Casio2C2DDeviceCoordinator {
/** CASIO brand identifier in GB Device name */
public static final String CASIO_IDENTIFIER = "CASIO";

View File

@ -36,11 +36,11 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
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.devices.casio.gwb5600.CasioGWB5600DeviceSupport;
public class CasioGWB5600DeviceCoordinator extends CasioDeviceCoordinator {
public class CasioGWB5600DeviceCoordinator extends Casio2C2DDeviceCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("CASIO GW-B5600");

View File

@ -642,7 +642,7 @@ public abstract class Casio2C2DSupport extends CasioSupport {
System.arraycopy(message, 0, data[2*pos], 2, Math.min(message.length, 18));
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 (reminder.getRepetition() == Reminder.EVERY_WEEK) {
final LocalDate first = LocalDate.of(2000, 1, 1);

View File

@ -92,6 +92,7 @@
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:foreground="?android:attr/selectableItemBackground"
android:visibility="visible"
app:cardBackgroundColor="?attr/cardview_background_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/card_date"
@ -134,7 +135,7 @@
app:cardBackgroundColor="?attr/cardview_background_color"
app:layout_constraintEnd_toEndOf="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:contentPadding="4dp">