From 5ab1934b3a5dc25283234d8443447623fa7668c0 Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 29 May 2024 20:23:09 +0530 Subject: [PATCH 1/6] Adding new NotificationStorageManager class to keep track of notification storage and retreival --- .../storage/NotificationStorageManager.java | 51 +++++++++++++++++++ volla-launcher.pro | 1 + 2 files changed, 52 insertions(+) create mode 100644 android/src/com/volla/launcher/storage/NotificationStorageManager.java diff --git a/android/src/com/volla/launcher/storage/NotificationStorageManager.java b/android/src/com/volla/launcher/storage/NotificationStorageManager.java new file mode 100644 index 00000000..5d9c805e --- /dev/null +++ b/android/src/com/volla/launcher/storage/NotificationStorageManager.java @@ -0,0 +1,51 @@ +package com.volla.launcher.storage; + +import android.content.Context; +import android.content.SharedPreferences; + +import java.util.HashMap; +import java.util.Map; + +public class NotificationStorageManager { + + private static final String PREF_NAME = "PendingNotifications"; + private static final String KEY_PACKAGE_PREFIX = "volla_"; + private static final String KEY_COUNT_SUFFIX = "_count"; + + private SharedPreferences sharedPreferences; + + public NotificationStorageManager(Context context) { + sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + } + + public void storeNotificationCount(String packageName, int count) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt(KEY_PACKAGE_PREFIX + packageName + KEY_COUNT_SUFFIX, count); + editor.apply(); + } + + public int getNotificationCount(String packageName) { + return sharedPreferences.getInt(KEY_PACKAGE_PREFIX + packageName + KEY_COUNT_SUFFIX, 0); + } + + public void clearNotificationCount(String packageName) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.remove(KEY_PACKAGE_PREFIX + packageName + KEY_COUNT_SUFFIX); + editor.apply(); + } + + + public Map getAllNotificationCounts() { + Map notificationCounts = new HashMap<>(); + Map allEntries = sharedPreferences.getAll(); + for (Map.Entry entry : allEntries.entrySet()) { + String key = entry.getKey(); + if (key.startsWith(KEY_PACKAGE_PREFIX) && key.endsWith(KEY_COUNT_SUFFIX)) { + String packageName = key.substring(KEY_PACKAGE_PREFIX.length(), key.length() - KEY_COUNT_SUFFIX.length()); + int count = (Integer) entry.getValue(); + notificationCounts.put(packageName, count); + } + } + return notificationCounts; + } + } diff --git a/volla-launcher.pro b/volla-launcher.pro index 623b7b92..0e7c7d0b 100644 --- a/volla-launcher.pro +++ b/volla-launcher.pro @@ -67,6 +67,7 @@ DISTFILES += \ android/src/com/volla/launcher/storage/MessageDatabase.java \ android/src/com/volla/launcher/storage/MessageV2.java \ android/src/com/volla/launcher/storage/MigrationFromVersion1To2.java \ + android/src/com/volla/launcher/storage/NotificationStorageManager.java \ android/src/com/volla/launcher/storage/Users.java \ android/src/com/volla/launcher/storage/UsersDao.java \ android/src/com/volla/launcher/util/MMSManager.java \ From 87fad24f87f52aca623d61cfb2767c2a7dd85639 Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 29 May 2024 20:27:25 +0530 Subject: [PATCH 2/6] Implementing worker side to retrieve notification data through NotificationStorageManager --- .../src/com/volla/launcher/worker/AppWorker.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/android/src/com/volla/launcher/worker/AppWorker.java b/android/src/com/volla/launcher/worker/AppWorker.java index 156a353d..7ab868f1 100644 --- a/android/src/com/volla/launcher/worker/AppWorker.java +++ b/android/src/com/volla/launcher/worker/AppWorker.java @@ -28,6 +28,7 @@ import java.io.ByteArrayOutputStream; import org.qtproject.qt5.android.QtNative; import androidnative.SystemDispatcher; +import com.volla.launcher.storage.NotificationStorageManager; public class AppWorker { @@ -35,6 +36,9 @@ public class AppWorker public static final String GET_APPS = "volla.launcher.appAction"; public static final String GOT_APPS = "volla.launcher.appResponse"; + public static final String GET_Notification = "volla.launcher.otherAppNotificationAction"; + public static final String GOT_Notification = "volla.launcher.otherAppNotificationResponce"; + public static final String CLEAR_RED_DOT = "volla.launcher.clearRedDot"; static { SystemDispatcher.addListener(new SystemDispatcher.Listener() { @@ -129,6 +133,15 @@ public void run() { Thread thread = new Thread(runnable); thread.start(); + } else if(type.equals(GET_Notification)) { + NotificationStorageManager storageManager = new NotificationStorageManager(activity); + Map allCounts = storageManager.getAllNotificationCounts(); + Map reply = new HashMap(); + reply.put("Notification", allCounts ); + SystemDispatcher.dispatch(GOT_Notification,reply); + } else if (type.equals(CLEAR_RED_DOT)) { + NotificationStorageManager storageManager = new NotificationStorageManager(activity); + storageManager.clearNotificationCount((String) message.get("package")); } } }); From bb24f9778ded339bec8cdff17b40f7063d7a658c Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 29 May 2024 20:32:52 +0530 Subject: [PATCH 3/6] Adding SystemDispatcher for apps(excluding Message and phone) Notifications Action --- AppGrid.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/AppGrid.qml b/AppGrid.qml index 9361e597..4124ea38 100644 --- a/AppGrid.qml +++ b/AppGrid.qml @@ -175,6 +175,7 @@ LauncherPage { function updateNotifications() { AN.SystemDispatcher.dispatch("volla.launcher.callCountAction", {"is_read": 0}) AN.SystemDispatcher.dispatch("volla.launcher.threadsCountAction", {"read": 0}) + AN.SystemDispatcher.dispatch("volla.launcher.otherAppNotificationAction", {"read": 0}) } function getAllApps() { From c7fafb0abc47c5018b9ecba6f0bb9c73ef9637e2 Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 29 May 2024 20:47:33 +0530 Subject: [PATCH 4/6] Adding clearRedDispatcher and handling notification data received from Dispatcher --- AppGroup.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AppGroup.qml b/AppGroup.qml index d8e87134..d45687c3 100644 --- a/AppGroup.qml +++ b/AppGroup.qml @@ -27,6 +27,7 @@ Item { property bool unreadMessages: false property bool newCalls: false + property var notificationData:"" property var iconMap: ({}) property var labelMap: ({}) @@ -225,6 +226,7 @@ Item { } else { AN.SystemDispatcher.dispatch("volla.launcher.runAppAction", {"appId": model.package}) } + AN.SystemDispatcher.dispatch("volla.launcher.clearRedDot", {"package": model.package}) } } onPressAndHold: { @@ -261,7 +263,8 @@ Item { Rectangle { id: notificationBadge visible: groupItem.messageApp.includes(model.package) ? groupItem.unreadMessages - : model.package === groupItem.phoneApp ? groupItem.newCalls : false + : model.package === groupItem.phoneApp ? groupItem.newCalls + : groupItem.notificationData.hasOwnProperty(model.package) ? true : false anchors.top: parent.top anchors.left: parent.left anchors.leftMargin: (parent.width - parent.width * 0.6) * 0.5 @@ -415,6 +418,8 @@ Item { } else if (type === "volla.launcher.threadsCountResponse") { console.log("AppGroup " + groupIndex + " | Unread messages: " + message["threadsCount"]) groupItem.unreadMessages = message["threadsCount"] > 0 + } else if(type === "volla.launcher.otherAppNotificationResponce") { + groupItem.notificationData = message["Notification"] } } } From aacc697307d46c3aa06dfe6310d1ed0b3e9543eb Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 29 May 2024 23:34:50 +0530 Subject: [PATCH 5/6] Storing notification with package name through NotificationStorageManager --- .../service/NotificationListenerExampleService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/com/volla/launcher/service/NotificationListenerExampleService.java b/android/src/com/volla/launcher/service/NotificationListenerExampleService.java index 0a5d1395..3f3543f0 100644 --- a/android/src/com/volla/launcher/service/NotificationListenerExampleService.java +++ b/android/src/com/volla/launcher/service/NotificationListenerExampleService.java @@ -40,6 +40,7 @@ import android.graphics.Matrix; import com.volla.launcher.util.NotificationPlugin; import java.util.Map; +import com.volla.launcher.storage.NotificationStorageManager; /** * MIT License @@ -91,6 +92,8 @@ public static final class InterceptedNotificationCode { private String lastAttachment =""; private String lastMessage =""; Map errorProperty; + private NotificationStorageManager storageManager; + void NotificationListenerExampleService(){ } @@ -153,6 +156,7 @@ public void onListenerConnected() { @Override public IBinder onBind(Intent intent) { repository = new MessageRepository(getApplication()); + storageManager = new NotificationStorageManager(getApplication()); return super.onBind(intent); } @@ -160,7 +164,7 @@ public IBinder onBind(Intent intent) { @Override public void onNotificationPosted(StatusBarNotification sbn){ Log.d(TAG, "onNotificationPosted"); - + storageManager.storeNotificationCount(sbn.getPackageName(), storageManager.getNotificationCount(sbn.getPackageName()) +1 ); Log.d(TAG, "listeners size : " +listeners.size()); for (NotificationListener listener : listeners) { listener.onNotificationPosted(sbn); @@ -175,7 +179,7 @@ public void onNotificationPosted(StatusBarNotification sbn){ try { my_custom = sbn; notificationData = new NotificationData(); - errorProperty = new HashMap(); + errorProperty = new HashMap(); notificationData.id = sbn.getId(); notificationData.key = sbn.getKey(); notificationData.userHandle = sbn.getUser().describeContents(); From e0b40de17f811529800ecbad8c2fd25c44c6a7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20J=C3=B6rg=20Wurzer?= Date: Sat, 8 Jun 2024 23:49:20 +0200 Subject: [PATCH 6/6] Red dot notifications --- AppGroup.qml | 1 + Collections.qml | 10 +++++----- android/AndroidManifest.xml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/AppGroup.qml b/AppGroup.qml index cabe25c2..212c126d 100644 --- a/AppGroup.qml +++ b/AppGroup.qml @@ -269,6 +269,7 @@ Item { : groupItem.notificationData.hasOwnProperty(model.package) ? true : false anchors.top: parent.top anchors.left: parent.left + anchors.topMargin: 6.0 anchors.leftMargin: (parent.width - parent.width * 0.6) * 0.5 width: parent.width * 0.15 height: parent.width * 0.15 diff --git a/Collections.qml b/Collections.qml index aa02ef8f..661eae15 100644 --- a/Collections.qml +++ b/Collections.qml @@ -310,7 +310,7 @@ LauncherPage { || collectionPage.currentCollectionMode === mainView.collectionMode.Notes ? contactBox.width - mainView.innerSpacing * 2 - contactRow.spacing : contactBox.width - mainView.innerSpacing * 2 - collectionPage.iconSize - contactRow.spacing - property var gradientColer: Universal.background + property var gradientColor: Universal.background Label { id: sourceLabel @@ -345,11 +345,11 @@ LauncherPage { gradient: Gradient { GradientStop { position: 0.0 - color: "#00000000" + color: "transparent" } GradientStop { position: 1.0 - color: backgroundItem.isMenuStatus ? mainView.accemtColor : contactColumn.gradientColer + color: backgroundItem.isMenuStatus ? mainView.accentColor : contactColumn.gradientColor } } visible: mainView.backgroundOpacity === 1.0 @@ -411,11 +411,11 @@ LauncherPage { gradient: Gradient { GradientStop { position: 0.0 - color: "#00000000" + color: "transparent" } GradientStop { position: 1.0 - color: backgroundItem.isMenuStatus ? mainView.accentColor : contactColumn.gradientColer + color: backgroundItem.isMenuStatus ? mainView.accentColor : contactColumn.gradientColor } } visible: mainView.backgroundOpacity === 1.0 diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index d430e3d0..be1c1e70 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - +