EMMA Coverage Report (generated Thu Feb 07 17:31:12 CET 2013)
[all classes][org.tomdroid.util]

COVERAGE SUMMARY FOR SOURCE FILE [Send.java]

nameclass, %method, %block, %line, %
Send.java0%   (0/3)0%   (0/9)0%   (0/114)0%   (0/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Send0%   (0/1)0%   (0/5)0%   (0/35)0%   (0/9)
Send (Activity, Note): void 0%   (0/1)0%   (0/15)0%   (0/5)
access$000 (Send): SpannableStringBuilder 0%   (0/1)0%   (0/3)0%   (0/1)
access$100 (Send): Note 0%   (0/1)0%   (0/3)0%   (0/1)
access$200 (Send): Activity 0%   (0/1)0%   (0/3)0%   (0/1)
send (): void 0%   (0/1)0%   (0/11)0%   (0/3)
     
class Send$10%   (0/1)0%   (0/2)0%   (0/70)0%   (0/11)
Send$1 (Send): void 0%   (0/1)0%   (0/6)0%   (0/1)
handleMessage (Message): void 0%   (0/1)0%   (0/64)0%   (0/10)
     
class Send$1$10%   (0/1)0%   (0/2)0%   (0/9)0%   (0/3)
Send$1$1 (Send$1): void 0%   (0/1)0%   (0/6)0%   (0/1)
onClick (DialogInterface, int): void 0%   (0/1)0%   (0/3)0%   (0/2)

1package org.tomdroid.util;
2 
3import org.tomdroid.Note;
4 
5import android.app.Activity;
6import android.app.AlertDialog;
7import android.content.DialogInterface;
8import android.content.Intent;
9import android.content.DialogInterface.OnClickListener;
10import android.os.Handler;
11import android.os.Message;
12import android.text.SpannableStringBuilder;
13 
14public class Send {
15        
16        private Activity activity;
17        private Note note;
18        private SpannableStringBuilder noteContent;
19        
20        public Send(Activity activity, Note note) {
21                this.activity = activity;
22                this.note = note;
23        }
24        
25        public void send() {
26                if (note != null) {
27                        noteContent = note.getNoteContent(noteContentHandler);
28                }
29        }
30        
31        private Handler noteContentHandler = new Handler() {
32 
33                @Override
34                public void handleMessage(Message msg) {
35                        
36                        //parsed ok - show
37                        if(msg.what == NoteContentBuilder.PARSE_OK) {
38                                
39                                String body = noteContent.toString();
40                                
41                            // Create a new Intent to send messages
42                            Intent sendIntent = new Intent(Intent.ACTION_SEND);
43                            // Add attributes to the intent
44                
45                            sendIntent.putExtra(Intent.EXTRA_SUBJECT, note.getTitle());
46                            sendIntent.putExtra(Intent.EXTRA_TEXT, body);
47                            sendIntent.setType("text/plain");
48                
49                            activity.startActivity(Intent.createChooser(sendIntent, note.getTitle()));
50 
51                        //parsed not ok - error
52                        } else if(msg.what == NoteContentBuilder.PARSE_ERROR) {
53                                
54                                // TODO put this String in a translatable resource
55                                new AlertDialog.Builder(activity)
56                                        .setMessage("The requested note could not be parsed. If you see this error " +
57                                                                " and you are able to replicate it, please file a bug!")
58                                        .setTitle("Error")
59                                        .setNeutralButton("Ok", new OnClickListener() {
60                                                public void onClick(DialogInterface dialog, int which) {
61                                                        dialog.dismiss();
62                                                }})
63                                        .show();
64                }
65                }
66        };
67}

[all classes][org.tomdroid.util]
EMMA 0.0.0 (unsupported private build) (C) Vladimir Roubtsov