Skip to content

Commit

Permalink
Merge pull request leolin310148#7 from mysms/add-more-launchers
Browse files Browse the repository at this point in the history
Add more launchers
  • Loading branch information
leolin310148 committed Nov 4, 2014
2 parents 203f55c + d3f4715 commit 48ab1bf
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ShortcutBadger/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@

<!--for sony-->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>

<!--for apex-->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public abstract class ShortcutBadger {
private static final String HOME_PACKAGE_LG = "com.lge.launcher2";
private static final String HOME_PACKAGE_HTC = "com.htc.launcher";
private static final String HOME_PACKAGE_ANDROID = "com.android.launcher";

private static final String HOME_PACKAGE_APEX = "com.anddoes.launcher";
private static final String HOME_PACKAGE_ADW = "org.adw.launcher";
private static final String HOME_PACKAGE_ADW_EX = "org.adwfreak.launcher";
private static final String HOME_PACKAGE_NOVA = "com.teslacoilsw.launcher";

private static final String MESSAGE_NOT_SUPPORT_BADGE_COUNT = "ShortBadger is currently not support the badgeCount \"%d\"";
private static final String MESSAGE_NOT_SUPPORT_THIS_HOME = "ShortcutBadger is currently not support the home launcher package \"%s\"";
Expand Down Expand Up @@ -65,6 +68,13 @@ public static void setBadge(Context context, int badgeCount) throws ShortcutBadg
mShortcutBadger = new NewHtcHomeBadger(context);
} else if (HOME_PACKAGE_ANDROID.equals(currentHomePackage)) {
mShortcutBadger = new AndroidHomeBadger(context);
} else if (HOME_PACKAGE_APEX.equals(currentHomePackage)) {
mShortcutBadger = new ApexHomeBadger(context);
} else if (HOME_PACKAGE_ADW.equals(currentHomePackage)
|| HOME_PACKAGE_ADW_EX.equals(currentHomePackage)) {
mShortcutBadger = new AdwHomeBadger(context);
} else if (HOME_PACKAGE_NOVA.equals(currentHomePackage)) {
mShortcutBadger = new NovaHomeBadger(context);
}

//not support this home launcher package
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package me.leolin.shortcutbadger.impl;

import android.content.Context;
import android.content.Intent;

import me.leolin.shortcutbadger.ShortcutBadgeException;
import me.leolin.shortcutbadger.ShortcutBadger;

/**
* @author Gernot Pansy
*/
public class AdwHomeBadger extends ShortcutBadger {

public static final String INTENT_UPDATE_COUNTER = "org.adw.launcher.counter.SEND";
public static final String PACKAGENAME = "PNAME";
public static final String COUNT = "COUNT";

public AdwHomeBadger(Context context) {
super(context);
}

@Override
protected void executeBadge(int badgeCount) throws ShortcutBadgeException {

Intent intent = new Intent(INTENT_UPDATE_COUNTER);
intent.putExtra(PACKAGENAME, getContextPackageName());
intent.putExtra(COUNT, badgeCount);
mContext.sendBroadcast(intent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package me.leolin.shortcutbadger.impl;

import android.content.Context;
import android.content.Intent;

import me.leolin.shortcutbadger.ShortcutBadgeException;
import me.leolin.shortcutbadger.ShortcutBadger;

/**
* @author Gernot Pansy
*/
public class ApexHomeBadger extends ShortcutBadger {

private static final String INTENT_UPDATE_COUNTER = "com.anddoes.launcher.COUNTER_CHANGED";
private static final String PACKAGENAME = "package";
private static final String COUNT = "count";
private static final String CLASS = "class";

public ApexHomeBadger(Context context) {
super(context);
}

@Override
protected void executeBadge(int badgeCount) throws ShortcutBadgeException {

Intent intent = new Intent(INTENT_UPDATE_COUNTER);
intent.putExtra(PACKAGENAME, getContextPackageName());
intent.putExtra(COUNT, badgeCount);
intent.putExtra(CLASS, getEntryActivityName());
mContext.sendBroadcast(intent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package me.leolin.shortcutbadger.impl;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

import me.leolin.shortcutbadger.ShortcutBadgeException;
import me.leolin.shortcutbadger.ShortcutBadger;

/**
* Shortcut Badger support for Nova Launcher.
*
* TeslaUnread must be installed.
*
* User: Gernot Pansy
* Date: 2014/11/03
* Time: 7:15
*/
public class NovaHomeBadger extends ShortcutBadger {

private static final String CONTENT_URI = "content://com.teslacoilsw.notifier/unread_count";
private static final String COUNT = "count";
private static final String TAG = "tag";

public NovaHomeBadger(final Context context) {
super(context);
}

@Override
protected void executeBadge(final int badgeCount) throws ShortcutBadgeException {
try {
ContentValues contentValues = new ContentValues();
contentValues.put(TAG, getContextPackageName() + "/" + getEntryActivityName());
contentValues.put(COUNT, badgeCount);
mContext.getContentResolver().insert(Uri.parse(CONTENT_URI), contentValues);
} catch (IllegalArgumentException ex) {
/* Fine, TeslaUnread is not installed. */
} catch (Exception ex) {

/* Some other error, possibly because the format
of the ContentValues are incorrect. */

throw new ShortcutBadgeException(ex.getMessage());
}
}
}

0 comments on commit 48ab1bf

Please sign in to comment.