Commit 4baa2db3 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Fix bug related to uninstall button and notification badge

parent d1f5ebce
......@@ -233,7 +233,7 @@ class IconTextView @JvmOverloads constructor(
cancelDotScaleAnim()
mDotScaleAnim = ObjectAnimator.ofFloat(
this,
UNINSTALL_SCALE_PROPERTY,
DOT_SCALE_PROPERTY,
*dotScales
).apply {
addListener(object : AnimatorListenerAdapter() {
......
......@@ -26,6 +26,7 @@ import android.location.LocationManager
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Process
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import android.provider.Settings
......@@ -274,28 +275,36 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
val cr = contentResolver
val setting = "enabled_notification_listeners"
var permissionString = Settings.Secure.getString(cr, setting)
if (permissionString == null || !permissionString.contains(packageName)) {
if (BuildConfig.DEBUG) {
val cn = ComponentName(this, NotificationListener::class.java)
val enabled = permissionString != null && (permissionString.contains(cn.flattenToString()) || permissionString.contains(cn.flattenToShortString()))
if (!enabled) {
val launcherApps: LauncherApps = getSystemService(LAUNCHER_APPS_SERVICE) as LauncherApps
val launcherInfo = launcherApps.getApplicationInfo(packageName, 0, Process.myUserHandle())
if(launcherInfo.flags and ApplicationInfo.FLAG_SYSTEM == 0) {
val args = Bundle()
args.putString(":settings:fragment_args_key", cn.flattenToString())
val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(":settings:fragment_args_key", cn.flattenToString())
.putExtra(":settings:show_fragment_args", args)
startActivity(
Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")
)
} else if (!Preferences.shouldAskForNotificationAccess(this)) {
val cn = ComponentName(
this,
NotificationService::class.java
intent
)
} else {
if (permissionString == null) {
permissionString = ""
} else {
permissionString += ":"
}
permissionString += cn.flattenToString()
val success = Settings.Secure.putString(cr, setting, permissionString)
if (success) {
Preferences.setNotToAskForNotificationAccess(this)
}
// Requires WRITE_SECURE_SETTINGS permission.
Settings.Secure.putString(cr, setting, permissionString)
}
}
Preferences.setNotToAskForNotificationAccess(this)
}
}
......
......@@ -6,6 +6,11 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import androidx.core.content.res.ResourcesCompat;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import foundation.e.blisslauncher.R;
......@@ -27,14 +32,10 @@ public class UninstallButtonRenderer {
}
public void draw(Canvas canvas, Rect iconBounds) {
Bitmap myBitmap = BitmapFactory.decodeResource(
mContext.getResources(),
R.drawable.ic_minus);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap, mSize, mSize, true);
canvas.drawBitmap(scaledBitmap, iconBounds.right - scaledBitmap.getWidth() / 2,
iconBounds.top - scaledBitmap.getHeight() / 2, mPaint);
//canvas.drawCircle(badgeCenterX, badgeCenterY, mSize/2, mPaint);
Drawable uninstallDrawable = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.ic_minus_white_16dp, mContext.getTheme());
uninstallDrawable.setBounds(iconBounds.right - mSize / 2,
iconBounds.top - mSize / 2, iconBounds.right + mSize / 2, iconBounds.top + mSize / 2);
uninstallDrawable.draw(canvas);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment