Commit 6277fd14 by Paktalin

Log out option added

parent 2d0634ca
package com.paktalin.vocabularynotebook.activities;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.paktalin.vocabularynotebook.R;
public class AddWordActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_word);
}
}
package com.paktalin.vocabularynotebook.activities
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.paktalin.vocabularynotebook.R
class AddWordActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_word)
}
}
...@@ -63,16 +63,13 @@ class LogInActivity : AppCompatActivity() { ...@@ -63,16 +63,13 @@ class LogInActivity : AppCompatActivity() {
//todo check if the password is good //todo check if the password is good
// todo verify email // todo verify email
mAuth!!.createUserWithEmailAndPassword(email, password) mAuth!!.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task -> .addOnSuccessListener { _ ->
if (task.isSuccessful) { Log.d(TAG, "Successfully signed up a new user")
Log.d(TAG, "Successfully signed up a new user") UserManager.addNewUserToDb(mAuth!!.currentUser!!, this)
UserManager.addNewUserToDb(mAuth!!.currentUser!!, this) }
} .addOnFailureListener {
else { Log.d(TAG, "createUserWithEmail:failure", it.fillInStackTrace())
Log.w(TAG, "createUserWithEmail:failure", task.exception) Toast.makeText(this@LogInActivity, it.message, Toast.LENGTH_SHORT).show()
Toast.makeText(this@LogInActivity, "Authentication failed.",
Toast.LENGTH_SHORT).show()
}
} }
} }
} }
......
package com.paktalin.vocabularynotebook.activities package com.paktalin.vocabularynotebook.activities
import android.content.Intent
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 com.google.firebase.auth.FirebaseAuth
import com.paktalin.vocabularynotebook.R import com.paktalin.vocabularynotebook.R
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
...@@ -14,11 +17,21 @@ class MainActivity : AppCompatActivity() { ...@@ -14,11 +17,21 @@ class MainActivity : AppCompatActivity() {
navigationView.setNavigationItemSelectedListener { menuItem -> navigationView.setNavigationItemSelectedListener { menuItem ->
menuItem.isChecked = true menuItem.isChecked = true
if(menuItem.itemId == R.id.logOut) { logOut() }
drawerLayout!!.closeDrawers() drawerLayout!!.closeDrawers()
true true
} }
} }
private fun logOut() {
Log.i(TAG, "User logged out")
FirebaseAuth.getInstance()!!.signOut()
val intentLogInActivity = Intent(this@MainActivity, LogInActivity::class.java)
startActivity(intentLogInActivity)
}
companion object { companion object {
private val TAG = "VN/" + MainActivity::class.simpleName private val TAG = "VN/" + MainActivity::class.simpleName
} }
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
<group android:checkableBehavior="single"> <group android:checkableBehavior="single">
<item <item
android:id="@+id/map" android:id="@+id/logOut"
android:icon="@drawable/common_google_signin_btn_icon_light" android:icon="@android:drawable/ic_lock_power_off"
android:title="Vocabulary" /> android:title="Log out" />
</group> </group>
</menu> </menu>
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