This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
permissionsManager.request(Permission.Location.Fine) | |
.doOnSuccess { | |
Toast.makeText( | |
dataBinding.root.context, | |
"Permission result for ${it[0].permission.value}, given: ${it[0].isGranted()}", | |
Toast.LENGTH_SHORT | |
).show() | |
} | |
.subscribe() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
permissionsManager.observe(Permission.Location.Fine) | |
.doOnNext { | |
println("Fine location granted: ${it[0].isGranted()}") | |
} | |
.subscribe() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
class AppModule { | |
@AppScope | |
@Provides | |
fun providePermissionsManager(context: Context): PermissionsManager = | |
PermissionsComponent.Initializer() | |
.context(context) | |
.prepare() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Maps to permission groups and permissions found here: | |
* https://developer.android.com/guide/topics/permissions/overview#permission-groups | |
*/ | |
sealed class Permission(val value: String) { | |
sealed class Calendar(value: String) : Permission(value) { | |
object Read : Calendar("android.permission.READ_CALENDAR") | |
object Write : Calendar("android.permission.WRITE_CALENDAR") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is the main API for the SDK. It provides methods to observe and request permissions. | |
*/ | |
interface PermissionsManager { | |
/** | |
* Observe the state of permissions. You will get notified when there's new changes to it. | |
*/ | |
fun observe(vararg permissions: Permission): Observable<List<PermissionResult>> | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class PermissionResult( | |
val permission: Permission, | |
val result: Result, | |
val hasAskedForPermissions: Boolean, | |
val isMarkedAsDontAsk: Boolean = false | |
) | |
enum class Result { | |
GRANTED, // PermissionChecker.PERMISSION_GRANTED | |
DENIED, // PermissionChecker.PERMISSION_DENIED |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Google Cloud SDK. We need it to setup the environment with the commands below | |
# https://discuss.circleci.com/t/gcloud-permissions-error/2631/25 | |
- run: | |
name: Downloading Google Cloud SDK | |
command: | | |
curl -L -o google-cloud-sdk.zip https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip \ | |
&& unzip google-cloud-sdk.zip \ | |
&& rm google-cloud-sdk.zip \ | |
&& google-cloud-sdk/install.sh \ | |
--usage-reporting=false \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post: | |
- echo $GCLOUD_SERVICE_KEY | base64 --decode > ${HOME}/gcloud-service-key.json | |
- sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update | |
- sudo /opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json | |
- sudo /opt/google-cloud-sdk/bin/gcloud config set project welnys-api | |
- sudo /opt/google-cloud-sdk/bin/gcloud --quiet components install app-engine-python | |
- sudo /opt/google-cloud-sdk/bin/gcloud --quiet components install app-engine-go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Go packages | |
- run: | |
name: Get Go packages | |
# go get. TODO: don't know why the command above is not enough. Probably gotta wait for golang/dep to be adopted. | |
command: | | |
go get github.com/jstemmer/go-junit-report \ | |
&& go get -u google.golang.org/appengine \ | |
&& go get -u github.com/golang/dep/cmd/dep \ | |
&& dep ensure \ | |
&& go get ./... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environment: | |
- MYSQL_ALLOW_EMPTY_PASSWORD=true | |
- MYSQL_ROOT_HOST=% | |
- MYSQL_USER=ubuntu | |
- MYSQL_PASSWORD=ubuntu |
NewerOlder