Handle PROCESS_TEXT in ShareLinkActivity

pull/513/head
Alex Baker 6 years ago
parent 9f3e31a78e
commit aae448be0c

@ -155,7 +155,16 @@
<!-- TODO: clearTaskOnLaunch probable cause of #275 -->
<activity
android:clearTaskOnLaunch="true"
android:name="com.todoroo.astrid.activity.ShareLinkActivity">
android:icon="@mipmap/ic_launcher_blue"
android:label="@string/action_create_new_task"
android:name="com.todoroo.astrid.activity.ShareLinkActivity"
android:roundIcon="@mipmap/ic_launcher_blue">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>

@ -1,6 +1,7 @@
/** TODO: make this lightweight, don't extend the entire MainActivity */
package com.todoroo.astrid.activity;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastMarshmallow;
import static org.tasks.intents.TaskIntents.getEditTaskStack;
import android.content.Intent;
@ -11,6 +12,7 @@ import com.todoroo.astrid.service.TaskCreator;
import javax.inject.Inject;
import org.tasks.injection.ActivityComponent;
import org.tasks.injection.InjectingAppCompatActivity;
import timber.log.Timber;
/**
* @author joshuagross
@ -44,15 +46,24 @@ public final class ShareLinkActivity extends InjectingAppCompatActivity {
private void readIntent() {
Intent intent = getIntent();
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
if (subject == null) {
subject = "";
}
Task task = taskCreator.createWithValues(null, subject);
if (task != null) {
if (atLeastMarshmallow() && Intent.ACTION_PROCESS_TEXT.equals(intent.getAction())) {
CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
if (text != null) {
Task task = taskCreator.createWithValues(null, text.toString());
getEditTaskStack(this, null, task).startActivities();
}
} else if (Intent.ACTION_SEND.equals(intent.getAction())) {
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
if (subject == null) {
subject = "";
}
Task task = taskCreator.createWithValues(null, subject);
task.setNotes(intent.getStringExtra(Intent.EXTRA_TEXT));
getEditTaskStack(this, null, task).startActivities();
} else {
Timber.e("Unhandled intent: %s", intent);
}
finish();
}

@ -895,4 +895,5 @@ File %1$s contained %2$s.\n\n
<string name="logout_warning">Log out of %s? All data for this account will be removed from your device</string>
<string name="cannot_access_account">Cannot access account</string>
<string name="reinitialize_account">Reinitialize</string>
<string name="action_create_new_task">Create new task</string>
</resources>

Loading…
Cancel
Save