1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.quicksearchbox.google 17 18 import android.content.ComponentName 19 import android.database.DataSetObserver 20 import com.android.quicksearchbox.R 21 import com.android.quicksearchbox.Source 22 import com.android.quicksearchbox.SourceResult 23 import com.android.quicksearchbox.SuggestionExtras 24 25 abstract class AbstractGoogleSourceResult(source: Source, userQuery: String) : SourceResult { 26 private val mSource: Source 27 override val userQuery: String = userQuery 28 override var position = 0 29 abstract override val count: Int 30 abstract override val suggestionQuery: String? 31 override val source: Source 32 get() = mSource 33 closenull34 override fun close() {} moveTonull35 override fun moveTo(pos: Int) { 36 position = pos 37 } 38 moveToNextnull39 override fun moveToNext(): Boolean { 40 val size = count 41 if (position >= size) { 42 // Already past the end 43 return false 44 } 45 position++ 46 return position < size 47 } 48 registerDataSetObservernull49 override fun registerDataSetObserver(observer: DataSetObserver?) {} unregisterDataSetObservernull50 override fun unregisterDataSetObserver(observer: DataSetObserver?) {} 51 override val suggestionText1: String? 52 get() = suggestionQuery 53 override val suggestionSource: Source 54 get() = mSource 55 override val isSuggestionShortcut: Boolean 56 get() = false 57 override val shortcutId: String? 58 get() = null 59 override val suggestionFormat: String? 60 get() = null 61 override val suggestionIcon1: String 62 get() = R.drawable.magnifying_glass.toString() 63 override val suggestionIcon2: String? 64 get() = null 65 override val suggestionIntentAction: String? 66 get() = mSource.defaultIntentAction 67 override val suggestionIntentComponent: ComponentName? 68 get() = mSource.intentComponent 69 override val suggestionIntentDataString: String? 70 get() = null 71 override val suggestionIntentExtraData: String? 72 get() = null 73 override val suggestionLogType: String? 74 get() = null 75 override val suggestionText2: String? 76 get() = null 77 override val suggestionText2Url: String? 78 get() = null 79 override val isSpinnerWhileRefreshing: Boolean 80 get() = false 81 override val isWebSearchSuggestion: Boolean 82 get() = true 83 override val isHistorySuggestion: Boolean 84 get() = false 85 override val extras: SuggestionExtras? 86 get() = null 87 override val extraColumns: Collection<String>? 88 get() = null 89 90 init { 91 mSource = source 92 } 93 } 94