Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Fix a crash on Oreo produced by casting an AdaptiveIconDrawable to Bi… #11

Open
wants to merge 1 commit 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
16 changes: 8 additions & 8 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.3"

lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0.0"
}
Expand All @@ -22,12 +22,12 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'

provided 'com.android.support:cardview-v7:23.1.1'
compileOnly 'com.android.support:cardview-v7:28.0.0'

// Used for the preference classes
provided 'com.github.afollestad.material-dialogs:core:0.8.5.4@aar'
provided 'com.github.afollestad.material-dialogs:commons:0.8.5.4@aar'
implementation 'com.github.afollestad.material-dialogs:core:0.8.5.4@aar'
implementation 'com.github.afollestad.material-dialogs:commons:0.8.5.4@aar'
}
14 changes: 13 additions & 1 deletion library/src/main/java/com/afollestad/appthemeengine/ATE.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.Canvas;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
Expand Down Expand Up @@ -246,7 +248,7 @@ private static void applyTaskDescription(@NonNull Activity activity, @Nullable S
color = ATEUtil.stripAlpha(color);
// Default is app's launcher icon
if (icon == null)
icon = ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap();
icon = (getBitmapFromDrawable(activity.getApplicationInfo().loadIcon(activity.getPackageManager())));

// Sets color of entry in the system recents page
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
Expand Down Expand Up @@ -288,6 +290,16 @@ public static void themeOverflow(@NonNull Activity activity, @Nullable String ke
ATEUtil.setOverflowButtonColor(activity, toolbar, tintColor);
}

@NonNull
private static Bitmap getBitmapFromDrawable(@NonNull Drawable drawable) {
Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bmp;
}

private ATE() {
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.afollestad.appthemeengine;

import android.graphics.Canvas;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
Expand Down