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

How to use iconPath? #688

Open
nomeata opened this issue Aug 30, 2020 · 2 comments
Open

How to use iconPath? #688

nomeata opened this issue Aug 30, 2020 · 2 comments

Comments

@nomeata
Copy link
Contributor

nomeata commented Aug 30, 2020

When I build my app with platform.android.buildApp, it gets a very generic icon, which I obviously want to replace. I see a iconPath parameter, as well a buildIcons derivation, but it is unclear to me how to use them – iconPath seems to be copied verbatim into the manifest, so surely a /nix/store path would not work well there…

@nomeata
Copy link
Contributor Author

nomeata commented Aug 30, 2020

Looks like I figured it out:

      platform.android.buildApp {
        package = p: p.…;
        …
        resources = platform.android.buildIcons {
          src = ./android-icon.png;
        };

does the job.

Unfortunately, now Android requires me to deal with figuring out how Adaptive Icons work.

@nomeata
Copy link
Contributor Author

nomeata commented Aug 30, 2020

Solved that with this quick hack:

--- /home/jojo/build/haskell/reflex/reflex-platform/android/buildIcons.nix	2019-05-11 11:44:46.110491485 +0200
+++ ./buildIcons.nix	2020-08-30 13:00:10.519888972 +0200
@@ -21,7 +21,18 @@
       local dir="$out/drawable-''${x}dpi"
       mkdir "$dir"
       convert -resize "$(launcherIconSize "$x")" -flatten "$src" "$dir/ic_launcher.png"
+      convert -resize "$(launcherIconSize "$x")" -flatten "$src" "$dir/ic_launcher_background.png"
+      convert -resize "$(launcherIconSize "$x")" -flatten "$src" "$dir/ic_launcher_foreground.png"
     done
+
+    mkdir $out/drawable-anydpi-v26
+    cat > $out/drawable-anydpi-v26/ic_launcher.xml <<__END__
+  <?xml version="1.0" encoding="utf-8"?>
+  <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+      <background android:drawable="@drawable/ic_launcher_background" />
+      <foreground android:drawable="@drawable/ic_launcher_foreground" />
+  </adaptive-icon>
+  __END__
   '';
   nativeBuildInputs = [
     imagemagick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants