Commit c34cf757 by Paktalin

Refactoring: signIn to logIn

parent f80abd62
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".UserActivity" /> <activity android:name=".activities.UserActivity" />
<activity android:name=".SignInActivity"> <activity android:name=".activities.LogInActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
...@@ -3,7 +3,7 @@ package com.paktalin.vocabularynotebook; ...@@ -3,7 +3,7 @@ package com.paktalin.vocabularynotebook;
public class User { public class User {
private String email, name; private String email, name;
User(String email) { public User(String email) {
this.email = email; this.email = email;
} }
......
package com.paktalin.vocabularynotebook package com.paktalin.vocabularynotebook.activities
import android.content.Intent import android.content.Intent
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
...@@ -10,19 +10,21 @@ import com.google.android.gms.signin.SignIn ...@@ -10,19 +10,21 @@ import com.google.android.gms.signin.SignIn
import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser import com.google.firebase.auth.FirebaseUser
import kotlinx.android.synthetic.main.activity_sign_in.* import kotlinx.android.synthetic.main.activity_log_in.*
import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.FirebaseFirestore
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.User
class SignInActivity : AppCompatActivity() { class LogInActivity : AppCompatActivity() {
private var mAuth: FirebaseAuth? = null private var mAuth: FirebaseAuth? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sign_in) setContentView(R.layout.activity_log_in)
mAuth = FirebaseAuth.getInstance() mAuth = FirebaseAuth.getInstance()
btnSignIn!!.setOnClickListener({ signIn() }) btnLogIn!!.setOnClickListener({ signIn() })
btnSignUp!!.setOnClickListener({ signUp() }) btnSignUp!!.setOnClickListener({ signUp() })
} }
...@@ -45,7 +47,7 @@ class SignInActivity : AppCompatActivity() { ...@@ -45,7 +47,7 @@ class SignInActivity : AppCompatActivity() {
} }
else { else {
Log.w(TAG, "signInWithEmail:failure", task.exception) Log.w(TAG, "signInWithEmail:failure", task.exception)
Toast.makeText(this@SignInActivity, "Authentication failed.", Toast.makeText(this@LogInActivity, "Authentication failed.",
Toast.LENGTH_SHORT).show() Toast.LENGTH_SHORT).show()
} }
} }
...@@ -68,7 +70,7 @@ class SignInActivity : AppCompatActivity() { ...@@ -68,7 +70,7 @@ class SignInActivity : AppCompatActivity() {
} }
else { else {
Log.w(TAG, "createUserWithEmail:failure", task.exception) Log.w(TAG, "createUserWithEmail:failure", task.exception)
Toast.makeText(this@SignInActivity, "Authentication failed.", Toast.makeText(this@LogInActivity, "Authentication failed.",
Toast.LENGTH_SHORT).show() Toast.LENGTH_SHORT).show()
} }
} }
...@@ -77,13 +79,13 @@ class SignInActivity : AppCompatActivity() { ...@@ -77,13 +79,13 @@ class SignInActivity : AppCompatActivity() {
private fun startUserActivity() { private fun startUserActivity() {
Log.d(TAG, "Signed in successfully") Log.d(TAG, "Signed in successfully")
val userActivityIntent = Intent(this@SignInActivity, UserActivity::class.java) val userActivityIntent = Intent(this@LogInActivity, UserActivity::class.java)
startActivity(userActivityIntent) startActivity(userActivityIntent)
} }
private fun fieldsNotEmpty(email: String, password: String): Boolean { private fun fieldsNotEmpty(email: String, password: String): Boolean {
if (TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) { if (TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) {
Toast.makeText(this@SignInActivity, "Please, enter email and password", Toast.LENGTH_SHORT).show() Toast.makeText(this@LogInActivity, "Please, enter email and password", Toast.LENGTH_SHORT).show()
return false return false
} }
return true return true
......
package com.paktalin.vocabularynotebook package com.paktalin.vocabularynotebook.activities
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.util.Log import android.util.Log
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.DocumentReference
import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.FirebaseFirestore
import com.paktalin.vocabularynotebook.R
import kotlinx.android.synthetic.main.activity_user.* import kotlinx.android.synthetic.main.activity_user.*
class UserActivity : AppCompatActivity() { class UserActivity : AppCompatActivity() {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".SignInActivity"> tools:context=".activities.LogInActivity">
<EditText <EditText
android:id="@+id/etEmail" android:id="@+id/etEmail"
...@@ -39,13 +39,13 @@ ...@@ -39,13 +39,13 @@
android:ems="10" android:ems="10"
android:hint="@string/password_hint" android:hint="@string/password_hint"
android:inputType="textPassword" android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="@+id/btnSignIn" app:layout_constraintBottom_toTopOf="@+id/btnLogIn"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etEmail" /> app:layout_constraintTop_toBottomOf="@+id/etEmail" />
<Button <Button
android:id="@+id/btnSignIn" android:id="@+id/btnLogIn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/sign_in_text" android:text="@string/log_in_text"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btnSignUp" app:layout_constraintEnd_toStartOf="@id/btnSignUp"
app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintHorizontal_chainStyle="packed"
...@@ -70,8 +70,8 @@ ...@@ -70,8 +70,8 @@
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:text="Sign Up" android:text="Sign Up"
app:layout_constraintBottom_toBottomOf="@+id/btnSignIn" app:layout_constraintBottom_toBottomOf="@+id/btnLogIn"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btnSignIn" app:layout_constraintStart_toEndOf="@+id/btnLogIn"
app:layout_constraintTop_toTopOf="@+id/btnSignIn" /> app:layout_constraintTop_toTopOf="@+id/btnLogIn" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
\ No newline at end of file
...@@ -2,19 +2,7 @@ ...@@ -2,19 +2,7 @@
<string name="app_name">VocabularyNotebook</string> <string name="app_name">VocabularyNotebook</string>
<string name="password_hint">Password</string> <string name="password_hint">Password</string>
<string name="email_hint">Email</string> <string name="email_hint">Email</string>
<string name="sign_in_text">Sign In</string> <string name="log_in_text">Log In</string>
<string name="sign_up_text">Sign Up</string>
<string name="title_activity_login">Sign in</string> <string name="title_activity_login">Sign in</string>
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Password (optional)</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_sign_in_short">Sign in</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email
completions."
</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment