149fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert/* 249fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * Copyright (C) 2010 The Android Open Source Project 349fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * 449fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * you may not use this file except in compliance with the License. 649fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * You may obtain a copy of the License at 749fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * 849fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 949fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * 1049fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * Unless required by applicable law or agreed to in writing, software 1149fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 1249fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1349fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * See the License for the specific language governing permissions and 1449fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert * limitations under the License. 1549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert */ 1649fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringertpackage com.android.quicksearchbox; 1749fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 1838eb02e676db9e5a633e3c88a90beb8a477b1ca1Bjorn Bringertimport android.content.ComponentName; 1949fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringertimport android.database.Cursor; 2049fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 21ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwoodimport com.android.quicksearchbox.google.GoogleSource; 22ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood 235229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport java.util.Collection; 245229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 2549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringertpublic class CursorBackedSourceResult extends CursorBackedSuggestionCursor 2649fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert implements SourceResult { 2749fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 28ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood private final GoogleSource mSource; 2949fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 30ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood public CursorBackedSourceResult(GoogleSource source, String userQuery) { 3149fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert this(source, userQuery, null); 3249fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert } 3349fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 34ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood public CursorBackedSourceResult(GoogleSource source, String userQuery, Cursor cursor) { 3549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert super(userQuery, cursor); 3649fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert mSource = source; 3749fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert } 3849fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 39ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood public GoogleSource getSource() { 4049fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert return mSource; 4149fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert } 4249fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 4349fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert @Override 44ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood public GoogleSource getSuggestionSource() { 4549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert return mSource; 4649fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert } 4749fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 4838eb02e676db9e5a633e3c88a90beb8a477b1ca1Bjorn Bringert @Override 4938eb02e676db9e5a633e3c88a90beb8a477b1ca1Bjorn Bringert public ComponentName getSuggestionIntentComponent() { 5038eb02e676db9e5a633e3c88a90beb8a477b1ca1Bjorn Bringert return mSource.getIntentComponent(); 5138eb02e676db9e5a633e3c88a90beb8a477b1ca1Bjorn Bringert } 5238eb02e676db9e5a633e3c88a90beb8a477b1ca1Bjorn Bringert 5349fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert public boolean isSuggestionShortcut() { 5449fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert return false; 5549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert } 5649fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 57fb8ce18922dae59db424fce906b5c113797fe81eBjorn Bringert public boolean isHistorySuggestion() { 58fb8ce18922dae59db424fce906b5c113797fe81eBjorn Bringert return false; 59fb8ce18922dae59db424fce906b5c113797fe81eBjorn Bringert } 60fb8ce18922dae59db424fce906b5c113797fe81eBjorn Bringert 6149fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert @Override 6249fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert public String toString() { 6349fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert return mSource + "[" + getUserQuery() + "]"; 6449fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert } 6549fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert 665229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood @Override 675229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood public SuggestionExtras getExtras() { 682f6c8b84b24d3adf767e8533627f6f63e73acbdeBjorn Bringert if (mCursor == null) return null; 695229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood return CursorBackedSuggestionExtras.createExtrasIfNecessary(mCursor, getPosition()); 705229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood } 715229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 725229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood public Collection<String> getExtraColumns() { 732f6c8b84b24d3adf767e8533627f6f63e73acbdeBjorn Bringert if (mCursor == null) return null; 745229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood return CursorBackedSuggestionExtras.getExtraColumns(mCursor); 755229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood } 765229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 7749fd8e0994577badc6194c2c3b5f771f2b793fe4Bjorn Bringert}