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
86480fca
authored
Sep 09, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keyboard is hidden after adding a new word
parent
70e56d3c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
13 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
app/src/main/res/layout/activity_main.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
View file @
86480fca
...
...
@@ -11,6 +11,10 @@ import com.google.firebase.firestore.FirebaseFirestore
import
com.paktalin.vocabularynotebook.R
import
kotlinx.android.synthetic.main.activity_main.*
import
android.view.WindowManager
import
android.app.Activity
import
android.view.View
import
android.view.inputmethod.InputMethodManager
class
MainActivity
:
AppCompatActivity
()
{
...
...
@@ -60,6 +64,15 @@ class MainActivity : AppCompatActivity() {
window
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_HIDDEN
)
}
fun
hideKeyboard
(
activity
:
Activity
)
{
val
imm
=
activity
.
getSystemService
(
Activity
.
INPUT_METHOD_SERVICE
)
as
InputMethodManager
var
view
=
activity
.
currentFocus
if
(
view
==
null
)
{
view
=
View
(
activity
)
}
imm
.
hideSoftInputFromWindow
(
view
.
windowToken
,
0
)
}
companion
object
{
private
val
TAG
=
"VN/"
+
MainActivity
::
class
.
simpleName
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
View file @
86480fca
...
...
@@ -8,6 +8,7 @@ import android.util.Log
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.FrameLayout
import
android.widget.ImageButton
import
android.widget.Toast
import
com.google.firebase.firestore.FirebaseFirestore
...
...
@@ -62,17 +63,18 @@ class NewWordFragment : Fragment() {
}
private
fun
showAddWordButton
()
{
activity
!!
.
findViewById
<
ImageButton
>(
R
.
id
.
btnAddWord
).
visibility
=
View
.
VISIBLE
}
activity
!!
.
findViewById
<
FrameLayout
>(
R
.
id
.
btnAddWordLayout
).
visibility
=
View
.
VISIBLE
}
private
fun
hideAddWordButton
()
{
activity
!!
.
findViewById
<
ImageButton
>(
R
.
id
.
btnAddWord
).
visibility
=
View
.
GONE
}
activity
!!
.
findViewById
<
FrameLayout
>(
R
.
id
.
btnAddWordLayout
).
visibility
=
View
.
GONE
}
private
fun
hideClearButton
()
{
btnClear
.
visibility
=
View
.
GONE
}
private
fun
showClearButton
()
{
btnClear
.
visibility
=
View
.
VISIBLE
}
private
fun
addWord
()
{
//todo get word data from edit texts and save it
(
activity
as
MainActivity
).
hideKeyboard
(
activity
as
MainActivity
)
val
word
=
etWord
.
text
.
toString
()
val
translation
=
etTranslation
.
text
.
toString
()
val
vocabularyId
=
(
activity
as
MainActivity
).
vocabularyId
...
...
app/src/main/res/layout/activity_main.xml
View file @
86480fca
...
...
@@ -41,18 +41,26 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/fragment_new_word"
/>
<
ImageButton
android:id=
"@+id/btnAddWord"
android:layout_width=
"
wrap_cont
ent"
<
FrameLayout
android:id=
"@+id/btnAddWord
Layout
"
android:layout_width=
"
match_par
ent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:background=
"@android:color/transparent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
android:visibility=
"invisible"
app:srcCompat=
"@drawable/ic_done_icon"
/>
android:background=
"@color/colorPrimary"
android:visibility=
"invisible"
>
<ImageButton
android:id=
"@+id/btnAddWord"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:background=
"@android:color/transparent"
android:layout_gravity=
"end"
app:srcCompat=
"@drawable/ic_done_icon"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
...
...
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