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

Add monochrome launcher icon #511

Merged
merged 5 commits into from
Oct 24, 2023
Merged

Add monochrome launcher icon #511

merged 5 commits into from
Oct 24, 2023

Conversation

AhegaHOE
Copy link

@AhegaHOE AhegaHOE commented Oct 13, 2023

In this MR the monochrome launcher icon has been added which enables custom colors for Android users that use the Themed Icons feature.

For more info see: https://developer.android.com/develop/ui/views/launch/icon_design_adaptive

Tested on my Device (Google Pixel 6 with Android 14) and it works, the minimum SDK has been bumped to 26 in order to support the monochrome icon.

@Chaphasilor Chaphasilor added the hacktoberfest Issues available for Hacktoberfest label Oct 13, 2023
Copy link
Owner

@jmshrv jmshrv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change, just need to make sure about the API level change

minSdkVersion 21
minSdkVersion 26
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is changing the minimum API level required here? I'd rather not drop so many (albeit old) Android versions

Copy link
Author

@AhegaHOE AhegaHOE Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried building the app with the old version and it threw an error stating that the minimum API version is 26. 🤔

More info can be found here: https://developer.android.com/develop/ui/views/launch/icon_design_adaptive

Copy link
Author

@AhegaHOE AhegaHOE Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next, in res/mipmap-anydpi-v26/ic_launcher.xml, create alternative drawable resources in your app for backward compatibility with Android 8.0 (API level 26). Use the <adaptive-icon> element to define the foreground, background, and monochromatic layer drawables for your icons. The <foreground>, <background>, and <monochrome> inner elements support the android:drawable attribute.

This was on the site that I provided in the MR description, seems like anything lower than Android 8.0 (API level 26) is no longer supported when monochrome icons are defined.

@Chaphasilor
Copy link
Collaborator

How about we use redesign as the target branch? That one will be a breaking change anyway, and during the beta we can gauge if there is demand for older versions of Android 😁

@AhegaHOE
Copy link
Author

Sounds good to me 🦾

@AhegaHOE AhegaHOE changed the base branch from main to redesign October 18, 2023 21:06
@AhegaHOE AhegaHOE changed the base branch from redesign to main October 18, 2023 21:15
@AhegaHOE
Copy link
Author

AhegaHOE commented Oct 18, 2023

I tried rebasing onto redesign but somehow it get's all weird on my end. So I changed it back to main for now as I wasn't able to push the rebased changed to my branch...

To https://github.com/AhegaHOE/finamp.git
! [rejected]        add-material-design-icon -> add-material-design-icon (non-fast-forward)
error: failed to push some refs to 'https://github.com/AhegaHOE/finamp.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

already tried pulling, fetching and what not but the push is still getting rejected. Sadly I'm not too familiar with GitHub as I mainly work with GitLab.

@Chaphasilor
Copy link
Collaborator

@AhegaHOE if you use VS Code, try checking out your branch and the using the "Merge branch" command and select the redesign branch. If that doesn't work, I guess you should be able to perform a git reset origin/redesign --hard on your add-material-design-icon branch and then either cherry-pick or manually re-apply your changes, since there are only two changed lines and some files added :)

@AhegaHOE AhegaHOE changed the base branch from main to redesign October 18, 2023 21:39
@AhegaHOE
Copy link
Author

Merged redesign into my add-material-design-icon hopefully this is correct now! I somehow completely forgot about merging 😂

@Chaphasilor
Copy link
Collaborator

Looking at the changed lines, something seems to have gone awry 🙃
I'll take a look tomorrow...

In this commit the monochrome launcher icon has been added which enables custom colors for Android users that use the Themed Icons feature.

For more info see: https://developer.android.com/develop/ui/views/launch/icon_design_adaptive
@AhegaHOE
Copy link
Author

That seems a lot better now 😂

@Chaphasilor
Copy link
Collaborator

Yeah, looks good! @jmshrv any idea why the build might be failing? 😅

@AhegaHOE
Copy link
Author

When building I came across the same issue. Running flutter pub cache repair before running flutter pub get fixed it. The build fails because flutter has still some invalid caches that need to be defreshed first and only flutter pub get won't work.

@Chaphasilor
Copy link
Collaborator

In that case, maybe try running these commands and the committing the updated pubspec.lock file?

@AhegaHOE
Copy link
Author

AhegaHOE commented Oct 19, 2023

Well, the pubspec.lock doesn't change so it won't impact the Pipeline. We either have to wait for the caches to be invalidated/updated or temporarily change the definition of the Pipeline.

You can try to reproduce it locally:

flutter pub cache clean
git checkout origin main
flutter pub get
git checkout add-material-design-icon
flutter pub get
flutter build apk --debug

PS: Somehow I can't build it locally anymore, running into the same exact error as the Pipeline and running

  1. flutter pub cache repair or flutter pub cache clean
  2. flutter pub get
  3. flutter build apk --debug

results in the same exact issue.

@Chaphasilor
Copy link
Collaborator

There we go 😉
The lockfile was messed up and contained packages that weren't being used :)

@Chaphasilor
Copy link
Collaborator

Also confirmed that this is working as intended on Android 13 as well 😁

@AhegaHOE
Copy link
Author

There we go 😉
The lockfile was messed up and contained packages that weren't being used :)

What did you end up doing to fix it?
flutter pub upgrade by any chance?

@Chaphasilor
Copy link
Collaborator

@AhegaHOE sorry didn't see your comment. I deleted the global flutter cache (fluter pub cache clean) and deleted pubspec.lock, then built the app. This generated a new and valid lockfile :)

@jmshrv should I merge this?

@jmshrv
Copy link
Owner

jmshrv commented Oct 22, 2023

Yeah go ahead, API 26 is 93% of users (source), so it shouldn't be too bad

@AhegaHOE
Copy link
Author

@Chaphasilor no worries and thank you for the information 😁

@Chaphasilor Chaphasilor added the hacktoberfest-accepted Issues accepted to count as a Hacktoberfest contribution label Oct 22, 2023
@Chaphasilor Chaphasilor merged commit 35a2301 into jmshrv:redesign Oct 24, 2023
2 checks passed
@Chaphasilor
Copy link
Collaborator

Chaphasilor commented Oct 24, 2023

Finally merged :) Thanks a ton! <3

@AhegaHOE
Copy link
Author

It ain't much but I hope that a lot of people will enjoy it! I'm happy to contribute at least a little bit to this awesome project. ^^

@AhegaHOE AhegaHOE deleted the add-material-design-icon branch October 29, 2023 13:18
@jmshrv jmshrv mentioned this pull request Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues available for Hacktoberfest hacktoberfest-accepted Issues accepted to count as a Hacktoberfest contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants