1a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk/* 2a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Copyright 2018 The Android Open Source Project 3a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * 4a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Licensed under the Apache License, Version 2.0 (the "License"); 5a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * you may not use this file except in compliance with the License. 6a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * You may obtain a copy of the License at 7a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * 8a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * http://www.apache.org/licenses/LICENSE-2.0 9a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * 10a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Unless required by applicable law or agreed to in writing, software 11a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * distributed under the License is distributed on an "AS IS" BASIS, 12a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * See the License for the specific language governing permissions and 14a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * limitations under the License. 15a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 16a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 1785ef1446b82c8783a50af92c4cb1389fe0d0e907Aurimas Liutikaspackage androidx.slice.builders.impl; 18a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 19ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport static androidx.annotation.RestrictTo.Scope.LIBRARY; 20a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 21a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monkimport android.app.PendingIntent; 22a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monkimport android.net.Uri; 238d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor 24ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.ColorInt; 25ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.NonNull; 26ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.RestrictTo; 273ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monkimport androidx.core.graphics.drawable.IconCompat; 2885ef1446b82c8783a50af92c4cb1389fe0d0e907Aurimas Liutikasimport androidx.slice.builders.SliceAction; 29af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor 30f0da2e67517c774cb034bd73830a3dfc8818afccMady Mellorimport java.util.List; 31f0da2e67517c774cb034bd73830a3dfc8818afccMady Mellor 32a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk/** 33a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * @hide 34a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 35a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk@RestrictTo(LIBRARY) 36a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monkpublic interface ListBuilder { 37a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 38a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 39a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Add a row to list builder. 40a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 41a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk void addRow(TemplateBuilderImpl impl); 42a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 43a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Add a grid row to the list builder. 44a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 45f0da2e67517c774cb034bd73830a3dfc8818afccMady Mellor void addGridRow(TemplateBuilderImpl impl); 4687a9bf551f300ae379245a3edcb836f628439237Mady Mellor 4787a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 4887a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Adds a header to this template. 4987a9bf551f300ae379245a3edcb836f628439237Mady Mellor * <p> 5087a9bf551f300ae379245a3edcb836f628439237Mady Mellor * The header should contain a title that is representative of the content in this slice along 5187a9bf551f300ae379245a3edcb836f628439237Mady Mellor * with an intent that links to the app activity associated with this content. 5287a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 5387a9bf551f300ae379245a3edcb836f628439237Mady Mellor void setHeader(TemplateBuilderImpl impl); 5487a9bf551f300ae379245a3edcb836f628439237Mady Mellor 55a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 56af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor * Adds an action to this template. Actions added with this method are grouped together and 57af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor * may be shown on the template in large or small formats. 58a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 59af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void addAction(SliceAction action); 60a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 61a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 62853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Add an input range row to the list builder. 63853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 64853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh void addInputRange(TemplateBuilderImpl builder); 65853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 66853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 67853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Add a range row to the list builder. 68853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 69853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh void addRange(TemplateBuilderImpl builder); 70853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 71853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 72e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * If all content in a slice cannot be shown, the row added here will be displayed where the 73e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * content is cut off. This row should have an affordance to take the user to an activity to 74e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * see all of the content. 75e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * <p> 76e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * Only one see more affordance can be added, this throws {@link IllegalStateException} if 77e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * a row or action has been previously added. 78e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * </p> 79e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor */ 80eefde12330498ed74472389b5c4dbda4239e61c8Mady Mellor void setSeeMoreRow(TemplateBuilderImpl builder); 81e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor /** 82e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * If all content in a slice cannot be shown, a "see more" affordance will be displayed where 83e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * the content is cut off. The action added here should take the user to an activity to see 84e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * all of the content, and will be invoked when the "see more" affordance is tapped. 85e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * <p> 86e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * Only one see more affordance can be added, this throws {@link IllegalStateException} if 87e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * a row or action has been previously added. 88e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor * </p> 89e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor */ 90eefde12330498ed74472389b5c4dbda4239e61c8Mady Mellor void setSeeMoreAction(PendingIntent intent); 91e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor 92e3b00e2b2346e4da67d083b3475ffc9302d72898Mady Mellor /** 93a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Sets the color to tint items displayed by this template (e.g. icons). 94a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 95ca3bf191270c01ba28dda3be273f49254be409fcAmin Shaikh void setColor(@ColorInt int color); 96a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 97a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 98ebdd84b863747bae349407af37f8822c5c589d95Mady Mellor * Sets keywords to associate with this slice. 99ebdd84b863747bae349407af37f8822c5c589d95Mady Mellor */ 100ebdd84b863747bae349407af37f8822c5c589d95Mady Mellor void setKeywords(List<String> keywords); 101ebdd84b863747bae349407af37f8822c5c589d95Mady Mellor 102ebdd84b863747bae349407af37f8822c5c589d95Mady Mellor /** 103e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor * Sets the time-to-live for this slice, i.e. how long the data contained in the slice 104e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor * can remain fresh. 105e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor * 106e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor * @param ttl the length in milliseconds that this content can live for. 107e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor */ 108e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor void setTtl(long ttl); 109e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor 110e7f1c6cf75ce36c633075445bd676572a9fe0f47Mady Mellor /** 111a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Create a builder that implements {@link RowBuilder}. 112a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 113a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk TemplateBuilderImpl createRowBuilder(); 114a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 115a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Create a builder that implements {@link RowBuilder}. 116a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 117a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk TemplateBuilderImpl createRowBuilder(Uri uri); 118a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 119f0da2e67517c774cb034bd73830a3dfc8818afccMady Mellor * Create a builder that implements {@link GridRowBuilder}. 120a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 121a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk TemplateBuilderImpl createGridBuilder(); 12287a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 12387a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Create a builder that implements {@link HeaderBuilder}. 12487a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 12587a9bf551f300ae379245a3edcb836f628439237Mady Mellor TemplateBuilderImpl createHeaderBuilder(); 12687a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 12787a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Create a builder that implements {@link HeaderBuilder}. 12887a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 12987a9bf551f300ae379245a3edcb836f628439237Mady Mellor TemplateBuilderImpl createHeaderBuilder(Uri uri); 13087a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 131853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Create a builder that implements {@link InputRangeBuilder}. 132853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 133853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh TemplateBuilderImpl createInputRangeBuilder(); 134853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 135853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Create a builder that implements {@link RangeBuilder}. 136853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 137853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh TemplateBuilderImpl createRangeBuilder(); 138853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 139853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 140853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Builder to construct a range. 141853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 142853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh interface RangeBuilder { 143853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 1443bc2c820c8cbab1cf67dbd836697f780265f0e7aMady Mellor * Set the lower limit. 1453bc2c820c8cbab1cf67dbd836697f780265f0e7aMady Mellor */ 1463bc2c820c8cbab1cf67dbd836697f780265f0e7aMady Mellor void setMin(int min); 1473bc2c820c8cbab1cf67dbd836697f780265f0e7aMady Mellor 1483bc2c820c8cbab1cf67dbd836697f780265f0e7aMady Mellor /** 149853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Set the upper limit. 150853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 151853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh void setMax(int max); 152853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 153853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 154853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Set the current value. 155853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 156853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh void setValue(int value); 157853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 158853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 159853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Set the title. 160853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 161853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh void setTitle(@NonNull CharSequence title); 1628d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor 1638d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor /** 164ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor * Set the subtitle. 165ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor */ 166ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor void setSubtitle(@NonNull CharSequence title); 167ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor 168ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor /** 169ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor * Set the primary action. 170ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor */ 171ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor void setPrimaryAction(@NonNull SliceAction action); 172ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor 173ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor /** 1748d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor * Sets the content description. 1758d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor */ 1768d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor void setContentDescription(CharSequence description); 177853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh } 178853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 179853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 180853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Builder to construct an input range. 181853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 182853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh interface InputRangeBuilder extends RangeBuilder { 183853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 184853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh * Set the {@link PendingIntent} to send when the value changes. 185853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 186ec2359f11170a2742cd1650900de320aa22eab58Mady Mellor void setInputAction(@NonNull PendingIntent action); 187853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 188853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 1893ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk * Set the {@link IconCompat} to be displayed as the thumb on the input range. 190853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh */ 1913ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk void setThumb(@NonNull IconCompat thumb); 192853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh } 193853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh 194853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh /** 195a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 196853c11f11cd3d1378eac2c37d1e8c258420644a8Amin Shaikh interface RowBuilder { 197a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 198a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 199a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Sets the title item to be the provided timestamp. Only one timestamp can be added, if 200a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * one is already added this will throw {@link IllegalArgumentException}. 201a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * <p> 202a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * There can only be one title item, this will replace any other title 203a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * items that may have been set. 204a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 205a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk void setTitleItem(long timeStamp); 206a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 207a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 208ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Sets the title item to be the provided icon. There can only be one title item, this 209ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * will replace any other title items that may have been set. 2103ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk * @param icon the image to display. 211588bcc115f4fbbfab66c2c7da304c42f3b2783b8Mady Mellor * @param imageMode the mode that image should be displayed in. 212a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 2133ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk void setTitleItem(IconCompat icon, int imageMode); 214a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 215a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 216ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Sets the title item to be the provided icon. There can only be one title item, this 217ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * will replace any other title items that may have been set. 218a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * <p> 219ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * When set to true, the parameter {@code isLoading} indicates that the app is doing work 220ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * to load this content in the background, in this case the template displays a placeholder 221ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * until updated. 2223ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk * @param icon the image to display. 223588bcc115f4fbbfab66c2c7da304c42f3b2783b8Mady Mellor * @param imageMode the mode that image should be displayed in. 224588bcc115f4fbbfab66c2c7da304c42f3b2783b8Mady Mellor * @param isLoading whether this content is being loaded in the background. 225ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor */ 2263ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk void setTitleItem(IconCompat icon, int imageMode, boolean isLoading); 227ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor 228ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor /** 229ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Sets the title item to be a tappable icon. There can only be one title item, this will 230ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * replace any other title items that may have been set. 231a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 232af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void setTitleItem(SliceAction action); 233a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 234a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 235ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Sets the title item to be a tappable icon. There can only be one title item, this will 236ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * replace any other title items that may have been set. 237ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * <p> 238ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * When set to true, the parameter {@code isLoading} indicates that the app is doing work 239ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * to load this content in the background, in this case the template displays a placeholder 240ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * until updated. 241ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor */ 242af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void setTitleItem(SliceAction action, boolean isLoading); 243ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor 244ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor /** 245a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Sets the action to be invoked if the user taps on the main content of the template. 246a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 247af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void setPrimaryAction(SliceAction action); 248a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 249a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 250a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Sets the title text. 251a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 252a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk void setTitle(CharSequence title); 253a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 254a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 255ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Sets the title text. 256ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * <p> 257ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * When set to true, the parameter {@code isLoading} indicates that the app is doing work 258ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * to load this content in the background, in this case the template displays a placeholder 259ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * until updated. 260ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor */ 261ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor void setTitle(CharSequence title, boolean isLoading); 262ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor 263ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor /** 264a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Sets the subtitle text. 265a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 266a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk void setSubtitle(CharSequence subtitle); 267a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 268a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 269ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Sets the subtitle text. 270ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * <p> 271ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * When set to true, the parameter {@code isLoading} indicates that the app is doing work 272ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * to load this content in the background, in this case the template displays a placeholder 273ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * until updated. 274ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor */ 275ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor void setSubtitle(CharSequence subtitle, boolean isLoading); 276ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor 277ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor /** 278a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Adds a timestamp to be displayed at the end of the row. 279a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 280a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk void addEndItem(long timeStamp); 281a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 282a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 283a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Adds an icon to be displayed at the end of the row. 2843ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk * @param icon the image to display. 285588bcc115f4fbbfab66c2c7da304c42f3b2783b8Mady Mellor * @param imageMode the mode that image should be displayed in. 286a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 2873ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk void addEndItem(IconCompat icon, int imageMode); 288a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 289a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 290ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Adds an icon to be displayed at the end of the row. 291ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * <p> 292ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * When set to true, the parameter {@code isLoading} indicates that the app is doing work 293ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * to load this content in the background, in this case the template displays a placeholder 294ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * until updated. 2953ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk * @param icon the image to display. 296588bcc115f4fbbfab66c2c7da304c42f3b2783b8Mady Mellor * @param imageMode the mode that image should be displayed in. 297588bcc115f4fbbfab66c2c7da304c42f3b2783b8Mady Mellor * @param isLoading whether this content is being loaded in the background. 298ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor */ 2993ec422a2e2a46b51d4cc6926fcaa35caacbdf98dJason Monk void addEndItem(IconCompat icon, int imageMode, boolean isLoading); 300ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor 301ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor /** 302a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk * Adds a tappable icon to be displayed at the end of the row. 303a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk */ 304af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void addEndItem(SliceAction action); 305a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk 306a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk /** 307ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * Adds a tappable icon to be displayed at the end of the row. 308ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * <p> 309ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * When set to true, the parameter {@code isLoading} indicates that the app is doing work 310ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * to load this content in the background, in this case the template displays a placeholder 311ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor * until updated. 312ba4198f4bc37284c5a6e8ce993f3652d3e3c88e6Mady Mellor */ 313af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void addEndItem(SliceAction action, boolean isLoading); 3148d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor 3158d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor /** 3168d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor * Sets the content description for this row. 3178d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor */ 3188d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor void setContentDescription(CharSequence description); 319a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk } 32087a9bf551f300ae379245a3edcb836f628439237Mady Mellor 32187a9bf551f300ae379245a3edcb836f628439237Mady Mellor 32287a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 32387a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Builder to construct a header. A header is displayed at the top of a list and can have 32487a9bf551f300ae379245a3edcb836f628439237Mady Mellor * a title, subtitle, and an action. 32587a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 32687a9bf551f300ae379245a3edcb836f628439237Mady Mellor public interface HeaderBuilder { 32787a9bf551f300ae379245a3edcb836f628439237Mady Mellor 32887a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 32987a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Sets the title to be shown in this header. 33087a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 33109ec20c424ec3e546b10424a401c2343c2df205aMady Mellor void setTitle(CharSequence title, boolean isLoading); 33287a9bf551f300ae379245a3edcb836f628439237Mady Mellor 33387a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 33487a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Sets the subtitle to be shown in this header. 33587a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 33609ec20c424ec3e546b10424a401c2343c2df205aMady Mellor void setSubtitle(CharSequence subtitle, boolean isLoading); 33787a9bf551f300ae379245a3edcb836f628439237Mady Mellor 33887a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 33987a9bf551f300ae379245a3edcb836f628439237Mady Mellor * Sets the summary subtitle to be shown in this header. If unset, the normal subtitle 34087a9bf551f300ae379245a3edcb836f628439237Mady Mellor * will be used. The summary is used when the parent template is presented in a 34187a9bf551f300ae379245a3edcb836f628439237Mady Mellor * small format. 34287a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 343d156eab29cd6c14308a32d7c116e16e904509a7aMady Mellor void setSummary(CharSequence summarySubtitle, boolean isLoading); 34487a9bf551f300ae379245a3edcb836f628439237Mady Mellor 34587a9bf551f300ae379245a3edcb836f628439237Mady Mellor /** 346da320e8eb3748ca67938c6c545bf45ac5bc9590dMady Mellor * Sets the action to invoke when the header is activated. 34787a9bf551f300ae379245a3edcb836f628439237Mady Mellor */ 348af76b3bd62a6b218bb44917b1dddfa1ee4803149Mady Mellor void setPrimaryAction(SliceAction action); 3498d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor 3508d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor /** 3518d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor * Sets the content description for the header. 3528d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor */ 3538d66e2cb94d97f4559eab97d0c1f348e5ed8b50aMady Mellor void setContentDescription(CharSequence description); 35487a9bf551f300ae379245a3edcb836f628439237Mady Mellor } 355a09cb677db982c92d3172fa79a6a4585fc29da14Jason Monk} 35687a9bf551f300ae379245a3edcb836f628439237Mady Mellor 357