1 /* 2 * Copyright 2024 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 17 package androidx.pdf.find; 18 19 import androidx.annotation.RestrictTo; 20 import androidx.pdf.util.ObservableValue; 21 22 import org.jspecify.annotations.Nullable; 23 24 /** 25 * Callback interface for listening to user actions to find text in a file. 26 */ 27 @RestrictTo(RestrictTo.Scope.LIBRARY) 28 public interface FindInFileListener { 29 30 /** 31 * Called when the query text is changed by the user. 32 * 33 * @param query The text the user is searching for. 34 */ onQueryTextChange(@ullable String query)35 boolean onQueryTextChange(@Nullable String query); 36 37 /** 38 * The user is attempting to find the next match of the query text. 39 * 40 * @param query The text the user is searching for. 41 * @param backwards True iff the user is searching for the previous match. 42 */ onFindNextMatch(@ullable String query, boolean backwards)43 boolean onFindNextMatch(@Nullable String query, boolean backwards); 44 45 /** 46 * Get an ObservableValue that changes whenever MatchCount data is changed - 47 * when more matches are found or the selected match is changed. 48 * Can be null if not supported, or if the document is not ready or is destroyed. 49 */ matchCount()50 @Nullable ObservableValue<MatchCount> matchCount(); 51 } 52