Android
After installing SaltUI, configure the Android application and window. Use the shared APIs for theme, screens, and components.
SaltApplication
Extend SaltApplication to use the library’s Android initialization and register the actual application class in the manifest.
import com.moriafly.salt.ui.app.SaltApplication
class App : SaltApplication()<application
android:name=".App">
<!-- Keep your existing activity and other application settings. -->
</application>If your app already has an Application subclass, refer to the implementation when integrating it.
Edge-to-edge layout
Call SaltUI’s activity extension edgeToEdge() before super.onCreate(). Set the Compose content afterward.
import com.moriafly.salt.ui.ext.edgeToEdge
override fun onCreate(savedInstanceState: Bundle?) {
edgeToEdge()
super.onCreate(savedInstanceState)
// setContent { ... }
}The Sample uses a window theme with a null background.
<style name="Theme.SaltUI" parent="@android:style/Theme.Holo">
<item name="android:windowBackground">@null</item>
</style>The layout still needs to account for system bars. If using BasicScreen, apply the provided content padding.
Platform utilities
| API | Use |
|---|---|
| WebView | WebView integration based on Accompanist. |
RomUtil, ScreenUtil | ROM and screen helpers. |
ThreadUtil, runOnMainThread | Main-thread execution. |
WindowUtil | System bar foreground colors. |
runOnMainThread {
// Run work that requires the main thread.
}
WindowUtil.setStatusBarForegroundColor(window, BarColor.White)
WindowUtil.setNavigationBarForegroundColor(window, BarColor.Black)Choose a system bar foreground with sufficient contrast against the content underneath.
Android version requirements
UI requires API 23 or later. Navigation requires API 24 or later. Use Core's OS API for version checks or Adaptive windows for layout decisions. See the source README for Google Play configuration.