android: Loader - load early (before service thread) both in activity and service.

Loader converted from java to kotlin.

Instead of loading libmpd when the service thread is started,
the service will not start the the thread if libmpd failed to load.

The loader is also accessed by the view data to let
the ui adjust if failed to load, by showing the failure reason
and disabling the Start MPD button.
This commit is contained in:
gd
2025-02-06 14:23:26 +02:00
parent ae1c5e3424
commit f1e43cb498
7 changed files with 155 additions and 60 deletions
+21 -10
View File
@@ -1,14 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MPD</string>
<string name="notification_title_mpd_running">Music Player Daemon is running</string>
<string name="notification_text_mpd_running">Touch for MPD options.</string>
<string name="toggle_button_run_on">MPD is running</string>
<string name="toggle_button_run_off">MPD is not running</string>
<string name="checkbox_run_on_boot">Run MPD automatically on boot</string>
<string name="checkbox_wakelock">Prevent suspend when MPD is running (Wakelock)</string>
<string name="checkbox_pause_on_headphones_disconnect">Pause MPD when headphones disconnect</string>
<string name="external_files_permission_request">MPD requires access to external files to play local music. Please grant the permission.</string>
<string name="title_open_app_info">Open app info</string>
<string name="app_name">MPD</string>
<string name="notification_title_mpd_running">Music Player Daemon is running</string>
<string name="notification_text_mpd_running">Touch for MPD options.</string>
<string name="toggle_button_run_on">MPD is running</string>
<string name="toggle_button_run_off">MPD is not running</string>
<string name="checkbox_run_on_boot">Run MPD automatically on boot</string>
<string name="checkbox_wakelock">Prevent suspend when MPD is running (Wakelock)</string>
<string name="checkbox_pause_on_headphones_disconnect">Pause MPD when headphones disconnect</string>
<string name="external_files_permission_request">MPD requires access to external files to play local music. Please grant the permission.</string>
<string name="title_open_app_info">Open app info</string>
<string name="mpd_load_failure_message">"Failed to load the native MPD library.
Report this problem to us, and include the following information:
SUPPORTED_ABIS=%1$s
PRODUCT=%2$s
FINGERPRINT=%3$s
error=%4$s"
</string>
<string name="stopped">Stopped</string>
<string name="running">Running</string>
<string name="stopMPD">Stop MPD</string>
<string name="startMPD">Start MPD</string>
</resources>
+18 -1
View File
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MPD" parent="android:Theme.Material.Light.NoActionBar" />
<color name="red_500">#F44336</color>
<color name="red_900">#B71C1C</color>
<color name="green_300">#81C784</color>
<color name="green_700">#388E3C</color>
<color name="colorErrorOnLight">@color/red_900</color>
<color name="colorErrorOnDark">@color/red_500</color>
<color name="colorSuccessOnLight">@color/green_700</color>
<color name="colorSuccessOnDark">@color/green_300</color>
<attr name="appColorNegative" format="color|reference" />
<attr name="appColorPositive" format="color|reference" />
<style name="Theme.MPD" parent="android:Theme.Material.Light.NoActionBar">
<item name="appColorNegative">@color/colorErrorOnLight</item>
<item name="appColorPositive">@color/colorSuccessOnLight</item>
</style>
</resources>