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
package com.amazon.aws.mobile.samples.tasks.activities | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import com.amazon.aws.mobile.samples.tasks.providers.AWSProvider | |
import com.amazonaws.mobile.auth.ui.SignInUI | |
class AuthenticatorActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { |
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
dependencies { | |
// Prerequisite libraries - use the right ones for your API level | |
implementation 'com.android.support:support-v4:24.+' | |
implementation 'com.android.support:appcompat-v7:24.+' | |
// AWS Mobile SDK for Android | |
implementation('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true } | |
implementation('com.amazonaws:aws-android-sdk-auth-userpools:2.6.+@aar') { transitive = true } | |
implementation('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true } | |
} |
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 onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// Create an auth UI configuration | |
var uiConfig = AuthUIConfiguration.Builder() | |
// Specify the providers | |
.userPools(true) | |
.canCancel(true) | |
// Specify the UI customizations | |
.logoResId(R.drawable.icon_tasks) |
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
package com.amazonaws.mobile.samples.customauth | |
import android.content.Context | |
import com.amazonaws.auth.CognitoCachingCredentialsProvider | |
import com.amazonaws.mobile.config.AWSConfiguration | |
class AWSProvider { | |
companion object { | |
private var mConfiguration: AWSConfiguration? = null | |
private var mCredentialsProvider: Cognito |
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 onResume() { | |
super.onResume() | |
thread(start = true) { | |
// Initialize the AWS Provider | |
AWSProvider.initialize(this@SplashActivity) | |
// Any other library initializations go here | |
// Transition to the next activity |
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
package com.shellmonger.apps.familyphotos.services | |
import android.content.Context | |
import android.util.Log | |
import com.amazonaws.auth.CognitoCachingCredentialsProvider | |
import com.amazonaws.mobile.config.AWSConfiguration | |
import com.amazonaws.mobileconnectors.pinpoint.PinpointConfiguration | |
import com.amazonaws.mobileconnectors.pinpoint.PinpointManager | |
class AWSAnalyticsService(context: Context) : AnalyticsService { |
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
package com.shellmonger.apps.familyphotos.lifecycle | |
import android.app.Application | |
import com.shellmonger.apps.familyphotos.services.AWSAnalyticsService | |
import com.shellmonger.apps.familyphotos.services.AnalyticsService | |
class ApplicationWrapper : Application() { | |
companion object { | |
var analyticsService: AnalyticsService? = null | |
} |
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
/** | |
* Hook called when the user requests to sign-in to the application | |
*/ | |
private fun onLoginMenuItemSelected(): Boolean { | |
// Close the options menu | |
closeOptionsMenu() | |
// Produce the Alert dialog with the login form | |
val formView = layoutInflater.inflate(R.layout.login_form, null, false) | |
val username = formView.find<EditText>(R.id.login_form_username) |
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
class AWSIdentityManager(context: Context) : IdentityManager { | |
/** | |
* The stored "current user" object | |
*/ | |
private val mutableCurrentUser: MutableLiveData<User> = MutableLiveData() | |
/** | |
* Reference to cognito user pools | |
*/ | |
private val userPool: CognitoUserPool |
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
field.addTextChangeListener(object: TextWatcher { | |
override fun afterTextChanged(s: Editable?) { | |
val content = s?.text.toString() | |
s?.error = if (content.length >= 6) null else "Minimum length = 6" | |
} | |
override fun beforeTextChanged(s: Editable?) { } | |
override fun onTextChanged(s: Editable?) { } | |
}) | |
field.error = if (field.text.toString().length >= 6) null else "Minimum length = 6" |