Skip to content

Commit

Permalink
Fixed receiving shared note
Browse files Browse the repository at this point in the history
  • Loading branch information
OmGodse committed Jun 28, 2023
1 parent 3f56a7e commit 92c43ef
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.omgodse.notally.activities

import android.content.Intent
import android.content.res.ColorStateList
import android.os.Build
import android.os.Bundle
import android.text.Editable
import android.util.TypedValue
import android.view.MenuItem
import android.view.View
Expand Down Expand Up @@ -61,6 +63,10 @@ abstract class NotallyActivity(private val type: Type) : AppCompatActivity() {
} else {
model.isNewNote = true
model.createBaseNote()

if (intent.action == Intent.ACTION_SEND) {
handleSharedNote()
}
}
model.isFirstInstance = false
}
Expand Down Expand Up @@ -93,6 +99,22 @@ abstract class NotallyActivity(private val type: Type) : AppCompatActivity() {
}


private fun handleSharedNote() {
val title = intent.getStringExtra(Intent.EXTRA_SUBJECT)

val string = intent.getStringExtra(Intent.EXTRA_TEXT)
val charSequence = intent.getCharSequenceExtra(Operations.extraCharSequence)
val body = charSequence ?: string

if (body != null) {
model.body = Editable.Factory.getInstance().newEditable(body)
}
if (title != null) {
model.title = title
}
}


private fun share() {
val body = when (type) {
Type.NOTE -> model.body
Expand Down

0 comments on commit 92c43ef

Please sign in to comment.