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
e1a5bbb4
authored
Nov 10, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring in layouts
parent
b1ca71d2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
129 additions
and
125 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ActivityUtil.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/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/fragment_new_word.xml
app/src/main/res/layout/notebook_sheet.xml
app/src/main/java/com/paktalin/vocabularynotebook/ActivityUtil.kt
View file @
e1a5bbb4
...
...
@@ -5,6 +5,7 @@ import android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v4.app.FragmentManager
import
android.text.TextUtils
import
android.view.View
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.ui.fragments.ProgressFragment
...
...
@@ -37,4 +38,12 @@ fun fieldsNotEmpty(text1: String, text2: String, toastMessage: String, context:
fun
shortToast
(
context
:
Context
,
text
:
String
)
{
Toast
.
makeText
(
context
,
text
,
Toast
.
LENGTH_SHORT
).
show
()
}
fun
show
(
view
:
View
)
{
view
.
visibility
=
View
.
VISIBLE
}
fun
hide
(
view
:
View
)
{
view
.
visibility
=
View
.
INVISIBLE
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/LogInActivity.kt
View file @
e1a5bbb4
...
...
@@ -18,9 +18,9 @@ class LogInActivity : AppCompatActivity() {
setContentView
(
R
.
layout
.
activity_log_in
)
mAuth
=
FirebaseAuth
.
getInstance
()
btnLogIn
!!
.
setOnClickListener
({
logIn
()
})
btnSignUp
!!
.
setOnClickListener
({
signUp
()
})
btnRandomUser
!!
.
setOnClickListener
({
createRandomUser
()
})
btnLogIn
!!
.
setOnClickListener
{
logIn
()
}
btnSignUp
!!
.
setOnClickListener
{
signUp
()
}
btnRandomUser
!!
.
setOnClickListener
{
createRandomUser
()
}
}
override
fun
onStart
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
e1a5bbb4
...
...
@@ -101,7 +101,7 @@ class MainActivity : AppCompatActivity() {
}
fun
addProgressBar
()
{
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_
main
)
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_
new_word
)
}
fun
removeProgressBar
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
e1a5bbb4
...
...
@@ -12,11 +12,11 @@ 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.hide
import
com.paktalin.vocabularynotebook.removeFragment
import
com.paktalin.vocabularynotebook.shortToast
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
import
kotlinx.android.synthetic.main.word_item.view.*
class
EditWordFragment
:
WordFragment
()
{
...
...
@@ -61,7 +61,7 @@ class EditWordFragment : WordFragment() {
.
collection
(
WORDS
).
document
(
wordItem
.
id
).
set
(
wordPojo
)
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"Successfully updated the word"
)
hide
SubmitButton
(
)
hide
(
btnSubmit
)
mainActivity
.
removeProgressBar
()
wordItem
.
pojo
=
wordPojo
updateRecycleView
(
wordItem
)
...
...
@@ -76,7 +76,7 @@ class EditWordFragment : WordFragment() {
private
fun
stop
()
{
// set onClickListener from AddWordFragment
mainActivity
.
btnSubmit
.
setOnClickListener
{
(
mainActivity
.
fragmentAdd
Word
as
AddWordFragment
).
submitWord
()
}
//mainActivity.btnSubmit.setOnClickListener { (mainActivity.fragmentNew
Word as AddWordFragment).submitWord() }
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
View file @
e1a5bbb4
...
...
@@ -9,9 +9,10 @@ import android.view.View
import
android.view.ViewGroup
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.hide
import
com.paktalin.vocabularynotebook.show
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
abstract
class
WordFragment
:
Fragment
()
{
protected
lateinit
var
mainActivity
:
MainActivity
...
...
@@ -29,7 +30,8 @@ abstract class WordFragment : Fragment() {
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
mainActivity
=
activity
as
MainActivity
mainActivity
.
btnSubmit
.
setOnClickListener
{
submitWord
()
}
btnSubmit
.
setOnClickListener
{
submitWord
()
}
word
.
addTextChangedListener
(
textWatcher
{
wordEmpty
=
word
.
text
.
isEmpty
()
})
...
...
@@ -40,8 +42,8 @@ abstract class WordFragment : Fragment() {
}
open
fun
updateButtons
()
{
if
(!
wordEmpty
&&
!
translationEmpty
)
show
SubmitButton
(
)
if
(
wordEmpty
||
translationEmpty
)
hide
SubmitButton
(
)
if
(!
wordEmpty
&&
!
translationEmpty
)
show
(
btnSubmit
)
if
(
wordEmpty
||
translationEmpty
)
hide
(
btnSubmit
)
}
private
fun
textWatcher
(
setEmpty
:
()
->
Unit
):
TextWatcher
{
...
...
@@ -52,13 +54,7 @@ abstract class WordFragment : Fragment() {
}
}
private
fun
showSubmitButton
()
{
mainActivity
.
btnSubmitLayout
.
visibility
=
View
.
VISIBLE
}
protected
fun
hideSubmitButton
()
{
mainActivity
.
btnSubmitLayout
.
visibility
=
View
.
GONE
}
fun
submitWord
()
{
private
fun
submitWord
()
{
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
val
word
=
word
.
text
.
toString
()
...
...
app/src/main/res/layout/activity_main.xml
View file @
e1a5bbb4
...
...
@@ -9,7 +9,7 @@
android:background=
"#66330E"
>
<FrameLayout
android:id=
"@+id/container_
main
"
android:id=
"@+id/container_
new_word
"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
app/src/main/res/layout/fragment_new_word.xml
View file @
e1a5bbb4
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_cont
ent"
>
android:layout_height=
"
match_par
ent"
>
<ImageView
<android.support.constraint.ConstraintLayout
android:id=
"@+id/container_new_word"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:src=
"@drawable/line"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
android:layout_marginBottom=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginStart=
"8dp"
tools:ignore=
"ContentDescription"
/>
android:layout_marginEnd=
"@dimen/small_margin"
android:layout_marginLeft=
"@dimen/small_margin"
android:layout_marginRight=
"@dimen/small_margin"
android:layout_marginStart=
"@dimen/small_margin"
android:layout_marginTop=
"@dimen/small_margin"
android:paddingStart=
"@dimen/small_padding"
android:paddingLeft=
"@dimen/small_padding"
android:paddingEnd=
"@dimen/small_padding"
android:paddingRight=
"@dimen/small_padding"
android:paddingTop=
"@dimen/small_padding"
android:background=
"@drawable/sheet_top"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:paddingLeft=
"16dp"
android:paddingStart=
"16dp"
android:paddingRight=
"16dp"
android:paddingEnd=
"16dp"
android:paddingTop=
"8dp"
android:paddingBottom=
"8dp"
android:background=
"@android:color/transparent"
>
<ImageView
android:id=
"@+id/line"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:src=
"@drawable/line"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<
EditText
android:id=
"@+id/
word
"
android:layout_width=
"
0dp
"
<
ImageButton
android:id=
"@+id/
btnClear
"
android:layout_width=
"
wrap_content
"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@android:color/transparent"
android:hint=
"@string/hint_new_word"
android:inputType=
"text"
android:textSize=
"22sp"
app:fontFamily=
"@font/neucha"
android:textColor=
"#000F55"
tools:ignore=
"LabelFor"
/>
android:visibility=
"gone"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_close_icon"
tools:ignore=
"ContentDescription"
/>
<
EditTex
t
android:id=
"@+id/
translation
"
android:layout_width=
"
0dp
"
<
LinearLayou
t
android:id=
"@+id/
word_layout
"
android:layout_width=
"
match_parent
"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@android:color/transparent"
android:hint=
"@string/hint_translation"
android:inputType=
"text"
android:textSize=
"22sp"
app:fontFamily=
"@font/neucha"
android:textColor=
"#000F55"
tools:ignore=
"LabelFor"
/>
</LinearLayout>
android:orientation=
"horizontal"
android:paddingLeft=
"16dp"
android:paddingStart=
"16dp"
android:paddingRight=
"16dp"
android:paddingEnd=
"16dp"
android:paddingTop=
"8dp"
android:paddingBottom=
"8dp"
android:background=
"@android:color/transparent"
>
<ImageButton
android:id=
"@+id/btnClear"
android:layout_width=
"wrap_content"
<EditText
android:id=
"@+id/word"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@android:color/transparent"
android:hint=
"@string/hint_new_word"
android:inputType=
"text"
android:textSize=
"22sp"
app:fontFamily=
"@font/neucha"
android:textColor=
"#000F55"
tools:ignore=
"LabelFor"
/>
<EditText
android:id=
"@+id/translation"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@android:color/transparent"
android:hint=
"@string/hint_translation"
android:inputType=
"text"
android:textSize=
"22sp"
app:fontFamily=
"@font/neucha"
android:textColor=
"#000F55"
tools:ignore=
"LabelFor"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/btnSubmitLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@android:color/transparent"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_close_icon"
tools:ignore=
"ContentDescription"
/>
android:background=
"@color/colorPrimary"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<ImageButton
android:id=
"@+id/btnSubmit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_done_icon"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/notebook_sheet.xml
View file @
e1a5bbb4
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools
"
android:id=
"@+id/container_notebook_sheet
"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:id=
"@+id/container_main"
<fragment
android:id=
"@+id/fragmentNewWord"
android:name=
"com.paktalin.vocabularynotebook.ui.fragments.AddWordFragment"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"@dimen/small_margin"
android:layout_marginLeft=
"@dimen/small_margin"
android:layout_marginRight=
"@dimen/small_margin"
android:layout_marginStart=
"@dimen/small_margin"
android:layout_marginTop=
"@dimen/small_margin"
android:paddingStart=
"@dimen/small_padding"
android:paddingLeft=
"@dimen/small_padding"
android:paddingEnd=
"@dimen/small_padding"
android:paddingRight=
"@dimen/small_padding"
android:paddingTop=
"@dimen/small_padding"
android:background=
"@drawable/sheet_top"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<fragment
android:id=
"@+id/fragmentAddWord"
android:name=
"com.paktalin.vocabularynotebook.ui.fragments.AddWordFragment"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</FrameLayout>
android:layout_height=
"match_parent"
/>
<ScrollView
android:layout_width=
"match_parent"
...
...
@@ -42,7 +22,7 @@
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/container_
main
"
app:layout_constraintTop_toBottomOf=
"@+id/container_
new_word
"
app:layout_constraintVertical_bias=
"0.0"
>
<LinearLayout
...
...
@@ -60,23 +40,4 @@
</ScrollView>
<FrameLayout
android:id=
"@+id/btnSubmitLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<ImageButton
android:id=
"@+id/btnSubmit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_done_icon"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
\ 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