Skip to content

Commit 4cd1dfc

Browse files
committed
minor tweaks to the word count code style
1 parent 7ecde39 commit 4cd1dfc

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import android.view.Gravity
1212
import android.view.LayoutInflater
1313
import android.view.View
1414
import android.view.ViewGroup
15+
import com.simplemobiletools.commons.extensions.beGone
16+
import com.simplemobiletools.commons.extensions.beVisible
1517
import com.simplemobiletools.notes.R
1618
import com.simplemobiletools.notes.activities.MainActivity
1719
import com.simplemobiletools.notes.extensions.*
@@ -120,28 +122,23 @@ class NoteFragment : Fragment() {
120122

121123
if (config.showWordCount) {
122124
view.notes_view.addTextChangedListener(textWatcher)
123-
view.notes_counter.visibility = View.VISIBLE
125+
view.notes_counter.beVisible()
126+
view.notes_counter.setTextColor(config.textColor)
124127
setWordCounter(view.notes_view.text)
125-
}
126-
else {
127-
view.notes_counter.visibility = View.GONE
128+
} else {
129+
view.notes_counter.beGone()
128130
}
129131
}
130132

131133
override fun onPause() {
132134
super.onPause()
133135
saveText()
134-
135-
removeTextWatcher()
136-
}
137-
138-
private fun removeTextWatcher() {
139136
view.notes_view.removeTextChangedListener(textWatcher)
140137
}
141138

142139
private fun setWordCounter(text: Editable) {
143-
val wordArray = text.toString().replace("\n", " ").split(" ")
144-
notes_counter.text = wordArray.count { it.isNotEmpty() }.toString()
140+
val words = text.toString().replace("\n", " ").split(" ")
141+
notes_counter.text = words.count { it.isNotEmpty() }.toString()
145142
}
146143

147144
private var textWatcher: TextWatcher = object : TextWatcher {
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<RelativeLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
34
xmlns:tools="http://schemas.android.com/tools"
45
android:id="@+id/note_Fragment_holder"
56
android:layout_width="match_parent"
@@ -12,33 +13,32 @@
1213
android:fillViewport="true">
1314

1415
<RelativeLayout
15-
android:layout_width="match_parent"
1616
android:id="@+id/notes_relative_layout"
17+
android:layout_width="match_parent"
1718
android:layout_height="wrap_content">
1819

19-
<com.simplemobiletools.commons.views.MyEditText
20-
android:id="@+id/notes_view"
21-
android:layout_width="match_parent"
22-
android:layout_height="wrap_content"
23-
android:background="@null"
24-
android:freezesText="true"
25-
android:gravity="top"
26-
android:inputType="textCapSentences|textMultiLine"
27-
android:padding="@dimen/activity_margin"
28-
android:textCursorDrawable="@null"/>
20+
<com.simplemobiletools.commons.views.MyEditText
21+
android:id="@+id/notes_view"
22+
android:layout_width="match_parent"
23+
android:layout_height="wrap_content"
24+
android:background="@null"
25+
android:freezesText="true"
26+
android:gravity="top"
27+
android:inputType="textCapSentences|textMultiLine"
28+
android:padding="@dimen/activity_margin"
29+
android:textCursorDrawable="@null"/>
2930

30-
<TextView
31+
<com.simplemobiletools.commons.views.MyTextView
3132
android:id="@+id/notes_counter"
3233
android:layout_width="wrap_content"
3334
android:layout_height="wrap_content"
34-
android:textStyle="italic"
35-
tools:text="123"
36-
android:padding="5dp"
3735
android:layout_alignParentBottom="true"
3836
android:layout_alignParentEnd="true"
39-
android:layout_alignParentRight="true" />
37+
android:layout_alignParentRight="true"
38+
android:padding="@dimen/small_margin"
39+
android:textStyle="italic"
40+
tools:text="123"/>
4041

4142
</RelativeLayout>
42-
4343
</ScrollView>
4444
</RelativeLayout>

app/src/main/res/values-sk/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<string name="place_cursor_end">Umiestniť kurzor na koniec poznámky</string>
3333
<string name="monospaced_font">Použiť písmo Monospace</string>
3434
<string name="show_keyboard">Zobraziť klávesnicu po spustení</string>
35-
<string name="show_word_count">Show word count</string>
35+
<string name="show_word_count">Zobraziť počítadlo slov</string>
3636
<string name="alignment">Zarovnanie</string>
3737
<string name="left">Vľavo</string>
3838
<string name="center">Uprostred</string>

0 commit comments

Comments
 (0)