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
Hide 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
import
android.content.Context
import
android.os.Build
import
android.text.TextUtils
import
android.widget.EditText
import
android.widget.Toast
class
Utils
{
companion
object
{
fun
fieldsNotEmpty
(
text1
:
String
,
text2
:
String
,
toastMessage
:
String
,
context
:
Context
):
Boolean
{
if
(
TextUtils
.
isEmpty
(
text1
)
||
TextUtils
.
isEmpty
(
text2
))
{
Toast
.
makeText
(
context
,
toastMessage
,
Toast
.
LENGTH_SHORT
).
show
(
)
Utils
.
shortToast
(
context
,
toastMessage
)
return
false
}
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
import
android.util.Log
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.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
...
...
@@ -24,7 +25,8 @@ class AddWordFragment : WordFragment() {
updateRecycleView
(
wordItem
)
}
.
addOnFailureListener
{
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
)
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/EditWordFragment.kt
View file @
0bd690e9
...
...
@@ -8,8 +8,12 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.inputmethod.InputMethodManager
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.Utils
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
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
import
kotlinx.android.synthetic.main.word_item.view.*
...
...
@@ -64,7 +68,7 @@ class EditWordFragment : WordFragment() {
}
.
addOnFailureListener
{
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
()
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/LogInActivity.kt
View file @
0bd690e9
...
...
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
import
android.os.Bundle
import
android.util.Log
import
android.view.View
import
android.widget.Toast
import
com.google.firebase.auth.FirebaseAuth
import
kotlinx.android.synthetic.main.activity_log_in.*
...
...
@@ -46,8 +45,7 @@ class LogInActivity : AppCompatActivity() {
}
.
addOnFailureListener
{
Log
.
w
(
TAG
,
"signInWithEmail:failure"
,
it
)
Toast
.
makeText
(
this
@LogInActivity
,
"Authentication failed."
,
Toast
.
LENGTH_SHORT
).
show
()
Utils
.
shortToast
(
this
@LogInActivity
,
getString
(
R
.
string
.
toast_auth_failed
))
}
}
}
...
...
@@ -68,7 +66,7 @@ class LogInActivity : AppCompatActivity() {
}
.
addOnFailureListener
{
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
import
android.view.MenuItem
import
android.view.View
import
android.view.inputmethod.InputMethodManager
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.VocabularyAdapter
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
import
android.support.v7.widget.SearchView
import
com.paktalin.vocabularynotebook.Utils
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
...
...
@@ -110,8 +110,7 @@ class MainActivity : AppCompatActivity() {
fun
hideProgressBar
()
{
progress
.
visibility
=
View
.
GONE
}
fun
showToastNoWords
()
{
Toast
.
makeText
(
this
@MainActivity
,
"You don't have any words yet. Add your fist one!"
,
Toast
.
LENGTH_SHORT
).
show
()
Utils
.
shortToast
(
this
,
getString
(
R
.
string
.
toast_no_words
))
}
fun
removeFragment
(
fragment
:
Fragment
)
{
...
...
app/src/main/res/values/strings.xml
View file @
0bd690e9
...
...
@@ -18,4 +18,7 @@
<!--Toast messages-->
<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>
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