EMMA Coverage Report (generated Tue Jun 26 14:54:12 CEST 2012)
[all classes][org.tomdroid.util]

COVERAGE SUMMARY FOR SOURCE FILE [Send.java]

nameclass, %method, %block, %line, %
Send.java67%  (2/3)78%  (7/9)73%  (83/114)81%  (17,9/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
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)
     
class Send$1100% (1/1)100% (2/2)69%  (48/70)90%  (9,9/11)
handleMessage (Message): void 100% (1/1)66%  (42/64)89%  (8,9/10)
Send$1 (Send): void 100% (1/1)100% (6/6)100% (1/1)
     
class Send100% (1/1)100% (5/5)100% (35/35)100% (9/9)
Send (Activity, Note): void 100% (1/1)100% (15/15)100% (5/5)
access$000 (Send): SpannableStringBuilder 100% (1/1)100% (3/3)100% (1/1)
access$100 (Send): Note 100% (1/1)100% (3/3)100% (1/1)
access$200 (Send): Activity 100% (1/1)100% (3/3)100% (1/1)
send (): void 100% (1/1)100% (11/11)100% (3/3)

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