Skip to content

Latest commit

 

History

History
74 lines (65 loc) · 2.61 KB

File metadata and controls

74 lines (65 loc) · 2.61 KB

Tasks

  • refactor code
    • DONE - remove capacitor - copy android project from minimalist music
    • DONE - update resources
    • DONE - update androidManifest
    • DONE - update package name
    • ~ update native code
    • DONE - remove JS modules
  • DONE - finish rearrange implementation
    • DONE - handle "drop" in UI
    • DONE - handle cancel
    • DONE - handle DB
  • DONE - fix UX anti-patterns:
    • DONE - labels dialog: save when clicking the checkmark button if the field isn't empty!
    • DONE - labels dialog: set a random color in the add label row
    • DONE - confirm deletion in both todo list and label list (using a simple confirm)
    • DONE - todo dialog: add a tooltip when no labels are created
  • due date
    • calendar integration (send broadcast)
  • backup/restore
// Request code for creating a PDF document.
const val CREATE_FILE = 1

private fun createFile(pickerInitialUri: Uri) {
    val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
        addCategory(Intent.CATEGORY_OPENABLE)
        type = "application/pdf"
        putExtra(Intent.EXTRA_TITLE, "invoice.pdf")

        // Optionally, specify a URI for the directory that should be opened in
        // the system file picker before your app creates the document.
        putExtra(DocumentsContract.EXTRA_INITIAL_URI, pickerInitialUri)
    }
    startActivityForResult(intent, CREATE_FILE)
}

// Request code for selecting a PDF document.
const val PICK_PDF_FILE = 2

fun openFile(pickerInitialUri: Uri) {
    val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
        addCategory(Intent.CATEGORY_OPENABLE)
        type = "application/pdf"

        // Optionally, specify a URI for the file that should appear in the
        // system file picker when it loads.
        putExtra(DocumentsContract.EXTRA_INITIAL_URI, pickerInitialUri)
    }

    startActivityForResult(intent, PICK_PDF_FILE)
}

override fun onActivityResult(
        requestCode: Int, resultCode: Int, resultData: Intent?) {
    if (requestCode == your-request-code
            && resultCode == Activity.RESULT_OK) {
        // The result data contains a URI for the document or directory that
        // the user selected.
        resultData?.data?.also { uri ->
            // Perform operations on the document using its URI.
        }
    }
}

val contentResolver = applicationContext.contentResolver

val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or
        Intent.FLAG_GRANT_WRITE_URI_PERMISSION
// Check for the freshest data.
contentResolver.takePersistableUriPermission(uri, takeFlags)