|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 DuckDuckGo |
| 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 | + |
| 17 | +package com.duckduckgo.app.browser.omnibar |
| 18 | + |
| 19 | +import android.view.ViewGroup |
| 20 | +import android.widget.EditText |
| 21 | +import android.widget.ImageView |
| 22 | +import com.duckduckgo.app.browser.databinding.IncludeFadeOmnibarFindInPageBinding |
| 23 | +import com.duckduckgo.app.browser.databinding.IncludeFindInPageBinding |
| 24 | +import com.duckduckgo.common.ui.view.text.DaxTextView |
| 25 | + |
| 26 | +/** |
| 27 | + * Compatibility interface for accessing [IncludeFindInPageBinding] or [IncludeFadeOmnibarFindInPageBinding], depending on which omnibar is used. |
| 28 | + */ |
| 29 | +interface FindInPage { |
| 30 | + val findInPageContainer: ViewGroup |
| 31 | + val findInPageInput: EditText |
| 32 | + val findInPageMatches: DaxTextView |
| 33 | + val previousSearchTermButton: ImageView |
| 34 | + val nextSearchTermButton: ImageView |
| 35 | + val closeFindInPagePanel: ImageView |
| 36 | +} |
| 37 | + |
| 38 | +class FindInPageImpl( |
| 39 | + override val findInPageContainer: ViewGroup, |
| 40 | + override val findInPageInput: EditText, |
| 41 | + override val findInPageMatches: DaxTextView, |
| 42 | + override val previousSearchTermButton: ImageView, |
| 43 | + override val nextSearchTermButton: ImageView, |
| 44 | + override val closeFindInPagePanel: ImageView, |
| 45 | +) : FindInPage { |
| 46 | + |
| 47 | + constructor(binding: IncludeFindInPageBinding) : this( |
| 48 | + findInPageContainer = binding.findInPageContainer, |
| 49 | + findInPageInput = binding.findInPageInput, |
| 50 | + findInPageMatches = binding.findInPageMatches, |
| 51 | + previousSearchTermButton = binding.previousSearchTermButton, |
| 52 | + nextSearchTermButton = binding.nextSearchTermButton, |
| 53 | + closeFindInPagePanel = binding.closeFindInPagePanel, |
| 54 | + ) |
| 55 | + |
| 56 | + constructor(binding: IncludeFadeOmnibarFindInPageBinding) : this( |
| 57 | + findInPageContainer = binding.findInPageContainer, |
| 58 | + findInPageInput = binding.findInPageInput, |
| 59 | + findInPageMatches = binding.findInPageMatches, |
| 60 | + previousSearchTermButton = binding.previousSearchTermButton, |
| 61 | + nextSearchTermButton = binding.nextSearchTermButton, |
| 62 | + closeFindInPagePanel = binding.closeFindInPagePanel, |
| 63 | + ) |
| 64 | +} |
0 commit comments