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

Fix error with adaptive_background_color and round image on android #17

Merged
merged 1 commit into from Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/src/android.dart
Expand Up @@ -110,7 +110,7 @@ void _createAndroidAdaptiveIcon({
_createAdaptiveForeground(adaptiveIcons, foreground);
_createAdaptiveBackground(adaptiveIcons, background);
if (round != null) {
_createAdaptiveRound(androidIcons, round);
_createAdaptiveRound(androidIcons, round, isValidHexaCode(background));
} else {
_removeAndroidManifestIconLauncherRound();
}
Expand Down Expand Up @@ -189,6 +189,7 @@ void _createAdaptiveForeground(
void _createAdaptiveRound(
List<AndroidMipMapIconTemplate> adaptiveIcons,
String round,
bool backgroundIsColor,
) {
final roundImage = Icon.loadFile(round);
if (roundImage == null) {
Expand All @@ -210,7 +211,7 @@ void _createAdaptiveRound(
'Generated adaptive round images',
level: CliLoggerLevel.two,
);
_createIcLauncherRoundMipMapXmlFile();
_createIcLauncherRoundMipMapXmlFile(backgroundIsColor);
_createAndroidManifestIconLauncherRound();
}

Expand Down Expand Up @@ -322,11 +323,13 @@ void _createIcLauncherMipMapXmlFile() {
// }

/// Create ic_launcher_round.xml file
void _createIcLauncherRoundMipMapXmlFile() {
void _createIcLauncherRoundMipMapXmlFile(bool backgroundIsColor) {
final icLauncherXml = File(
'${_flavorHelper.androidResFolder}$ANDROID_ADAPTIVE_XML_DIR/$ANDROID_ADAPTIVE_ROUND_XML_FILE_NAME');
icLauncherXml.createSync(recursive: true);
icLauncherXml.writeAsStringSync(IC_LAUNCHER_ROUND_MIP_MAP_XML);
icLauncherXml.writeAsStringSync(backgroundIsColor
? IC_LAUNCHER_ROUND_BACKGROUND_COLOR_XML
: IC_LAUNCHER_ROUND_MIP_MAP_XML);
CliLogger.success(
'Created `$ANDROID_ADAPTIVE_ROUND_XML_FILE_NAME`',
level: CliLoggerLevel.two,
Expand Down