From f049fb0cad0d137271c97796763d332043110ab3 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 15 Jun 2023 09:24:13 +0200 Subject: [PATCH] Honor badger --- FAQ.md | 3 ++ app/src/amazon/AndroidManifest.xml | 5 +++ app/src/fdroid/AndroidManifest.xml | 5 +++ app/src/github/AndroidManifest.xml | 5 +++ app/src/main/AndroidManifest.xml | 5 +++ .../leolin/shortcutbadger/ShortcutBadger.java | 2 ++ .../shortcutbadger/impl/HonorHomeBadger.java | 34 +++++++++++++++++++ app/src/play/AndroidManifest.xml | 5 +++ 8 files changed, 64 insertions(+) create mode 100644 app/src/main/java/me/leolin/shortcutbadger/impl/HonorHomeBadger.java diff --git a/FAQ.md b/FAQ.md index 43697bade9..dd34539f01 100644 --- a/FAQ.md +++ b/FAQ.md @@ -445,6 +445,9 @@ The following permissions are needed to show the count of unread messages as a b * *com.huawei.android.launcher.permission.CHANGE_BADGE* * *com.huawei.android.launcher.permission.READ_SETTINGS* * *com.huawei.android.launcher.permission.WRITE_SETTINGS* +* *com.hihonor.android.launcher.permission.CHANGE_BADGE* +* *com.hihonor.android.launcher.permission.READ_SETTINGS* +* *com.hihonor.android.launcher.permission.WRITE_SETTINGS* * *android.permission.READ_APP_BADGE* * *com.oppo.launcher.permission.READ_SETTINGS* * *com.oppo.launcher.permission.WRITE_SETTINGS* diff --git a/app/src/amazon/AndroidManifest.xml b/app/src/amazon/AndroidManifest.xml index cf7475ae97..4dbae788de 100644 --- a/app/src/amazon/AndroidManifest.xml +++ b/app/src/amazon/AndroidManifest.xml @@ -55,6 +55,11 @@ + + + + + diff --git a/app/src/fdroid/AndroidManifest.xml b/app/src/fdroid/AndroidManifest.xml index 5ea3b6803b..1a86c91bbb 100644 --- a/app/src/fdroid/AndroidManifest.xml +++ b/app/src/fdroid/AndroidManifest.xml @@ -57,6 +57,11 @@ + + + + + diff --git a/app/src/github/AndroidManifest.xml b/app/src/github/AndroidManifest.xml index 627db307f2..189c01a7d4 100644 --- a/app/src/github/AndroidManifest.xml +++ b/app/src/github/AndroidManifest.xml @@ -57,6 +57,11 @@ + + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index be99be32ac..46f25bf04d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -55,6 +55,11 @@ + + + + + diff --git a/app/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java b/app/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java index fa0ffa11a1..d51419a2e4 100644 --- a/app/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java +++ b/app/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java @@ -21,6 +21,7 @@ import me.leolin.shortcutbadger.impl.AsusHomeBadger; import me.leolin.shortcutbadger.impl.DefaultBadger; import me.leolin.shortcutbadger.impl.EverythingMeHomeBadger; import me.leolin.shortcutbadger.impl.HuaweiHomeBadger; +import me.leolin.shortcutbadger.impl.HonorHomeBadger; import me.leolin.shortcutbadger.impl.NewHtcHomeBadger; import me.leolin.shortcutbadger.impl.NovaHomeBadger; import me.leolin.shortcutbadger.impl.OPPOHomeBader; @@ -54,6 +55,7 @@ public final class ShortcutBadger { BADGERS.add(SonyHomeBadger.class); BADGERS.add(AsusHomeBadger.class); BADGERS.add(HuaweiHomeBadger.class); + BADGERS.add(HonorHomeBadger.class); BADGERS.add(OPPOHomeBader.class); BADGERS.add(SamsungHomeBadger.class); BADGERS.add(ZukHomeBadger.class); diff --git a/app/src/main/java/me/leolin/shortcutbadger/impl/HonorHomeBadger.java b/app/src/main/java/me/leolin/shortcutbadger/impl/HonorHomeBadger.java new file mode 100644 index 0000000000..0232c6ebd2 --- /dev/null +++ b/app/src/main/java/me/leolin/shortcutbadger/impl/HonorHomeBadger.java @@ -0,0 +1,34 @@ +package me.leolin.shortcutbadger.impl; + +import android.content.ComponentName; +import android.content.Context; +import android.net.Uri; +import android.os.Bundle; + +import java.util.Arrays; +import java.util.List; + +import me.leolin.shortcutbadger.Badger; +import me.leolin.shortcutbadger.ShortcutBadgeException; + +/** + * @author Jason Ling + */ +public class HonorHomeBadger implements Badger { + + @Override + public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException { + Bundle localBundle = new Bundle(); + localBundle.putString("package", context.getPackageName()); + localBundle.putString("class", componentName.getClassName()); + localBundle.putInt("badgenumber", badgeCount); + context.getContentResolver().call(Uri.parse("content://com.hihonor.android.launcher.settings/badge/"), "change_badge", null, localBundle); + } + + @Override + public List getSupportLaunchers() { + return Arrays.asList( + "com.hihonor.android.launcher" + ); + } +} diff --git a/app/src/play/AndroidManifest.xml b/app/src/play/AndroidManifest.xml index 2f0be1c3e2..fd00a46457 100644 --- a/app/src/play/AndroidManifest.xml +++ b/app/src/play/AndroidManifest.xml @@ -55,6 +55,11 @@ + + + + +