From c921b8d23c80ff774e52d8c666d64ff0811c45c8 Mon Sep 17 00:00:00 2001 From: BHOOMI Date: Sun, 1 Oct 2023 11:33:33 +0530 Subject: [PATCH 1/2] Share Checklist with checkmark --- .../notes/pro/activities/MainActivity.kt | 32 ++++++++++++++++++- gradle.properties | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 77414759..04837f9c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -47,6 +47,7 @@ import com.simplemobiletools.notes.pro.fragments.TextFragment import com.simplemobiletools.notes.pro.helpers.* import com.simplemobiletools.notes.pro.models.Note import com.simplemobiletools.notes.pro.models.NoteType +import org.json.JSONArray import java.io.File import java.nio.charset.Charset import java.util.* @@ -1165,7 +1166,11 @@ class MainActivity : SimpleActivity() { } private fun shareText() { - val text = if (mCurrentNote.type == NoteType.TYPE_TEXT) getCurrentNoteText() else mCurrentNote.value + val text = if (mCurrentNote.type == NoteType.TYPE_TEXT) { + getCurrentNoteText() + } else { + getTitlesFromCheckList(mCurrentNote.value) + } if (text.isNullOrEmpty()) { toast(R.string.cannot_share_empty_text) return @@ -1182,6 +1187,31 @@ class MainActivity : SimpleActivity() { } } + private fun getTitlesFromCheckList(jsonStr: String): String { + + val jsonArray = JSONArray(jsonStr) + + val stringBuilder = StringBuilder() + + for (i in 0 until jsonArray.length()) { + val jsonObject = jsonArray.getJSONObject(i) + val title = jsonObject.getString("title") + val isDone = jsonObject.getBoolean("isDone") + + // Append a checkmark based on the "isDone" value + val checkmark = if (isDone) "✔" else "✘" + + stringBuilder.append("$checkmark $title") + + // Add a newline separator if it's not the last item + if (i < jsonArray.length() - 1) { + stringBuilder.append("\n") + } + } + + return stringBuilder.toString() + } + @SuppressLint("NewApi") private fun createShortcut() { val manager = getSystemService(ShortcutManager::class.java) diff --git a/gradle.properties b/gradle.properties index b2d106ed..9488527e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ android.enableJetifier=true android.useAndroidX=true android.nonTransitiveRClass=true +org.gradle.jvmargs=-Xmx1024m From b690bc696de47c41f4f34ef993f81e40711a9ce1 Mon Sep 17 00:00:00 2001 From: BHOOMI Date: Mon, 2 Oct 2023 00:37:39 +0530 Subject: [PATCH 2/2] Comments removed --- .../com/simplemobiletools/notes/pro/activities/MainActivity.kt | 2 -- gradle.properties | 1 - 2 files changed, 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 04837f9c..573d0ad6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -1198,12 +1198,10 @@ class MainActivity : SimpleActivity() { val title = jsonObject.getString("title") val isDone = jsonObject.getBoolean("isDone") - // Append a checkmark based on the "isDone" value val checkmark = if (isDone) "✔" else "✘" stringBuilder.append("$checkmark $title") - // Add a newline separator if it's not the last item if (i < jsonArray.length() - 1) { stringBuilder.append("\n") } diff --git a/gradle.properties b/gradle.properties index 9488527e..b2d106ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ android.enableJetifier=true android.useAndroidX=true android.nonTransitiveRClass=true -org.gradle.jvmargs=-Xmx1024m