From b588ce23552216eb17ccc19a5bd2a9fb25256c8c Mon Sep 17 00:00:00 2001 From: xavis Date: Wed, 30 Jul 2025 18:42:10 +0200 Subject: [PATCH] Added i18n, and time units, v1.1.0 --- android/gradle.properties | 7 ++++- app/widgets/widget-task-handler.tsx | 40 ++++++++++++++++------------- index.tsx | 2 -- translations/ar.json | 4 ++- translations/de.json | 4 ++- translations/en.json | 4 ++- translations/es.json | 4 ++- translations/fr.json | 4 ++- translations/it.json | 4 ++- translations/ja.json | 4 ++- translations/pt.json | 4 ++- translations/ru.json | 4 ++- translations/zh.json | 4 ++- 13 files changed, 58 insertions(+), 31 deletions(-) diff --git a/android/gradle.properties b/android/gradle.properties index a6164f7..6182938 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -59,4 +59,9 @@ expo.useLegacyPackaging=false expo.edgeToEdgeEnabled=true android.packagingOptions.pickFirsts=**/libc++_shared.so expo.sqlite.enableFTS=false -expo.sqlite.useSQLCipher=false \ No newline at end of file +expo.sqlite.useSQLCipher=false + +MYAPP_UPLOAD_STORE_FILE=taskeep.keystore +MYAPP_UPLOAD_STORE_PASSWORD=123?_Tk_?123 +MYAPP_UPLOAD_KEY_ALIAS=taskeep +MYAPP_UPLOAD_KEY_PASSWORD=123?_Tk_?123 \ No newline at end of file diff --git a/app/widgets/widget-task-handler.tsx b/app/widgets/widget-task-handler.tsx index 4755bbe..5d8cefa 100644 --- a/app/widgets/widget-task-handler.tsx +++ b/app/widgets/widget-task-handler.tsx @@ -1,12 +1,13 @@ +import { throttle } from '@/utils/throttle'; import * as Notifications from 'expo-notifications'; import React from 'react'; import type { WidgetTaskHandlerProps } from 'react-native-android-widget'; +import i18n from '../../i18n'; import { Category, CategoryQuery } from '../../models/category'; import { Task, TaskQuery } from '../../models/task'; import { CategoryRepository } from '../../repositories/CategoryRepository'; import { TaskRepository } from '../../repositories/TaskRepository'; import { SQLiteDataService } from '../../services/data/sqliteDataService'; -import { throttle } from '../../utils/throttle'; import { HelloWidget } from './hello'; @@ -15,6 +16,7 @@ const categoryRepository = new CategoryRepository(new SQLiteDataService ({ @@ -66,8 +68,8 @@ const CheckTaskAndNotify = async (): Promise<{ newTasks: Task[], newCategories: await Notifications.scheduleNotificationAsync({ identifier: `task-due-${task.id}`, content: { - title: 'Task Reminder', - body: `${category?.icon} "${task.title}" is due! ⌛`, + title: i18n.t("task_reminder_title"), + body: `${category?.icon} "${task.title}" ${i18n.t("is_due")} ⌛`, data: { taskId: task.id }, }, trigger: null @@ -78,35 +80,37 @@ const CheckTaskAndNotify = async (): Promise<{ newTasks: Task[], newCategories: return { newTasks: tasks, newCategories: categories }; } -const throttledCheckTaskAndNotify = throttle(CheckTaskAndNotify, 1000); // Throttle to prevent too frequent calls - setInterval(async () => { - const { newTasks, newCategories } = await throttledCheckTaskAndNotify(); + const { newTasks, newCategories } = await CheckTaskAndNotify(); console.log("Throttled task check and notify executed OUT"); console.log("New tasks:", newTasks); console.log("New categories:", newCategories); tasks = newTasks; categories = newCategories; -}, 1000 * 60 * 30); // Check every 30 minutes +}, 1000 * 60); // Check every minute +let lastRender = 0; export async function widgetTaskHandler(props: WidgetTaskHandlerProps) { - async function updateAndRenderWidget() { - const { newTasks, newCategories } = await throttledCheckTaskAndNotify(); - tasks = newTasks; - categories = newCategories; - console.log("Throttled task check and notify executed IN"); - console.log("New tasks:", newTasks); - console.log("New categories:", newCategories); - props.renderWidget(); + const throttledDraw = throttle(props.renderWidget, 1000); + + + async function updateAndRenderWidget(force = false) { + console.log("Updating widget with tasks and categories"); + const { newTasks, newCategories } = await CheckTaskAndNotify(); + throttledDraw(); + if (lastRender > Date.now() - 1000 || force) { + lastRender = Date.now(); + console.log("Rendering widget"); + props.renderWidget(); + } } switch (props.widgetAction) { case 'WIDGET_ADDED': case 'WIDGET_UPDATE': case 'WIDGET_RESIZED': - // Not needed for now updateAndRenderWidget(); break; @@ -117,7 +121,7 @@ export async function widgetTaskHandler(props: WidgetTaskHandlerProps) { case 'WIDGET_CLICK': switch (props.clickAction) { case 'REFRESH': - await updateAndRenderWidget(); + await updateAndRenderWidget(true); break; case 'UPDATE_TASK': if (props.clickActionData && props.clickActionData.id) { @@ -126,7 +130,7 @@ export async function widgetTaskHandler(props: WidgetTaskHandlerProps) { if (task) { task.lastDone = Math.floor(Date.now() / 1000 / 60 / 60 / 24); // Set last done to today await taskRepository.update(parseInt(taskId.toString()), { ...task, lastDone: new Date().getTime() }); - await updateAndRenderWidget(); + await updateAndRenderWidget(true); } } break; diff --git a/index.tsx b/index.tsx index f3496bf..40efcbf 100644 --- a/index.tsx +++ b/index.tsx @@ -5,5 +5,3 @@ import "./i18n.js"; registerWidgetTaskHandler(widgetTaskHandler); -console.log(registerWidgetTaskHandler); - diff --git a/translations/ar.json b/translations/ar.json index 3ea4265..da78b7a 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -61,5 +61,7 @@ "Months": "أشهر", "select_icon_and_enter_title": "اختر رمزًا وأدخل عنوانًا", "Tasks": "المهام", - "Categories": "الفئات" + "Categories": "الفئات", + "task_reminder_title": "تذكير بالمهمة", + "is_due": "مستحقة!" } \ No newline at end of file diff --git a/translations/de.json b/translations/de.json index 47b9665..59b54d2 100644 --- a/translations/de.json +++ b/translations/de.json @@ -61,5 +61,7 @@ "Months": "Monate", "select_icon_and_enter_title": "Wählen Sie ein Symbol und geben Sie einen Titel ein", "Tasks": "Aufgaben", - "Categories": "Kategorien" + "Categories": "Kategorien", + "task_reminder_title": "Aufgabenerinnerung", + "is_due": "ist fällig!" } \ No newline at end of file diff --git a/translations/en.json b/translations/en.json index 43dfdcc..0591029 100644 --- a/translations/en.json +++ b/translations/en.json @@ -61,5 +61,7 @@ "Months": "Months", "select_icon_and_enter_title": "Select an icon and enter a title", "Tasks": "Tasks", - "Categories": "Categories" + "Categories": "Categories", + "task_reminder_title": "Task Reminder", + "is_due": "is due!" } \ No newline at end of file diff --git a/translations/es.json b/translations/es.json index 6ca255c..9eb0785 100644 --- a/translations/es.json +++ b/translations/es.json @@ -61,5 +61,7 @@ "Months": "Meses", "select_icon_and_enter_title": "Selecciona un ícono e ingresa un título", "Tasks": "Tareas", - "Categories": "Categorías" + "Categories": "Categorías", + "task_reminder_title": "Recordatorio de Tarea", + "is_due": "está vencida!" } \ No newline at end of file diff --git a/translations/fr.json b/translations/fr.json index 7ee6830..4a78d11 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -61,5 +61,7 @@ "Months": "Mois", "select_icon_and_enter_title": "Sélectionnez une icône et entrez un titre", "Tasks": "Tâches", - "Categories": "Catégories" + "Categories": "Catégories", + "task_reminder_title": "Rappel de Tâche", + "is_due": "est due!" } \ No newline at end of file diff --git a/translations/it.json b/translations/it.json index 0ad87e2..31fdbd6 100644 --- a/translations/it.json +++ b/translations/it.json @@ -61,5 +61,7 @@ "Months": "Mesi", "select_icon_and_enter_title": "Seleziona un'icona e inserisci un titolo", "Tasks": "Attività", - "Categories": "Categorie" + "Categories": "Categorie", + "task_reminder_title": "Promemoria Attività", + "is_due": "è scaduta!" } \ No newline at end of file diff --git a/translations/ja.json b/translations/ja.json index 52bddcd..a926889 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -61,5 +61,7 @@ "Months": "月", "select_icon_and_enter_title": "アイコンを選択してタイトルを入力", "Tasks": "タスク", - "Categories": "カテゴリ" + "Categories": "カテゴリ", + "task_reminder_title": "タスクリマインダー", + "is_due": "期限です!" } \ No newline at end of file diff --git a/translations/pt.json b/translations/pt.json index 68893d0..68f6d54 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -61,5 +61,7 @@ "Months": "Meses", "select_icon_and_enter_title": "Selecione um ícone e insira um título", "Tasks": "Tarefas", - "Categories": "Categorias" + "Categories": "Categorias", + "task_reminder_title": "Lembrete de Tarefa", + "is_due": "está vencida!" } \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json index 408cb42..b738a28 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -61,5 +61,7 @@ "Months": "Месяцы", "select_icon_and_enter_title": "Выберите значок и введите название", "Tasks": "Задачи", - "Categories": "Категории" + "Categories": "Категории", + "task_reminder_title": "Напоминание о задаче", + "is_due": "просрочено!" } \ No newline at end of file diff --git a/translations/zh.json b/translations/zh.json index 160b290..6f052d7 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -61,5 +61,7 @@ "Months": "月", "select_icon_and_enter_title": "选择一个图标并输入标题", "Tasks": "任务", - "Categories": "类别" + "Categories": "类别", + "task_reminder_title": "任务提醒", + "is_due": "已到期!" } \ No newline at end of file