mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 15:02:05 +02:00
minor tweaks to the word count code style
This commit is contained in:
parent
7ecde39e0b
commit
4cd1dfc4f9
@ -12,6 +12,8 @@ import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.beVisible
|
||||
import com.simplemobiletools.notes.R
|
||||
import com.simplemobiletools.notes.activities.MainActivity
|
||||
import com.simplemobiletools.notes.extensions.*
|
||||
@ -120,28 +122,23 @@ class NoteFragment : Fragment() {
|
||||
|
||||
if (config.showWordCount) {
|
||||
view.notes_view.addTextChangedListener(textWatcher)
|
||||
view.notes_counter.visibility = View.VISIBLE
|
||||
view.notes_counter.beVisible()
|
||||
view.notes_counter.setTextColor(config.textColor)
|
||||
setWordCounter(view.notes_view.text)
|
||||
}
|
||||
else {
|
||||
view.notes_counter.visibility = View.GONE
|
||||
} else {
|
||||
view.notes_counter.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
saveText()
|
||||
|
||||
removeTextWatcher()
|
||||
}
|
||||
|
||||
private fun removeTextWatcher() {
|
||||
view.notes_view.removeTextChangedListener(textWatcher)
|
||||
}
|
||||
|
||||
private fun setWordCounter(text: Editable) {
|
||||
val wordArray = text.toString().replace("\n", " ").split(" ")
|
||||
notes_counter.text = wordArray.count { it.isNotEmpty() }.toString()
|
||||
val words = text.toString().replace("\n", " ").split(" ")
|
||||
notes_counter.text = words.count { it.isNotEmpty() }.toString()
|
||||
}
|
||||
|
||||
private var textWatcher: TextWatcher = object : TextWatcher {
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/note_Fragment_holder"
|
||||
android:layout_width="match_parent"
|
||||
@ -12,33 +13,32 @@
|
||||
android:fillViewport="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/notes_relative_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/notes_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:freezesText="true"
|
||||
android:gravity="top"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:textCursorDrawable="@null"/>
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/notes_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:freezesText="true"
|
||||
android:gravity="top"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:textCursorDrawable="@null"/>
|
||||
|
||||
<TextView
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/notes_counter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="italic"
|
||||
tools:text="123"
|
||||
android:padding="5dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true" />
|
||||
android:layout_alignParentRight="true"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:textStyle="italic"
|
||||
tools:text="123"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
|
@ -32,7 +32,7 @@
|
||||
<string name="place_cursor_end">Umiestniť kurzor na koniec poznámky</string>
|
||||
<string name="monospaced_font">Použiť písmo Monospace</string>
|
||||
<string name="show_keyboard">Zobraziť klávesnicu po spustení</string>
|
||||
<string name="show_word_count">Show word count</string>
|
||||
<string name="show_word_count">Zobraziť počítadlo slov</string>
|
||||
<string name="alignment">Zarovnanie</string>
|
||||
<string name="left">Vľavo</string>
|
||||
<string name="center">Uprostred</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user