Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for ZTE MFV launcher badger #338

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions ShortcutBadger/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,13 @@ else if (Build.MANUFACTURER.equalsIgnoreCase("ZTE"))
* is <b>NOT</b> used by <b><i>sShortcutBadger</i></b>.
*/
private static boolean isLauncherVersionSupported(Context context, String currentHomePackage) {
if (!YandexLauncherBadger.PACKAGE_NAME.equals(currentHomePackage)) {
if (YandexLauncherBadger.PACKAGE_NAME.equals(currentHomePackage)) {
return YandexLauncherBadger.isVersionSupported(context);
} else if (ZTEHomeBadger.PACKAGE_NAME_MFV.equals(currentHomePackage)) {
return ZTEHomeBadger.isMFVLauncher(currentHomePackage);
} else {
return true;
}
return YandexLauncherBadger.isVersionSupported(context);
}

/**
Expand Down
28 changes: 24 additions & 4 deletions ShortcutBadger/src/main/java/me/leolin/shortcutbadger/impl/ZTEHomeBadger.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
import android.os.Bundle;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import me.leolin.shortcutbadger.Badger;
import me.leolin.shortcutbadger.ShortcutBadgeException;

public class ZTEHomeBadger implements Badger {

public static final String PACKAGE_NAME_MFV = "com.zte.mifavor.launcher";
public static final String PACKAGE_NAME_STOCK = "com.android.launcher3";
private static boolean mMFVBadger = false;

@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount)
throws ShortcutBadgeException {
Expand All @@ -22,15 +27,30 @@ public void executeBadge(Context context, ComponentName componentName, int badge
extra.putString("app_badge_component_name", componentName.flattenToString());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
context.getContentResolver().call(
Uri.parse("content://com.android.launcher3.cornermark.unreadbadge"),
"setAppUnreadCount", null, extra);
if (mMFVBadger) {
context.getContentResolver().call(
Uri.parse("content://com.zte.mifavor.launcher.unreadbadge"),
"setAppUnreadCount", null, extra);
} else {
context.getContentResolver().call(
Uri.parse("content://com.android.launcher3.cornermark.unreadbadge"),
"setAppUnreadCount", null, extra);
}
}
}

public static boolean isMFVLauncher(String currentHomePackage) {
if (PACKAGE_NAME_MFV.equals(currentHomePackage)) {
mMFVBadger = true;
} else {
mMFVBadger = false;
}
return mMFVBadger;
}

@Override
public List<String> getSupportLaunchers() {
return new ArrayList<String>(0);
return Collections.singletonList(PACKAGE_NAME_MFV);
}
}