merge conflict
This commit is contained in:
commit
3815ce2ec0
|
|
@ -3,4 +3,4 @@
|
||||||
build
|
build
|
||||||
.gradle
|
.gradle
|
||||||
local.properties
|
local.properties
|
||||||
**/gradle.properties
|
**/gradle.properties
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,4 @@ LICENSE
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
||||||
compileSdkVersion 19
|
compileSdkVersion 19
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,7 @@
|
||||||
<!--for apex-->
|
<!--for apex-->
|
||||||
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
|
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
|
||||||
|
|
||||||
|
<!--for solid-->
|
||||||
|
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ public abstract class ShortcutBadger {
|
||||||
private static final String HOME_PACKAGE_ANDROID1 = "com.android.launcher";
|
private static final String HOME_PACKAGE_ANDROID1 = "com.android.launcher";
|
||||||
private static final String HOME_PACKAGE_ANDROID2 = "com.android.launcher2";
|
private static final String HOME_PACKAGE_ANDROID2 = "com.android.launcher2";
|
||||||
private static final String HOME_PACKAGE_ANDROID3 = "com.google.android.googlequicksearchbox";
|
private static final String HOME_PACKAGE_ANDROID3 = "com.google.android.googlequicksearchbox";
|
||||||
|
private static final String HOME_PACKAGE_SOLID = "com.majeur.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_BADGE_COUNT = "ShortBadger is currently not support the badgeCount \"%d\"";
|
||||||
|
|
@ -78,7 +79,6 @@ public abstract class ShortcutBadger {
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new ShortcutBadgeException("Unable to execute badge:" + e.getMessage());
|
throw new ShortcutBadgeException("Unable to execute badge:" + e.getMessage());
|
||||||
}
|
}
|
||||||
shortcutBadger.executeBadge(badgeCount);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,6 +117,8 @@ public abstract class ShortcutBadger {
|
||||||
sShortcutBadger = new AdwHomeBadger(context);
|
sShortcutBadger = new AdwHomeBadger(context);
|
||||||
} else if (HOME_PACKAGE_NOVA.equals(currentHomePackage)) {
|
} else if (HOME_PACKAGE_NOVA.equals(currentHomePackage)) {
|
||||||
sShortcutBadger = new NovaHomeBadger(context);
|
sShortcutBadger = new NovaHomeBadger(context);
|
||||||
|
} else if (HOME_PACKAGE_SOLID.equals(currentHomePackage)) {
|
||||||
|
sShortcutBadger = new SolidHomeBadger(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ public class SamsungHomeBadger extends ShortcutBadger {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
int id = cursor.getInt(0);
|
int id = cursor.getInt(0);
|
||||||
ContentValues contentValues = getContentValues(badgeCount);
|
ContentValues contentValues = getContentValues(badgeCount, false);
|
||||||
contentResolver.update(mUri, contentValues, "_id=?", new String[]{String.valueOf(id)});
|
contentResolver.update(mUri, contentValues, "_id=?", new String[]{String.valueOf(id)});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ContentValues contentValues = getContentValues(badgeCount);
|
ContentValues contentValues = getContentValues(badgeCount, true);
|
||||||
contentResolver.insert(mUri, contentValues);
|
contentResolver.insert(mUri, contentValues);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -42,11 +42,15 @@ public class SamsungHomeBadger extends ShortcutBadger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContentValues getContentValues(int badgeCount) {
|
private ContentValues getContentValues(int badgeCount, boolean isInsert) {
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
contentValues.put("package", getContextPackageName());
|
if (isInsert) {
|
||||||
contentValues.put("class", getEntryActivityName());
|
contentValues.put("package", getContextPackageName());
|
||||||
|
contentValues.put("class", getEntryActivityName());
|
||||||
|
}
|
||||||
|
|
||||||
contentValues.put("badgecount", badgeCount);
|
contentValues.put("badgecount", badgeCount);
|
||||||
|
|
||||||
return contentValues;
|
return contentValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package me.leolin.shortcutbadger.impl;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import me.leolin.shortcutbadger.ShortcutBadgeException;
|
||||||
|
import me.leolin.shortcutbadger.ShortcutBadger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author MajeurAndroid
|
||||||
|
*/
|
||||||
|
public class SolidHomeBadger extends ShortcutBadger {
|
||||||
|
|
||||||
|
private static final String INTENT_UPDATE_COUNTER = "com.majeur.launcher.intent.action.UPDATE_BADGE";
|
||||||
|
private static final String PACKAGENAME = "com.majeur.launcher.intent.extra.BADGE_PACKAGE";
|
||||||
|
private static final String COUNT = "com.majeur.launcher.intent.extra.BADGE_COUNT";
|
||||||
|
private static final String CLASS = "com.majeur.launcher.intent.extra.BADGE_CLASS";
|
||||||
|
|
||||||
|
public SolidHomeBadger(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
package me.leolin.shortcutbadger.util;
|
package me.leolin.shortcutbadger.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import me.leolin.shortcutbadger.ShortcutBadgeException;
|
import me.leolin.shortcutbadger.ShortcutBadgeException;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created with IntelliJ IDEA.
|
* Created with IntelliJ IDEA.
|
||||||
|
|
@ -41,19 +40,18 @@ public class ImageUtil {
|
||||||
|
|
||||||
public static byte[] drawBadgeOnAppIcon(Context context, int badgeCount) throws ShortcutBadgeException {
|
public static byte[] drawBadgeOnAppIcon(Context context, int badgeCount) throws ShortcutBadgeException {
|
||||||
|
|
||||||
Bitmap appIcon = null;
|
Bitmap appIcon;
|
||||||
String gText = String.valueOf(badgeCount);
|
String gText = String.valueOf(badgeCount);
|
||||||
|
|
||||||
List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
|
try {
|
||||||
for (PackageInfo packageInfo : packages) {
|
Drawable iconDrawable = context.getPackageManager().getApplicationIcon(context.getPackageName());
|
||||||
if (context.getPackageName().equals(packageInfo.packageName)) {
|
appIcon = drawableToBitmap(iconDrawable);
|
||||||
Drawable drawable = packageInfo.applicationInfo.loadIcon(context.getPackageManager());
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
appIcon = drawableToBitmap(drawable);
|
throw new ShortcutBadgeException("Could not load the app Icon");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appIcon == null) {
|
if (appIcon == null) {
|
||||||
throw new ShortcutBadgeException("count not load the app Icon");
|
throw new ShortcutBadgeException("Could not load the app Icon");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badgeCount == 0) {
|
if (badgeCount == 0) {
|
||||||
|
|
@ -78,38 +76,31 @@ public class ImageUtil {
|
||||||
float cx = appIcon.getWidth() - radius;
|
float cx = appIcon.getWidth() - radius;
|
||||||
float cy = radius;
|
float cy = radius;
|
||||||
|
|
||||||
|
|
||||||
Paint paint_red = new Paint();
|
|
||||||
paint_red.setColor(Color.RED);
|
|
||||||
Paint paint_white = new Paint();
|
|
||||||
paint_white.setColor(Color.WHITE);
|
|
||||||
Canvas canvas = new Canvas(appIcon);
|
Canvas canvas = new Canvas(appIcon);
|
||||||
canvas.drawCircle(cx, cy, radius, paint_white);
|
//ANTI_ALIAS to avoid glitched circles
|
||||||
|
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
paint.setColor(Color.WHITE);
|
||||||
|
canvas.drawCircle(cx, cy, radius, paint);
|
||||||
|
paint.setColor(Color.RED);
|
||||||
|
canvas.drawCircle(cx, cy, radius * 6 / 7, paint);
|
||||||
|
|
||||||
|
paint.setColor(Color.WHITE);
|
||||||
canvas.drawCircle(cx, cy, radius * 6 / 7, paint_red);
|
|
||||||
|
|
||||||
|
|
||||||
// new antialised Paint
|
|
||||||
Paint paint_text = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
||||||
// text color - #3D3D3D
|
|
||||||
paint_text.setColor(Color.WHITE);
|
|
||||||
// text size in pixels
|
// text size in pixels
|
||||||
int textSize = (int)(radius*0.7);
|
int textSize = (int) (radius * 0.7);
|
||||||
if (gText.length() > 1) {
|
if (gText.length() > 1) {
|
||||||
textSize = (int)(radius*0.5);
|
textSize = (int) (radius * 0.5);
|
||||||
}
|
}
|
||||||
paint_text.setTextSize((int) (textSize * scale));
|
paint.setTextSize((int) (textSize * scale));
|
||||||
paint_text.setFakeBoldText(true);
|
paint.setFakeBoldText(true);
|
||||||
// draw text to the Canvas center
|
// draw text to the Canvas center
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
paint_text.getTextBounds(gText, 0, gText.length(), bounds);
|
paint.getTextBounds(gText, 0, gText.length(), bounds);
|
||||||
float bw = bounds.width() / 2;
|
float bw = bounds.width() / 2;
|
||||||
if (gText.endsWith("1")) {
|
if (gText.endsWith("1")) {
|
||||||
bw *= 1.25;
|
bw *= 1.25;
|
||||||
}
|
}
|
||||||
float bh = bounds.height() / 2;
|
float bh = bounds.height() / 2;
|
||||||
canvas.drawText(gText, cx - bw, cy + bh, paint_text);
|
canvas.drawText(gText, cx - bw, cy + bh, paint);
|
||||||
|
|
||||||
return bitmapToByteArray(appIcon);
|
return bitmapToByteArray(appIcon);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#Wed Mar 04 10:08:25 CST 2015
|
#Thu Mar 12 21:22:24 CST 2015
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue