11be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee/* 21be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * Copyright (C) 2012 The Android Open Source Project 31be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * 41be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * Licensed under the Apache License, Version 2.0 (the "License"); 51be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * you may not use this file except in compliance with the License. 61be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * You may obtain a copy of the License at 71be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * 81be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * http://www.apache.org/licenses/LICENSE-2.0 91be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * 101be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * Unless required by applicable law or agreed to in writing, software 111be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * distributed under the License is distributed on an "AS IS" BASIS, 121be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * See the License for the specific language governing permissions and 141be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * limitations under the License. 151be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee */ 161be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 171be0178a11b1cc3b06867b14446e1e041e97a82cYorke Leepackage com.android.dialer.dialpad; 181be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 191be0178a11b1cc3b06867b14446e1e041e97a82cYorke Leeimport android.util.Log; 201be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 211be0178a11b1cc3b06867b14446e1e041e97a82cYorke Leeimport java.util.ArrayList; 221be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 231be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee/** 241be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * Stores information about a range of characters matched in a display name The integers 251be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * start and end indicate that the range start to end (exclusive) correspond to some characters 26f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee * in the query. Used to highlight certain parts of the contact's display name to indicate that 27f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee * those ranges matched the user's query. 281be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee */ 29dfb2eee7d98f8540fd1614db66bb03e8e1f3a26aYorke Leepublic class SmartDialMatchPosition { 30f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee private static final String TAG = SmartDialMatchPosition.class.getSimpleName(); 31f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee 321be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee public int start; 331be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee public int end; 341be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 351be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee public SmartDialMatchPosition(int start, int end) { 361be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee this.start = start; 371be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee this.end = end; 381be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee } 391be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 401be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee private void advance(int toAdvance) { 411be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee this.start += toAdvance; 421be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee this.end += toAdvance; 431be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee } 441be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 451be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee /** 461be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * Used by {@link SmartDialNameMatcher} to advance the positions of a match position found in 471be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * a sub query. 481be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * 491be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * @param inList ArrayList of SmartDialMatchPositions to modify. 501be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * @param toAdvance Offset to modify by. 511be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee */ 521be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee public static void advanceMatchPositions(ArrayList<SmartDialMatchPosition> inList, 531be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee int toAdvance) { 541be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee for (int i = 0; i < inList.size(); i++) { 551be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee inList.get(i).advance(toAdvance); 561be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee } 571be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee } 581be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee 591be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee /** 601be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * Used mainly for debug purposes. Displays contents of an ArrayList of SmartDialMatchPositions. 611be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * 621be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee * @param list ArrayList of SmartDialMatchPositions to print out in a human readable fashion. 631be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee */ 641be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee public static void print(ArrayList<SmartDialMatchPosition> list) { 651be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee for (int i = 0; i < list.size(); i ++) { 661be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee SmartDialMatchPosition m = list.get(i); 67f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee Log.d(TAG, "[" + m.start + "," + m.end + "]"); 681be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee } 691be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee } 701be0178a11b1cc3b06867b14446e1e041e97a82cYorke Lee} 71