Notes widget: add share action
This commit is contained in:
parent
a294980627
commit
e8d0bb5d63
@ -1,5 +1,6 @@
|
||||
package de.mm20.launcher2.ui.launcher.widgets.notes
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
@ -15,6 +16,7 @@ import androidx.compose.material.icons.rounded.Add
|
||||
import androidx.compose.material.icons.rounded.Delete
|
||||
import androidx.compose.material.icons.rounded.MoreVert
|
||||
import androidx.compose.material.icons.rounded.SaveAlt
|
||||
import androidx.compose.material.icons.rounded.Share
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
@ -149,6 +151,20 @@ fun NotesWidget(
|
||||
showMenu = false
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.menu_share)) },
|
||||
leadingIcon = {
|
||||
Icon(Icons.Rounded.Share, null)
|
||||
},
|
||||
onClick = {
|
||||
Intent(Intent.ACTION_SEND).apply {
|
||||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_TEXT, text.text)
|
||||
context.startActivity(Intent.createChooser(this, null))
|
||||
}
|
||||
showMenu = false
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.notes_widget_action_dismiss)) },
|
||||
leadingIcon = {
|
||||
|
||||
@ -53,7 +53,6 @@ class NotesWidgetVM(
|
||||
fun exportNote(context: Context, uri: Uri) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val text = noteText.value.text
|
||||
Log.d("MM20", text)
|
||||
val outputStream = context.contentResolver.openOutputStream(uri)
|
||||
outputStream?.use {
|
||||
it.write(text.toByteArray())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user