@@ -44,6 +44,7 @@ import com.simplemobiletools.notes.pro.extensions.*
4444import com.simplemobiletools.notes.pro.fragments.TextFragment
4545import com.simplemobiletools.notes.pro.helpers.*
4646import com.simplemobiletools.notes.pro.models.Note
47+ import com.simplemobiletools.notes.pro.models.NoteType
4748import kotlinx.android.synthetic.main.activity_main.*
4849import kotlinx.android.synthetic.main.item_checklist.*
4950import java.io.File
@@ -165,12 +166,12 @@ class MainActivity : SimpleActivity() {
165166
166167 main_toolbar.menu.apply {
167168 findItem(R .id.undo).apply {
168- isVisible = showUndoButton && mCurrentNote.type == NoteType .TYPE_TEXT .value
169+ isVisible = showUndoButton && mCurrentNote.type == NoteType .TYPE_TEXT
169170 icon?.alpha = if (isEnabled) 255 else 127
170171 }
171172
172173 findItem(R .id.redo).apply {
173- isVisible = showRedoButton && mCurrentNote.type == NoteType .TYPE_TEXT .value
174+ isVisible = showRedoButton && mCurrentNote.type == NoteType .TYPE_TEXT
174175 icon?.alpha = if (isEnabled) 255 else 127
175176 }
176177
@@ -187,7 +188,7 @@ class MainActivity : SimpleActivity() {
187188
188189 saveNoteButton = findItem(R .id.save_note)
189190 saveNoteButton!! .isVisible =
190- ! config.autosaveNotes && showSaveButton && (::mCurrentNote.isInitialized && mCurrentNote.type == NoteType .TYPE_TEXT .value )
191+ ! config.autosaveNotes && showSaveButton && (::mCurrentNote.isInitialized && mCurrentNote.type == NoteType .TYPE_TEXT )
191192 }
192193
193194 pager_tab_strip.beVisibleIf(multipleNotesExist)
@@ -281,7 +282,7 @@ class MainActivity : SimpleActivity() {
281282 }
282283 }
283284
284- private fun isCurrentItemChecklist () = if (::mCurrentNote.isInitialized) mCurrentNote.type == NoteType .TYPE_CHECKLIST .value else false
285+ private fun isCurrentItemChecklist () = if (::mCurrentNote.isInitialized) mCurrentNote.type == NoteType .TYPE_CHECKLIST else false
285286
286287 @SuppressLint(" NewApi" )
287288 private fun checkShortcuts () {
@@ -353,10 +354,10 @@ class MainActivity : SimpleActivity() {
353354 val file = File (realPath)
354355 handleUri(Uri .fromFile(file))
355356 } else if (intent.getBooleanExtra(NEW_TEXT_NOTE , false )) {
356- val newTextNote = Note (null , getCurrentFormattedDateTime(), " " , NoteType .TYPE_TEXT .value , " " , PROTECTION_NONE , " " )
357+ val newTextNote = Note (null , getCurrentFormattedDateTime(), " " , NoteType .TYPE_TEXT , " " , PROTECTION_NONE , " " )
357358 addNewNote(newTextNote)
358359 } else if (intent.getBooleanExtra(NEW_CHECKLIST , false )) {
359- val newChecklist = Note (null , getCurrentFormattedDateTime(), " " , NoteType .TYPE_CHECKLIST .value , " " , PROTECTION_NONE , " " )
360+ val newChecklist = Note (null , getCurrentFormattedDateTime(), " " , NoteType .TYPE_CHECKLIST , " " , PROTECTION_NONE , " " )
360361 addNewNote(newChecklist)
361362 } else {
362363 handleUri(data!! )
@@ -431,7 +432,7 @@ class MainActivity : SimpleActivity() {
431432 }
432433 }
433434
434- if (! config.showKeyboard || mCurrentNote.type == NoteType .TYPE_CHECKLIST .value ) {
435+ if (! config.showKeyboard || mCurrentNote.type == NoteType .TYPE_CHECKLIST ) {
435436 hideKeyboard()
436437 }
437438 refreshMenuItems()
@@ -663,7 +664,7 @@ class MainActivity : SimpleActivity() {
663664 val checklistItems = fileText.parseChecklistItems()
664665 if (checklistItems != null ) {
665666 val title = it.absolutePath.getFilenameFromPath().substringBeforeLast(' .' )
666- val note = Note (null , title, fileText, NoteType .TYPE_CHECKLIST .value , " " , PROTECTION_NONE , " " )
667+ val note = Note (null , title, fileText, NoteType .TYPE_CHECKLIST , " " , PROTECTION_NONE , " " )
667668 runOnUiThread {
668669 OpenFileDialog (this , it.path) {
669670 displayNewNoteDialog(note.value, title = it.title, it.path, setChecklistAsDefault = true )
@@ -765,7 +766,7 @@ class MainActivity : SimpleActivity() {
765766 }
766767 }
767768
768- val noteType = if (checklistItems != null ) NoteType .TYPE_CHECKLIST .value else NoteType .TYPE_TEXT .value
769+ val noteType = if (checklistItems != null ) NoteType .TYPE_CHECKLIST else NoteType .TYPE_TEXT
769770 if (! canSyncNoteWithFile) {
770771 val note = Note (null , noteTitle, content, noteType, " " , PROTECTION_NONE , " " )
771772 displayNewNoteDialog(note.value, title = noteTitle, " " )
@@ -791,9 +792,9 @@ class MainActivity : SimpleActivity() {
791792 val fileText = it.readText().trim()
792793 val checklistItems = fileText.parseChecklistItems()
793794 val note = if (checklistItems != null ) {
794- Note (null , title.substringBeforeLast(' .' ), fileText, NoteType .TYPE_CHECKLIST .value , " " , PROTECTION_NONE , " " )
795+ Note (null , title.substringBeforeLast(' .' ), fileText, NoteType .TYPE_CHECKLIST , " " , PROTECTION_NONE , " " )
795796 } else {
796- Note (null , title, " " , NoteType .TYPE_TEXT .value , path, PROTECTION_NONE , " " )
797+ Note (null , title, " " , NoteType .TYPE_TEXT , path, PROTECTION_NONE , " " )
797798 }
798799
799800 if (mNotes.any { it.title.equals(note.title, true ) }) {
@@ -864,10 +865,10 @@ class MainActivity : SimpleActivity() {
864865
865866 private fun exportAsFile () {
866867 ExportFileDialog (this , mCurrentNote) {
867- val textToExport = if (mCurrentNote.type == NoteType .TYPE_TEXT .value ) getCurrentNoteText() else mCurrentNote.value
868+ val textToExport = if (mCurrentNote.type == NoteType .TYPE_TEXT ) getCurrentNoteText() else mCurrentNote.value
868869 if (textToExport == null || textToExport.isEmpty()) {
869870 toast(R .string.unknown_error_occurred)
870- } else if (mCurrentNote.type == NoteType .TYPE_TEXT .value ) {
871+ } else if (mCurrentNote.type == NoteType .TYPE_TEXT ) {
871872 showExportFilePickUpdateDialog(it, textToExport)
872873 } else {
873874 tryExportNoteValueToFile(it, mCurrentNote.title, textToExport, true )
@@ -1018,15 +1019,15 @@ class MainActivity : SimpleActivity() {
10181019 private fun getCurrentNoteText () = getPagerAdapter().getCurrentNoteViewText(view_pager.currentItem)
10191020
10201021 private fun getCurrentNoteValue (): String {
1021- return if (mCurrentNote.type == NoteType .TYPE_TEXT .value ) {
1022+ return if (mCurrentNote.type == NoteType .TYPE_TEXT ) {
10221023 getCurrentNoteText() ? : " "
10231024 } else {
10241025 getPagerAdapter().getNoteChecklistItems(view_pager.currentItem) ? : " "
10251026 }
10261027 }
10271028
10281029 private fun getPrintableText (): String {
1029- return if (mCurrentNote.type == NoteType .TYPE_TEXT .value ) {
1030+ return if (mCurrentNote.type == NoteType .TYPE_TEXT ) {
10301031 getCurrentNoteText() ? : " "
10311032 } else {
10321033 var printableText = " "
@@ -1041,7 +1042,7 @@ class MainActivity : SimpleActivity() {
10411042
10421043 private fun saveCurrentNote (force : Boolean ) {
10431044 getPagerAdapter().saveCurrentNote(view_pager.currentItem, force)
1044- if (mCurrentNote.type == NoteType .TYPE_CHECKLIST .value ) {
1045+ if (mCurrentNote.type == NoteType .TYPE_CHECKLIST ) {
10451046 mCurrentNote.value = getPagerAdapter().getNoteChecklistItems(view_pager.currentItem) ? : " "
10461047 }
10471048 }
@@ -1139,8 +1140,8 @@ class MainActivity : SimpleActivity() {
11391140 }
11401141
11411142 private fun shareText () {
1142- val text = if (mCurrentNote.type == NoteType .TYPE_TEXT .value ) getCurrentNoteText() else mCurrentNote.value
1143- if (text == null || text.isEmpty ()) {
1143+ val text = if (mCurrentNote.type == NoteType .TYPE_TEXT ) getCurrentNoteText() else mCurrentNote.value
1144+ if (text.isNullOrEmpty ()) {
11441145 toast(R .string.cannot_share_empty_text)
11451146 return
11461147 }
0 commit comments