this library enables you to add a composable view to the window manager easily using a foreground service
flyView-demo.webm
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.aabadaa:Fly-view:Tag'
}
At first you need to define a FlyViewInfo
like this:
val controller = ExampleController()
FlyViewInfo(controller = controller, onRemove = {
controller.x = 10
controller.auto = false
delay(1000)
}) {
DraggableFlyView(autoGoToBorder = controller.auto) {
BackHandler(true) {
Log.i(ContentValues.TAG, "createFlyView: backHandler")
removeView()
}
Column(modifier = Modifier.background(Color.White)) {
Text(text = "test ${controller.x}")
Button(onClick = removeView) {
Text("Close")
}
Button(onClick = {
controller.x
}) {
Text("x ")
}
Button(onClick = { controller.auto = controller.auto.not() }) {
Text(text = controller.auto.toString())
}
}
}
}
}
Then you can call show method to launch the service, for example:
FlyViewService.show(context, "example")
Be sure that there is a defined FlyViewInfo object that is associated to the passed key.
Check the full example here
A holder to all information needed for the FlyView
@property controller used to send bundles from anywhere to the FlyView
@property onRemove pass a lambda which will be called before removing the FlyView
@property params a WindowManager.LayoutParams
that passed when adding the FlyView
@property keyDispatcher this will be passed to the FlyView
to handle key events
@property content the content of the flyView
@property flyView the android.view.View
object that will be added to the WindowManager
@property removeView call it in your view to remove it
@property params pass your lambda that updates the view's layout params to update it
has a static show
method to show a FlyViewInfo
that you added to the infoProviders
@param context
a context to start the service
@param key
the key you used to add your FlyViewInfo
to the infoProviders
@param bundle
an optional bundle that will be passed to your controller FlyController.update
method
Designed and developed by 2023 AbdulAleem Alsayed
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.