-
Notifications
You must be signed in to change notification settings - Fork 42
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
Jvm Implementation #120
base: develop
Are you sure you want to change the base?
Jvm Implementation #120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.icerock.moko.permissions.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import dev.icerock.moko.permissions.PermissionsController | ||
|
||
@Composable | ||
@Suppress("FunctionNaming") | ||
actual fun BindEffect(permissionsController: PermissionsController) { | ||
LaunchedEffect(permissionsController) { | ||
permissionsController.bind() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.icerock.moko.permissions.compose | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copyright required |
||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import dev.icerock.moko.permissions.PermissionsController | ||
import dev.icerock.moko.permissions.PermissionsControllerImpl | ||
|
||
@Composable | ||
actual fun rememberPermissionsControllerFactory(): PermissionsControllerFactory { | ||
return remember { | ||
PermissionsControllerFactory { | ||
PermissionsControllerImpl() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.icerock.moko.permissions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copyright required |
||
|
||
actual interface PermissionsController { | ||
/** | ||
* Check is permission already granted and if not - request permission from user. | ||
* | ||
* @param permission what permission we want to provide | ||
* | ||
* @throws DeniedException if user decline request, but we can retry (only on Android) | ||
* @throws DeniedAlwaysException if user decline request and we can't show request again | ||
* (we should send user to settings) | ||
* @throws RequestCanceledException if user cancel request without response (only on Android) | ||
*/ | ||
actual suspend fun providePermission(permission: Permission) | ||
|
||
/** | ||
* @return true if permission already granted. In all other cases - false. | ||
*/ | ||
actual suspend fun isPermissionGranted(permission: Permission): Boolean | ||
|
||
/** | ||
* Returns current state of permission. Can be suspended because on | ||
* Android detection of `Denied`/`NotDetermined` requires a bound FragmentManager. | ||
* | ||
* @param permission state of what permission we want | ||
* | ||
* @return current state. On Android can't be `DeniedAlways` (except push notifications). | ||
* On iOS can't be `Denied`. | ||
* @see PermissionState for a detailed description. | ||
*/ | ||
actual suspend fun getPermissionState(permission: Permission): PermissionState | ||
|
||
/** | ||
* Open system UI of application settings to change permissions state | ||
*/ | ||
actual fun openAppSettings() | ||
|
||
fun bind() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.icerock.moko.permissions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copyright required |
||
|
||
class PermissionsControllerImpl : PermissionsController { | ||
override suspend fun providePermission(permission: Permission) { | ||
//TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun isPermissionGranted(permission: Permission): Boolean { | ||
return true | ||
// TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun getPermissionState(permission: Permission): PermissionState { | ||
return PermissionState.Granted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not true. on macos for example we have runtime permissions and JVM desktop should work with it too |
||
// TODO("Not yet implemented") | ||
} | ||
|
||
override fun openAppSettings() { | ||
//TODO("Not yet implemented") | ||
} | ||
|
||
override fun bind() { | ||
//TODO("Not yet implemented") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright required