Add voice command activity

Closes #95
pull/120/head
Alex Baker 10 years ago
parent 5c2b90a31d
commit 8ef4f4c9c7

@ -581,6 +581,18 @@
</intent-filter>
</receiver>
<activity
android:name=".voice.VoiceCommandActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<action android:name="com.google.android.gm.action.AUTO_SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
<service android:name="com.todoroo.astrid.reminders.ReminderSchedulingService" />
<!-- Uses Library -->

@ -0,0 +1,44 @@
package org.tasks.voice;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.TaskService;
import org.tasks.R;
public class VoiceCommandActivity extends Activity {
@Autowired
TaskService taskService;
public VoiceCommandActivity() {
DependencyInjectionService.getInstance().inject(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
switch (intent.getAction()) {
case "com.google.android.gm.action.AUTO_SEND":
final String text = intent.getStringExtra(Intent.EXTRA_TEXT);
taskService.save(new Task() {{
setTitle(text);
}});
Context context = getApplicationContext();
if (context != null) {
Toast.makeText(context, getString(R.string.voice_command_added_task), Toast.LENGTH_LONG).show();
}
finish();
}
}
}

@ -4,4 +4,5 @@
<string name="EPr_use_dark_theme_widget">Dark widget theme</string>
<string name="delete_task">Delete task</string>
<string name="TLA_menu_support">Support</string>
<string name="voice_command_added_task">Added task</string>
</resources>
Loading…
Cancel
Save