1b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio/* 2b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * Copyright (C) 2014 The Android Open Source Project 3b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 4b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * Licensed under the Apache License, Version 2.0 (the "License"); 5b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * you may not use this file except in compliance with the License. 6b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * You may obtain a copy of the License at 7b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 8b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * http://www.apache.org/licenses/LICENSE-2.0 9b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 10b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * Unless required by applicable law or agreed to in writing, software 11b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * distributed under the License is distributed on an "AS IS" BASIS, 12b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * See the License for the specific language governing permissions and 14b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * limitations under the License. 15b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 16b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 17b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Megliopackage android.provider; 18b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 1927e13347344276f337d4289e3197f8ab7d5c74d2Fabrice Di Meglioimport android.annotation.SystemApi; 20b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglioimport android.content.Context; 21b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 22b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglioimport java.util.Locale; 23b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 24b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio/** 2516f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio * The Indexable data for Search. 2616f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio * 2716f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio * This abstract class defines the common parts for all search indexable data. 28b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 29b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @hide 30b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 3127e13347344276f337d4289e3197f8ab7d5c74d2Fabrice Di Meglio@SystemApi 32b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Megliopublic abstract class SearchIndexableData { 33b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 34b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 3516f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio * The context for the data. Will usually allow retrieving some resources. 36b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 37b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see Context 38b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 39b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public Context context; 40b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 41b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 42b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The locale for the data 43b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 44b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public Locale locale; 45b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 46b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 4716f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio * Tells if the data will be included into the search results. This is application specific. 4816f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio */ 4916f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio public boolean enabled; 5016f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio 5116f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio /** 52b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The rank for the data. This is application specific. 53b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 54b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public int rank; 55b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 56b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 57738691d610c918691b386f332548bbd6abc783f9Fabrice Di Meglio * The key for the data. This is application specific. Should be unique per data as the data 58738691d610c918691b386f332548bbd6abc783f9Fabrice Di Meglio * should be able to be retrieved by the key. 5955a7c5ad5624334dfb7a16bebacddba8f706f7ccFan Zhang * <p/> 6055a7c5ad5624334dfb7a16bebacddba8f706f7ccFan Zhang * This is required for indexing to work. 61738691d610c918691b386f332548bbd6abc783f9Fabrice Di Meglio */ 62738691d610c918691b386f332548bbd6abc783f9Fabrice Di Meglio public String key; 63738691d610c918691b386f332548bbd6abc783f9Fabrice Di Meglio 64738691d610c918691b386f332548bbd6abc783f9Fabrice Di Meglio /** 652331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio * The UserID for the data (in a multi user context). This is application specific and -1 is the 662331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio * default non initialized value. 672331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio */ 682331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio public int userId = -1; 692331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio 702331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio /** 71b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The class name associated with the data. Generally this is a Fragment class name for 72b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * referring where the data is coming from and for launching the associated Fragment for 73b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * displaying the data. This is used only when the data is provided "locally". 74b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 75b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * If the data is provided "externally", the relevant information come from the 76b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * {@link SearchIndexableData#intentAction} and {@link SearchIndexableData#intentTargetPackage} 77b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * and {@link SearchIndexableData#intentTargetClass}. 78b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 79b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentAction 80b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentTargetPackage 81b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentTargetClass 82b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 83b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public String className; 84b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 85b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 86b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The package name for retrieving the icon associated with the data. 87b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 88b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#iconResId 89b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 90b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public String packageName; 91b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 92b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 93b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The icon resource ID associated with the data. 94b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 95b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#packageName 96b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 97b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public int iconResId; 98b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 99b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 100b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The Intent action associated with the data. This is used when the 101b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * {@link SearchIndexableData#className} is not relevant. 102b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 103b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentTargetPackage 104b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentTargetClass 105b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 106b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public String intentAction; 107b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 108b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 109b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The Intent target package associated with the data. 110b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 111b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentAction 112b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentTargetClass 113b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 114b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public String intentTargetPackage; 115b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 116b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 117b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * The Intent target class associated with the data. 118b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 119b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentAction 120b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @see SearchIndexableData#intentTargetPackage 121b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 122b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public String intentTargetClass; 123b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 124b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 125b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * Default constructor. 126b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 127b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public SearchIndexableData() { 128773a56bbf48beaa0ee10de55e08387ab1024ae26Fabrice Di Meglio locale = Locale.getDefault(); 12916f81e75423a9ffa602ad45a679d9e0283f4e499Fabrice Di Meglio enabled = true; 130b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio } 131b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio 132b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio /** 133b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * Constructor with a {@link Context}. 134b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * 135b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio * @param ctx the Context 136b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio */ 137b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio public SearchIndexableData(Context ctx) { 138773a56bbf48beaa0ee10de55e08387ab1024ae26Fabrice Di Meglio this(); 139b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio context = ctx; 140b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio } 14171b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio 14271b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio @Override 14371b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio public String toString() { 14471b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio final StringBuilder sb = new StringBuilder(); 14571b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("SearchIndexableData[context: "); 14671b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(context); 14771b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 14871b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("locale: "); 14971b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(locale); 15071b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 15171b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("enabled: "); 15271b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(enabled); 15371b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 15471b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("rank: "); 15571b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(rank); 15671b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 15771b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("key: "); 15871b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(key); 15971b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 1602331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio sb.append("userId: "); 1612331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio sb.append(userId); 1622331e9ebade7c7ebc55eaed7a642ba0f90fbc0f7Fabrice Di Meglio sb.append(", "); 16371b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("className: "); 16471b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(className); 16571b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 16671b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("packageName: "); 16771b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(packageName); 16871b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 16971b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("iconResId: "); 17071b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(iconResId); 17171b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 17271b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("intentAction: "); 17371b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(intentAction); 17471b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 17571b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("intentTargetPackage: "); 17671b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(intentTargetPackage); 17771b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(", "); 17871b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("intentTargetClass: "); 17971b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append(intentTargetClass); 18071b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio sb.append("]"); 18171b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio 18271b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio return sb.toString(); 18371b3975c8a9c11a88d18b2851066049dda4000c2Fabrice Di Meglio } 184b49995d4d997bf086c2f3214ca410b2a30861b13Fabrice Di Meglio} 185