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
cf0341cf
authored
Sep 10, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed columns
parent
fa2d779e
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
20 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ConfiguredFirestore.kt
app/src/main/java/com/paktalin/vocabularynotebook/UserManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyFragment.kt
app/src/main/res/layout/fragment_new_word.xml
app/src/main/res/layout/word_item.xml
app/src/main/java/com/paktalin/vocabularynotebook/ConfiguredFirestore.kt
0 → 100644
View file @
cf0341cf
package
com.paktalin.vocabularynotebook
import
com.google.firebase.firestore.FirebaseFirestore
import
com.google.firebase.firestore.FirebaseFirestoreSettings
object
ConfiguredFirestore
{
val
instance
:
FirebaseFirestore
get
()
{
val
firestore
=
FirebaseFirestore
.
getInstance
()
val
settings
=
FirebaseFirestoreSettings
.
Builder
()
.
setTimestampsInSnapshotsEnabled
(
true
)
.
build
()
firestore
.
firestoreSettings
=
settings
return
firestore
}
}
app/src/main/java/com/paktalin/vocabularynotebook/UserManager.kt
View file @
cf0341cf
...
@@ -2,7 +2,6 @@ package com.paktalin.vocabularynotebook
...
@@ -2,7 +2,6 @@ package com.paktalin.vocabularynotebook
import
android.util.Log
import
android.util.Log
import
com.google.firebase.auth.FirebaseUser
import
com.google.firebase.auth.FirebaseUser
import
com.google.firebase.firestore.FirebaseFirestore
import
com.paktalin.vocabularynotebook.ui.LogInActivity
import
com.paktalin.vocabularynotebook.ui.LogInActivity
import
com.paktalin.vocabularynotebook.pojo.UserPojo
import
com.paktalin.vocabularynotebook.pojo.UserPojo
import
com.paktalin.vocabularynotebook.pojo.VocabularyPojo
import
com.paktalin.vocabularynotebook.pojo.VocabularyPojo
...
@@ -20,7 +19,7 @@ class UserManager {
...
@@ -20,7 +19,7 @@ class UserManager {
fun
addNewUserToDb
(
newUser
:
FirebaseUser
,
logInActivity
:
LogInActivity
)
{
fun
addNewUserToDb
(
newUser
:
FirebaseUser
,
logInActivity
:
LogInActivity
)
{
//todo add condition to writing to the db in Firebase Console (request.auth.uid)
//todo add condition to writing to the db in Firebase Console (request.auth.uid)
val
db
=
FirebaseFirestore
.
getInstance
()
val
db
=
ConfiguredFirestore
.
instance
val
user
=
UserPojo
(
newUser
.
email
)
val
user
=
UserPojo
(
newUser
.
email
)
db
.
collection
(
"vocabularies"
).
add
(
VocabularyPojo
())
db
.
collection
(
"vocabularies"
).
add
(
VocabularyPojo
())
...
...
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.kt
View file @
cf0341cf
...
@@ -2,11 +2,6 @@ package com.paktalin.vocabularynotebook
...
@@ -2,11 +2,6 @@ package com.paktalin.vocabularynotebook
import
android.util.Log
import
android.util.Log
import
com.google.android.gms.tasks.OnFailureListener
import
com.google.android.gms.tasks.OnSuccessListener
import
com.google.firebase.firestore.DocumentReference
import
com.google.firebase.firestore.FirebaseFirestore
import
java.io.Serializable
import
java.io.Serializable
class
WordItem
(
word
:
String
,
translation
:
String
,
var
id
:
String
,
private
val
vocabularyId
:
String
)
:
Serializable
{
class
WordItem
(
word
:
String
,
translation
:
String
,
var
id
:
String
,
private
val
vocabularyId
:
String
)
:
Serializable
{
...
@@ -22,7 +17,7 @@ class WordItem(word: String, translation: String, var id: String, private val vo
...
@@ -22,7 +17,7 @@ class WordItem(word: String, translation: String, var id: String, private val vo
:
this
(
pojo
.
word
!!
,
pojo
.
translation
!!
,
id
,
vocabularyId
)
:
this
(
pojo
.
word
!!
,
pojo
.
translation
!!
,
id
,
vocabularyId
)
fun
delete
()
{
fun
delete
()
{
FirebaseFirestore
.
getInstance
()
.
collection
(
"vocabularies"
).
document
(
vocabularyId
)
ConfiguredFirestore
.
instance
.
collection
(
"vocabularies"
).
document
(
vocabularyId
)
.
collection
(
"words"
).
document
(
id
!!
).
delete
()
.
collection
(
"words"
).
document
(
id
!!
).
delete
()
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"Successfully deleted word with id $id"
)
}
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"Successfully deleted word with id $id"
)
}
.
addOnFailureListener
{
e
->
Log
.
w
(
TAG
,
"deleteWordWithId $id:failure"
,
e
.
fillInStackTrace
())
}
.
addOnFailureListener
{
e
->
Log
.
w
(
TAG
,
"deleteWordWithId $id:failure"
,
e
.
fillInStackTrace
())
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
View file @
cf0341cf
...
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
...
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
import
android.util.Log
import
android.util.Log
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.firestore.DocumentReference
import
com.google.firebase.firestore.DocumentReference
import
com.google.firebase.firestore.FirebaseFirestore
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,6 +13,7 @@ import android.view.WindowManager
...
@@ -14,6 +13,7 @@ import android.view.WindowManager
import
android.app.Activity
import
android.app.Activity
import
android.view.View
import
android.view.View
import
android.view.inputmethod.InputMethodManager
import
android.view.inputmethod.InputMethodManager
import
com.paktalin.vocabularynotebook.ConfiguredFirestore
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
...
@@ -45,7 +45,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -45,7 +45,7 @@ class MainActivity : AppCompatActivity() {
private
fun
extractVocabularyData
()
{
private
fun
extractVocabularyData
()
{
val
userId
=
FirebaseAuth
.
getInstance
().
currentUser
!!
.
uid
val
userId
=
FirebaseAuth
.
getInstance
().
currentUser
!!
.
uid
val
db
=
FirebaseFirestore
.
getInstance
()
val
db
=
ConfiguredFirestore
.
instance
val
userDocument
=
db
.
collection
(
"users"
).
document
(
userId
)
val
userDocument
=
db
.
collection
(
"users"
).
document
(
userId
)
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
View file @
cf0341cf
...
@@ -11,7 +11,7 @@ import android.view.ViewGroup
...
@@ -11,7 +11,7 @@ import android.view.ViewGroup
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
android.widget.ImageButton
import
android.widget.ImageButton
import
android.widget.Toast
import
android.widget.Toast
import
com.
google.firebase.firestore.Firebase
Firestore
import
com.
paktalin.vocabularynotebook.Configured
Firestore
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.WordItem
import
com.paktalin.vocabularynotebook.WordItem
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_new_word.*
...
@@ -79,7 +79,7 @@ class NewWordFragment : Fragment() {
...
@@ -79,7 +79,7 @@ class NewWordFragment : Fragment() {
val
translation
=
etTranslation
.
text
.
toString
()
val
translation
=
etTranslation
.
text
.
toString
()
val
vocabularyId
=
(
activity
as
MainActivity
).
vocabularyId
val
vocabularyId
=
(
activity
as
MainActivity
).
vocabularyId
val
newWordItemPojo
=
WordItem
.
WordItemPojo
(
word
,
translation
)
val
newWordItemPojo
=
WordItem
.
WordItemPojo
(
word
,
translation
)
FirebaseFirestore
.
getInstance
()
ConfiguredFirestore
.
instance
.
collection
(
"vocabularies"
).
document
(
vocabularyId
)
.
collection
(
"vocabularies"
).
document
(
vocabularyId
)
.
collection
(
"words"
).
add
(
newWordItemPojo
)
.
collection
(
"words"
).
add
(
newWordItemPojo
)
.
addOnSuccessListener
{
.
addOnSuccessListener
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyFragment.kt
View file @
cf0341cf
...
@@ -8,7 +8,6 @@ import android.view.View
...
@@ -8,7 +8,6 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.firestore.DocumentSnapshot
import
com.google.firebase.firestore.DocumentSnapshot
import
com.google.firebase.firestore.FirebaseFirestore
import
com.paktalin.vocabularynotebook.*
import
com.paktalin.vocabularynotebook.*
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
...
@@ -19,7 +18,7 @@ class VocabularyFragment : Fragment() {
...
@@ -19,7 +18,7 @@ class VocabularyFragment : Fragment() {
private
const
val
WORDS
=
"words"
private
const
val
WORDS
=
"words"
}
}
private
val
db
=
FirebaseFirestore
.
getInstance
()
private
val
db
=
ConfiguredFirestore
.
instance
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_vocabulary
,
container
,
false
)
return
inflater
.
inflate
(
R
.
layout
.
fragment_vocabulary
,
container
,
false
)
...
...
app/src/main/res/layout/fragment_new_word.xml
View file @
cf0341cf
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<EditText
<EditText
android:id=
"@+id/etWord"
android:id=
"@+id/etWord"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:layout_weight=
"8"
android:background=
"@android:color/transparent"
android:background=
"@android:color/transparent"
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<EditText
<EditText
android:id=
"@+id/etTranslation"
android:id=
"@+id/etTranslation"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:layout_weight=
"8"
android:background=
"@android:color/transparent"
android:background=
"@android:color/transparent"
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
<ImageButton
<ImageButton
android:id=
"@+id/btnClear"
android:id=
"@+id/btnClear"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:visibility=
"invisible"
android:visibility=
"invisible"
...
...
app/src/main/res/layout/word_item.xml
View file @
cf0341cf
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<TextView
<TextView
android:id=
"@+id/etWord"
android:id=
"@+id/etWord"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:layout_weight=
"8"
android:textSize=
"22sp"
android:textSize=
"22sp"
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<TextView
<TextView
android:id=
"@+id/etTranslation"
android:id=
"@+id/etTranslation"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:layout_weight=
"8"
android:textSize=
"22sp"
android:textSize=
"22sp"
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
<ImageButton
<ImageButton
android:id=
"@+id/btnClear"
android:id=
"@+id/btnClear"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:background=
"@android:color/transparent"
android:background=
"@android:color/transparent"
...
...
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