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

COVERAGE SUMMARY FOR SOURCE FILE [Search.java]

nameclass, %method, %block, %line, %
Search.java0%   (0/1)0%   (0/7)0%   (0/157)0%   (0/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Search0%   (0/1)0%   (0/7)0%   (0/157)0%   (0/37)
Search (): void 0%   (0/1)0%   (0/9)0%   (0/2)
handleIntent (Intent): void 0%   (0/1)0%   (0/33)0%   (0/8)
onCreate (Bundle): void 0%   (0/1)0%   (0/31)0%   (0/8)
onListItemClick (ListView, View, int, long): void 0%   (0/1)0%   (0/36)0%   (0/6)
onNewIntent (Intent): void 0%   (0/1)0%   (0/7)0%   (0/3)
onResume (): void 0%   (0/1)0%   (0/8)0%   (0/4)
showResults (String): void 0%   (0/1)0%   (0/33)0%   (0/6)

1/*
2 * Tomdroid
3 * Tomboy on Android
4 * http://www.launchpad.net/tomdroid
5 * 
6 * Copyright 2011 Olivier Bilodeau <olivier@bottomlesspit.org>
7 * Copyright 2011 Stefan Hammer <j.4@gmx.at>
8 * 
9 * This file is part of Tomdroid.
10 * 
11 * Tomdroid is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 * 
16 * Tomdroid is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 * 
21 * You should have received a copy of the GNU General Public License
22 * along with Tomdroid.  If not, see <http://www.gnu.org/licenses/>.
23 */
24package org.tomdroid.ui;
25 
26import org.tomdroid.Note;
27import org.tomdroid.NoteManager;
28import org.tomdroid.R;
29import org.tomdroid.sync.SyncManager;
30import org.tomdroid.util.SearchSuggestionProvider;
31 
32import android.app.ListActivity;
33import android.app.SearchManager;
34import android.content.Intent;
35import android.database.Cursor;
36import android.graphics.Color;
37import android.net.Uri;
38import android.os.Bundle;
39import android.os.Handler;
40import android.provider.SearchRecentSuggestions;
41import android.util.Log;
42import android.view.View;
43import android.widget.ListAdapter;
44import android.widget.ListView;
45import android.widget.TextView;
46 
47public class Search extends ListActivity {
48        
49        // Logging info
50        private static final String        TAG                                        = "Tomdroid Search";
51        // UI elements
52        private TextView title;
53        // UI to data model glue
54        private TextView                        listEmptyView;        
55        // UI feedback handler
56        private Handler        syncMessageHandler        = new SyncMessageHandler(this);
57 
58        private ListAdapter                        adapter;
59 
60        
61        @Override
62        public void onCreate(Bundle savedInstanceState) {
63            super.onCreate(savedInstanceState);
64            setContentView(R.layout.search);
65            
66                title = (TextView) findViewById(R.id.title);
67                title.setTextColor(Color.DKGRAY);
68                title.setTextSize(18.0f);
69                title.setText((CharSequence) getString(R.string.SearchResultTitle));
70                        
71            handleIntent(getIntent());
72        }
73 
74        @Override
75        protected void onNewIntent(Intent intent) {
76            setIntent(intent);
77            handleIntent(intent);
78        }
79 
80        private void handleIntent(Intent intent) {
81                //handles a search query
82            if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
83              String query = intent.getStringExtra(SearchManager.QUERY);
84              showResults(query);
85            }
86            
87            //adds query to search history suggestions
88            if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
89                String query = intent.getStringExtra(SearchManager.QUERY);
90                SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
91                        SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
92                suggestions.saveRecentQuery(query, null);
93            }
94        }
95 
96        public void showResults(String query) {
97                if (Tomdroid.LOGGING_ENABLED) Log.d(TAG,"Start searching for: "+query);
98                
99                
100                // adapter that binds the ListView UI to the notes in the note manager
101                adapter = NoteManager.getListAdapter(this, query);
102                setListAdapter(adapter);
103                
104                // set the view shown when query not found
105                listEmptyView = (TextView) findViewById(R.id.no_results);
106                listEmptyView.setText(getString(R.string.strNoResults, new Object[] {query}));
107                getListView().setEmptyView(listEmptyView);
108        }
109        
110        @Override
111        protected void onListItemClick(ListView l, View v, int position, long id) {
112 
113                Cursor item = (Cursor) adapter.getItem(position);
114                int noteId = item.getInt(item.getColumnIndexOrThrow(Note.ID));
115 
116                Uri intentUri = Uri.parse(Tomdroid.CONTENT_URI + "/" + noteId);
117                Intent i = new Intent(Intent.ACTION_VIEW, intentUri, this, ViewNote.class);
118                startActivity(i);
119        }
120        
121        @Override
122        public void onResume(){
123                super.onResume();
124                SyncManager.setActivity(this);
125                SyncManager.setHandler(this.syncMessageHandler);
126        }
127}

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