From e5a59d6a08495875414b5811da721913db573355 Mon Sep 17 00:00:00 2001 From: YaMiN Date: Mon, 11 Sep 2023 15:00:19 +0330 Subject: [PATCH] fixed share data --- app/build.gradle | 8 ++-- .../yamin8000/owl/content/home/HomeState.kt | 41 +++++++++++-------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 175b68d5..a4293060 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,8 +33,8 @@ android { applicationId "io.github.yamin8000.owl" minSdk 21 targetSdk 34 - versionCode 20 - versionName "1.4.0" + versionCode 21 + versionName "1.4.1" vectorDrawables { useSupportLibrary true } @@ -89,7 +89,7 @@ android { dependencies { //core android - implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.palette:palette-ktx:1.0.0") //compose def material3_version = "1.1.1" @@ -110,7 +110,7 @@ dependencies { implementation("io.coil-kt:coil:$coil_version") implementation("io.coil-kt:coil-compose:$coil_version") //navigation - def nav_version = "2.7.1" + def nav_version = "2.7.2" implementation("androidx.navigation:navigation-compose:$nav_version") //datastore implementation("androidx.datastore:datastore-preferences:1.0.0") diff --git a/app/src/main/java/io/github/yamin8000/owl/content/home/HomeState.kt b/app/src/main/java/io/github/yamin8000/owl/content/home/HomeState.kt index 1bfff65f..15f94330 100644 --- a/app/src/main/java/io/github/yamin8000/owl/content/home/HomeState.kt +++ b/app/src/main/java/io/github/yamin8000/owl/content/home/HomeState.kt @@ -64,7 +64,6 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import retrofit2.HttpException import java.util.Locale -import java.util.Map.entry class HomeState( val listState: ScrollState, @@ -316,26 +315,32 @@ class HomeState( private fun createShareText() = buildString { append("Word: ") append(entry.value?.word ?: "-") - append("\n") + appendLine() append("Pronunciation(IPA): ") append(entry.value?.phonetics?.firstOrNull { it.text != null }?.text ?: "-") - append("\n\n") - /*entry { index, item -> - if (searchResult.value.item.size > 1) - append("${index + 1})\n") - append("Definition: ${item.definition}\n\n") - item.type?.let { append("Type: $it\n\n") } - item.example?.let { append("Example: $it\n\n") } - item.emoji?.let { append("Emoji: $it") } - }*/ + appendLine() + appendLine() + entry.value?.meanings?.forEachIndexed { index, meaning -> + appendLine("${index + 1})") + appendLine("Type: ${meaning.partOfSpeech}") + meaning.definitions.take(5).forEach { definition -> + appendLine("Definition: ${definition.definition}") + if (definition.example != null) + appendLine("Example: ${definition.example}") + if (definition.synonyms.isNotEmpty()) + appendLine("Synonyms: ${definition.synonyms.take(5).joinToString()}") + if (definition.antonyms.isNotEmpty()) + appendLine("Antonyms: ${definition.antonyms.take(5).joinToString()}") + appendLine() + } + appendLine() + } trim() - append("\n\n") - append(context.getString(R.string.this_text_generated_using_owl)) - append("\n") - append(context.getString(R.string.github_source)) - append("\n") - append(context.getString(R.string.this_text_extracted_from_free_dictionary)) - append("\n") + appendLine() + appendLine() + appendLine(context.getString(R.string.this_text_generated_using_owl)) + appendLine(context.getString(R.string.github_source)) + appendLine(context.getString(R.string.this_text_extracted_from_free_dictionary)) append(context.getString(R.string.free_dictionary_link)) }