Skip to content

Commit 1ee4b2e

Browse files
committed
🔥 EyuCoder#9 added
1 parent 74277b9 commit 1ee4b2e

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

.idea/deploymentTargetDropDown.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
applicationId "com.codexo.notes"
1515
minSdkVersion 23
1616
targetSdkVersion 30
17-
versionCode 1
18-
versionName "1.0"
17+
versionCode 2
18+
versionName "1.0.1"
1919

2020
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2121
}

app/release/app-release.aab

-181 KB
Binary file not shown.

app/src/main/java/com/codexo/notes/ui/add/AddFragment.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ class AddFragment : Fragment(R.layout.fragment_detail) {
7676
}
7777

7878
override fun onOptionsItemSelected(item: MenuItem): Boolean {
79-
if (item.itemId == R.id.menu_save) {
80-
addNewNote()
79+
when (item.itemId) {
80+
R.id.menu_save -> addNewNote()
81+
android.R.id.home -> hideKeyboard()
8182
}
8283
return super.onOptionsItemSelected(item)
8384
}
@@ -90,7 +91,7 @@ class AddFragment : Fragment(R.layout.fragment_detail) {
9091
if (title.isEmpty() && note.isEmpty()) {
9192
val snackbar = Snackbar.make(
9293
requireView(),
93-
"Please fill out one of the fields",
94+
"Please fill out title or description of the note",
9495
Snackbar.LENGTH_LONG
9596
)
9697
snackbar.show()

app/src/main/java/com/codexo/notes/ui/edit/EditFragment.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ class EditFragment : Fragment(R.layout.fragment_detail) {
7070
}
7171
}
7272

73-
private var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
74-
if (result.resultCode == Activity.RESULT_OK) {
75-
val data = result.data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
76-
data?.let {
77-
binding!!.etAddNote.text = binding?.etAddNote?.text?.append(it[0])
73+
private var resultLauncher =
74+
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
75+
if (result.resultCode == Activity.RESULT_OK) {
76+
val data = result.data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
77+
data?.let {
78+
binding!!.etAddNote.text = binding?.etAddNote?.text?.append(it[0])
79+
}
7880
}
7981
}
80-
}
8182

8283
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
8384
inflater.inflate(R.menu.menu_fragment_edit, menu)
@@ -87,6 +88,9 @@ class EditFragment : Fragment(R.layout.fragment_detail) {
8788
} else {
8889
item.title = "Add to favorites"
8990
}
91+
when (item.itemId) {
92+
android.R.id.home -> hideKeyboard()
93+
}
9094
}
9195

9296
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@@ -134,7 +138,7 @@ class EditFragment : Fragment(R.layout.fragment_detail) {
134138
if (title.isEmpty() && note.isEmpty()) {
135139
val snackbar = Snackbar.make(
136140
requireView(),
137-
"Please fill out one of the fields.",
141+
"Please fill out title or description of the note.",
138142
Snackbar.LENGTH_LONG
139143
)
140144
snackbar.show()

app/src/main/res/layout/fragment_notes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:id="@+id/rv_notes"
2323
android:layout_width="match_parent"
2424
android:layout_height="match_parent"
25-
android:layout_marginTop="@dimen/margin_4"
25+
android:layout_margin="@dimen/margin_4"
2626
tools:listitem="@layout/item_notes" />
2727

2828
<TextView

0 commit comments

Comments
 (0)