Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.55 KB

android-config-screen.md

File metadata and controls

31 lines (25 loc) · 1.55 KB

Configuration screen

One of the easiest ways to update a configuration value will be an excellent user interface. The library is able to generate a configuration screen dynamically based on your configuration file.

How to use

To show the screen, you just need to create a new activity for it and attach it to any view, as shown in the sample below.

class DevToolsActivity: AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val contentView = findViewById<ViewGroup>(android.R.id.content)
        DevToolsConfigurationScreen.attachToView(
            rootView = binding.devToolsContainer,
            devTools = devtools,
            configScreenRouter = object : ConfigurationScreenRouter {
                override var onBack: (() -> Boolean)? = null

                override fun closeScreen() = finish()
            }
        )
    }
}

You can attach this config screen view to any other view from your app. Note that configScreenRouter parameter is optional the library needs it to show a neat confirmation dialog when the config screen users will try to close the screen having unsaved changes.

Theming

The android library is based on material design. There is a Theme.DevTools that you might extend inside your app to update the colors, text appearance, and shaping.