diff --git a/app/src/main/java/com/omgodse/notally/activities/NotallyActivity.kt b/app/src/main/java/com/omgodse/notally/activities/NotallyActivity.kt index d604b4b6..87dc45ca 100644 --- a/app/src/main/java/com/omgodse/notally/activities/NotallyActivity.kt +++ b/app/src/main/java/com/omgodse/notally/activities/NotallyActivity.kt @@ -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 @@ -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 } @@ -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