diff --git a/app/build.gradle b/app/build.gradle index a70da05..463dc73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,7 +16,7 @@ android { minSdkVersion 21 targetSdkVersion 29 versionCode 1 - versionName '4.0.0' + versionName '4.0.1' testInstrumentationRunner 'com.smlnskgmail.jaman.randomnotes.runner.AndroidJacocoTestRunner' diff --git a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/BaseAuthTest.kt b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/BaseAuthTest.kt index 5b16452..6ab4f7d 100644 --- a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/BaseAuthTest.kt +++ b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/BaseAuthTest.kt @@ -87,12 +87,12 @@ open class BaseAuthTest { fun openAuthScreen() { try { - onView(withId(R.id.menu_login_action)).perform(click()) + onView(withId(R.id.menu_auth_action)).perform(click()) } catch (e: NoMatchingViewException) { openActionBarOverflowOrOptionsMenu( activityTestRule.activity ) - onView(withId(R.id.menu_login_action)).perform(click()) + onView(withId(R.id.menu_auth_action)).perform(click()) } delay() } diff --git a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/EmailAuthTest.kt b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/EmailAuthTest.kt index df6235f..61a3e4a 100644 --- a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/EmailAuthTest.kt +++ b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/EmailAuthTest.kt @@ -50,7 +50,7 @@ class EmailAuthTest : BaseAuthTest() { ) delay() - onView(withId(R.id.login_action)).perform(click()) + onView(withId(R.id.auth_action)).perform(click()) delay() } @@ -67,7 +67,7 @@ class EmailAuthTest : BaseAuthTest() { } @Test - fun logInWithEmail() { + fun signInWithEmail() { whenever(cloudAuth.isValidEmail(any())).thenReturn(true) whenever(cloudAuth.isValidPassword(any())).thenReturn(true) whenever(cloudAuth.signInWithEmail(any(), any(), any())).thenAnswer { diff --git a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/FacebookAuthTest.kt b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/FacebookAuthTest.kt index 185f68e..98a343d 100644 --- a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/FacebookAuthTest.kt +++ b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/FacebookAuthTest.kt @@ -18,8 +18,8 @@ import org.junit.runner.RunWith class FacebookAuthTest : BaseAuthTest() { @Test - fun logInWithFacebook() { - whenever(cloudAuth.logInWithFacebook(any(), any())).thenAnswer { + fun signInWithFacebook() { + whenever(cloudAuth.signInWithFacebook(any(), any())).thenAnswer { val callback = it.getArgument(1) as ((e: Exception?) -> Unit) callback.invoke( null @@ -30,7 +30,7 @@ class FacebookAuthTest : BaseAuthTest() { openAuthScreen() - onView(withId(R.id.facebook_login)).perform(scrollTo()).perform(click()) + onView(withId(R.id.facebook_sign_in)).perform(scrollTo()).perform(click()) delay() val fragmentManager = activityTestRule.activity.supportFragmentManager @@ -46,7 +46,7 @@ class FacebookAuthTest : BaseAuthTest() { @Test fun authWithError() { - whenever(cloudAuth.logInWithFacebook(any(), any())).thenAnswer { + whenever(cloudAuth.signInWithFacebook(any(), any())).thenAnswer { val callback = it.getArgument(1) as ((e: Exception?) -> Unit) callback.invoke( RuntimeException( @@ -59,7 +59,7 @@ class FacebookAuthTest : BaseAuthTest() { openAuthScreen() - onView(withId(R.id.facebook_login)).perform(scrollTo()).perform(click()) + onView(withId(R.id.facebook_sign_in)).perform(scrollTo()).perform(click()) delay() val fragmentManager = activityTestRule.activity.supportFragmentManager diff --git a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/GoogleAuthTest.kt b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/GoogleAuthTest.kt index 3423969..4a67855 100644 --- a/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/GoogleAuthTest.kt +++ b/app/src/androidTest/java/com/smlnskgmail/jaman/randomnotes/auth/GoogleAuthTest.kt @@ -17,8 +17,8 @@ import org.junit.runner.RunWith class GoogleAuthTest : BaseAuthTest() { @Test - fun logInWithGoogle() { - whenever(cloudAuth.logInWithGoogle(any(), any())).thenAnswer { + fun signInWithGoogle() { + whenever(cloudAuth.signInWithGoogle(any(), any())).thenAnswer { val callback = it.getArgument(1) as ((e: Exception?) -> Unit) callback.invoke( null @@ -29,7 +29,7 @@ class GoogleAuthTest : BaseAuthTest() { openAuthScreen() - onView(withId(R.id.google_login)).perform(click()) + onView(withId(R.id.google_sign_in)).perform(click()) delay() val fragmentManager = activityTestRule.activity.supportFragmentManager @@ -45,7 +45,7 @@ class GoogleAuthTest : BaseAuthTest() { @Test fun authWithError() { - whenever(cloudAuth.logInWithGoogle(any(), any())).thenAnswer { + whenever(cloudAuth.signInWithGoogle(any(), any())).thenAnswer { val callback = it.getArgument(1) as ((e: Exception?) -> Unit) callback.invoke( RuntimeException( @@ -58,7 +58,7 @@ class GoogleAuthTest : BaseAuthTest() { openAuthScreen() - onView(withId(R.id.google_login)).perform(click()) + onView(withId(R.id.google_sign_in)).perform(click()) delay() val fragmentManager = activityTestRule.activity.supportFragmentManager diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/MainActivity.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/MainActivity.kt index 353d9ff..a74007e 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/MainActivity.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/MainActivity.kt @@ -28,7 +28,7 @@ class MainActivity : AppCompatActivity() { ) } - fun showLoginFragment() { + fun showAuthFragment() { showBaseFragment( CloudAuthFragment() ) diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/api/cloud/CloudAuth.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/api/cloud/CloudAuth.kt index 39e019d..30a55b7 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/api/cloud/CloudAuth.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/api/cloud/CloudAuth.kt @@ -11,23 +11,23 @@ interface CloudAuth { username: String, email: String, password: String, - afterLogin: (e: Exception?) -> Unit + signUpResult: (e: Exception?) -> Unit ) fun signInWithEmail( username: String, password: String, - afterRegister: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) - fun logInWithGoogle( + fun signInWithGoogle( activity: Activity, - afterFacebookLogin: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) - fun logInWithFacebook( + fun signInWithFacebook( activity: Activity, - afterFacebookLogin: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) fun bindForAuth( diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/fake/FakeCloudAuth.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/fake/FakeCloudAuth.kt index 8d0b556..83ee7bf 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/fake/FakeCloudAuth.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/fake/FakeCloudAuth.kt @@ -26,40 +26,40 @@ class FakeCloudAuth : CloudAuth { username: String, email: String, password: String, - afterLogin: (e: Exception?) -> Unit + signUpResult: (e: Exception?) -> Unit ) { handleAuth() - afterLogin(null) + signUpResult(null) } override fun signInWithEmail( username: String, password: String, - afterRegister: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) { handleAuth() - afterRegister(null) + signInResult(null) } - override fun logInWithFacebook( + override fun signInWithFacebook( activity: Activity, - afterFacebookLogin: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) { handleAuth() - afterFacebookLogin(null) + signInResult(null) } private fun handleAuth() { isAuth = true } - override fun logInWithGoogle( + override fun signInWithGoogle( activity: Activity, - afterFacebookLogin: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) { handleAuth() - afterFacebookLogin(null) + signInResult(null) } override fun bindForAuth( diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/parse/ParseServerAuth.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/parse/ParseServerAuth.kt index 59c45a7..954c1e1 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/parse/ParseServerAuth.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/model/impl/cloud/parse/ParseServerAuth.kt @@ -31,44 +31,44 @@ class ParseServerAuth : CloudAuth { return ParseUser.getCurrentUser() != null } - override fun logInWithFacebook( + override fun signInWithFacebook( activity: Activity, - afterFacebookLogin: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) { ParseFacebookUtils.logInWithReadPermissionsInBackground( activity, listOf("public_profile") - ) { _, e -> afterFacebookLogin(e) } + ) { _, e -> signInResult(e) } } override fun signUpWithEmail( username: String, email: String, password: String, - afterLogin: (e: Exception?) -> Unit + signUpResult: (e: Exception?) -> Unit ) { val parseUser = ParseUser() parseUser.username = username parseUser.email = email parseUser.setPassword(password) parseUser.signUpInBackground { - afterLogin(it) + signUpResult(it) } } override fun signInWithEmail( username: String, password: String, - afterRegister: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) { ParseUser.logInInBackground(username, password) { _, e -> - afterRegister(e) + signInResult(e) } } - override fun logInWithGoogle( + override fun signInWithGoogle( activity: Activity, - afterFacebookLogin: (e: Exception?) -> Unit + signInResult: (e: Exception?) -> Unit ) { val signInOptions = getGoogleSignInOptions(activity) val signInClient = GoogleSignIn.getClient( @@ -78,7 +78,7 @@ class ParseServerAuth : CloudAuth { googleAuthCallback = object : GoogleAuthCallback { override fun sendResult(exception: Exception?) { - afterFacebookLogin(exception) + signInResult(exception) } } diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenter.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenter.kt index e278747..913838a 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenter.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenter.kt @@ -16,15 +16,15 @@ interface CloudAuthPresenter { email: String, password: String ) - fun logInWithEmail( + fun signInWithEmail( email: String, password: String ) - fun logInWithGoogle( + fun signInWithGoogle( activity: Activity ) - fun logInWithFacebook( + fun signInWithFacebook( activity: Activity ) diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenterImpl.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenterImpl.kt index 26b5dc0..8c19daa 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenterImpl.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/presenter/auth/CloudAuthPresenterImpl.kt @@ -39,7 +39,7 @@ class CloudAuthPresenterImpl : CloudAuthPresenter { } } - override fun logInWithEmail( + override fun signInWithEmail( email: String, password: String ) { @@ -49,18 +49,18 @@ class CloudAuthPresenterImpl : CloudAuthPresenter { ) { handleAuthResult(it) } } - override fun logInWithGoogle( + override fun signInWithGoogle( activity: Activity ) { - cloudAuth.logInWithGoogle( + cloudAuth.signInWithGoogle( activity ) { handleAuthResult(it) } } - override fun logInWithFacebook( + override fun signInWithFacebook( activity: Activity ) { - cloudAuth.logInWithFacebook( + cloudAuth.signInWithFacebook( activity ) { handleAuthResult(it) } } diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/auth/CloudAuthFragment.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/auth/CloudAuthFragment.kt index d0baf37..ad2abc3 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/auth/CloudAuthFragment.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/auth/CloudAuthFragment.kt @@ -11,7 +11,7 @@ import com.smlnskgmail.jaman.randomnotes.components.LongSnackbar import com.smlnskgmail.jaman.randomnotes.model.api.cloud.CloudAuth import com.smlnskgmail.jaman.randomnotes.presenter.auth.CloudAuthPresenter import com.smlnskgmail.jaman.randomnotes.presenter.auth.CloudAuthPresenterImpl -import kotlinx.android.synthetic.main.fragment_login.* +import kotlinx.android.synthetic.main.fragment_auth.* import javax.inject.Inject class CloudAuthFragment : BaseFragment(), CloudAuthView { @@ -21,7 +21,7 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { private lateinit var cloudAuthPresenter: CloudAuthPresenter - private var loginMode = true + private var isSignInMode = true override fun onViewCreated( view: View, @@ -37,32 +37,32 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { ) register_account.setOnClickListener { - changeLoginMode() + changeAuthMode() } - login_action.setOnClickListener { + auth_action.setOnClickListener { actionWithEmail() } - google_login.setOnClickListener { - cloudAuthPresenter.logInWithGoogle( + google_sign_in.setOnClickListener { + cloudAuthPresenter.signInWithGoogle( activity!! ) } - facebook_login.setOnClickListener { - cloudAuthPresenter.logInWithFacebook( + facebook_sign_in.setOnClickListener { + cloudAuthPresenter.signInWithFacebook( activity!! ) } } - private fun changeLoginMode() { - if (loginMode) { - login_action.text = getString(R.string.action_sign_up) + private fun changeAuthMode() { + if (isSignInMode) { + auth_action.text = getString(R.string.action_sign_up) register_account.text = getString(R.string.message_have_account) } else { - login_action.text = getString(R.string.action_login) + auth_action.text = getString(R.string.action_sign_in) register_account.text = getString(R.string.message_not_account) } - loginMode = !loginMode + isSignInMode = !isSignInMode } override fun authSuccess() { @@ -71,7 +71,7 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { override fun authError() { LongSnackbar( - login_screen, + auth_screen, getString(R.string.error_auth) ).show() } @@ -80,7 +80,7 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { val email = email.text.toString() if (!cloudAuth.isValidEmail(email)) { LongSnackbar( - login_screen, + auth_screen, getString(R.string.message_incorrect_email_format) ).show() return @@ -88,7 +88,7 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { val password = password.text.toString() if (!cloudAuth.isValidPassword(password)) { LongSnackbar( - login_screen, + auth_screen, getString(R.string.message_incorrect_password_length).format( cloudAuth.passwordMinimumLength(), cloudAuth.passwordMaximumLength() @@ -96,8 +96,8 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { ).show() return } - if (loginMode) { - cloudAuthPresenter.logInWithEmail( + if (isSignInMode) { + cloudAuthPresenter.signInWithEmail( email, password ) @@ -121,11 +121,11 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView { ) } - override fun getTitleResId() = R.string.title_login_fragment + override fun getTitleResId() = R.string.title_auth_fragment override fun showToolbarMenu() = false - override fun layoutResId() = R.layout.fragment_login + override fun layoutResId() = R.layout.fragment_auth override fun showMenuInToolbar() = false diff --git a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/list/NotesListFragment.kt b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/list/NotesListFragment.kt index 56dd544..127a423 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/list/NotesListFragment.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/randomnotes/view/list/NotesListFragment.kt @@ -136,18 +136,18 @@ class NotesListFragment : BaseFragment(), } override fun openAuthPage() { - (activity as MainActivity).showLoginFragment() + (activity as MainActivity).showAuthFragment() } override fun setAuthenticated() { if (getMenu() == null) { menuInitTasks.add(object : MenuTask { override fun execute() { - validateLoginMenuIcon(true) + validateAuthMenuIcon(true) } }) } else { - validateLoginMenuIcon(true) + validateAuthMenuIcon(true) } } @@ -155,11 +155,11 @@ class NotesListFragment : BaseFragment(), if (getMenu() == null) { menuInitTasks.add(object : MenuTask { override fun execute() { - validateLoginMenuIcon(false) + validateAuthMenuIcon(false) } }) } else { - validateLoginMenuIcon(false) + validateAuthMenuIcon(false) } } @@ -195,22 +195,22 @@ class NotesListFragment : BaseFragment(), override fun handleMenuItemClick(menuItemId: Int) { when (menuItemId) { - R.id.menu_login_action -> { + R.id.menu_auth_action -> { notesListPresenter.handleAuthRequest() } } } - private fun validateLoginMenuIcon( + private fun validateAuthMenuIcon( isAuth: Boolean ) { val icon = if (isAuth) { R.drawable.ic_logout } else { - R.drawable.ic_login + R.drawable.ic_sign_in } getMenu()!!.findItem( - R.id.menu_login_action + R.id.menu_auth_action )!!.icon = ContextCompat.getDrawable(context!!, icon) } diff --git a/app/src/main/res/drawable/ic_login.xml b/app/src/main/res/drawable/ic_sign_in.xml similarity index 100% rename from app/src/main/res/drawable/ic_login.xml rename to app/src/main/res/drawable/ic_sign_in.xml diff --git a/app/src/main/res/drawable/ic_login_background.xml b/app/src/main/res/drawable/ic_sign_in_background.xml similarity index 100% rename from app/src/main/res/drawable/ic_login_background.xml rename to app/src/main/res/drawable/ic_sign_in_background.xml diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_auth.xml similarity index 73% rename from app/src/main/res/layout/fragment_login.xml rename to app/src/main/res/layout/fragment_auth.xml index 6f25019..8e5119c 100644 --- a/app/src/main/res/layout/fragment_login.xml +++ b/app/src/main/res/layout/fragment_auth.xml @@ -1,7 +1,7 @@ @@ -21,14 +21,14 @@ android:textSize="@dimen/text_size_large" android:textColor="@color/colorPrimary" android:textStyle="italic" - android:text="@string/app_name"/> + android:text="@string/app_name" /> + tools:ignore="Autofill,TextFields" /> + tools:ignore="Autofill,TextFields" /> + android:text="@string/action_sign_in" /> + android:text="@string/message_not_account" /> + android:id="@+id/google_sign_in" + style="@style/AppGoogleSignInButton" + android:layout_marginTop="@dimen/margin_large" /> + android:id="@+id/facebook_sign_in" + style="@style/AppFacebookSignInButton" + android:layout_marginTop="@dimen/margin_small" /> diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 7b32db2..44240f9 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -3,9 +3,9 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2e3eb31..59cf0d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,7 +7,7 @@ This is subtitle - Auth + Auth Subtitle @@ -20,7 +20,7 @@ Restore Sync Add note - Login + Sign in Sign up Continue with Google diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bba3c18..3d5ff13 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -40,15 +40,15 @@ wrap_content - - -