Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert plugin to a federated plugin and remove Android APIs #97

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.lakscastro.sharedstorage.environment.EnvironmentApi
import io.lakscastro.sharedstorage.mediastore.MediaStoreApi
import io.lakscastro.sharedstorage.storageaccessframework.StorageAccessFrameworkApi
import io.lakscastro.sharedstorage.plugin.SharedStorageApi

const val ROOT_CHANNEL = "io.lakscastro.plugins/sharedstorage"

/** Flutter plugin Kotlin implementation `SharedStoragePlugin` */
class SharedStoragePlugin : FlutterPlugin, ActivityAware {
/** `Environment` API channel */
private val environmentApi = EnvironmentApi(this)

/** `MediaStore` API channel */
private val mediaStoreApi = MediaStoreApi(this)

/** `DocumentFile` API channel */
private val storageAccessFrameworkApi = StorageAccessFrameworkApi(this)
private val sharedStorageApi = SharedStorageApi(this)

lateinit var context: Context
var binding: ActivityPluginBinding? = null
Expand All @@ -30,25 +22,21 @@ class SharedStoragePlugin : FlutterPlugin, ActivityAware {
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPluginBinding) {
context = flutterPluginBinding.applicationContext

environmentApi.startListening(flutterPluginBinding.binaryMessenger)
mediaStoreApi.startListening(flutterPluginBinding.binaryMessenger)
storageAccessFrameworkApi.startListening(flutterPluginBinding.binaryMessenger)
sharedStorageApi.startListening(flutterPluginBinding.binaryMessenger)
}

override fun onAttachedToActivity(binding: ActivityPluginBinding) {
this.binding = binding

storageAccessFrameworkApi.startListeningToActivity()
sharedStorageApi.startListeningToActivity()
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPluginBinding) {
environmentApi.stopListening()
mediaStoreApi.stopListening()
storageAccessFrameworkApi.stopListening()
sharedStorageApi.stopListening()
}

override fun onDetachedFromActivityForConfigChanges() {
storageAccessFrameworkApi.stopListeningToActivity()
sharedStorageApi.stopListeningToActivity()
}

override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.lakscastro.sharedstorage.plugin
package io.lakscastro.sharedstorage.common

/**
* Interface shared across API classes to make intuitive and clean [init] and [dispose] plugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.lakscastro.sharedstorage.plugin
package io.lakscastro.sharedstorage.common

import android.os.Build
import io.flutter.plugin.common.MethodChannel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.lakscastro.sharedstorage.plugin
package io.lakscastro.sharedstorage.common

import io.flutter.plugin.common.BinaryMessenger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.lakscastro.sharedstorage.plugin
package io.lakscastro.sharedstorage.common

import android.os.Build

Expand Down

This file was deleted.

This file was deleted.

Loading