Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"try_changing_it": "Try changing it",
"example_hostname": "e.g. https://dipantau.id",
"screenshot_notification": "Screenshot Notification",
"subtitle_screenshot_notification": "Show notification while capture screenshot",
"subtitle_screenshot_notification": "Show notification while capture screenshot.",
"setting": "Setting",
"current": "Current",
"warning_change_hostname": "Make sure your data has been synced. This change requires restarting the app.",
Expand Down Expand Up @@ -147,11 +147,11 @@
"general": "General",
"company": "Company",
"members": "Members",
"add_edit_or_remove_member": "Add, edit, or remove member",
"add_edit_or_remove_member": "Add, edit, or remove member.",
"projects": "Projects",
"add_edit_or_remove_project": "Add, edit, or remove project",
"add_edit_or_remove_project": "Add, edit, or remove project.",
"tasks_2": "Tasks",
"add_edit_or_remove_task": "Add, edit, or remove task",
"add_edit_or_remove_task": "Add, edit, or remove task.",
"member_setting": "Member Setting",
"name": "Name",
"role": "Role",
Expand Down Expand Up @@ -185,7 +185,7 @@
"avg_activity": "Avg. Activity",
"idle_time": "Idle Time",
"discord_channel_id": "Discord Channel ID",
"subtitle_discord_channel_id": "It's used as cloud storage for all screenshots members",
"subtitle_discord_channel_id": "It's used as cloud storage for all screenshots members.",
"discord_channel_id_sucessfully_updated": "Discord channel ID successfully updated",
"set_discord_channel_id": "Set Discord Channel ID",
"cannot_be_empty": "Cannot be empty",
Expand All @@ -208,7 +208,24 @@
"check": "Check",
"version_app": "Version App",
"always_on_top": "Always on Top",
"subtitle_always_on_top": "Set Dipantau window always on top of other windows",
"subtitle_always_on_top": "Set Dipantau window always on top of other windows.",
"back_to_main_menu": "Back to Main Menu",
"screenshot": "Screenshot"
"screenshot": "Screenshot",
"remind_me_to_track_time": "Reminder Not Track",
"subtitle_remind_me_to_track_time": "Show notification for remind me to track time.",
"from": "From",
"to": "to",
"on_these_days": "On these days",
"mon": "Mon",
"tue": "Tue",
"wed": "Wed",
"thu": "Thu",
"fri": "Fri",
"sat": "Sat",
"sun": "Sun",
"if_i_havent_tracked_time_in": "If I haven't tracked time in",
"alias_minutes": "minutes",
"n_minute": "{} minutes",
"choose": "Choose",
"finish_time_must_be_after_start_time": "Finish time must be after start time"
}
5 changes: 5 additions & 0 deletions lib/core/util/shared_preferences_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class SharedPreferencesManager {
static const keyBaseFilePathScreenshot = 'base_file_path_screenshot';
static const keyIsLaunchAtStartup = 'is_launch_at_startup';
static const keyIsAlwaysOnTop = 'is_always_on_top';
static const keyIsEnableReminderTrack = 'is_enable_reminder_track';
static const keyStartTimeReminderTrack = 'start_time_reminder_track';
static const keyFinishTimeReminderTrack = 'finish_time_reminder_track';
static const keyDayReminderTrack = 'day_reminder_track';
static const keyIntervalReminderTrack = 'interval_reminder_track';

SharedPreferencesManager();

Expand Down
99 changes: 89 additions & 10 deletions lib/feature/presentation/page/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import 'package:path_provider/path_provider.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';

var countTimeReminderTrackInSeconds = 0;

class HomePage extends StatefulWidget {
static const routePath = '/home';
static const routeName = 'home';
Expand Down Expand Up @@ -65,7 +67,6 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
final notificationHelper = sl<NotificationHelper>();
final intervalScreenshot = 60 * 5; // 300 detik (5 menit)
final listTrackLocal = <Track>[];
final intervalReminderNotTrack = 60 * 10; // 600 detik (10 menit)

var isWindowVisible = true;
var userId = '';
Expand All @@ -76,7 +77,6 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
TrackTask? selectedTask;
Timer? timeTrack, timerCronTrack, timerDate;
var countTimerInSeconds = 0;
var countTimerReminderNotTrack = 0;
var isHaveActivity = false;
var counterActivity = 0;
DateTime? startTime;
Expand Down Expand Up @@ -127,13 +127,93 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
);
timerDate = Timer.periodic(const Duration(seconds: 1), (_) {
if (!isTimerStart) {
countTimerReminderNotTrack += 1;
if (countTimerReminderNotTrack == intervalReminderNotTrack) {
countTimerReminderNotTrack = 0;
notificationHelper.showReminderNotTrackNotification();
// reminder track
var isShowReminderTrack = false;
final now = DateTime.now();
countTimeReminderTrackInSeconds += 1;
final isEnableReminderTrack =
sharedPreferencesManager.getBool(SharedPreferencesManager.keyIsEnableReminderTrack) ?? false;
if (isEnableReminderTrack) {
DateTime? startReminderTrack, finishReminderTrack;
final strStartReminderTrack = sharedPreferencesManager.getString(
SharedPreferencesManager.keyStartTimeReminderTrack,
) ??
'';
if (strStartReminderTrack.contains(':') && strStartReminderTrack.split(':').length == 2) {
final splitStrStartReminderTrack = strStartReminderTrack.split(':');
final strStartHourReminderTrack = splitStrStartReminderTrack.first;
final strStartMinuteReminderTrack = splitStrStartReminderTrack.last;
final startHourReminderTrack = int.tryParse(strStartHourReminderTrack);
final startMinuteReminderTrack = int.tryParse(strStartMinuteReminderTrack);
if (startHourReminderTrack != null && startMinuteReminderTrack != null) {
startReminderTrack = DateTime(
now.year,
now.month,
now.day,
startHourReminderTrack,
startMinuteReminderTrack,
);
}
}

final strFinishReminderTrack = sharedPreferencesManager.getString(
SharedPreferencesManager.keyFinishTimeReminderTrack,
) ??
'';
if (strFinishReminderTrack.contains(':') && strFinishReminderTrack.split(':').length == 2) {
final splitStrFinishReminderTrack = strFinishReminderTrack.split(':');
final strFinishHourReminderTrack = splitStrFinishReminderTrack.first;
final strFinishMinuteReminderTrack = splitStrFinishReminderTrack.last;
final finishHourReminderTrack = int.tryParse(strFinishHourReminderTrack);
final finishMinuteReminderTrack = int.tryParse(strFinishMinuteReminderTrack);
if (finishHourReminderTrack != null && finishMinuteReminderTrack != null) {
finishReminderTrack = DateTime(
now.year,
now.month,
now.day,
finishHourReminderTrack,
finishMinuteReminderTrack,
);
}
}

final daysReminderTrack =
sharedPreferencesManager.getStringList(SharedPreferencesManager.keyDayReminderTrack) ?? [];
final nowWeekday = now.weekday;
final isTodayReminderTrackEnabled =
daysReminderTrack.where((element) => element == nowWeekday.toString()).isNotEmpty;

int? intervalReminderTrackInSeconds;
final intervalReminderTrackInMinutes =
sharedPreferencesManager.getInt(SharedPreferencesManager.keyIntervalReminderTrack) ?? -1;
if (intervalReminderTrackInMinutes != -1 && intervalReminderTrackInMinutes > 0) {
intervalReminderTrackInSeconds = intervalReminderTrackInMinutes * 60;
}

if (startReminderTrack != null &&
finishReminderTrack != null &&
isTodayReminderTrackEnabled &&
countTimeReminderTrackInSeconds == intervalReminderTrackInSeconds) {
if (now.isAfter(startReminderTrack) && now.isBefore(finishReminderTrack) ||
(now.isAtSameMomentAs(startReminderTrack) || now.isAtSameMomentAs(finishReminderTrack))) {
isShowReminderTrack = true;
}
}

if (countTimeReminderTrackInSeconds == intervalReminderTrackInSeconds ||
intervalReminderTrackInSeconds == null) {
countTimeReminderTrackInSeconds = 0;
}

if (isShowReminderTrack) {
notificationHelper.showReminderNotTrackNotification();
}
} else {
countTimeReminderTrackInSeconds = 0;
}
}

// reset timer jika berpindah hari
final now = DateTime.now();
final dateTimeNow = DateTime(
now.year,
Expand Down Expand Up @@ -965,8 +1045,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
final activity = percentActivity.round();

final listPathScreenshots = await platformChannelHelper.doTakeScreenshot();
final isPermissionScreenRecordingGranted =
await platformChannelHelper.checkPermissionScreenRecording();
final isPermissionScreenRecordingGranted = await platformChannelHelper.checkPermissionScreenRecording();
if (isPermissionScreenRecordingGranted != null && !isPermissionScreenRecordingGranted) {
debugPrint('screen recording not granted');
notificationHelper.showPermissionScreenRecordingIssuedNotification();
Expand Down Expand Up @@ -1047,15 +1126,15 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
}

void startTimer() {
countTimerReminderNotTrack = 0;
countTimeReminderTrackInSeconds = 0;
stopTimer();
timeTrack = Timer.periodic(const Duration(seconds: 1), (_) {
increaseTimerTray();
});
}

void stopTimer() {
countTimerReminderNotTrack = 0;
countTimeReminderTrackInSeconds = 0;
if (timeTrack != null && timeTrack!.isActive) {
timeTrack!.cancel();
}
Expand Down
Loading