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
0bd690e9
authored
Sep 22, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extracted toast messages to resources
parent
115907ef
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
13 deletions
app/src/main/java/com/paktalin/vocabularynotebook/Utils.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/AddWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/LogInActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
app/src/main/res/values/strings.xml
app/src/main/java/com/paktalin/vocabularynotebook/Utils.kt
View file @
0bd690e9
package
com.paktalin.vocabularynotebook
package
com.paktalin.vocabularynotebook
import
android.content.Context
import
android.content.Context
import
android.os.Build
import
android.text.TextUtils
import
android.text.TextUtils
import
android.widget.EditText
import
android.widget.Toast
import
android.widget.Toast
class
Utils
{
class
Utils
{
companion
object
{
companion
object
{
fun
fieldsNotEmpty
(
text1
:
String
,
text2
:
String
,
toastMessage
:
String
,
context
:
Context
):
Boolean
{
fun
fieldsNotEmpty
(
text1
:
String
,
text2
:
String
,
toastMessage
:
String
,
context
:
Context
):
Boolean
{
if
(
TextUtils
.
isEmpty
(
text1
)
||
TextUtils
.
isEmpty
(
text2
))
{
if
(
TextUtils
.
isEmpty
(
text1
)
||
TextUtils
.
isEmpty
(
text2
))
{
Toast
.
makeText
(
context
,
toastMessage
,
Toast
.
LENGTH_SHORT
).
show
(
)
Utils
.
shortToast
(
context
,
toastMessage
)
return
false
return
false
}
}
return
true
return
true
}
}
fun
shortToast
(
context
:
Context
,
text
:
String
)
{
Toast
.
makeText
(
context
,
text
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/AddWordFragment.kt
View file @
0bd690e9
...
@@ -2,7 +2,8 @@ package com.paktalin.vocabularynotebook.ui
...
@@ -2,7 +2,8 @@ package com.paktalin.vocabularynotebook.ui
import
android.util.Log
import
android.util.Log
import
android.view.View
import
android.view.View
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.Utils
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
...
@@ -24,7 +25,8 @@ class AddWordFragment : WordFragment() {
...
@@ -24,7 +25,8 @@ class AddWordFragment : WordFragment() {
updateRecycleView
(
wordItem
)
}
updateRecycleView
(
wordItem
)
}
.
addOnFailureListener
{
.
addOnFailureListener
{
Log
.
w
(
TAG
,
"addNewWordToDb:failure"
,
it
.
fillInStackTrace
())
Log
.
w
(
TAG
,
"addNewWordToDb:failure"
,
it
.
fillInStackTrace
())
Toast
.
makeText
(
mainActivity
,
"Couldn't add the word"
,
Toast
.
LENGTH_SHORT
).
show
()}
Utils
.
shortToast
(
mainActivity
,
getString
(
R
.
string
.
toast_new_word_fail
))
}
}
}
override
fun
updateRecycleView
(
wordItem
:
WordItem
)
{
override
fun
updateRecycleView
(
wordItem
:
WordItem
)
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/EditWordFragment.kt
View file @
0bd690e9
...
@@ -8,8 +8,12 @@ import android.view.View
...
@@ -8,8 +8,12 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.view.inputmethod.InputMethodManager
import
android.view.inputmethod.InputMethodManager
import
android.widget.Toast
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.Utils
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
import
kotlinx.android.synthetic.main.word_item.view.*
import
kotlinx.android.synthetic.main.word_item.view.*
...
@@ -64,7 +68,7 @@ class EditWordFragment : WordFragment() {
...
@@ -64,7 +68,7 @@ class EditWordFragment : WordFragment() {
}
}
.
addOnFailureListener
{
.
addOnFailureListener
{
Log
.
w
(
TAG
,
"updateExistingWord:failure"
,
it
.
fillInStackTrace
())
Log
.
w
(
TAG
,
"updateExistingWord:failure"
,
it
.
fillInStackTrace
())
Toast
.
makeText
(
mainActivity
,
"Couldn't update the word"
,
Toast
.
LENGTH_SHORT
).
show
(
)
Utils
.
shortToast
(
mainActivity
,
getString
(
R
.
string
.
toast_update_word_failed
)
)
stop
()
stop
()
}
}
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/LogInActivity.kt
View file @
0bd690e9
...
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
...
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
import
android.os.Bundle
import
android.os.Bundle
import
android.util.Log
import
android.util.Log
import
android.view.View
import
android.view.View
import
android.widget.Toast
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.auth.FirebaseAuth
import
kotlinx.android.synthetic.main.activity_log_in.*
import
kotlinx.android.synthetic.main.activity_log_in.*
...
@@ -46,8 +45,7 @@ class LogInActivity : AppCompatActivity() {
...
@@ -46,8 +45,7 @@ class LogInActivity : AppCompatActivity() {
}
}
.
addOnFailureListener
{
.
addOnFailureListener
{
Log
.
w
(
TAG
,
"signInWithEmail:failure"
,
it
)
Log
.
w
(
TAG
,
"signInWithEmail:failure"
,
it
)
Toast
.
makeText
(
this
@LogInActivity
,
"Authentication failed."
,
Utils
.
shortToast
(
this
@LogInActivity
,
getString
(
R
.
string
.
toast_auth_failed
))
Toast
.
LENGTH_SHORT
).
show
()
}
}
}
}
}
}
...
@@ -68,7 +66,7 @@ class LogInActivity : AppCompatActivity() {
...
@@ -68,7 +66,7 @@ class LogInActivity : AppCompatActivity() {
}
}
.
addOnFailureListener
{
.
addOnFailureListener
{
Log
.
d
(
TAG
,
"createUserWithEmail:failure"
,
it
.
fillInStackTrace
())
Log
.
d
(
TAG
,
"createUserWithEmail:failure"
,
it
.
fillInStackTrace
())
Toast
.
makeText
(
this
@LogInActivity
,
it
.
message
,
Toast
.
LENGTH_SHORT
).
show
(
)
Utils
.
shortToast
(
this
@LogInActivity
,
it
.
message
!!
)
}
}
}
}
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
View file @
0bd690e9
...
@@ -16,11 +16,11 @@ import android.view.Menu
...
@@ -16,11 +16,11 @@ import android.view.Menu
import
android.view.MenuItem
import
android.view.MenuItem
import
android.view.View
import
android.view.View
import
android.view.inputmethod.InputMethodManager
import
android.view.inputmethod.InputMethodManager
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.VocabularyAdapter
import
com.paktalin.vocabularynotebook.VocabularyAdapter
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
import
android.support.v7.widget.SearchView
import
android.support.v7.widget.SearchView
import
com.paktalin.vocabularynotebook.Utils
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
...
@@ -110,8 +110,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -110,8 +110,7 @@ class MainActivity : AppCompatActivity() {
fun
hideProgressBar
()
{
progress
.
visibility
=
View
.
GONE
}
fun
hideProgressBar
()
{
progress
.
visibility
=
View
.
GONE
}
fun
showToastNoWords
()
{
fun
showToastNoWords
()
{
Toast
.
makeText
(
this
@MainActivity
,
Utils
.
shortToast
(
this
,
getString
(
R
.
string
.
toast_no_words
))
"You don't have any words yet. Add your fist one!"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
fun
removeFragment
(
fragment
:
Fragment
)
{
fun
removeFragment
(
fragment
:
Fragment
)
{
...
...
app/src/main/res/values/strings.xml
View file @
0bd690e9
...
@@ -18,4 +18,7 @@
...
@@ -18,4 +18,7 @@
<!--Toast messages-->
<!--Toast messages-->
<string
name=
"toast_no_words"
>
You don\'t have any words yet. Add your fist one!
</string>
<string
name=
"toast_no_words"
>
You don\'t have any words yet. Add your fist one!
</string>
<string
name=
"toast_auth_failed"
>
Authentication failed
</string>
<string
name=
"toast_new_word_fail"
>
Couldn\'t add the word
</string>
<string
name=
"toast_update_word_failed"
>
Couldn\'t update the word
</string>
</resources>
</resources>
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