From b07038b02413f9cc03af61b04117880ea091b8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Romero?= Date: Sat, 31 Oct 2026 16:43:15 +0100 Subject: [PATCH] ohos: hide the app icon choice --- platform/README.md | 1 + src/app_icon.rs | 8 ++++++-- src/platform/android.rs | 3 +++ src/platform/ios.rs | 3 +++ src/platform/ohos.rs | 5 ++++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/README.md b/platform/README.md index cb4d4813..3f57993c 100644 --- a/platform/README.md +++ b/platform/README.md @@ -86,6 +86,7 @@ provides these crate-internal items, which shared code calls without a `cfg`: | `lower_current_thread_priority()` | Run the PDF worker thread at background priority. | | `install_preview_lifecycle()` | Register for background/memory-pressure notifications, which must call `flectar_mail::suspend_file_preview()`. | | `NAME` | The platform's name, which Settings uses to describe where the app icon appears. | +| `SWITCHES_APP_ICON` | Whether apps may switch their home screen icon. Settings offers the choice only where they may. | | `show_app_icon(icon)` | Show the app icon chosen in Settings on the home screen. Android forwards it to the bridge its host registers with `configure_launcher_icon`; iOS switches to the alternate icon sets declared in `platform/ios/project.yml`. | | `email_font_dir()` | Platform font directory for the email (Blitz/Parley) renderer on hosts without Fontconfig; `None` when the fontique system backend provides the fonts. | diff --git a/src/app_icon.rs b/src/app_icon.rs index ada86def..a42b7f00 100644 --- a/src/app_icon.rs +++ b/src/app_icon.rs @@ -13,15 +13,19 @@ //! - mobile home screens switch to icons bundled with the app, through the //! platform layer. //! -//! Flatpak can neither show a tray nor write to the host's icon theme, so the -//! choice is not offered there. +//! Flatpak can neither show a tray nor write to the host's icon theme, and +//! some mobile platforms reserve switching the home screen icon for system +//! apps, so the choice is not offered there. use crate::{AppIconVariant, AppWindow, tray_ui::FlectarTray}; use flectar_mail_core::models; use slint::ComponentHandle; use std::cell::RefCell; +#[cfg(desktop)] pub(crate) const AVAILABLE: bool = cfg!(not(feature = "flatpak")); +#[cfg(mobile)] +pub(crate) const AVAILABLE: bool = crate::platform::SWITCHES_APP_ICON; /// Lets Settings describe where this platform shows the icon. #[cfg(desktop)] diff --git a/src/platform/android.rs b/src/platform/android.rs index 7f6e45ac..6aafd123 100644 --- a/src/platform/android.rs +++ b/src/platform/android.rs @@ -61,6 +61,9 @@ pub fn configure_launcher_icon(switch: impl Fn(&str) + Send + Sync + 'static) { let _ = LAUNCHER_ICON.set(Box::new(switch)); } +/// Android apps may switch their launcher icon, so Settings offers the choice. +pub(crate) const SWITCHES_APP_ICON: bool = true; + pub(crate) fn show_app_icon(icon: AppIcon) { if let Some(switch) = LAUNCHER_ICON.get() { switch(icon.as_str()); diff --git a/src/platform/ios.rs b/src/platform/ios.rs index 2d7eddd4..bf20a622 100644 --- a/src/platform/ios.rs +++ b/src/platform/ios.rs @@ -73,6 +73,9 @@ pub(crate) fn install_preview_lifecycle() { unsafe { install_pdf_lifecycle_observers() } } +/// iOS apps may switch to alternate icons, so Settings offers the choice. +pub(crate) const SWITCHES_APP_ICON: bool = true; + /// Show the alternate icon set declared in project.yml, or the primary icon. pub(crate) fn show_app_icon(icon: AppIcon) { let name: Option<&CStr> = match icon { diff --git a/src/platform/ohos.rs b/src/platform/ohos.rs index 0e40b33f..b4d381eb 100644 --- a/src/platform/ohos.rs +++ b/src/platform/ohos.rs @@ -55,7 +55,10 @@ pub(crate) fn lower_current_thread_priority() { pub(crate) fn install_preview_lifecycle() {} /// Switching the home screen icon is a system API on OpenHarmony -/// (`bundleManager.enableDynamicIcon`), so the choice applies inside the app. +/// (`bundleManager.enableDynamicIcon`), so Settings does not offer the choice. +pub(crate) const SWITCHES_APP_ICON: bool = false; + +/// Only the default icon reaches here; see [`SWITCHES_APP_ICON`]. pub(crate) fn show_app_icon(_icon: AppIcon) {} /// Directory the email (Blitz/Parley) renderer loads fonts from. OpenHarmony