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 @Suppress("MUST_BE_INITIALIZED_OR_FINAL_OR_ABSTRACT_WARNING") 28 override val userQuery: String 29 override var position = 0 30 abstract override val count: Int 31 abstract override val suggestionQuery: String? 32 override val source: Source 33 get() = mSource 34 closenull35 override fun close() {} moveTonull36 override fun moveTo(pos: Int) { 37 position = pos 38 } 39 moveToNextnull40 override fun moveToNext(): Boolean { 41 val size = count 42 if (position >= size) { 43 // Already past the end 44 return false 45 } 46 position++ 47 return position < size 48 } 49 registerDataSetObservernull50 override fun registerDataSetObserver(observer: DataSetObserver?) {} unregisterDataSetObservernull51 override fun unregisterDataSetObserver(observer: DataSetObserver?) {} 52 override val suggestionText1: String? 53 get() = suggestionQuery 54 override val suggestionSource: Source 55 get() = mSource 56 override val isSuggestionShortcut: Boolean 57 get() = false 58 override val shortcutId: String? 59 get() = null 60 override val suggestionFormat: String? 61 get() = null 62 override val suggestionIcon1: String 63 get() = R.drawable.magnifying_glass.toString() 64 override val suggestionIcon2: String? 65 get() = null 66 override val suggestionIntentAction: String? 67 get() = mSource.defaultIntentAction 68 override val suggestionIntentComponent: ComponentName? 69 get() = mSource.intentComponent 70 override val suggestionIntentDataString: String? 71 get() = null 72 override val suggestionIntentExtraData: String? 73 get() = null 74 override val suggestionLogType: String? 75 get() = null 76 override val suggestionText2: String? 77 get() = null 78 override val suggestionText2Url: String? 79 get() = null 80 override val isSpinnerWhileRefreshing: Boolean 81 get() = false 82 override val isWebSearchSuggestion: Boolean 83 get() = true 84 override val isHistorySuggestion: Boolean 85 get() = false 86 override val extras: SuggestionExtras? 87 get() = null 88 override val extraColumns: Collection<String>? 89 get() = null 90 91 init { 92 mSource = source 93 this.userQuery = userQuery 94 } 95 } 96