Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
vocabulary_notebook
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8a981912
authored
Nov 11, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed naming issues
parent
81792b36
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
32 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordItem.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/LogInActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/VocabularyFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/utils/FirestoreManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/utils/UserManager.kt
app/src/main/AndroidManifest.xml
View file @
8a981912
...
...
@@ -2,7 +2,7 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.paktalin.vocabularynotebook"
>
<!-- To auto-complete the email text field in the
logi
n form with the user's emails -->
<!-- To auto-complete the email text field in the
mLogI
n form with the user's emails -->
<uses-permission
android:name=
"android.permission.GET_ACCOUNTS"
/>
<uses-permission
android:name=
"android.permission.READ_PROFILE"
/>
<uses-permission
android:name=
"android.permission.READ_CONTACTS"
/>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordItem.kt
View file @
8a981912
...
...
@@ -2,9 +2,8 @@ package com.paktalin.vocabularynotebook.firestoreitems
import
android.util.Log
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.WORDS
import
java.io.Serializable
import
java.util.Date
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/LogInActivity.kt
View file @
8a981912
package
com.paktalin.vocabularynotebook.ui.activities
import
android.annotation.SuppressLint
import
android.content.Intent
import
android.support.v7.app.AppCompatActivity
import
android.os.Bundle
import
android.util.Log
...
...
@@ -24,19 +23,19 @@ class LogInActivity : AppCompatActivity() {
override
fun
onStart
()
{
super
.
onStart
()
if
(
u
serLoggedIn
())
{
startUserActivity
()
}
if
(
mU
serLoggedIn
())
{
startUserActivity
()
}
}
fun
login
()
{
processUser
{
com
.
paktalin
.
vocabularynotebook
.
utils
.
logi
n
(
mLogI
n
(
{
removeProgressBar
()
},
{
startUserActivity
()
},
{
showToastFailure
()
},
email
!!
,
password
!!
)
}
}
private
fun
signUp
()
{
processUser
{
s
ignUp
(
this
,
email
!!
,
password
!!
)
}
}
private
fun
signUp
()
{
processUser
{
mS
ignUp
(
this
,
email
!!
,
password
!!
)
}
}
private
fun
processUser
(
authAction
:
()
->
Unit
)
{
email
=
etEmail
!!
.
text
.
toString
()
...
...
@@ -67,7 +66,7 @@ class LogInActivity : AppCompatActivity() {
private
fun
createRandomUser
()
{
etEmail
.
setText
(
"random@gmail.com"
)
etPassword
.
setText
(
"123456"
)
processUser
{
s
ignUp
(
this
@LogInActivity
,
email
!!
,
password
!!
)
}
processUser
{
mS
ignUp
(
this
@LogInActivity
,
email
!!
,
password
!!
)
}
}
companion
object
{
private
val
TAG
=
"VN/"
+
LogInActivity
::
class
.
simpleName
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
8a981912
...
...
@@ -18,7 +18,6 @@ import com.paktalin.vocabularynotebook.utils.*
class
MainActivity
:
AppCompatActivity
()
{
lateinit
var
vocabularyId
:
String
lateinit
var
vocabularyFragment
:
VocabularyFragment
lateinit
var
searchView
:
SearchView
...
...
@@ -43,7 +42,7 @@ class MainActivity : AppCompatActivity() {
}
private
fun
logOut
()
{
l
ogOut
()
mL
ogOut
()
startActivity
(
this
@MainActivity
,
LogInActivity
::
class
.
java
)
}
...
...
@@ -67,7 +66,6 @@ class MainActivity : AppCompatActivity() {
}
private
fun
addVocabularyFragment
(
vocabularyId
:
String
)
{
this
.
vocabularyId
=
vocabularyId
vocabularyFragment
=
VocabularyFragment
()
val
arguments
=
Bundle
()
arguments
.
putString
(
"vocabularyId"
,
vocabularyId
)
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
View file @
8a981912
...
...
@@ -4,9 +4,9 @@ import android.util.Log
import
android.view.View
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.WORDS
import
com.paktalin.vocabularynotebook.utils.shortToast
import
kotlinx.android.synthetic.main.fragment_editable_word.*
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
8a981912
...
...
@@ -10,9 +10,9 @@ import android.view.inputmethod.InputMethodManager
import
com.paktalin.vocabularynotebook.*
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.WORDS
import
com.paktalin.vocabularynotebook.utils.disableScrolling
import
com.paktalin.vocabularynotebook.utils.enableScrolling
import
com.paktalin.vocabularynotebook.utils.removeFragment
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/VocabularyFragment.kt
View file @
8a981912
...
...
@@ -12,11 +12,11 @@ import com.google.firebase.firestore.Query
import
com.paktalin.vocabularynotebook.*
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.WORDS
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
class
VocabularyFragment
:
Fragment
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
View file @
8a981912
...
...
@@ -10,6 +10,7 @@ import android.view.ViewGroup
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.content_main.*
...
...
@@ -63,7 +64,7 @@ abstract class WordFragment : Fragment() {
val
word
=
word
.
text
.
toString
()
val
translation
=
translation
.
text
.
toString
()
val
vocabularyId
=
mainActivity
.
vocabularyId
val
vocabularyId
=
FirestoreManager
.
vocabularyId
mainActivity
.
addProgressBar
()
saveToFirestore
(
word
,
translation
,
vocabularyId
)
return
...
...
app/src/main/java/com/paktalin/vocabularynotebook/utils/FirestoreManager.kt
View file @
8a981912
...
...
@@ -23,7 +23,7 @@ class FirestoreManager {
.
addOnSuccessListener
{
task
->
removeProgressBar
()
if
(
task
.
get
(
VOCABULARIES
)
!=
null
)
{
val
vocabularyId
=
retrieve
VocabularyID
(
task
,
db
)
set
VocabularyID
(
task
,
db
)
onSuccess
(
vocabularyId
)
}
else
{
Log
.
w
(
TAG
,
"There's no collection \"vocabularies\""
)
...
...
@@ -39,7 +39,7 @@ class FirestoreManager {
}
.
addOnFailureListener
{
Log
.
w
(
TAG
,
"Couldn't add user to the database"
,
it
.
cause
)
d
eleteUser
(
firebaseUser
)
mD
eleteUser
(
firebaseUser
)
}
}
...
...
@@ -62,16 +62,18 @@ class FirestoreManager {
}
}
private
fun
retrieveVocabularyID
(
task
:
DocumentSnapshot
,
db
:
FirebaseFirestore
):
String
{
private
fun
setVocabularyID
(
task
:
DocumentSnapshot
,
db
:
FirebaseFirestore
)
{
val
vocabularies
:
List
<
DocumentReference
>
=
task
.
get
(
VOCABULARIES
)
as
List
<
DocumentReference
>
val
vocabulary
=
db
.
collection
(
VOCABULARIES
).
document
(
vocabularies
[
0
].
id
)
return
vocabulary
.
id
vocabularyId
=
vocabulary
.
id
}
companion
object
{
private
const
val
USERS
=
"users"
private
const
val
WORDS
=
"words"
private
const
val
VOCABULARIES
=
"vocabularies"
const
val
USERS
=
"users"
const
val
WORDS
=
"words"
const
val
VOCABULARIES
=
"vocabularies"
private
const
val
TAG
=
"VN/FirestoreManager"
lateinit
var
vocabularyId
:
String
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/utils/UserManager.kt
View file @
8a981912
...
...
@@ -8,13 +8,13 @@ import com.paktalin.vocabularynotebook.ui.activities.LogInActivity
private
const
val
TAG
=
"VN/UserManager"
private
var
mAuth
:
FirebaseAuth
?
=
FirebaseAuth
.
getInstance
()
fun
d
eleteUser
(
user
:
FirebaseUser
)
{
fun
mD
eleteUser
(
user
:
FirebaseUser
)
{
user
.
delete
()
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"UserPojo was successfully deleted"
)
}
.
addOnFailureListener
{
Log
.
i
(
TAG
,
"
d
eleteUser:failure"
,
it
.
cause
)}
.
addOnFailureListener
{
Log
.
i
(
TAG
,
"
mD
eleteUser:failure"
,
it
.
cause
)}
}
fun
logi
n
(
onComplete
:
()
->
Unit
,
onSuccess
:
()
->
Unit
,
onFailure
:
()
->
Unit
,
fun
mLogI
n
(
onComplete
:
()
->
Unit
,
onSuccess
:
()
->
Unit
,
onFailure
:
()
->
Unit
,
email
:
String
,
password
:
String
)
{
mAuth
!!
.
signInWithEmailAndPassword
(
email
,
password
)
.
addOnCompleteListener
{
onComplete
()
}
...
...
@@ -28,7 +28,7 @@ fun login(onComplete: () -> Unit, onSuccess: () -> Unit, onFailure: () -> Unit,
}
}
fun
s
ignUp
(
activity
:
LogInActivity
,
email
:
String
,
password
:
String
)
{
fun
mS
ignUp
(
activity
:
LogInActivity
,
email
:
String
,
password
:
String
)
{
mAuth
!!
.
createUserWithEmailAndPassword
(
email
,
password
)
.
addOnCompleteListener
{
removeProgressBar
(
activity
.
supportFragmentManager
)
}
.
addOnSuccessListener
{
...
...
@@ -41,11 +41,11 @@ fun signUp(activity: LogInActivity, email: String, password: String) {
shortToast
(
activity
,
it
.
message
!!
)
}
}
fun
u
serLoggedIn
():
Boolean
{
fun
mU
serLoggedIn
():
Boolean
{
return
mAuth
!!
.
currentUser
!=
null
}
fun
l
ogOut
()
{
fun
mL
ogOut
()
{
mAuth
!!
.
signOut
()
Log
.
i
(
TAG
,
"User logged out"
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment