Skip to content

Commit 8253e9a

Browse files
committed
More code formatting
1 parent 072a690 commit 8253e9a

1 file changed

Lines changed: 70 additions & 36 deletions

File tree

app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -764,40 +764,49 @@ class MainActivity : SimpleActivity() {
764764

765765
val faqItems = arrayListOf(
766766
FAQItem(
767-
org.fossify.commons.R.string.faq_1_title_commons,
768-
org.fossify.commons.R.string.faq_1_text_commons
767+
title = org.fossify.commons.R.string.faq_1_title_commons,
768+
text = org.fossify.commons.R.string.faq_1_text_commons
769769
),
770-
FAQItem(R.string.faq_1_title, R.string.faq_1_text)
770+
FAQItem(
771+
title = R.string.faq_1_title,
772+
text = R.string.faq_1_text
773+
)
771774
)
772775

773776
if (!resources.getBoolean(org.fossify.commons.R.bool.hide_google_relations)) {
774777
faqItems.add(
775778
FAQItem(
776-
org.fossify.commons.R.string.faq_2_title_commons,
777-
org.fossify.commons.R.string.faq_2_text_commons
779+
title = org.fossify.commons.R.string.faq_2_title_commons,
780+
text = org.fossify.commons.R.string.faq_2_text_commons
778781
)
779782
)
780783
faqItems.add(
781784
FAQItem(
782-
org.fossify.commons.R.string.faq_6_title_commons,
783-
org.fossify.commons.R.string.faq_6_text_commons
785+
title = org.fossify.commons.R.string.faq_6_title_commons,
786+
text = org.fossify.commons.R.string.faq_6_text_commons
784787
)
785788
)
786789
faqItems.add(
787790
FAQItem(
788-
org.fossify.commons.R.string.faq_7_title_commons,
789-
org.fossify.commons.R.string.faq_7_text_commons
791+
title = org.fossify.commons.R.string.faq_7_title_commons,
792+
text = org.fossify.commons.R.string.faq_7_text_commons
790793
)
791794
)
792795
faqItems.add(
793796
FAQItem(
794-
org.fossify.commons.R.string.faq_10_title_commons,
795-
org.fossify.commons.R.string.faq_10_text_commons
797+
title = org.fossify.commons.R.string.faq_10_title_commons,
798+
text = org.fossify.commons.R.string.faq_10_text_commons
796799
)
797800
)
798801
}
799802

800-
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
803+
startAboutActivity(
804+
appNameId = R.string.app_name,
805+
licenseMask = licenses,
806+
versionName = BuildConfig.VERSION_NAME,
807+
faqItems = faqItems,
808+
showFAQBeforeMail = true
809+
)
801810
}
802811

803812
private fun tryOpenFile() {
@@ -852,7 +861,11 @@ class MainActivity : SimpleActivity() {
852861
} else {
853862
runOnUiThread {
854863
OpenFileDialog(this, it.path) {
855-
displayNewNoteDialog(it.value, title = it.title, it.path)
864+
displayNewNoteDialog(
865+
value = it.value,
866+
title = it.title,
867+
path = it.path
868+
)
856869
}
857870
}
858871
}
@@ -861,7 +874,11 @@ class MainActivity : SimpleActivity() {
861874
}
862875
}
863876

864-
private fun checkFile(path: String, checkTitle: Boolean, onChecksPassed: (file: File) -> Unit) {
877+
private fun checkFile(
878+
path: String,
879+
checkTitle: Boolean,
880+
onChecksPassed: (file: File) -> Unit,
881+
) {
865882
val file = File(path)
866883
if (path.isMediaFile()) {
867884
toast(org.fossify.commons.R.string.invalid_file_format)
@@ -977,7 +994,7 @@ class MainActivity : SimpleActivity() {
977994
protectionType = PROTECTION_NONE,
978995
protectionHash = ""
979996
)
980-
displayNewNoteDialog(note.value, title = noteTitle, path)
997+
displayNewNoteDialog(value = note.value, title = noteTitle, path = path)
981998
}
982999
}
9831000
}
@@ -1078,14 +1095,23 @@ class MainActivity : SimpleActivity() {
10781095

10791096
private fun exportAsFile() {
10801097
ExportFileDialog(this, mCurrentNote) {
1081-
val textToExport =
1082-
if (mCurrentNote.type == NoteType.TYPE_TEXT) getCurrentNoteText() else mCurrentNote.value
1098+
val textToExport = if (mCurrentNote.type == NoteType.TYPE_TEXT) {
1099+
getCurrentNoteText()
1100+
} else {
1101+
mCurrentNote.value
1102+
}
1103+
10831104
if (textToExport == null || textToExport.isEmpty()) {
10841105
toast(org.fossify.commons.R.string.unknown_error_occurred)
10851106
} else if (mCurrentNote.type == NoteType.TYPE_TEXT) {
10861107
showExportFilePickUpdateDialog(it, textToExport)
10871108
} else {
1088-
tryExportNoteValueToFile(it, mCurrentNote.title, textToExport, true)
1109+
tryExportNoteValueToFile(
1110+
path = it,
1111+
title = mCurrentNote.title,
1112+
content = textToExport,
1113+
showSuccessToasts = true
1114+
)
10891115
}
10901116
}
10911117
}
@@ -1099,10 +1125,10 @@ class MainActivity : SimpleActivity() {
10991125
RadioGroupDialog(this, items) {
11001126
val syncFile = it as Int == EXPORT_FILE_SYNC
11011127
tryExportNoteValueToFile(
1102-
exportPath,
1103-
mCurrentNote.title,
1104-
textToExport,
1105-
true
1128+
path = exportPath,
1129+
title = mCurrentNote.title,
1130+
content = textToExport,
1131+
showSuccessToasts = true
11061132
) { exportedSuccessfully ->
11071133
if (exportedSuccessfully) {
11081134
if (syncFile) {
@@ -1114,9 +1140,9 @@ class MainActivity : SimpleActivity() {
11141140
}
11151141

11161142
getPagerAdapter().updateCurrentNoteData(
1117-
binding.viewPager.currentItem,
1118-
mCurrentNote.path,
1119-
mCurrentNote.value
1143+
position = binding.viewPager.currentItem,
1144+
path = mCurrentNote.path,
1145+
value = mCurrentNote.value
11201146
)
11211147
NotesHelper(this).insertOrUpdateNote(mCurrentNote)
11221148
}
@@ -1132,7 +1158,13 @@ class MainActivity : SimpleActivity() {
11321158
callback: ((success: Boolean) -> Unit)? = null,
11331159
) {
11341160
if (path.startsWith("content://")) {
1135-
exportNoteValueToUri(path.toUri(), title, content, showSuccessToasts, callback)
1161+
exportNoteValueToUri(
1162+
uri = path.toUri(),
1163+
title = title,
1164+
content = content,
1165+
showSuccessToasts = showSuccessToasts,
1166+
callback = callback
1167+
)
11361168
} else {
11371169
handlePermission(PERMISSION_WRITE_STORAGE) {
11381170
if (it) {
@@ -1257,8 +1289,9 @@ class MainActivity : SimpleActivity() {
12571289

12581290
private fun getPagerAdapter() = binding.viewPager.adapter as NotesPagerAdapter
12591291

1260-
private fun getCurrentNoteText() =
1261-
getPagerAdapter().getCurrentNoteViewText(binding.viewPager.currentItem)
1292+
private fun getCurrentNoteText(): String? {
1293+
return getPagerAdapter().getCurrentNoteViewText(binding.viewPager.currentItem)
1294+
}
12621295

12631296
private fun getCurrentNoteValue(): String {
12641297
return if (mCurrentNote.type == NoteType.TYPE_TEXT) {
@@ -1280,14 +1313,15 @@ class MainActivity : SimpleActivity() {
12801313
}
12811314
}
12821315

1283-
private fun addTextToCurrentNote(text: String) =
1316+
private fun addTextToCurrentNote(text: String) {
12841317
getPagerAdapter().appendText(binding.viewPager.currentItem, text)
1318+
}
12851319

12861320
private fun saveCurrentNote(force: Boolean, callback: ((note: Note) -> Unit)? = null) {
12871321
getPagerAdapter().saveCurrentNote(binding.viewPager.currentItem, force, callback)
12881322
if (mCurrentNote.type == NoteType.TYPE_CHECKLIST) {
1289-
mCurrentNote.value =
1290-
getPagerAdapter().getNoteChecklistItems(binding.viewPager.currentItem) ?: ""
1323+
mCurrentNote.value = getPagerAdapter()
1324+
.getNoteChecklistItems(binding.viewPager.currentItem) ?: ""
12911325
}
12921326
}
12931327

@@ -1441,11 +1475,11 @@ class MainActivity : SimpleActivity() {
14411475

14421476
private fun lockNote() {
14431477
ConfirmationDialog(
1444-
this,
1445-
"",
1446-
R.string.locking_warning,
1447-
org.fossify.commons.R.string.ok,
1448-
org.fossify.commons.R.string.cancel
1478+
activity = this,
1479+
message = "",
1480+
messageId = R.string.locking_warning,
1481+
positive = org.fossify.commons.R.string.ok,
1482+
negative = org.fossify.commons.R.string.cancel
14491483
) {
14501484
SecurityDialog(this, "", SHOW_ALL_TABS) { hash, type, success ->
14511485
if (success) {

0 commit comments

Comments
 (0)