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
| <com.freeletics.statelayout.StateLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:id="@+id/state_layout" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" /> |
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
| import { Application } from 'probot' | |
| import { PullRequestsCreateReviewParams } from '@octokit/rest' | |
| export = (app: Application) => { | |
| app.on(['pull_request.opened', 'pull_request.labeled'], async (context) => { | |
| const pullRequest = context.payload.pull_request | |
| const hasShiptItLabel: string[] = pullRequest.labels | |
| .map((label: any) => label.name) | |
| .includes('shipit') |
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
| val credential = Credential.Builder(login) | |
| .setName(login) | |
| .setPassword(password) | |
| .build() | |
| RxGoogleSmartLockManager.deleteStoredCredentials(context, credential) | |
| .subscribe({ | |
| Toast.makeText(this, "Deleted credential successfully", Toast.LENGTH_SHORT).show() | |
| }, { | |
| Toast.makeText(this, "Failed deleting credential: $it", Toast.LENGTH_SHORT).show() |
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
| RxGoogleSmartLockManager.retrieveCredentials(context) | |
| .subscribe({ | |
| Toast.makeText(this, "Retrieved: name ${it.name}, pass ${it.password}", Toast.LENGTH_SHORT).show() | |
| }, { | |
| Toast.makeText(this, "Failed retrieving credentials: $it", Toast.LENGTH_SHORT).show() | |
| }) |
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
| val credential = Credential.Builder(login) | |
| .setName(login) | |
| .setPassword(password) | |
| .build() | |
| RxGoogleSmartLockManager.storeCredentials(context, credential) | |
| .subscribe({ | |
| Toast.makeText(this, "Credential stored successfully", Toast.LENGTH_SHORT).show() | |
| }, { | |
| Toast.makeText(this, "Failed storing credential: $it", Toast.LENGTH_SHORT).show() |
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
| interface SmartLockManager { | |
| /** | |
| * Retrieves stored credentials from Smartlock | |
| * | |
| * @return Single that emits stored credentials if there are any | |
| */ | |
| fun retrieveCredentials(context: Context): Single<Credential> | |
| /** |
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
| fun handleSaveCredentialsResult(resultCode: Int, emitter: CompletableEmitter) { | |
| if (resultCode == Activity.RESULT_OK) { | |
| emitter.onComplete() | |
| } else { | |
| emitter.onError(Exception("Saving credentials failed: $resultCode")) | |
| } | |
| } |
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
| private val activityResultSubject = PublishSubject.create<ActivityResult>() | |
| fun saveCredentialsRequest(credentialsToSave: Credential): Completable { | |
| return Completable.create { emitter -> | |
| Auth.CredentialsApi | |
| .save(googleApiClient, credentialsToSave) | |
| .setResultCallback { result -> | |
| val status = result.status | |
| if (status.isSuccess) { | |
| emitter.onComplete() |
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
| lateinit var googleApiClient: GoogleApiClient | |
| private var googleApiClientSubject = PublishSubject.create<GoogleApiClient>() | |
| fun init() { | |
| googleApiClient = GoogleApiClient.Builder(context) | |
| .addConnectionCallbacks(object : GoogleApiClient.ConnectionCallbacks { | |
| override fun onConnected(connectionHint: Bundle?) { | |
| googleApiClientSubject.onNext(googleApiClient!!) | |
| } |
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
| override fun storeCredentials(credential: Credential): Completable { | |
| startHiddenActivity(REQUEST_CODE_STORE_CREDENTIALS) | |
| return googleApiClientSubject.concatMapCompletable { | |
| saveCredentialsRequest(credential) | |
| } | |
| } |