diff --git a/README.md b/README.md index 3aac5044..6dc53088 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -*Please use the issues tab only for bug reports* +*Please use the pull requests tab only for translations or bug reports* ### Background Although there are many notes apps out there, they're all hideous, glitchy, low quality or all 3 at the same time. @@ -23,7 +23,7 @@ Well, Notally is none of these things. It's extremely light, minimalistic and el * APK size of 1.5 MB (1.9 MB Uncompressed) * Add labels to your notes for quick organisation * Archive notes to keep them around, but out of your way -* Export notes as plain text, HTML or PDF files with formatting +* Export notes as plain text, XML, HTML or PDF files with formatting * Create rich text notes with support for bold, italics, mono space and strike-through * Add clickable links to notes with support for phone numbers, email addresses and web urls diff --git a/app/build.gradle b/app/build.gradle index ddbb1874..41e189b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,9 +13,9 @@ android { applicationId "com.omgodse.notally" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 33 - versionName "3.8" - resConfigs "en", "ca", "cs", "de", "es", "fr", "hu", "in", "it", "ja", "nb", "nl", "pl", "pt-rBR", "ru", "sv", "tl", "tr", "uk" + versionCode 34 + versionName "3.9" + resConfigs "en", "ca", "cs", "de", "es", "fr", "hu", "in", "it", "ja", "nb", "nl", "pl", "pt-rBR", "ru", "sk", "sv", "tl", "tr", "uk" vectorDrawables.generatedDensities = [] } @@ -56,7 +56,7 @@ dependencies { implementation "androidx.navigation:navigation-fragment-ktx:$navVersion" implementation "org.ocpsoft.prettytime:prettytime:4.0.6.Final" - implementation "com.google.android.material:material:1.3.0" + implementation "com.google.android.material:material:1.4.0" implementation project(":Post") } \ No newline at end of file diff --git a/app/src/main/java/com/omgodse/notally/fragments/NotallyFragment.kt b/app/src/main/java/com/omgodse/notally/fragments/NotallyFragment.kt index 046cfe65..08517645 100644 --- a/app/src/main/java/com/omgodse/notally/fragments/NotallyFragment.kt +++ b/app/src/main/java/com/omgodse/notally/fragments/NotallyFragment.kt @@ -11,6 +11,7 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.Toast import androidx.core.content.FileProvider +import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.lifecycle.LiveData @@ -140,10 +141,7 @@ abstract class NotallyFragment : Fragment(), OperationsParent, ItemListener { private fun setupObserver() { getObservable()?.observe(viewLifecycleOwner, { list -> adapter?.submitList(list) - - if (list.isNotEmpty()) { - binding?.RecyclerView?.visibility = View.VISIBLE - } else binding?.RecyclerView?.visibility = View.GONE + binding?.RecyclerView?.isVisible = list.isNotEmpty() }) } @@ -176,6 +174,7 @@ abstract class NotallyFragment : Fragment(), OperationsParent, ItemListener { MenuDialog(mContext) .addItem(Operation(R.string.pdf, R.drawable.pdf) { exportBaseNoteToPDF(baseNote) }) .addItem(Operation(R.string.txt, R.drawable.txt) { exportBaseNoteToTXT(baseNote) }) + .addItem(Operation(R.string.xml, R.drawable.xml) { exportBaseNoteToXML(baseNote) }) .addItem(Operation(R.string.html, R.drawable.html) { exportBaseNoteToHTML(baseNote) }) .show() } @@ -196,7 +195,7 @@ abstract class NotallyFragment : Fragment(), OperationsParent, ItemListener { } override fun onFailure(message: String?) { - Toast.makeText(context, R.string.something_went_wrong, Toast.LENGTH_SHORT).show() + Toast.makeText(mContext, R.string.something_went_wrong, Toast.LENGTH_SHORT).show() } }) } @@ -208,6 +207,13 @@ abstract class NotallyFragment : Fragment(), OperationsParent, ItemListener { } } + private fun exportBaseNoteToXML(baseNote: BaseNote) { + lifecycleScope.launch { + val file = model.getXMLFile(baseNote) + showFileOptionsDialog(file, "text/xml") + } + } + private fun exportBaseNoteToHTML(baseNote: BaseNote) { lifecycleScope.launch { val file = model.getHTMLFile(baseNote, settingsHelper.getShowDateCreated()) @@ -227,29 +233,29 @@ abstract class NotallyFragment : Fragment(), OperationsParent, ItemListener { private fun viewFile(uri: Uri, mimeType: String) { - val intent = Intent(Intent.ACTION_VIEW).apply { - setDataAndType(uri, mimeType) - flags = Intent.FLAG_GRANT_READ_URI_PERMISSION - } + val intent = Intent(Intent.ACTION_VIEW) + intent.setDataAndType(uri, mimeType) + intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION + val chooser = Intent.createChooser(intent, mContext.getString(R.string.view_note)) startActivity(chooser) } private fun shareFile(uri: Uri, mimeType: String) { - val intent = Intent(Intent.ACTION_SEND).apply { - type = mimeType - putExtra(Intent.EXTRA_STREAM, uri) - } + val intent = Intent(Intent.ACTION_SEND) + intent.type = mimeType + intent.putExtra(Intent.EXTRA_STREAM, uri) + val chooser = Intent.createChooser(intent, mContext.getString(R.string.share_note)) startActivity(chooser) } private fun saveFileToDevice(file: File, mimeType: String) { - val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply { - type = mimeType - addCategory(Intent.CATEGORY_OPENABLE) - putExtra(Intent.EXTRA_TITLE, file.nameWithoutExtension) - } + val intent = Intent(Intent.ACTION_CREATE_DOCUMENT) + intent.type = mimeType + intent.addCategory(Intent.CATEGORY_OPENABLE) + intent.putExtra(Intent.EXTRA_TITLE, file.nameWithoutExtension) + model.currentFile = file startActivityForResult(intent, Constants.RequestCodeExportFile) } diff --git a/app/src/main/java/com/omgodse/notally/viewmodels/BaseNoteModel.kt b/app/src/main/java/com/omgodse/notally/viewmodels/BaseNoteModel.kt index fe029dbd..287a4f2f 100644 --- a/app/src/main/java/com/omgodse/notally/viewmodels/BaseNoteModel.kt +++ b/app/src/main/java/com/omgodse/notally/viewmodels/BaseNoteModel.kt @@ -132,6 +132,15 @@ class BaseNoteModel(private val app: Application) : AndroidViewModel(app) { } + suspend fun getXMLFile(baseNote: BaseNote) = withContext(Dispatchers.IO) { + val fileName = getFileName(baseNote) + val file = File(getExportedPath(), "$fileName.xml") + val outputStream = FileOutputStream(file) + XMLUtils.writeBaseNoteToStream(baseNote, outputStream) + outputStream.close() + file + } + suspend fun getTXTFile(baseNote: BaseNote, showDateCreated: Boolean) = withContext(Dispatchers.IO) { val fileName = getFileName(baseNote) val file = File(getExportedPath(), "$fileName.txt") @@ -233,6 +242,7 @@ class BaseNoteModel(private val app: Application) : AndroidViewModel(app) { private fun getHTML(baseNote: BaseNote, showDateCreated: Boolean) = buildString { val date = formatter.format(baseNote.timestamp) + append("") append("
") append("$body
") + append(body) } Type.LIST -> { append("