Skip to content

Commit

Permalink
Merge pull request #238 from HelloVolla/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
wurzer authored Jun 9, 2024
2 parents fce386e + 2bee58a commit a580e74
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 9 deletions.
1 change: 1 addition & 0 deletions AppGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 7 additions & 1 deletion AppGroup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Item {

property bool unreadMessages: false
property bool newCalls: false
property var notificationData:""

property var iconMap: ({})
property var labelMap: ({})
Expand Down Expand Up @@ -227,6 +228,7 @@ Item {
} else {
AN.SystemDispatcher.dispatch("volla.launcher.runAppAction", {"appId": model.package})
}
AN.SystemDispatcher.dispatch("volla.launcher.clearRedDot", {"package": model.package})
}
}
onPressAndHold: {
Expand Down Expand Up @@ -263,9 +265,11 @@ 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.topMargin: 6.0
anchors.leftMargin: (parent.width - parent.width * 0.6) * 0.5
width: parent.width * 0.15
height: parent.width * 0.15
Expand Down Expand Up @@ -417,6 +421,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"]
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions Collections.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="com.volla.launcher" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.4.9" android:versionCode="306" android:installLocation="auto">
<manifest package="com.volla.launcher" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.4.10" android:versionCode="307" android:installLocation="auto">
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="29"/>

<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +92,8 @@ public static final class InterceptedNotificationCode {
private String lastAttachment ="";
private String lastMessage ="";
Map errorProperty;
private NotificationStorageManager storageManager;

void NotificationListenerExampleService(){

}
Expand Down Expand Up @@ -153,14 +156,15 @@ public void onListenerConnected() {
@Override
public IBinder onBind(Intent intent) {
repository = new MessageRepository(getApplication());
storageManager = new NotificationStorageManager(getApplication());
return super.onBind(intent);
}

@RequiresApi(api = Build.VERSION_CODES.M)
@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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, Integer> getAllNotificationCounts() {
Map<String, Integer> notificationCounts = new HashMap<>();
Map<String, ?> allEntries = sharedPreferences.getAll();
for (Map.Entry<String, ?> 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;
}
}
13 changes: 13 additions & 0 deletions android/src/com/volla/launcher/worker/AppWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
import java.io.ByteArrayOutputStream;
import org.qtproject.qt5.android.QtNative;
import androidnative.SystemDispatcher;
import com.volla.launcher.storage.NotificationStorageManager;

public class AppWorker
{
private static final String TAG = "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() {
Expand Down Expand Up @@ -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<String, Integer> allCounts = storageManager.getAllNotificationCounts();
Map<String, Map> reply = new HashMap<String, Map>();
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"));
}
}
});
Expand Down
1 change: 1 addition & 0 deletions volla-launcher.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit a580e74

Please sign in to comment.