1 /* <lambda>null2 * Copyright 2021 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.core.widget 18 19 import android.annotation.SuppressLint 20 import android.appwidget.AppWidgetManager 21 import android.content.Context 22 import android.content.res.ColorStateList 23 import android.graphics.BlendMode 24 import android.graphics.drawable.Icon 25 import android.os.Build 26 import android.os.Parcel 27 import android.os.Parcelable 28 import android.widget.RemoteViews 29 import androidx.annotation.AttrRes 30 import androidx.annotation.ColorInt 31 import androidx.annotation.ColorRes 32 import androidx.annotation.DimenRes 33 import androidx.annotation.DrawableRes 34 import androidx.annotation.IdRes 35 import androidx.annotation.LayoutRes 36 import androidx.annotation.Px 37 import androidx.annotation.RequiresApi 38 import androidx.annotation.StringRes 39 40 /** Helper for accessing features in [RemoteViews]. */ 41 public object RemoteViewsCompat { 42 /** 43 * Creates a simple Adapter for the widgetId and viewId specified. The viewId must point to an 44 * AdapterView, ie. [android.widget.ListView], [android.widget.GridView], 45 * [android.widget.StackView], or [android.widget.AdapterViewAnimator]. 46 * 47 * This is a simpler but less flexible approach to populating collection widgets. Its use is 48 * encouraged for most scenarios, as long as the total memory within the list of RemoteViews is 49 * relatively small (ie. doesn't contain large or numerous Bitmaps, see 50 * [RemoteViews.setImageViewBitmap]). In the case of numerous images, the use of API is still 51 * possible by setting image URIs instead of Bitmaps, see [RemoteViews.setImageViewUri]. 52 * 53 * If you use this API, you should not call [AppWidgetManager.notifyAppWidgetViewDataChanged] 54 * and should instead update your app widget, calling this method with the new 55 * [RemoteCollectionItems]. 56 * 57 * @param context The [Context] of the app providing the widget. 58 * @param remoteViews The [RemoteViews] to receive the adapter. 59 * @param appWidgetId the id of the widget for which the adapter is being set. 60 * @param viewId The id of the [android.widget.AdapterView]. 61 * @param items The items to display in the [android.widget.AdapterView]. 62 */ 63 @JvmStatic 64 @Suppress("DEPRECATION") 65 public fun setRemoteAdapter( 66 context: Context, 67 remoteViews: RemoteViews, 68 appWidgetId: Int, 69 @IdRes viewId: Int, 70 items: RemoteCollectionItems 71 ) { 72 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S) { 73 // Due to an inefficient Parcelable implementation, the platform collections API is 74 // unsuitable on API 31. 75 CollectionItemsApi31Impl.setRemoteAdapter(remoteViews, viewId, items) 76 return 77 } 78 val intent = RemoteViewsCompatService.createIntent(context, appWidgetId, viewId) 79 check(context.packageManager.resolveService(intent, /* flags= */ 0) != null) { 80 "RemoteViewsCompatService could not be resolved, ensure that you have declared it in " + 81 "your app manifest." 82 } 83 remoteViews.setRemoteAdapter(viewId, intent) 84 RemoteViewsCompatService.saveItems(context, appWidgetId, viewId, items) 85 AppWidgetManager.getInstance(context).notifyAppWidgetViewDataChanged(appWidgetId, viewId) 86 } 87 88 /** Representation of a fixed list of items to be displayed in a RemoteViews collection. */ 89 public class RemoteCollectionItems { 90 private val mIds: LongArray 91 private val mViews: Array<RemoteViews> 92 private val mHasStableIds: Boolean 93 private val mViewTypeCount: Int 94 95 internal constructor( 96 ids: LongArray, 97 views: Array<RemoteViews>, 98 hasStableIds: Boolean, 99 viewTypeCount: Int 100 ) { 101 mIds = ids 102 mViews = views 103 mHasStableIds = hasStableIds 104 mViewTypeCount = viewTypeCount 105 106 require(ids.size == views.size) { 107 "RemoteCollectionItems has different number of ids and views" 108 } 109 require(viewTypeCount >= 1) { "View type count must be >= 1" } 110 111 val layoutIdCount = views.map { it.layoutId }.distinct().count() 112 require(layoutIdCount <= viewTypeCount) { 113 "View type count is set to $viewTypeCount, but the collection contains " + 114 "$layoutIdCount different layout ids" 115 } 116 } 117 118 internal constructor(parcel: Parcel) { 119 val length = parcel.readInt() 120 mIds = LongArray(length) 121 parcel.readLongArray(mIds) 122 mViews = parcel.readNonNullTypedArray(length, RemoteViews.CREATOR) 123 mHasStableIds = parcel.readInt() == 1 124 mViewTypeCount = parcel.readInt() 125 } 126 127 internal fun writeToParcel(dest: Parcel, flags: Int) { 128 dest.writeInt(mIds.size) 129 dest.writeLongArray(mIds) 130 dest.writeTypedArray(mViews, flags) 131 dest.writeInt(if (mHasStableIds) 1 else 0) 132 dest.writeInt(mViewTypeCount) 133 } 134 135 /** 136 * Returns the id for [position]. See [hasStableIds] for whether this id should be 137 * considered meaningful across collection updates. 138 * 139 * @return Id for the position. 140 */ 141 public fun getItemId(position: Int): Long = mIds[position] 142 143 /** 144 * Returns the [RemoteViews] to display at [position]. 145 * 146 * @return RemoteViews for the position. 147 */ 148 public fun getItemView(position: Int): RemoteViews = mViews[position] 149 150 /** 151 * Returns the number of elements in the collection. 152 * 153 * @return Count of items. 154 */ 155 public val itemCount: Int 156 get() = mIds.size 157 158 /** 159 * Returns the view type count for the collection when used in an adapter 160 * 161 * @return Count of view types for the collection when used in an adapter. 162 * @see android.widget.Adapter.getViewTypeCount 163 */ 164 public val viewTypeCount: Int 165 get() = mViewTypeCount 166 167 /** 168 * Indicates whether the item ids are stable across changes to the underlying data. 169 * 170 * @return True if the same id always refers to the same object. 171 * @see android.widget.Adapter.hasStableIds 172 */ 173 public fun hasStableIds(): Boolean = mHasStableIds 174 175 /** Builder class for [RemoteCollectionItems] objects. */ 176 public class Builder { 177 private val mIds = arrayListOf<Long>() 178 private val mViews = arrayListOf<RemoteViews>() 179 private var mHasStableIds = false 180 private var mViewTypeCount = 0 181 182 /** 183 * Adds a [RemoteViews] to the collection. 184 * 185 * @param id Id to associate with the row. Use [.setHasStableIds] to indicate that ids 186 * are stable across changes to the collection. 187 * @param view RemoteViews to display for the row. 188 */ 189 // Covered by getItemId, getItemView, getItemCount. 190 @SuppressLint("MissingGetterMatchingBuilder") 191 public fun addItem(id: Long, view: RemoteViews): Builder { 192 mIds.add(id) 193 mViews.add(view) 194 return this 195 } 196 197 /** 198 * Sets whether the item ids are stable across changes to the underlying data. 199 * 200 * @see android.widget.Adapter.hasStableIds 201 */ 202 public fun setHasStableIds(hasStableIds: Boolean): Builder { 203 mHasStableIds = hasStableIds 204 return this 205 } 206 207 /** 208 * Sets the view type count for the collection when used in an adapter. This can be set 209 * to the maximum number of different layout ids that will be used by RemoteViews in 210 * this collection. 211 * 212 * If this value is not set, then a value will be inferred from the provided items. As a 213 * result, the adapter may need to be recreated when the list is updated with previously 214 * unseen RemoteViews layouts for new items. 215 * 216 * @see android.widget.Adapter.getViewTypeCount 217 */ 218 public fun setViewTypeCount(viewTypeCount: Int): Builder { 219 mViewTypeCount = viewTypeCount 220 return this 221 } 222 223 /** Creates the [RemoteCollectionItems] defined by this builder. */ 224 public fun build(): RemoteCollectionItems { 225 if (mViewTypeCount < 1) { 226 // If a view type count wasn't specified, set it to be the number of distinct 227 // layout ids used in the items. 228 mViewTypeCount = mViews.map { it.layoutId }.distinct().count() 229 } 230 return RemoteCollectionItems( 231 mIds.toLongArray(), 232 mViews.toTypedArray(), 233 mHasStableIds, 234 maxOf(mViewTypeCount, 1) 235 ) 236 } 237 } 238 239 private companion object { 240 /** Reads a non-null array of [T] of [size] from the [Parcel]. */ 241 inline fun <reified T : Any> Parcel.readNonNullTypedArray( 242 size: Int, 243 creator: Parcelable.Creator<T> 244 ): Array<T> { 245 val array = arrayOfNulls<T?>(size) 246 readTypedArray(array, creator) 247 return array.requireNoNulls() 248 } 249 } 250 } 251 252 /** 253 * Version-specific static inner class to avoid verification errors that negatively affect 254 * run-time performance. 255 */ 256 @RequiresApi(31) 257 private object CollectionItemsApi31Impl { 258 fun setRemoteAdapter(remoteViews: RemoteViews, viewId: Int, items: RemoteCollectionItems) { 259 remoteViews.setRemoteAdapter(viewId, toPlatformCollectionItems(items)) 260 } 261 262 /** 263 * Returns a [RemoteViews.RemoteCollectionItems] equivalent to this [RemoteCollectionItems]. 264 */ 265 private fun toPlatformCollectionItems( 266 items: RemoteCollectionItems 267 ): RemoteViews.RemoteCollectionItems { 268 return RemoteViews.RemoteCollectionItems.Builder() 269 .setHasStableIds(items.hasStableIds()) 270 .setViewTypeCount(items.viewTypeCount) 271 .also { builder -> 272 repeat(items.itemCount) { index -> 273 builder.addItem(items.getItemId(index), items.getItemView(index)) 274 } 275 } 276 .build() 277 } 278 } 279 280 /** 281 * Equivalent to calling [android.widget.Chronometer.setBase]. 282 * 283 * @param viewId The id of the target view 284 * @param base The time at which the timer would have read 0:00. This time should be based off 285 * of [android.os.SystemClock.elapsedRealtime]. 286 */ 287 @JvmStatic 288 public fun RemoteViews.setChronometerBase(@IdRes viewId: Int, base: Long) { 289 setLong(viewId, "setBase", base) 290 } 291 292 /** 293 * Equivalent to calling [android.widget.Chronometer.setFormat]. 294 * 295 * @param viewId The id of the target view 296 * @param format The Chronometer format string, or null to simply display the timer value. 297 */ 298 @JvmStatic 299 public fun RemoteViews.setChronometerFormat(@IdRes viewId: Int, format: String?) { 300 setString(viewId, "setFormat", format) 301 } 302 303 /** 304 * Equivalent to calling [android.widget.CompoundButton.setButtonDrawable]. 305 * 306 * @param viewId The id of the target view 307 * @param resId The resource identifier of the drawable, or 0 to clear the button. 308 */ 309 @RequiresApi(31) 310 @JvmStatic 311 public fun RemoteViews.setCompoundButtonDrawable(@IdRes viewId: Int, @DrawableRes resId: Int) { 312 setInt(viewId, "setButtonDrawable", resId) 313 } 314 315 /** 316 * Equivalent to calling [android.widget.CompoundButton.setButtonIcon]. 317 * 318 * @param viewId The id of the target view 319 * @param icon An Icon holding the desired button, or null to clear the button. 320 */ 321 @RequiresApi(31) 322 @JvmStatic 323 public fun RemoteViews.setCompoundButtonIcon(@IdRes viewId: Int, icon: Icon?) { 324 Api23Impl.setIcon(this, viewId, "setButtonIcon", icon) 325 } 326 327 /** 328 * Equivalent to calling [android.widget.CompoundButton.setButtonTintBlendMode]. 329 * 330 * @param viewId The id of the target view 331 * @param tintMode The blending mode used to apply the tint, may be null to clear tint. 332 */ 333 @RequiresApi(31) 334 @JvmStatic 335 public fun RemoteViews.setCompoundButtonTintBlendMode( 336 @IdRes viewId: Int, 337 tintMode: BlendMode? 338 ) { 339 Api31Impl.setBlendMode(this, viewId, "setButtonTintBlendMode", tintMode) 340 } 341 342 /** 343 * Equivalent to calling [android.widget.CompoundButton.setButtonTintList]. 344 * 345 * @param viewId The id of the target view 346 * @param tint The tint to apply, may be null to clear tint. 347 */ 348 @RequiresApi(31) 349 @JvmStatic 350 public fun RemoteViews.setCompoundButtonTintList(@IdRes viewId: Int, tint: ColorStateList?) { 351 Api31Impl.setColorStateList(this, viewId, "setButtonTintList", tint) 352 } 353 354 /** 355 * Equivalent to calling [android.widget.CompoundButton.setButtonTintList]. 356 * 357 * @param viewId The id of the target view 358 * @param notNight The tint to apply when the UI is not in night mode, may be null to clear 359 * tint. 360 * @param night The tint to apply when the UI is in night mode, may be null to clear tint. 361 */ 362 @RequiresApi(31) 363 @JvmStatic 364 public fun RemoteViews.setCompoundButtonTintList( 365 @IdRes viewId: Int, 366 notNight: ColorStateList?, 367 night: ColorStateList? 368 ) { 369 Api31Impl.setColorStateList(this, viewId, "setButtonTintList", notNight, night) 370 } 371 372 /** 373 * Equivalent to calling [android.widget.CompoundButton.setButtonTintList]. 374 * 375 * @param viewId The id of the target view 376 * @param resId The resource id for the tint to apply, may be 0 to clear tint. 377 */ 378 @RequiresApi(31) 379 @JvmStatic 380 public fun RemoteViews.setCompoundButtonTintList(@IdRes viewId: Int, @ColorRes resId: Int) { 381 Api31Impl.setColorStateList(this, viewId, "setButtonTintList", resId) 382 } 383 384 /** 385 * Equivalent to calling [android.widget.CompoundButton.setButtonTintList]. 386 * 387 * @param viewId The id of the target view 388 * @param resId The attribute id for the tint to apply, may be 0 to clear tint. 389 */ 390 @RequiresApi(31) 391 @JvmStatic 392 public fun RemoteViews.setCompoundButtonTintListAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 393 Api31Impl.setColorStateListAttr(this, viewId, "setButtonTintList", resId) 394 } 395 396 /** 397 * Equivalent to calling [android.widget.FrameLayout.setForegroundGravity]. 398 * 399 * @param viewId The id of the target view 400 * @param foregroundGravity See [android.view.Gravity]. 401 */ 402 @JvmStatic 403 public fun RemoteViews.setFrameLayoutForegroundGravity( 404 @IdRes viewId: Int, 405 foregroundGravity: Int 406 ) { 407 setInt(viewId, "setForegroundGravity", foregroundGravity) 408 } 409 410 /** 411 * Equivalent to calling [android.widget.FrameLayout.setMeasureAllChildren]. 412 * 413 * @param viewId The id of the target view 414 * @param measureAll True to consider children marked GONE, false otherwise. 415 */ 416 @JvmStatic 417 public fun RemoteViews.setFrameLayoutMeasureAllChildren( 418 @IdRes viewId: Int, 419 measureAll: Boolean 420 ) { 421 setBoolean(viewId, "setMeasureAllChildren", measureAll) 422 } 423 424 /** 425 * Equivalent to calling [android.widget.GridLayout.setAlignmentMode]. 426 * 427 * @param viewId The id of the target view 428 * @param alignmentMode Either [android.widget.GridLayout.ALIGN_BOUNDS] or 429 * [android.widget.GridLayout.ALIGN_MARGINS]. 430 */ 431 @RequiresApi(31) 432 @JvmStatic 433 public fun RemoteViews.setGridLayoutAlignmentMode(@IdRes viewId: Int, alignmentMode: Int) { 434 setInt(viewId, "setAlignmentMode", alignmentMode) 435 } 436 437 /** 438 * Equivalent to calling [android.widget.GridLayout.setColumnCount]. 439 * 440 * @param viewId The id of the target view 441 * @param columnCount The number of columns. 442 */ 443 @RequiresApi(31) 444 @JvmStatic 445 public fun RemoteViews.setGridLayoutColumnCount(@IdRes viewId: Int, columnCount: Int) { 446 setInt(viewId, "setColumnCount", columnCount) 447 } 448 449 /** 450 * Equivalent to calling [android.widget.GridLayout.setRowCount]. 451 * 452 * @param viewId The id of the target view 453 * @param rowCount The number of rows. 454 */ 455 @RequiresApi(31) 456 @JvmStatic 457 public fun RemoteViews.setGridLayoutRowCount(@IdRes viewId: Int, rowCount: Int) { 458 setInt(viewId, "setRowCount", rowCount) 459 } 460 461 /** 462 * Equivalent to calling [android.widget.GridView.setColumnWidth]. 463 * 464 * @param viewId The id of the target view 465 * @param value The column width. 466 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 467 */ 468 @RequiresApi(31) 469 @JvmStatic 470 public fun RemoteViews.setGridViewColumnWidth(@IdRes viewId: Int, value: Float, unit: Int) { 471 Api31Impl.setIntDimen(this, viewId, "setColumnWidth", value, unit) 472 } 473 474 /** 475 * Equivalent to calling [android.widget.GridView.setColumnWidth]. 476 * 477 * @param viewId The id of the target view 478 * @param columnWidth The resource id of a dimension resource for the column width. 479 */ 480 @RequiresApi(31) 481 @JvmStatic 482 public fun RemoteViews.setGridViewColumnWidthDimen( 483 @IdRes viewId: Int, 484 @DimenRes columnWidth: Int 485 ) { 486 Api31Impl.setIntDimen(this, viewId, "setColumnWidth", columnWidth) 487 } 488 489 /** 490 * Equivalent to calling [android.widget.GridView.setColumnWidth]. 491 * 492 * @param viewId The id of the target view 493 * @param columnWidth The resource id of a dimension resource for the column width. 494 */ 495 @RequiresApi(31) 496 @JvmStatic 497 public fun RemoteViews.setGridViewColumnWidthDimenAttr( 498 @IdRes viewId: Int, 499 @AttrRes columnWidth: Int 500 ) { 501 Api31Impl.setIntDimenAttr(this, viewId, "setColumnWidth", columnWidth) 502 } 503 504 /** 505 * Equivalent to calling [android.widget.GridView.setGravity]. 506 * 507 * @param viewId The id of the target view 508 * @param gravity The gravity to apply to this grid's children. 509 */ 510 @RequiresApi(31) 511 @JvmStatic 512 public fun RemoteViews.setGridViewGravity(@IdRes viewId: Int, gravity: Int) { 513 setInt(viewId, "setGravity", gravity) 514 } 515 516 /** 517 * Equivalent to calling [android.widget.GridView.setHorizontalSpacing]. 518 * 519 * @param viewId The id of the target view 520 * @param value The amount of horizontal space between items. 521 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 522 */ 523 @RequiresApi(31) 524 @JvmStatic 525 public fun RemoteViews.setGridViewHorizontalSpacing( 526 @IdRes viewId: Int, 527 value: Float, 528 unit: Int 529 ) { 530 Api31Impl.setIntDimen(this, viewId, "setHorizontalSpacing", value, unit) 531 } 532 533 /** 534 * Equivalent to calling [android.widget.GridView.setHorizontalSpacing]. 535 * 536 * @param viewId The id of the target view 537 * @param resId The resource id of a dimension resource for the amount of horizontal space 538 * between items. 539 */ 540 @RequiresApi(31) 541 @JvmStatic 542 public fun RemoteViews.setGridViewHorizontalSpacingDimen( 543 @IdRes viewId: Int, 544 @DimenRes resId: Int 545 ) { 546 Api31Impl.setIntDimen(this, viewId, "setHorizontalSpacing", resId) 547 } 548 549 /** 550 * Equivalent to calling [android.widget.GridView.setHorizontalSpacing]. 551 * 552 * @param viewId The id of the target view 553 * @param resId The resource id of a dimension attribute for the amount of horizontal space 554 * between items. 555 */ 556 @RequiresApi(31) 557 @JvmStatic 558 public fun RemoteViews.setGridViewHorizontalSpacingDimenAttr( 559 @IdRes viewId: Int, 560 @AttrRes resId: Int 561 ) { 562 Api31Impl.setIntDimenAttr(this, viewId, "setHorizontalSpacing", resId) 563 } 564 565 /** 566 * Equivalent to calling [android.widget.GridView.setNumColumns]. 567 * 568 * @param viewId The id of the target view 569 * @param numColumns The desired number of columns. 570 */ 571 @RequiresApi(31) 572 @JvmStatic 573 public fun RemoteViews.setGridViewNumColumns(@IdRes viewId: Int, numColumns: Int) { 574 setInt(viewId, "setNumColumns", numColumns) 575 } 576 577 /** 578 * Equivalent to calling [android.widget.GridView.setStretchMode]. 579 * 580 * @param viewId The id of the target view 581 * @param stretchMode Either [android.widget.GridView.NO_STRETCH], 582 * [android.widget.GridView.STRETCH_SPACING], 583 * [android.widget.GridView.STRETCH_SPACING_UNIFORM], or 584 * [android.widget.GridView.STRETCH_COLUMN_WIDTH]. 585 */ 586 @RequiresApi(31) 587 @JvmStatic 588 public fun RemoteViews.setGridViewStretchMode(@IdRes viewId: Int, stretchMode: Int) { 589 setInt(viewId, "setStretchMode", stretchMode) 590 } 591 592 /** 593 * Equivalent to calling [android.widget.GridView.setVerticalSpacing]. 594 * 595 * @param viewId The id of the target view 596 * @param value The amount of vertical space between items. 597 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 598 */ 599 @RequiresApi(31) 600 @JvmStatic 601 public fun RemoteViews.setGridViewVerticalSpacing(@IdRes viewId: Int, value: Float, unit: Int) { 602 Api31Impl.setIntDimen(this, viewId, "setVerticalSpacing", value, unit) 603 } 604 605 /** 606 * Equivalent to calling [android.widget.GridView.setVerticalSpacing]. 607 * 608 * @param viewId The id of the target view 609 * @param resId The resource id of a dimension resource for the amount of vertical space between 610 * items. 611 */ 612 @RequiresApi(31) 613 @JvmStatic 614 public fun RemoteViews.setGridViewVerticalSpacingDimen( 615 @IdRes viewId: Int, 616 @DimenRes resId: Int 617 ) { 618 Api31Impl.setIntDimen(this, viewId, "setVerticalSpacing", resId) 619 } 620 621 /** 622 * Equivalent to calling [android.widget.GridView.setVerticalSpacing]. 623 * 624 * @param viewId The id of the target view 625 * @param resId The resource id of a dimension attribute for the amount of vertical space 626 * between items. 627 */ 628 @RequiresApi(31) 629 @JvmStatic 630 public fun RemoteViews.setGridViewVerticalSpacingDimenAttr( 631 @IdRes viewId: Int, 632 @AttrRes resId: Int 633 ) { 634 Api31Impl.setIntDimenAttr(this, viewId, "setVerticalSpacing", resId) 635 } 636 637 /** 638 * Equivalent to calling [android.widget.ImageView.setAdjustViewBounds]. 639 * 640 * @param viewId The id of the target view 641 * @param adjustViewBounds Whether to adjust the bounds of this view to preserve the original 642 * aspect ratio of the drawable. 643 */ 644 @JvmStatic 645 public fun RemoteViews.setImageViewAdjustViewBounds( 646 @IdRes viewId: Int, 647 adjustViewBounds: Boolean 648 ) { 649 setBoolean(viewId, "setAdjustViewBounds", adjustViewBounds) 650 } 651 652 /** 653 * Equivalent to calling [android.widget.ImageView.setColorFilter]. 654 * 655 * @param viewId The id of the target view 656 * @param color Color tint to apply. 657 */ 658 @JvmStatic 659 public fun RemoteViews.setImageViewColorFilter(@IdRes viewId: Int, @ColorInt color: Int) { 660 setInt(viewId, "setColorFilter", color) 661 } 662 663 /** 664 * Equivalent to calling [android.widget.ImageView.setColorFilter]. 665 * 666 * @param viewId The id of the target view 667 * @param notNight The color tint to apply when the UI is not in night mode. 668 * @param night The color tint to apply when the UI is in night mode. 669 */ 670 @RequiresApi(31) 671 @JvmStatic 672 public fun RemoteViews.setImageViewColorFilter( 673 @IdRes viewId: Int, 674 @ColorInt notNight: Int, 675 @ColorInt night: Int 676 ) { 677 Api31Impl.setColorInt(this, viewId, "setColorFilter", notNight, night) 678 } 679 680 /** 681 * Equivalent to calling [android.widget.ImageView.setColorFilter]. 682 * 683 * @param viewId The id of the target view 684 * @param resId The resource id of the color tint to apply. 685 */ 686 @RequiresApi(31) 687 @JvmStatic 688 public fun RemoteViews.setImageViewColorFilterResource( 689 @IdRes viewId: Int, 690 @ColorRes resId: Int 691 ) { 692 Api31Impl.setColor(this, viewId, "setColorFilter", resId) 693 } 694 695 /** 696 * Equivalent to calling [android.widget.ImageView.setColorFilter]. 697 * 698 * @param viewId The id of the target view 699 * @param resId The attribute id of the color tint to apply. 700 */ 701 @RequiresApi(31) 702 @JvmStatic 703 public fun RemoteViews.setImageViewColorFilterAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 704 Api31Impl.setColorAttr(this, viewId, "setColorFilter", resId) 705 } 706 707 /** 708 * Equivalent to calling [android.widget.ImageView.setImageLevel]. 709 * 710 * @param viewId The id of the target view 711 * @param level The new level for the image. 712 */ 713 @JvmStatic 714 public fun RemoteViews.setImageViewImageLevel(@IdRes viewId: Int, level: Int) { 715 setInt(viewId, "setImageLevel", level) 716 } 717 718 /** 719 * Equivalent to calling [android.widget.ImageView.setImageAlpha]. 720 * 721 * @param viewId The id of the target view 722 * @param alpha The alpha value that should be applied to the image (between 0 and 255 723 * inclusive, with 0 being transparent and 255 being opaque) 724 */ 725 @JvmStatic 726 public fun RemoteViews.setImageViewImageAlpha(@IdRes viewId: Int, alpha: Int) { 727 // Note: setImageAlpha was added and is preferred to setAlpha since API 16. 728 setInt(viewId, "setImageAlpha", alpha) 729 } 730 731 /** 732 * Equivalent to calling [android.widget.ImageView.setImageTintBlendMode]. 733 * 734 * @param viewId The id of the target view 735 * @param blendMode The blending mode used to apply the tint, may be null to clear. 736 */ 737 @RequiresApi(31) 738 @JvmStatic 739 public fun RemoteViews.setImageViewImageTintBlendMode( 740 @IdRes viewId: Int, 741 blendMode: BlendMode? 742 ) { 743 Api31Impl.setBlendMode(this, viewId, "setImageTintBlendMode", blendMode) 744 } 745 746 /** 747 * Equivalent to calling [android.widget.ImageView.setImageTintList]. 748 * 749 * @param viewId The id of the target view 750 * @param tint The tint to apply, may be null to clear tint 751 */ 752 @RequiresApi(31) 753 @JvmStatic 754 public fun RemoteViews.setImageViewImageTintList(@IdRes viewId: Int, tint: ColorStateList?) { 755 Api31Impl.setColorStateList(this, viewId, "setImageTintList", tint) 756 } 757 758 /** 759 * Equivalent to calling [android.widget.ImageView.setImageTintList]. 760 * 761 * @param viewId The id of the target view 762 * @param notNightTint The tint to apply when the UI is not in night mode, may be null to clear 763 * tint. 764 * @param nightTint The tint to apply when the UI is in night mode, may be null to clear tint. 765 */ 766 @RequiresApi(31) 767 @JvmStatic 768 public fun RemoteViews.setImageViewImageTintList( 769 @IdRes viewId: Int, 770 notNightTint: ColorStateList?, 771 nightTint: ColorStateList? 772 ) { 773 Api31Impl.setColorStateList(this, viewId, "setImageTintList", notNightTint, nightTint) 774 } 775 776 /** 777 * Equivalent to calling [android.widget.ImageView.setImageTintList]. 778 * 779 * @param viewId The id of the target view 780 * @param resId The resource id of the tint to apply, may be 0 to clear tint. 781 */ 782 @RequiresApi(31) 783 @JvmStatic 784 public fun RemoteViews.setImageViewImageTintList(@IdRes viewId: Int, @ColorRes resId: Int) { 785 Api31Impl.setColorStateList(this, viewId, "setImageTintList", resId) 786 } 787 788 /** 789 * Equivalent to calling [android.widget.ImageView.setImageTintList]. 790 * 791 * @param viewId The id of the target view 792 * @param resId The attribute of the tint to apply, may be 0 to clear tint. 793 */ 794 @RequiresApi(31) 795 @JvmStatic 796 public fun RemoteViews.setImageViewImageTintListAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 797 Api31Impl.setColorStateListAttr(this, viewId, "setImageTintList", resId) 798 } 799 800 /** 801 * Equivalent to calling [android.widget.ImageView.setMaxHeight]. 802 * 803 * @param viewId The id of the target view 804 * @param maxHeight The maximum height of the view, in pixels. 805 */ 806 @JvmStatic 807 public fun RemoteViews.setImageViewMaxHeight(@IdRes viewId: Int, @Px maxHeight: Int) { 808 setInt(viewId, "setMaxHeight", maxHeight) 809 } 810 811 /** 812 * Equivalent to calling [android.widget.ImageView.setMaxHeight]. 813 * 814 * @param viewId The id of the target view 815 * @param value The maximum height of the view. 816 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 817 */ 818 @RequiresApi(31) 819 @JvmStatic 820 public fun RemoteViews.setImageViewMaxHeight(@IdRes viewId: Int, value: Float, unit: Int) { 821 Api31Impl.setIntDimen(this, viewId, "setMaxHeight", value, unit) 822 } 823 824 /** 825 * Equivalent to calling [android.widget.ImageView.setMaxHeight]. 826 * 827 * @param viewId The id of the target view 828 * @param resId A dimension resource identifier for maximum height of the view. 829 */ 830 @RequiresApi(31) 831 @JvmStatic 832 public fun RemoteViews.setImageViewMaxHeightDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 833 Api31Impl.setIntDimen(this, viewId, "setMaxHeight", resId) 834 } 835 836 /** 837 * Equivalent to calling [android.widget.ImageView.setMaxHeight]. 838 * 839 * @param viewId The id of the target view 840 * @param resId A dimension resource attribute for maximum height of the view. 841 */ 842 @RequiresApi(31) 843 @JvmStatic 844 public fun RemoteViews.setImageViewMaxHeightDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 845 Api31Impl.setIntDimenAttr(this, viewId, "setMaxHeight", resId) 846 } 847 848 /** 849 * Equivalent to calling [android.widget.ImageView.setMaxWidth]. 850 * 851 * @param viewId The id of the target view 852 * @param maxWidth The maximum width of the view, in pixels. 853 */ 854 @JvmStatic 855 public fun RemoteViews.setImageViewMaxWidth(@IdRes viewId: Int, @Px maxWidth: Int) { 856 setInt(viewId, "setMaxWidth", maxWidth) 857 } 858 859 /** 860 * Equivalent to calling [android.widget.ImageView.setMaxWidth]. 861 * 862 * @param viewId The id of the target view 863 * @param value The maximum width of the view. 864 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 865 */ 866 @RequiresApi(31) 867 @JvmStatic 868 public fun RemoteViews.setImageViewMaxWidth(@IdRes viewId: Int, value: Float, unit: Int) { 869 Api31Impl.setIntDimen(this, viewId, "setMaxWidth", value, unit) 870 } 871 872 /** 873 * Equivalent to calling [android.widget.ImageView.setMaxWidth]. 874 * 875 * @param viewId The id of the target view 876 * @param resId A dimension resource identifier for maximum width of the view. 877 */ 878 @RequiresApi(31) 879 @JvmStatic 880 public fun RemoteViews.setImageViewMaxWidthDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 881 Api31Impl.setIntDimen(this, viewId, "setMaxWidth", resId) 882 } 883 884 /** 885 * Equivalent to calling [android.widget.ImageView.setMaxWidth]. 886 * 887 * @param viewId The id of the target view 888 * @param resId A dimension resource attribute for maximum width of the view. 889 */ 890 @RequiresApi(31) 891 @JvmStatic 892 public fun RemoteViews.setImageViewMaxWidthDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 893 Api31Impl.setIntDimenAttr(this, viewId, "setMaxWidth", resId) 894 } 895 896 /** 897 * Equivalent to calling [android.widget.LinearLayout.setBaselineAligned]. 898 * 899 * @param viewId The id of the target view 900 * @param baselineAligned True to align widgets on their baseline, false otherwise. 901 */ 902 @JvmStatic 903 public fun RemoteViews.setLinearLayoutBaselineAligned( 904 @IdRes viewId: Int, 905 baselineAligned: Boolean 906 ) { 907 setBoolean(viewId, "setBaselineAligned", baselineAligned) 908 } 909 910 /** 911 * Equivalent to calling [android.widget.LinearLayout.setBaselineAlignedChildIndex]. 912 * 913 * @param viewId The id of the target view 914 * @param i True to align widgets on their baseline, false otherwise. 915 */ 916 @JvmStatic 917 public fun RemoteViews.setLinearLayoutBaselineAlignedChildIndex(@IdRes viewId: Int, i: Int) { 918 setInt(viewId, "setBaselineAlignedChildIndex", i) 919 } 920 921 /** 922 * Equivalent to calling [android.widget.LinearLayout.setGravity]. 923 * 924 * @param viewId The id of the target view 925 * @param gravity See [android.view.Gravity]. 926 */ 927 @JvmStatic 928 public fun RemoteViews.setLinearLayoutGravity(@IdRes viewId: Int, gravity: Int) { 929 setInt(viewId, "setGravity", gravity) 930 } 931 932 /** 933 * Equivalent to calling [android.widget.LinearLayout.setHorizontalGravity]. 934 * 935 * @param viewId The id of the target view 936 * @param horizontalGravity See [android.view.Gravity]. 937 */ 938 @JvmStatic 939 public fun RemoteViews.setLinearLayoutHorizontalGravity( 940 @IdRes viewId: Int, 941 horizontalGravity: Int 942 ) { 943 setInt(viewId, "setHorizontalGravity", horizontalGravity) 944 } 945 946 /** 947 * Equivalent to calling [android.widget.LinearLayout.setVerticalGravity]. 948 * 949 * @param viewId The id of the target view 950 * @param verticalGravity See [android.view.Gravity]. 951 */ 952 @JvmStatic 953 public fun RemoteViews.setLinearLayoutVerticalGravity( 954 @IdRes viewId: Int, 955 verticalGravity: Int 956 ) { 957 setInt(viewId, "setVerticalGravity", verticalGravity) 958 } 959 960 /** 961 * Equivalent to calling [android.widget.LinearLayout.setMeasureWithLargestChildEnabled]. 962 * 963 * @param viewId The id of the target view 964 * @param enabled True to measure children with a weight using the minimum size of the largest 965 * child, false otherwise. 966 */ 967 @JvmStatic 968 public fun RemoteViews.setLinearLayoutMeasureWithLargestChildEnabled( 969 @IdRes viewId: Int, 970 enabled: Boolean 971 ) { 972 setBoolean(viewId, "setMeasureWithLargestChildEnabled", enabled) 973 } 974 975 /** 976 * Equivalent to calling [android.widget.LinearLayout.setWeightSum]. 977 * 978 * @param viewId The id of the target view 979 * @param weightSum A number greater than 0.0f, or a number lower than or equals to 0.0f if the 980 * weight sum should be computed from the children's layout_weight 981 */ 982 @JvmStatic 983 public fun RemoteViews.setLinearLayoutWeightSum(@IdRes viewId: Int, weightSum: Float) { 984 setFloat(viewId, "setWeightSum", weightSum) 985 } 986 987 /** 988 * Equivalent to calling [android.widget.ProgressBar.setIndeterminate]. 989 * 990 * @param viewId The id of the target view 991 * @param indeterminate True to enable the indeterminate mode. 992 */ 993 @JvmStatic 994 public fun RemoteViews.setProgressBarIndeterminate(@IdRes viewId: Int, indeterminate: Boolean) { 995 setBoolean(viewId, "setIndeterminate", indeterminate) 996 } 997 998 /** 999 * Equivalent to calling [android.widget.ProgressBar.setIndeterminateTintBlendMode]. 1000 * 1001 * @param viewId The id of the target view 1002 * @param blendMode The blending mode used to apply the tint, may be null to clear. 1003 */ 1004 @RequiresApi(31) 1005 @JvmStatic 1006 public fun RemoteViews.setProgressBarIndeterminateTintBlendMode( 1007 @IdRes viewId: Int, 1008 blendMode: BlendMode? 1009 ) { 1010 Api31Impl.setBlendMode(this, viewId, "setIndeterminateTintBlendMode", blendMode) 1011 } 1012 1013 /** 1014 * Equivalent to calling [android.widget.ProgressBar.setIndeterminateTintList]. 1015 * 1016 * @param viewId The id of the target view 1017 * @param tint The tint to apply, may be null to clear tint. 1018 */ 1019 @RequiresApi(31) 1020 @JvmStatic 1021 public fun RemoteViews.setProgressBarIndeterminateTintList( 1022 @IdRes viewId: Int, 1023 tint: ColorStateList? 1024 ) { 1025 Api31Impl.setColorStateList(this, viewId, "setIndeterminateTintList", tint) 1026 } 1027 1028 /** 1029 * Equivalent to calling [android.widget.ProgressBar.setIndeterminateTintList]. 1030 * 1031 * @param viewId The id of the target view 1032 * @param notNightTint The tint to apply when the UI is not in night mode, may be null to clear 1033 * tint. 1034 * @param nightTint The tint to apply when the UI is in night mode, may be null to clear tint. 1035 */ 1036 @RequiresApi(31) 1037 @JvmStatic 1038 public fun RemoteViews.setProgressBarIndeterminateTintList( 1039 @IdRes viewId: Int, 1040 notNightTint: ColorStateList?, 1041 nightTint: ColorStateList? 1042 ) { 1043 Api31Impl.setColorStateList( 1044 this, 1045 viewId, 1046 "setIndeterminateTintList", 1047 notNightTint, 1048 nightTint 1049 ) 1050 } 1051 1052 /** 1053 * Equivalent to calling [android.widget.ProgressBar.setIndeterminateTintList]. 1054 * 1055 * @param viewId The id of the target view 1056 * @param resId The resource id of the tint to apply, may be 0 to clear tint. 1057 */ 1058 @RequiresApi(31) 1059 @JvmStatic 1060 public fun RemoteViews.setProgressBarIndeterminateTintList( 1061 @IdRes viewId: Int, 1062 @ColorRes resId: Int 1063 ) { 1064 Api31Impl.setColorStateList(this, viewId, "setIndeterminateTintList", resId) 1065 } 1066 1067 /** 1068 * Equivalent to calling [android.widget.ProgressBar.setIndeterminateTintList]. 1069 * 1070 * @param viewId The id of the target view 1071 * @param resId The attribute id of the tint to apply, may be 0 to clear tint. 1072 */ 1073 @RequiresApi(31) 1074 @JvmStatic 1075 public fun RemoteViews.setProgressBarIndeterminateTintListAttr( 1076 @IdRes viewId: Int, 1077 @AttrRes resId: Int 1078 ) { 1079 Api31Impl.setColorStateListAttr(this, viewId, "setIndeterminateTintList", resId) 1080 } 1081 1082 /** 1083 * Equivalent to calling [android.widget.ProgressBar.setMax]. 1084 * 1085 * @param viewId The id of the target view 1086 * @param max The upper range of this progress bar. 1087 */ 1088 @JvmStatic 1089 public fun RemoteViews.setProgressBarMax(@IdRes viewId: Int, max: Int) { 1090 setInt(viewId, "setMax", max) 1091 } 1092 1093 /** 1094 * Equivalent to calling [android.widget.ProgressBar.setMin]. 1095 * 1096 * @param viewId The id of the target view 1097 * @param min The lower range of this progress bar. 1098 */ 1099 @RequiresApi(26) 1100 @JvmStatic 1101 public fun RemoteViews.setProgressBarMin(@IdRes viewId: Int, min: Int) { 1102 requireSdk(26, "setMin") 1103 setInt(viewId, "setMin", min) 1104 } 1105 1106 /** 1107 * Equivalent to calling [android.widget.ProgressBar.setProgressTintBlendMode]. 1108 * 1109 * @param viewId The id of the target view 1110 * @param blendMode The blending mode used to apply the tint, may be null to clear. 1111 */ 1112 @RequiresApi(31) 1113 @JvmStatic 1114 public fun RemoteViews.setProgressBarProgressTintBlendMode( 1115 @IdRes viewId: Int, 1116 blendMode: BlendMode? 1117 ) { 1118 Api31Impl.setBlendMode(this, viewId, "setProgressTintBlendMode", blendMode) 1119 } 1120 1121 /** 1122 * Equivalent to calling [android.widget.ProgressBar.setProgress]. 1123 * 1124 * @param viewId The id of the target view 1125 * @param progress The new progress. 1126 */ 1127 @JvmStatic 1128 public fun RemoteViews.setProgressBarProgress(@IdRes viewId: Int, progress: Int) { 1129 setInt(viewId, "setProgress", progress) 1130 } 1131 1132 /** 1133 * Equivalent to calling [android.widget.ProgressBar.setProgressTintList]. 1134 * 1135 * @param viewId The id of the target view 1136 * @param tint The tint to apply, may be null to clear tint. 1137 */ 1138 @RequiresApi(31) 1139 @JvmStatic 1140 public fun RemoteViews.setProgressBarProgressTintList( 1141 @IdRes viewId: Int, 1142 tint: ColorStateList? 1143 ) { 1144 Api31Impl.setColorStateList(this, viewId, "setProgressTintList", tint) 1145 } 1146 1147 /** 1148 * Equivalent to calling [android.widget.ProgressBar.setProgressTintList]. 1149 * 1150 * @param viewId The id of the target view 1151 * @param notNightTint The tint to apply when the UI is not in night mode, may be null to clear 1152 * tint. 1153 * @param nightTint The tint to apply when the UI is in night mode, may be null to clear tint. 1154 */ 1155 @RequiresApi(31) 1156 @JvmStatic 1157 public fun RemoteViews.setProgressBarProgressTintList( 1158 @IdRes viewId: Int, 1159 notNightTint: ColorStateList?, 1160 nightTint: ColorStateList? 1161 ) { 1162 Api31Impl.setColorStateList(this, viewId, "setProgressTintList", notNightTint, nightTint) 1163 } 1164 1165 /** 1166 * Equivalent to calling [android.widget.ProgressBar.setProgressTintList]. 1167 * 1168 * @param viewId The id of the target view 1169 * @param resId The resource id of the tint to apply, may be 0 to clear tint. 1170 */ 1171 @RequiresApi(31) 1172 @JvmStatic 1173 public fun RemoteViews.setProgressBarProgressTintList( 1174 @IdRes viewId: Int, 1175 @ColorRes resId: Int 1176 ) { 1177 Api31Impl.setColorStateList(this, viewId, "setProgressTintList", resId) 1178 } 1179 1180 /** 1181 * Equivalent to calling [android.widget.ProgressBar.setProgressTintList]. 1182 * 1183 * @param viewId The id of the target view 1184 * @param resId The attribute id of the tint to apply, may be 0 to clear tint. 1185 */ 1186 @RequiresApi(31) 1187 @JvmStatic 1188 public fun RemoteViews.setProgressBarProgressTintListAttr( 1189 @IdRes viewId: Int, 1190 @AttrRes resId: Int 1191 ) { 1192 Api31Impl.setColorStateListAttr(this, viewId, "setProgressTintList", resId) 1193 } 1194 1195 /** 1196 * Equivalent to calling [android.widget.ProgressBar.setProgressBackgroundTintBlendMode]. 1197 * 1198 * @param viewId The id of the target view 1199 * @param blendMode The blending mode used to apply the tint, may be null to clear. 1200 */ 1201 @RequiresApi(31) 1202 @JvmStatic 1203 public fun RemoteViews.setProgressBarProgressBackgroundTintBlendMode( 1204 @IdRes viewId: Int, 1205 blendMode: BlendMode? 1206 ) { 1207 Api31Impl.setBlendMode(this, viewId, "setProgressBackgroundTintBlendMode", blendMode) 1208 } 1209 1210 /** 1211 * Equivalent to calling [android.widget.ProgressBar.setProgressBackgroundTintList]. 1212 * 1213 * @param viewId The id of the target view 1214 * @param tint The tint to apply, may be null to clear tint. 1215 */ 1216 @RequiresApi(31) 1217 @JvmStatic 1218 public fun RemoteViews.setProgressBarProgressBackgroundTintList( 1219 @IdRes viewId: Int, 1220 tint: ColorStateList? 1221 ) { 1222 Api31Impl.setColorStateList(this, viewId, "setProgressBackgroundTintList", tint) 1223 } 1224 1225 /** 1226 * Equivalent to calling [android.widget.ProgressBar.setProgressBackgroundTintList]. 1227 * 1228 * @param viewId The id of the target view 1229 * @param notNightTint The tint to apply when the UI is not in night mode, may be null to clear 1230 * tint. 1231 * @param nightTint The tint to apply when the UI is in night mode, may be null to clear tint. 1232 */ 1233 @RequiresApi(31) 1234 @JvmStatic 1235 public fun RemoteViews.setProgressBarProgressBackgroundTintList( 1236 @IdRes viewId: Int, 1237 notNightTint: ColorStateList?, 1238 nightTint: ColorStateList? 1239 ) { 1240 Api31Impl.setColorStateList( 1241 this, 1242 viewId, 1243 "setProgressBackgroundTintList", 1244 notNightTint, 1245 nightTint 1246 ) 1247 } 1248 1249 /** 1250 * Equivalent to calling [android.widget.ProgressBar.setProgressBackgroundTintList]. 1251 * 1252 * @param viewId The id of the target view 1253 * @param resId The resource id of the tint to apply, may be 0 to clear tint. 1254 */ 1255 @RequiresApi(31) 1256 @JvmStatic 1257 public fun RemoteViews.setProgressBarProgressBackgroundTintList( 1258 @IdRes viewId: Int, 1259 @ColorRes resId: Int 1260 ) { 1261 Api31Impl.setColorStateList(this, viewId, "setProgressBackgroundTintList", resId) 1262 } 1263 1264 /** 1265 * Equivalent to calling [android.widget.ProgressBar.setProgressBackgroundTintList]. 1266 * 1267 * @param viewId The id of the target view 1268 * @param resId The attribute of the tint to apply, may be 0 to clear tint. 1269 */ 1270 @RequiresApi(31) 1271 @JvmStatic 1272 public fun RemoteViews.setProgressBarProgressBackgroundTintListAttr( 1273 @IdRes viewId: Int, 1274 @AttrRes resId: Int 1275 ) { 1276 Api31Impl.setColorStateListAttr(this, viewId, "setProgressBackgroundTintList", resId) 1277 } 1278 1279 /** 1280 * Equivalent to calling [android.widget.ProgressBar.setSecondaryProgress]. 1281 * 1282 * @param viewId The id of the target view 1283 * @param secondaryProgress The new secondary progress. 1284 */ 1285 @JvmStatic 1286 public fun RemoteViews.setProgressBarSecondaryProgress( 1287 @IdRes viewId: Int, 1288 secondaryProgress: Int 1289 ) { 1290 setInt(viewId, "setSecondaryProgress", secondaryProgress) 1291 } 1292 1293 /** 1294 * Equivalent to calling [android.widget.ProgressBar.setSecondaryProgressTintBlendMode]. 1295 * 1296 * @param viewId The id of the target view 1297 * @param blendMode The blending mode used to apply the tint, may be null to clear. 1298 */ 1299 @RequiresApi(31) 1300 @JvmStatic 1301 public fun RemoteViews.setProgressBarSecondaryProgressTintBlendMode( 1302 @IdRes viewId: Int, 1303 blendMode: BlendMode? 1304 ) { 1305 Api31Impl.setBlendMode(this, viewId, "setSecondaryProgressTintBlendMode", blendMode) 1306 } 1307 1308 /** 1309 * Equivalent to calling [android.widget.ProgressBar.setSecondaryProgressTintList]. 1310 * 1311 * @param viewId The id of the target view 1312 * @param tint The tint to apply, may be null to clear tint. 1313 */ 1314 @RequiresApi(31) 1315 @JvmStatic 1316 public fun RemoteViews.setProgressBarSecondaryProgressTintList( 1317 @IdRes viewId: Int, 1318 tint: ColorStateList? 1319 ) { 1320 Api31Impl.setColorStateList(this, viewId, "setSecondaryProgressTintList", tint) 1321 } 1322 1323 /** 1324 * Equivalent to calling [android.widget.ProgressBar.setSecondaryProgressTintList]. 1325 * 1326 * @param viewId The id of the target view 1327 * @param notNightTint The tint to apply when the UI is not in night mode, may be null to clear 1328 * tint. 1329 * @param nightTint The tint to apply when the UI is in night mode, may be null to clear tint. 1330 */ 1331 @RequiresApi(31) 1332 @JvmStatic 1333 public fun RemoteViews.setProgressBarSecondaryProgressTintList( 1334 @IdRes viewId: Int, 1335 notNightTint: ColorStateList?, 1336 nightTint: ColorStateList? 1337 ) { 1338 Api31Impl.setColorStateList( 1339 this, 1340 viewId, 1341 "setSecondaryProgressTintList", 1342 notNightTint, 1343 nightTint 1344 ) 1345 } 1346 1347 /** 1348 * Equivalent to calling [android.widget.ProgressBar.setSecondaryProgressTintList]. 1349 * 1350 * @param viewId The id of the target view 1351 * @param resId The resource id of the tint to apply, may be 0 to clear tint. 1352 */ 1353 @RequiresApi(31) 1354 @JvmStatic 1355 public fun RemoteViews.setProgressBarSecondaryProgressTintList( 1356 @IdRes viewId: Int, 1357 @ColorRes resId: Int 1358 ) { 1359 Api31Impl.setColorStateList(this, viewId, "setSecondaryProgressTintList", resId) 1360 } 1361 1362 /** 1363 * Equivalent to calling [android.widget.ProgressBar.setSecondaryProgressTintList]. 1364 * 1365 * @param viewId The id of the target view 1366 * @param resId The attribute of the tint to apply, may be 0 to clear tint. 1367 */ 1368 @RequiresApi(31) 1369 @JvmStatic 1370 public fun RemoteViews.setProgressBarSecondaryProgressTintListAttr( 1371 @IdRes viewId: Int, 1372 @AttrRes resId: Int 1373 ) { 1374 Api31Impl.setColorStateListAttr(this, viewId, "setSecondaryProgressTintList", resId) 1375 } 1376 1377 /** 1378 * Equivalent to calling [android.widget.ProgressBar.setStateDescription]. 1379 * 1380 * @param viewId The id of the target view 1381 * @param stateDescription The state description, or null to reset to the default ProgressBar 1382 * state description. 1383 */ 1384 @RequiresApi(31) 1385 @JvmStatic 1386 public fun RemoteViews.setProgressBarStateDescription( 1387 @IdRes viewId: Int, 1388 stateDescription: CharSequence? 1389 ) { 1390 requireSdk(31, "setStateDescription") 1391 setCharSequence(viewId, "setStateDescription", stateDescription) 1392 } 1393 1394 /** 1395 * Equivalent to calling [android.widget.ProgressBar.setStateDescription]. 1396 * 1397 * @param viewId The id of the target view 1398 * @param resId The resource id of the state description, or 0 to reset to the default 1399 * ProgressBar state description. 1400 */ 1401 @RequiresApi(31) 1402 @JvmStatic 1403 public fun RemoteViews.setProgressBarStateDescription( 1404 @IdRes viewId: Int, 1405 @StringRes resId: Int 1406 ) { 1407 Api31Impl.setCharSequence(this, viewId, "setStateDescription", resId) 1408 } 1409 1410 /** 1411 * Equivalent to calling [android.widget.ProgressBar.setStateDescription]. 1412 * 1413 * @param viewId The id of the target view 1414 * @param resId The attribute id of the state description, or 0 to reset to the default 1415 * ProgressBar state description. 1416 */ 1417 @RequiresApi(31) 1418 @JvmStatic 1419 public fun RemoteViews.setProgressBarStateDescriptionAttr( 1420 @IdRes viewId: Int, 1421 @AttrRes resId: Int 1422 ) { 1423 Api31Impl.setCharSequenceAttr(this, viewId, "setStateDescription", resId) 1424 } 1425 1426 /** 1427 * Equivalent to calling [android.widget.RelativeLayout.setGravity]. 1428 * 1429 * @param viewId The id of the target view 1430 * @param gravity See [android.view.Gravity]. 1431 */ 1432 @JvmStatic 1433 public fun RemoteViews.setRelativeLayoutGravity(@IdRes viewId: Int, gravity: Int) { 1434 setInt(viewId, "setGravity", gravity) 1435 } 1436 1437 /** 1438 * Equivalent to calling [android.widget.RelativeLayout.setHorizontalGravity]. 1439 * 1440 * @param viewId The id of the target view 1441 * @param horizontalGravity See [android.view.Gravity]. 1442 */ 1443 @JvmStatic 1444 public fun RemoteViews.setRelativeLayoutHorizontalGravity( 1445 @IdRes viewId: Int, 1446 horizontalGravity: Int 1447 ) { 1448 setInt(viewId, "setHorizontalGravity", horizontalGravity) 1449 } 1450 1451 /** 1452 * Equivalent to calling [android.widget.RelativeLayout.setIgnoreGravity]. 1453 * 1454 * @param viewId The id of the target view 1455 * @param childViewId The id of the child View to be ignored by gravity, or 0 if no View should 1456 * be ignored. 1457 */ 1458 @JvmStatic 1459 public fun RemoteViews.setRelativeLayoutIgnoreGravity( 1460 @IdRes viewId: Int, 1461 @IdRes childViewId: Int 1462 ) { 1463 setInt(viewId, "setIgnoreGravity", childViewId) 1464 } 1465 1466 /** 1467 * Equivalent to calling [android.widget.RelativeLayout.setVerticalGravity]. 1468 * 1469 * @param viewId The id of the target view 1470 * @param verticalGravity See [android.view.Gravity]. 1471 */ 1472 @JvmStatic 1473 public fun RemoteViews.setRelativeLayoutVerticalGravity( 1474 @IdRes viewId: Int, 1475 verticalGravity: Int 1476 ) { 1477 setInt(viewId, "setVerticalGravity", verticalGravity) 1478 } 1479 1480 /** 1481 * Equivalent to calling [android.widget.Switch.setSwitchMinWidth]. 1482 * 1483 * @param viewId The id of the target view 1484 * @param value Minimum width of the switch. 1485 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 1486 */ 1487 @RequiresApi(31) 1488 @JvmStatic 1489 public fun RemoteViews.setSwitchMinWidth(@IdRes viewId: Int, value: Float, unit: Int) { 1490 Api31Impl.setIntDimen(this, viewId, "setSwitchMinWidth", value, unit) 1491 } 1492 1493 /** 1494 * Equivalent to calling [android.widget.Switch.setSwitchMinWidth]. 1495 * 1496 * @param viewId The id of the target view 1497 * @param resId The id of a dimension resource for the minimum width of the switch. 1498 */ 1499 @RequiresApi(31) 1500 @JvmStatic 1501 public fun RemoteViews.setSwitchMinWidthDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 1502 Api31Impl.setIntDimen(this, viewId, "setSwitchMinWidth", resId) 1503 } 1504 1505 /** 1506 * Equivalent to calling [android.widget.Switch.setSwitchMinWidth]. 1507 * 1508 * @param viewId The id of the target view 1509 * @param resId The id of a dimension attribute for the minimum width of the switch. 1510 */ 1511 @RequiresApi(31) 1512 @JvmStatic 1513 public fun RemoteViews.setSwitchMinWidthDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1514 Api31Impl.setIntDimenAttr(this, viewId, "setSwitchMinWidth", resId) 1515 } 1516 1517 /** 1518 * Equivalent to calling [android.widget.Switch.setSwitchPadding]. 1519 * 1520 * @param viewId The id of the target view 1521 * @param value Amount of padding. 1522 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 1523 */ 1524 @RequiresApi(31) 1525 @JvmStatic 1526 public fun RemoteViews.setSwitchPadding(@IdRes viewId: Int, value: Float, unit: Int) { 1527 Api31Impl.setIntDimen(this, viewId, "setSwitchPadding", value, unit) 1528 } 1529 1530 /** 1531 * Equivalent to calling [android.widget.Switch.setSwitchPadding]. 1532 * 1533 * @param viewId The id of the target view 1534 * @param resId The id of a dimension resource for the amount of padding. 1535 */ 1536 @RequiresApi(31) 1537 @JvmStatic 1538 public fun RemoteViews.setSwitchPaddingDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 1539 Api31Impl.setIntDimen(this, viewId, "setSwitchPadding", resId) 1540 } 1541 1542 /** 1543 * Equivalent to calling [android.widget.Switch.setSwitchPadding]. 1544 * 1545 * @param viewId The id of the target view 1546 * @param resId The id of a dimension attribute for the amount of padding. 1547 */ 1548 @RequiresApi(31) 1549 @JvmStatic 1550 public fun RemoteViews.setSwitchPaddingDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1551 Api31Impl.setIntDimenAttr(this, viewId, "setSwitchPadding", resId) 1552 } 1553 1554 /** 1555 * Equivalent to calling [android.widget.Switch.setShowText]. 1556 * 1557 * @param viewId The id of the target view 1558 * @param showText True to display on/off text. 1559 */ 1560 @RequiresApi(31) 1561 @JvmStatic 1562 public fun RemoteViews.setSwitchShowText(@IdRes viewId: Int, showText: Boolean) { 1563 requireSdk(31, "setShowText") 1564 setBoolean(viewId, "setShowText", showText) 1565 } 1566 1567 /** 1568 * Equivalent to calling [android.widget.Switch.setSplitTrack]. 1569 * 1570 * @param viewId The id of the target view 1571 * @param splitTrack Whether the track should be split by the thumb. 1572 */ 1573 @RequiresApi(31) 1574 @JvmStatic 1575 public fun RemoteViews.setSwitchSplitTrack(@IdRes viewId: Int, splitTrack: Boolean) { 1576 requireSdk(31, "setSplitTrack") 1577 setBoolean(viewId, "setSplitTrack", splitTrack) 1578 } 1579 1580 /** 1581 * Equivalent to calling [android.widget.Switch.setTextOff]. 1582 * 1583 * @param viewId The id of the target view 1584 * @param textOff The text displayed when the button is not in the checked state. 1585 */ 1586 @RequiresApi(31) 1587 @JvmStatic 1588 public fun RemoteViews.setSwitchTextOff(@IdRes viewId: Int, textOff: CharSequence?) { 1589 requireSdk(31, "setTextOff") 1590 setCharSequence(viewId, "setTextOff", textOff) 1591 } 1592 1593 /** 1594 * Equivalent to calling [android.widget.Switch.setTextOff]. 1595 * 1596 * @param viewId The id of the target view 1597 * @param resId The resource id for the text displayed when the button is not in the checked 1598 * state. 1599 */ 1600 @RequiresApi(31) 1601 @JvmStatic 1602 public fun RemoteViews.setSwitchTextOff(@IdRes viewId: Int, @StringRes resId: Int) { 1603 Api31Impl.setCharSequence(this, viewId, "setTextOff", resId) 1604 } 1605 1606 /** 1607 * Equivalent to calling [android.widget.Switch.setTextOff]. 1608 * 1609 * @param viewId The id of the target view 1610 * @param resId The attribute id for the text displayed when the button is not in the checked 1611 * state. 1612 */ 1613 @RequiresApi(31) 1614 @JvmStatic 1615 public fun RemoteViews.setSwitchTextOffAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1616 Api31Impl.setCharSequenceAttr(this, viewId, "setTextOff", resId) 1617 } 1618 1619 /** 1620 * Equivalent to calling [android.widget.Switch.setTextOn]. 1621 * 1622 * @param viewId The id of the target view 1623 * @param textOn The text displayed when the button is in the checked state. 1624 */ 1625 @RequiresApi(31) 1626 @JvmStatic 1627 public fun RemoteViews.setSwitchTextOn(@IdRes viewId: Int, textOn: CharSequence?) { 1628 setCharSequence(viewId, "setTextOn", textOn) 1629 } 1630 1631 /** 1632 * Equivalent to calling [android.widget.Switch.setTextOn]. 1633 * 1634 * @param viewId The id of the target view 1635 * @param resId The resource id for the text displayed when the button is in the checked state. 1636 */ 1637 @RequiresApi(31) 1638 @JvmStatic 1639 public fun RemoteViews.setSwitchTextOn(@IdRes viewId: Int, @StringRes resId: Int) { 1640 Api31Impl.setCharSequence(this, viewId, "setTextOn", resId) 1641 } 1642 1643 /** 1644 * Equivalent to calling [android.widget.Switch.setTextOn]. 1645 * 1646 * @param viewId The id of the target view 1647 * @param resId The attribute id for the text displayed when the button is in the checked state. 1648 */ 1649 @RequiresApi(31) 1650 @JvmStatic 1651 public fun RemoteViews.setSwitchTextOnAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1652 Api31Impl.setCharSequenceAttr(this, viewId, "setTextOn", resId) 1653 } 1654 1655 /** 1656 * Equivalent to calling [android.widget.Switch.setThumbIcon]. 1657 * 1658 * @param viewId The id of the target view 1659 * @param icon An Icon holding the desired thumb, or null to clear the thumb. 1660 */ 1661 @RequiresApi(31) 1662 @JvmStatic 1663 public fun RemoteViews.setSwitchThumbIcon(@IdRes viewId: Int, icon: Icon?) { 1664 Api23Impl.setIcon(this, viewId, "setThumbIcon", icon) 1665 } 1666 1667 /** 1668 * Equivalent to calling [android.widget.Switch.setThumbIcon]. 1669 * 1670 * @param viewId The id of the target view 1671 * @param notNight An Icon holding the desired thumb when the UI is not in night mode, or null 1672 * to clear the thumb. 1673 * @param night An Icon holding the desired thumb when the UI is in night mode, or null to clear 1674 * the thumb. 1675 */ 1676 @RequiresApi(31) 1677 @JvmStatic 1678 public fun RemoteViews.setSwitchThumbIcon(@IdRes viewId: Int, notNight: Icon?, night: Icon?) { 1679 Api31Impl.setIcon(this, viewId, "setThumbIcon", notNight, night) 1680 } 1681 1682 /** 1683 * Equivalent to calling [android.widget.Switch.setThumbResource]. 1684 * 1685 * @param viewId The id of the target view 1686 * @param resId Resource id of a thumb drawable. 1687 */ 1688 @RequiresApi(31) 1689 @JvmStatic 1690 public fun RemoteViews.setSwitchThumbResource(@IdRes viewId: Int, @DrawableRes resId: Int) { 1691 requireSdk(31, "setThumbResource") 1692 setInt(viewId, "setThumbResource", resId) 1693 } 1694 1695 /** 1696 * Equivalent to calling [android.widget.Switch.setThumbTextPadding]. 1697 * 1698 * @param viewId The id of the target view 1699 * @param value Horizontal padding for switch thumb text. 1700 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 1701 */ 1702 @RequiresApi(31) 1703 @JvmStatic 1704 public fun RemoteViews.setSwitchThumbTextPadding(@IdRes viewId: Int, value: Float, unit: Int) { 1705 Api31Impl.setIntDimen(this, viewId, "setThumbTextPadding", value, unit) 1706 } 1707 1708 /** 1709 * Equivalent to calling [android.widget.Switch.setThumbTextPadding]. 1710 * 1711 * @param viewId The id of the target view 1712 * @param resId The id of a dimension resource for the horizontal padding for switch thumb text. 1713 */ 1714 @RequiresApi(31) 1715 @JvmStatic 1716 public fun RemoteViews.setSwitchThumbTextPaddingDimen( 1717 @IdRes viewId: Int, 1718 @DimenRes resId: Int 1719 ) { 1720 Api31Impl.setIntDimen(this, viewId, "setThumbTextPadding", resId) 1721 } 1722 1723 /** 1724 * Equivalent to calling [android.widget.Switch.setThumbTextPadding]. 1725 * 1726 * @param viewId The id of the target view 1727 * @param resId The id of a dimension attribute for the horizontal padding for switch thumb 1728 * text. 1729 */ 1730 @RequiresApi(31) 1731 @JvmStatic 1732 public fun RemoteViews.setSwitchThumbTextPaddingDimenAttr( 1733 @IdRes viewId: Int, 1734 @AttrRes resId: Int 1735 ) { 1736 Api31Impl.setIntDimenAttr(this, viewId, "setThumbTextPadding", resId) 1737 } 1738 1739 /** 1740 * Equivalent to calling [android.widget.Switch.setThumbTintBlendMode]. 1741 * 1742 * @param viewId The id of the target view 1743 * @param blendMode The blending mode used to apply the tint, may be null to clear tint. 1744 */ 1745 @RequiresApi(31) 1746 @JvmStatic 1747 public fun RemoteViews.setSwitchThumbTintBlendMode(@IdRes viewId: Int, blendMode: BlendMode?) { 1748 Api31Impl.setBlendMode(this, viewId, "setThumbTintBlendMode", blendMode) 1749 } 1750 1751 /** 1752 * Equivalent to calling [android.widget.Switch.setThumbTintList]. 1753 * 1754 * @param viewId The id of the target view 1755 * @param tint The tint to apply, may be null to clear tint. 1756 */ 1757 @RequiresApi(31) 1758 @JvmStatic 1759 public fun RemoteViews.setSwitchThumbTintList(@IdRes viewId: Int, tint: ColorStateList?) { 1760 Api31Impl.setColorStateList(this, viewId, "setThumbTintList", tint) 1761 } 1762 1763 /** 1764 * Equivalent to calling [android.widget.Switch.setThumbTintList]. 1765 * 1766 * @param viewId The id of the target view 1767 * @param notNight The tint to apply when the UI is not in night mode, may be null to clear 1768 * tint. 1769 * @param night The tint to apply when the UI is in night mode, may be null to clear tint. 1770 */ 1771 @RequiresApi(31) 1772 @JvmStatic 1773 public fun RemoteViews.setSwitchThumbTintList( 1774 @IdRes viewId: Int, 1775 notNight: ColorStateList?, 1776 night: ColorStateList? 1777 ) { 1778 Api31Impl.setColorStateList(this, viewId, "setThumbTintList", notNight, night) 1779 } 1780 1781 /** 1782 * Equivalent to calling [android.widget.Switch.setThumbTintList]. 1783 * 1784 * @param viewId The id of the target view 1785 * @param resId The resource id for the tint to apply, may be 0 to clear tint. 1786 */ 1787 @RequiresApi(31) 1788 @JvmStatic 1789 public fun RemoteViews.setSwitchThumbTintList(@IdRes viewId: Int, @ColorRes resId: Int) { 1790 Api31Impl.setColorStateList(this, viewId, "setThumbTintList", resId) 1791 } 1792 1793 /** 1794 * Equivalent to calling [android.widget.Switch.setThumbTintList]. 1795 * 1796 * @param viewId The id of the target view 1797 * @param resId The attribute id for the tint to apply, may be 0 to clear tint. 1798 */ 1799 @RequiresApi(31) 1800 @JvmStatic 1801 public fun RemoteViews.setSwitchThumbTintListAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1802 Api31Impl.setColorStateListAttr(this, viewId, "setThumbTintList", resId) 1803 } 1804 1805 /** 1806 * Equivalent to calling [android.widget.Switch.setTrackIcon]. 1807 * 1808 * @param viewId The id of the target view 1809 * @param icon An Icon holding the desired track, or null to clear the track. 1810 */ 1811 @RequiresApi(31) 1812 @JvmStatic 1813 public fun RemoteViews.setSwitchTrackIcon(@IdRes viewId: Int, icon: Icon?) { 1814 Api23Impl.setIcon(this, viewId, "setTrackIcon", icon) 1815 } 1816 1817 /** 1818 * Equivalent to calling [android.widget.Switch.setTrackIcon]. 1819 * 1820 * @param viewId The id of the target view 1821 * @param notNight An Icon holding the desired track when the UI is not in night mode, or null 1822 * to clear the track. 1823 * @param night An Icon holding the desired track when the UI is in night mode, or null to clear 1824 * the track. 1825 */ 1826 @RequiresApi(31) 1827 @JvmStatic 1828 public fun RemoteViews.setSwitchTrackIcon(@IdRes viewId: Int, notNight: Icon?, night: Icon?) { 1829 Api31Impl.setIcon(this, viewId, "setTrackIcon", notNight, night) 1830 } 1831 1832 /** 1833 * Equivalent to calling [android.widget.Switch.setTrackResource]. 1834 * 1835 * @param viewId The id of the target view 1836 * @param resId Resource id of a track drawable. 1837 */ 1838 @RequiresApi(31) 1839 @JvmStatic 1840 public fun RemoteViews.setSwitchTrackResource(@IdRes viewId: Int, @DrawableRes resId: Int) { 1841 requireSdk(31, "setTrackResource") 1842 setInt(viewId, "setTrackResource", resId) 1843 } 1844 1845 /** 1846 * Equivalent to calling [android.widget.Switch.setTrackTintBlendMode]. 1847 * 1848 * @param viewId The id of the target view 1849 * @param blendMode The blending mode used to apply the tint, may be null to clear tint. 1850 */ 1851 @RequiresApi(31) 1852 @JvmStatic 1853 public fun RemoteViews.setSwitchTrackTintBlendMode(@IdRes viewId: Int, blendMode: BlendMode?) { 1854 Api31Impl.setBlendMode(this, viewId, "setTrackTintBlendMode", blendMode) 1855 } 1856 1857 /** 1858 * Equivalent to calling [android.widget.Switch.setTrackTintList]. 1859 * 1860 * @param viewId The id of the target view 1861 * @param tint The tint to apply, may be null to clear tint. 1862 */ 1863 @RequiresApi(31) 1864 @JvmStatic 1865 public fun RemoteViews.setSwitchTrackTintList(@IdRes viewId: Int, tint: ColorStateList?) { 1866 Api31Impl.setColorStateList(this, viewId, "setTrackTintList", tint) 1867 } 1868 1869 /** 1870 * Equivalent to calling [android.widget.Switch.setTrackTintList]. 1871 * 1872 * @param viewId The id of the target view 1873 * @param notNight The tint to apply when the UI is not in night mode, may be null to clear 1874 * tint. 1875 * @param night The tint to apply when the UI is in night mode, may be null to clear tint. 1876 */ 1877 @RequiresApi(31) 1878 @JvmStatic 1879 public fun RemoteViews.setSwitchTrackTintList( 1880 @IdRes viewId: Int, 1881 notNight: ColorStateList?, 1882 night: ColorStateList? 1883 ) { 1884 Api31Impl.setColorStateList(this, viewId, "setTrackTintList", notNight, night) 1885 } 1886 1887 /** 1888 * Equivalent to calling [android.widget.Switch.setTrackTintList]. 1889 * 1890 * @param viewId The id of the target view 1891 * @param resId The resource id for the tint to apply, may be 0 to clear tint. 1892 */ 1893 @RequiresApi(31) 1894 @JvmStatic 1895 public fun RemoteViews.setSwitchTrackTintList(@IdRes viewId: Int, @ColorRes resId: Int) { 1896 Api31Impl.setColorStateList(this, viewId, "setTrackTintList", resId) 1897 } 1898 1899 /** 1900 * Equivalent to calling [android.widget.Switch.setTrackTintList]. 1901 * 1902 * @param viewId The id of the target view 1903 * @param resId The attribute id for the tint to apply, may be 0 to clear tint. 1904 */ 1905 @RequiresApi(31) 1906 @JvmStatic 1907 public fun RemoteViews.setSwitchTrackTintListAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1908 Api31Impl.setColorStateListAttr(this, viewId, "setTrackTintList", resId) 1909 } 1910 1911 /** 1912 * Equivalent to calling [android.widget.TextClock.setFormat12Hour]. 1913 * 1914 * @param viewId The id of the target view 1915 * @param format A date/time formatting pattern as described in 1916 * [android.text.format.DateFormat]. 1917 */ 1918 @JvmStatic 1919 public fun RemoteViews.setTextClockFormat12Hour(@IdRes viewId: Int, format: CharSequence?) { 1920 requireSdk(17, "setFormat12Hour") 1921 setCharSequence(viewId, "setFormat12Hour", format) 1922 } 1923 1924 /** 1925 * Equivalent to calling [android.widget.TextClock.setFormat12Hour]. 1926 * 1927 * @param viewId The id of the target view 1928 * @param resId A resource id for a date/time formatting pattern as described in 1929 * [android.text.format.DateFormat]. 1930 */ 1931 @RequiresApi(31) 1932 @JvmStatic 1933 public fun RemoteViews.setTextClockFormat12Hour(@IdRes viewId: Int, @StringRes resId: Int) { 1934 Api31Impl.setCharSequence(this, viewId, "setFormat12Hour", resId) 1935 } 1936 1937 /** 1938 * Equivalent to calling [android.widget.TextClock.setFormat12Hour]. 1939 * 1940 * @param viewId The id of the target view 1941 * @param resId An attribute id for a date/time formatting pattern as described in 1942 * [android.text.format.DateFormat]. 1943 */ 1944 @RequiresApi(31) 1945 @JvmStatic 1946 public fun RemoteViews.setTextClockFormat12HourAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1947 Api31Impl.setCharSequenceAttr(this, viewId, "setFormat12Hour", resId) 1948 } 1949 1950 /** 1951 * Equivalent to calling [android.widget.TextClock.setFormat24Hour]. 1952 * 1953 * @param viewId The id of the target view 1954 * @param format A date/time formatting pattern as described in 1955 * [android.text.format.DateFormat]. 1956 */ 1957 @JvmStatic 1958 public fun RemoteViews.setTextClockFormat24Hour(@IdRes viewId: Int, format: CharSequence?) { 1959 requireSdk(17, "setFormat24Hour") 1960 setCharSequence(viewId, "setFormat24Hour", format) 1961 } 1962 1963 /** 1964 * Equivalent to calling [android.widget.TextClock.setFormat24Hour]. 1965 * 1966 * @param viewId The id of the target view 1967 * @param resId A resource id for a date/time formatting pattern as described in 1968 * [android.text.format.DateFormat]. 1969 */ 1970 @RequiresApi(31) 1971 @JvmStatic 1972 public fun RemoteViews.setTextClockFormat24Hour(@IdRes viewId: Int, @StringRes resId: Int) { 1973 Api31Impl.setCharSequence(this, viewId, "setFormat24Hour", resId) 1974 } 1975 1976 /** 1977 * Equivalent to calling [android.widget.TextClock.setFormat24Hour]. 1978 * 1979 * @param viewId The id of the target view 1980 * @param resId An attribute id for a date/time formatting pattern as described in 1981 * [android.text.format.DateFormat]. 1982 */ 1983 @RequiresApi(31) 1984 @JvmStatic 1985 public fun RemoteViews.setTextClockFormat24HourAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 1986 Api31Impl.setCharSequenceAttr(this, viewId, "setFormat24Hour", resId) 1987 } 1988 1989 /** 1990 * Equivalent to calling [android.widget.TextClock.setTimeZone]. 1991 * 1992 * @param viewId The id of the target view 1993 * @param timeZone The desired time zone's ID as specified in [java.util.TimeZone] or null to 1994 * use the time zone specified by the user (system time zone). 1995 */ 1996 @JvmStatic 1997 public fun RemoteViews.setTextClockTimeZone(@IdRes viewId: Int, timeZone: String?) { 1998 requireSdk(17, "setTimeZone") 1999 setString(viewId, "setTimeZone", timeZone) 2000 } 2001 2002 /** 2003 * Equivalent to calling [android.widget.TextView.setAllCaps]. 2004 * 2005 * @param viewId The id of the target view 2006 * @param allCaps Whether the text should display in all caps. 2007 */ 2008 @RequiresApi(31) 2009 @JvmStatic 2010 public fun RemoteViews.setTextViewAllCaps(@IdRes viewId: Int, allCaps: Boolean) { 2011 requireSdk(31, "setAllCaps") 2012 setBoolean(viewId, "setAllCaps", allCaps) 2013 } 2014 2015 /** 2016 * Equivalent to calling [android.widget.TextView.setAutoLinkMask]. 2017 * 2018 * @param viewId The id of the target view 2019 * @param mask See [android.text.util.Linkify.ALL] and peers for possible values. 2020 */ 2021 @JvmStatic 2022 public fun RemoteViews.setTextViewAutoLinkMask(@IdRes viewId: Int, mask: Int) { 2023 setInt(viewId, "setAutoLinkMask", mask) 2024 } 2025 2026 /** 2027 * Equivalent to calling [android.widget.TextView.setCompoundDrawablePadding]. 2028 * 2029 * @param viewId The id of the target view 2030 * @param pad The padding between the compound drawables and the text, in pixels. 2031 */ 2032 @JvmStatic 2033 public fun RemoteViews.setTextViewCompoundDrawablePadding(@IdRes viewId: Int, @Px pad: Int) { 2034 requireSdk(16, "setCompoundDrawablePadding") 2035 setInt(viewId, "setCompoundDrawablePadding", pad) 2036 } 2037 2038 /** 2039 * Equivalent to calling [android.widget.TextView.setCompoundDrawablePadding]. 2040 * 2041 * @param viewId The id of the target view 2042 * @param value The padding between the compound drawables and the text. 2043 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2044 */ 2045 @RequiresApi(31) 2046 @JvmStatic 2047 public fun RemoteViews.setTextViewCompoundDrawablePadding( 2048 @IdRes viewId: Int, 2049 value: Float, 2050 unit: Int 2051 ) { 2052 Api31Impl.setIntDimen(this, viewId, "setCompoundDrawablePadding", value, unit) 2053 } 2054 2055 /** 2056 * Equivalent to calling [android.widget.TextView.setCompoundDrawablePadding]. 2057 * 2058 * @param viewId The id of the target view 2059 * @param resId The id of a dimension resource for the padding between the compound drawables 2060 * and the text. 2061 */ 2062 @RequiresApi(31) 2063 @JvmStatic 2064 public fun RemoteViews.setTextViewCompoundDrawablePaddingDimen( 2065 @IdRes viewId: Int, 2066 @DimenRes resId: Int 2067 ) { 2068 Api31Impl.setIntDimen(this, viewId, "setCompoundDrawablePadding", resId) 2069 } 2070 2071 /** 2072 * Equivalent to calling [android.widget.TextView.setCompoundDrawablePadding]. 2073 * 2074 * @param viewId The id of the target view 2075 * @param resId The id of a dimension attribute for the padding between the compound drawables 2076 * and the text. 2077 */ 2078 @RequiresApi(31) 2079 @JvmStatic 2080 public fun RemoteViews.setTextViewCompoundDrawablePaddingDimenAttr( 2081 @IdRes viewId: Int, 2082 @AttrRes resId: Int 2083 ) { 2084 Api31Impl.setIntDimenAttr(this, viewId, "setCompoundDrawablePadding", resId) 2085 } 2086 2087 /** 2088 * Equivalent to calling [android.widget.TextView.setEms]. 2089 * 2090 * @param viewId The id of the target view 2091 * @param ems The width of the TextView, in ems. 2092 */ 2093 @JvmStatic 2094 public fun RemoteViews.setTextViewEms(@IdRes viewId: Int, ems: Int) { 2095 setInt(viewId, "setEms", ems) 2096 } 2097 2098 /** 2099 * Equivalent to calling [android.widget.TextView.setError]. 2100 * 2101 * @param viewId The id of the target view 2102 * @param error The error message for the TextView. 2103 */ 2104 @JvmStatic 2105 public fun RemoteViews.setTextViewError(@IdRes viewId: Int, error: CharSequence?) { 2106 setCharSequence(viewId, "setError", error) 2107 } 2108 2109 /** 2110 * Equivalent to calling [android.widget.TextView.setError]. 2111 * 2112 * @param viewId The id of the target view 2113 * @param resId A string resource for the error. 2114 */ 2115 @RequiresApi(31) 2116 @JvmStatic 2117 public fun RemoteViews.setTextViewError(@IdRes viewId: Int, @StringRes resId: Int) { 2118 // Note: Unlike setHint and setText, there's no API to pass a resId as an int directly, so 2119 // this is only available with the setCharSequence API adding in API 31. 2120 Api31Impl.setCharSequence(this, viewId, "setError", resId) 2121 } 2122 2123 /** 2124 * Equivalent to calling [android.widget.TextView.setError]. 2125 * 2126 * @param viewId The id of the target view 2127 * @param resId A string attribute for the error. 2128 */ 2129 @RequiresApi(31) 2130 @JvmStatic 2131 public fun RemoteViews.setTextViewErrorAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2132 Api31Impl.setCharSequenceAttr(this, viewId, "setError", resId) 2133 } 2134 2135 /** 2136 * Equivalent to calling [android.widget.TextView.setFontFeatureSettings]. 2137 * 2138 * @param viewId The id of the target view 2139 * @param fontFeatureSettings Font feature settings represented as CSS compatible string. 2140 */ 2141 @RequiresApi(21) 2142 @JvmStatic 2143 public fun RemoteViews.setTextViewFontFeatureSettings( 2144 @IdRes viewId: Int, 2145 fontFeatureSettings: String 2146 ) { 2147 requireSdk(21, "setFontFeatureSettings") 2148 setString(viewId, "setFontFeatureSettings", fontFeatureSettings) 2149 } 2150 2151 /** 2152 * Equivalent to calling [android.widget.TextView.setGravity]. 2153 * 2154 * @param viewId The id of the target view 2155 * @param gravity The gravity value, from [android.view.Gravity]. 2156 */ 2157 @RequiresApi(31) 2158 @JvmStatic 2159 public fun RemoteViews.setTextViewGravity(@IdRes viewId: Int, gravity: Int) { 2160 requireSdk(31, "setGravity") 2161 setInt(viewId, "setGravity", gravity) 2162 } 2163 2164 /** 2165 * Equivalent to calling [android.widget.TextView.setHeight]. 2166 * 2167 * @param viewId The id of the target view 2168 * @param pixels The height of the TextView, in pixels. 2169 */ 2170 @JvmStatic 2171 public fun RemoteViews.setTextViewHeight(@IdRes viewId: Int, @Px pixels: Int) { 2172 setInt(viewId, "setHeight", pixels) 2173 } 2174 2175 /** 2176 * Equivalent to calling [android.widget.TextView.setHeight]. 2177 * 2178 * @param viewId The id of the target view 2179 * @param value The height of the TextView. 2180 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2181 */ 2182 @RequiresApi(31) 2183 @JvmStatic 2184 public fun RemoteViews.setTextViewHeight(@IdRes viewId: Int, value: Float, unit: Int) { 2185 Api31Impl.setIntDimen(this, viewId, "setHeight", value, unit) 2186 } 2187 2188 /** 2189 * Equivalent to calling [android.widget.TextView.setHeight]. 2190 * 2191 * @param viewId The id of the target view 2192 * @param resId The id of a dimension resource for the height of the TextView. 2193 */ 2194 @RequiresApi(31) 2195 @JvmStatic 2196 public fun RemoteViews.setTextViewHeightDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2197 Api31Impl.setIntDimen(this, viewId, "setHeight", resId) 2198 } 2199 2200 /** 2201 * Equivalent to calling [android.widget.TextView.setHeight]. 2202 * 2203 * @param viewId The id of the target view 2204 * @param resId The id of a dimension attribute for the height of the TextView. 2205 */ 2206 @RequiresApi(31) 2207 @JvmStatic 2208 public fun RemoteViews.setTextViewHeightDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2209 Api31Impl.setIntDimenAttr(this, viewId, "setHeight", resId) 2210 } 2211 2212 /** 2213 * Equivalent to calling [android.widget.TextView.setHighlightColor]. 2214 * 2215 * @param viewId The id of the target view 2216 * @param color The highlight color to use. 2217 */ 2218 @JvmStatic 2219 public fun RemoteViews.setTextViewHighlightColor(@IdRes viewId: Int, @ColorInt color: Int) { 2220 setInt(viewId, "setHighlightColor", color) 2221 } 2222 2223 /** 2224 * Equivalent to calling [android.widget.TextView.setHighlightColor]. 2225 * 2226 * @param viewId The id of the target view 2227 * @param notNight The highlight color to use when night mode is not active. 2228 * @param night The highlight color to use when night mode is active. 2229 */ 2230 @RequiresApi(31) 2231 @JvmStatic 2232 public fun RemoteViews.setTextViewHighlightColor( 2233 @IdRes viewId: Int, 2234 @ColorInt notNight: Int, 2235 @ColorInt night: Int 2236 ) { 2237 Api31Impl.setColorInt(this, viewId, "setHighlightColor", notNight, night) 2238 } 2239 2240 /** 2241 * Equivalent to calling [android.widget.TextView.setHighlightColor]. 2242 * 2243 * @param viewId The id of the target view 2244 * @param resId The resource id for the highlight color. 2245 */ 2246 @RequiresApi(31) 2247 @JvmStatic 2248 public fun RemoteViews.setTextViewHighlightColorResource( 2249 @IdRes viewId: Int, 2250 @ColorRes resId: Int 2251 ) { 2252 Api31Impl.setColor(this, viewId, "setHighlightColor", resId) 2253 } 2254 2255 /** 2256 * Equivalent to calling [android.widget.TextView.setHighlightColor]. 2257 * 2258 * @param viewId The id of the target view 2259 * @param resId The attribute id for the highlight color. 2260 */ 2261 @RequiresApi(31) 2262 @JvmStatic 2263 public fun RemoteViews.setTextViewHighlightColorAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2264 Api31Impl.setColorAttr(this, viewId, "setHighlightColor", resId) 2265 } 2266 2267 /** 2268 * Equivalent to calling [android.widget.TextView.setHint]. 2269 * 2270 * @param viewId The id of the target view 2271 * @param hint The hint for the TextView. 2272 */ 2273 @JvmStatic 2274 public fun RemoteViews.setTextViewHint(@IdRes viewId: Int, hint: CharSequence?) { 2275 setCharSequence(viewId, "setHint", hint) 2276 } 2277 2278 /** 2279 * Equivalent to calling [android.widget.TextView.setHint]. 2280 * 2281 * @param viewId The id of the target view 2282 * @param resId A string resource for the hint. 2283 */ 2284 @JvmStatic 2285 public fun RemoteViews.setTextViewHint(@IdRes viewId: Int, @StringRes resId: Int) { 2286 // Note: TextView.setHint(int) can be used to do this on any API instead of needing the 2287 // setCharSequence method added in API 31. 2288 setInt(viewId, "setHint", resId) 2289 } 2290 2291 /** 2292 * Equivalent to calling [android.widget.TextView.setHint]. 2293 * 2294 * @param viewId The id of the target view 2295 * @param resId A string attribute for the hint. 2296 */ 2297 @RequiresApi(31) 2298 @JvmStatic 2299 public fun RemoteViews.setTextViewHintAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2300 Api31Impl.setCharSequenceAttr(this, viewId, "setHint", resId) 2301 } 2302 2303 /** 2304 * Equivalent to calling [android.widget.TextView.setHintTextColor]. 2305 * 2306 * @param viewId The id of the target view 2307 * @param color The hint text color to use. 2308 */ 2309 @JvmStatic 2310 public fun RemoteViews.setTextViewHintTextColor(@IdRes viewId: Int, @ColorInt color: Int) { 2311 setInt(viewId, "setHintTextColor", color) 2312 } 2313 2314 /** 2315 * Equivalent to calling [android.widget.TextView.setHintTextColor]. 2316 * 2317 * @param viewId The id of the target view 2318 * @param notNight The hint text color to use when night mode is not active. 2319 * @param night The hint text color to use when night mode is active. 2320 */ 2321 @RequiresApi(31) 2322 @JvmStatic 2323 public fun RemoteViews.setTextViewHintTextColor( 2324 @IdRes viewId: Int, 2325 @ColorInt notNight: Int, 2326 @ColorInt night: Int 2327 ) { 2328 Api31Impl.setColorInt(this, viewId, "setHintTextColor", notNight, night) 2329 } 2330 2331 /** 2332 * Equivalent to calling [android.widget.TextView.setHintTextColor]. 2333 * 2334 * @param viewId The id of the target view 2335 * @param resId The resource id for the hint text color. 2336 */ 2337 @RequiresApi(31) 2338 @JvmStatic 2339 public fun RemoteViews.setTextViewHintTextColorResource( 2340 @IdRes viewId: Int, 2341 @ColorRes resId: Int 2342 ) { 2343 Api31Impl.setColor(this, viewId, "setHintTextColor", resId) 2344 } 2345 2346 /** 2347 * Equivalent to calling [android.widget.TextView.setHintTextColor]. 2348 * 2349 * @param viewId The id of the target view 2350 * @param resId The attribute id for the hint text color. 2351 */ 2352 @RequiresApi(31) 2353 @JvmStatic 2354 public fun RemoteViews.setTextViewHintTextColorAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2355 Api31Impl.setColorAttr(this, viewId, "setHintTextColor", resId) 2356 } 2357 2358 /** 2359 * Equivalent to calling [android.widget.TextView.setJustificationMode]. 2360 * 2361 * @param viewId The id of the target view 2362 * @param justificationMode The justification mode to set. 2363 */ 2364 @RequiresApi(31) 2365 @JvmStatic 2366 public fun RemoteViews.setTextViewJustificationMode( 2367 @IdRes viewId: Int, 2368 justificationMode: Int 2369 ) { 2370 requireSdk(31, "setJustificationMode") 2371 setInt(viewId, "setJustificationMode", justificationMode) 2372 } 2373 2374 /** 2375 * Equivalent to calling [android.widget.TextView.setLetterSpacing]. 2376 * 2377 * @param viewId The id of the target view 2378 * @param letterSpacing A text letter-space value in ems. 2379 */ 2380 @RequiresApi(21) 2381 @JvmStatic 2382 public fun RemoteViews.setTextViewLetterSpacing(@IdRes viewId: Int, letterSpacing: Float) { 2383 requireSdk(21, "setLetterSpacing") 2384 setFloat(viewId, "setLetterSpacing", letterSpacing) 2385 } 2386 2387 /** 2388 * Equivalent to calling [android.widget.TextView.setLineHeight]. 2389 * 2390 * @param viewId The id of the target view 2391 * @param value The value of the dimension for the line height. 2392 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2393 */ 2394 @RequiresApi(31) 2395 @JvmStatic 2396 public fun RemoteViews.setTextViewLineHeight(@IdRes viewId: Int, value: Float, unit: Int) { 2397 Api31Impl.setIntDimen(this, viewId, "setLineHeight", value, unit) 2398 } 2399 2400 /** 2401 * Equivalent to calling [android.widget.TextView.setLineHeight]. 2402 * 2403 * @param viewId The id of the target view 2404 * @param resId The id of a dimension resource for the line height. 2405 */ 2406 @RequiresApi(31) 2407 @JvmStatic 2408 public fun RemoteViews.setTextViewLineHeightDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2409 Api31Impl.setIntDimen(this, viewId, "setLineHeight", resId) 2410 } 2411 2412 /** 2413 * Equivalent to calling [android.widget.TextView.setLineHeight]. 2414 * 2415 * @param viewId The id of the target view 2416 * @param resId The id of a dimension attribute for the line height. 2417 */ 2418 @RequiresApi(31) 2419 @JvmStatic 2420 public fun RemoteViews.setTextViewLineHeightDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2421 Api31Impl.setIntDimenAttr(this, viewId, "setLineHeight", resId) 2422 } 2423 2424 /** 2425 * Equivalent to calling [android.widget.TextView.setLines]. 2426 * 2427 * @param viewId The id of the target view 2428 * @param lines The number of lines for the height of the TextView. 2429 */ 2430 @JvmStatic 2431 public fun RemoteViews.setTextViewLines(@IdRes viewId: Int, lines: Int) { 2432 setInt(viewId, "setLines", lines) 2433 } 2434 2435 /** 2436 * Equivalent to calling [android.widget.TextView.setLinkTextColor]. 2437 * 2438 * @param viewId The id of the target view 2439 * @param color The link text color to use. 2440 */ 2441 @JvmStatic 2442 public fun RemoteViews.setTextViewLinkTextColor(@IdRes viewId: Int, @ColorInt color: Int) { 2443 setInt(viewId, "setLinkTextColor", color) 2444 } 2445 2446 /** 2447 * Equivalent to calling [android.widget.TextView.setLinkTextColor]. 2448 * 2449 * @param viewId The id of the target view 2450 * @param notNight The link text color to use when night mode is not active. 2451 * @param night The link text color to use when night mode is active. 2452 */ 2453 @RequiresApi(31) 2454 @JvmStatic 2455 public fun RemoteViews.setTextViewLinkTextColor( 2456 @IdRes viewId: Int, 2457 @ColorInt notNight: Int, 2458 @ColorInt night: Int 2459 ) { 2460 Api31Impl.setColorInt(this, viewId, "setLinkTextColor", notNight, night) 2461 } 2462 2463 /** 2464 * Equivalent to calling [android.widget.TextView.setLinkTextColor]. 2465 * 2466 * @param viewId The id of the target view 2467 * @param resId The resource id for the link text color. 2468 */ 2469 @RequiresApi(31) 2470 @JvmStatic 2471 public fun RemoteViews.setTextViewLinkTextColorResource( 2472 @IdRes viewId: Int, 2473 @ColorRes resId: Int 2474 ) { 2475 Api31Impl.setColor(this, viewId, "setLinkTextColor", resId) 2476 } 2477 2478 /** 2479 * Equivalent to calling [android.widget.TextView.setLinkTextColor]. 2480 * 2481 * @param viewId The id of the target view 2482 * @param resId The attribute id for the link text color. 2483 */ 2484 @RequiresApi(31) 2485 @JvmStatic 2486 public fun RemoteViews.setTextViewLinkTextColorAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2487 Api31Impl.setColorAttr(this, viewId, "setLinkTextColor", resId) 2488 } 2489 2490 /** 2491 * Equivalent to calling [android.widget.TextView.setLinksClickable]. 2492 * 2493 * @param viewId The id of the target view 2494 * @param whether Whether detected links will be clickable (see TextView documentation). 2495 */ 2496 @JvmStatic 2497 public fun RemoteViews.setTextViewLinksClickable(@IdRes viewId: Int, whether: Boolean) { 2498 setBoolean(viewId, "setLinksClickable", whether) 2499 } 2500 2501 /** 2502 * Equivalent to calling [android.widget.TextView.setMaxHeight]. 2503 * 2504 * @param viewId The id of the target view 2505 * @param maxHeight The maximum height of the TextView, in pixels. 2506 */ 2507 @JvmStatic 2508 public fun RemoteViews.setTextViewMaxHeight(@IdRes viewId: Int, @Px maxHeight: Int) { 2509 setInt(viewId, "setMaxHeight", maxHeight) 2510 } 2511 2512 /** 2513 * Equivalent to calling [android.widget.TextView.setMaxHeight]. 2514 * 2515 * @param viewId The id of the target view 2516 * @param value The maximum height of the TextView. 2517 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2518 */ 2519 @RequiresApi(31) 2520 @JvmStatic 2521 public fun RemoteViews.setTextViewMaxHeight(@IdRes viewId: Int, value: Float, unit: Int) { 2522 Api31Impl.setIntDimen(this, viewId, "setMaxHeight", value, unit) 2523 } 2524 2525 /** 2526 * Equivalent to calling [android.widget.TextView.setMaxHeight]. 2527 * 2528 * @param viewId The id of the target view 2529 * @param resId The id of a dimension resource for the maximum height of the TextView. 2530 */ 2531 @RequiresApi(31) 2532 @JvmStatic 2533 public fun RemoteViews.setTextViewMaxHeightDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2534 Api31Impl.setIntDimen(this, viewId, "setMaxHeight", resId) 2535 } 2536 2537 /** 2538 * Equivalent to calling [android.widget.TextView.setMaxHeight]. 2539 * 2540 * @param viewId The id of the target view 2541 * @param resId The id of a dimension attribute for the maximum height of the TextView. 2542 */ 2543 @RequiresApi(31) 2544 @JvmStatic 2545 public fun RemoteViews.setTextViewMaxHeightDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2546 Api31Impl.setIntDimenAttr(this, viewId, "setMaxHeight", resId) 2547 } 2548 2549 /** 2550 * Equivalent to calling [android.widget.TextView.setMaxEms]. 2551 * 2552 * @param viewId The id of the target view 2553 * @param maxems The maximum width of the TextView, in ems. 2554 */ 2555 @JvmStatic 2556 public fun RemoteViews.setTextViewMaxEms(@IdRes viewId: Int, maxems: Int) { 2557 setInt(viewId, "setMaxEms", maxems) 2558 } 2559 2560 /** 2561 * Equivalent to calling [android.widget.TextView.setMaxLines]. 2562 * 2563 * @param viewId The id of the target view 2564 * @param maxLines The maximum number of lines for the height of the TextView. 2565 */ 2566 @JvmStatic 2567 public fun RemoteViews.setTextViewMaxLines(@IdRes viewId: Int, maxLines: Int) { 2568 setInt(viewId, "setMaxLines", maxLines) 2569 } 2570 2571 /** 2572 * Equivalent to calling [android.widget.TextView.setMinEms]. 2573 * 2574 * @param viewId The id of the target view 2575 * @param minems The minimum width of the TextView, in ems. 2576 */ 2577 @JvmStatic 2578 public fun RemoteViews.setTextViewMinEms(@IdRes viewId: Int, minems: Int) { 2579 setInt(viewId, "setMinEms", minems) 2580 } 2581 2582 /** 2583 * Equivalent to calling [android.widget.TextView.setMaxWidth]. 2584 * 2585 * @param viewId The id of the target view 2586 * @param maxWidth The maximum width of the TextView, in pixels. 2587 */ 2588 @JvmStatic 2589 public fun RemoteViews.setTextViewMaxWidth(@IdRes viewId: Int, @Px maxWidth: Int) { 2590 setInt(viewId, "setMaxWidth", maxWidth) 2591 } 2592 2593 /** 2594 * Equivalent to calling [android.widget.TextView.setMaxWidth]. 2595 * 2596 * @param viewId The id of the target view 2597 * @param value The maximum width of the TextView. 2598 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2599 */ 2600 @RequiresApi(31) 2601 @JvmStatic 2602 public fun RemoteViews.setTextViewMaxWidth(@IdRes viewId: Int, value: Float, unit: Int) { 2603 Api31Impl.setIntDimen(this, viewId, "setMaxWidth", value, unit) 2604 } 2605 2606 /** 2607 * Equivalent to calling [android.widget.TextView.setMaxWidth]. 2608 * 2609 * @param viewId The id of the target view 2610 * @param resId The id of a dimension resource for the maximum width of the TextView. 2611 */ 2612 @RequiresApi(31) 2613 @JvmStatic 2614 public fun RemoteViews.setTextViewMaxWidthDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2615 Api31Impl.setIntDimen(this, viewId, "setMaxWidth", resId) 2616 } 2617 2618 /** 2619 * Equivalent to calling [android.widget.TextView.setMaxWidth]. 2620 * 2621 * @param viewId The id of the target view 2622 * @param resId The id of a dimension attribute for the maximum width of the TextView. 2623 */ 2624 @RequiresApi(31) 2625 @JvmStatic 2626 public fun RemoteViews.setTextViewMaxWidthDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2627 Api31Impl.setIntDimenAttr(this, viewId, "setMaxWidth", resId) 2628 } 2629 2630 /** 2631 * Equivalent to calling [android.widget.TextView.setMinHeight]. 2632 * 2633 * @param viewId The id of the target view 2634 * @param minHeight The minimum height of the TextView, in pixels. 2635 */ 2636 @JvmStatic 2637 public fun RemoteViews.setTextViewMinHeight(@IdRes viewId: Int, @Px minHeight: Int) { 2638 setInt(viewId, "setMinHeight", minHeight) 2639 } 2640 2641 /** 2642 * Equivalent to calling [android.widget.TextView.setMinHeight]. 2643 * 2644 * @param viewId The id of the target view 2645 * @param value The minimum height of the TextView. 2646 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2647 */ 2648 @RequiresApi(31) 2649 @JvmStatic 2650 public fun RemoteViews.setTextViewMinHeight(@IdRes viewId: Int, value: Float, unit: Int) { 2651 Api31Impl.setIntDimen(this, viewId, "setMinHeight", value, unit) 2652 } 2653 2654 /** 2655 * Equivalent to calling [android.widget.TextView.setMinHeight]. 2656 * 2657 * @param viewId The id of the target view 2658 * @param resId The id of a dimension resource for the minimum height of the TextView. 2659 */ 2660 @RequiresApi(31) 2661 @JvmStatic 2662 public fun RemoteViews.setTextViewMinHeightDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2663 Api31Impl.setIntDimen(this, viewId, "setMinHeight", resId) 2664 } 2665 2666 /** 2667 * Equivalent to calling [android.widget.TextView.setMinHeight]. 2668 * 2669 * @param viewId The id of the target view 2670 * @param resId The id of a dimension attribute for the minimum height of the TextView. 2671 */ 2672 @RequiresApi(31) 2673 @JvmStatic 2674 public fun RemoteViews.setTextViewMinHeightDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2675 Api31Impl.setIntDimenAttr(this, viewId, "setMinHeight", resId) 2676 } 2677 2678 /** 2679 * Equivalent to calling [android.widget.TextView.setMinLines]. 2680 * 2681 * @param viewId The id of the target view 2682 * @param minLines The minimum number of lines for the height of the TextView. 2683 */ 2684 @JvmStatic 2685 public fun RemoteViews.setTextViewMinLines(@IdRes viewId: Int, minLines: Int) { 2686 setInt(viewId, "setMinLines", minLines) 2687 } 2688 2689 /** 2690 * Equivalent to calling [android.widget.TextView.setMinWidth]. 2691 * 2692 * @param viewId The id of the target view 2693 * @param minWidth The minimum width of the TextView, in pixels. 2694 */ 2695 @JvmStatic 2696 public fun RemoteViews.setTextViewMinWidth(@IdRes viewId: Int, @Px minWidth: Int) { 2697 setInt(viewId, "setMinWidth", minWidth) 2698 } 2699 2700 /** 2701 * Equivalent to calling [android.widget.TextView.setMinWidth]. 2702 * 2703 * @param viewId The id of the target view 2704 * @param value The minimum width of the TextView. 2705 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2706 */ 2707 @RequiresApi(31) 2708 @JvmStatic 2709 public fun RemoteViews.setTextViewMinWidth(@IdRes viewId: Int, value: Float, unit: Int) { 2710 Api31Impl.setIntDimen(this, viewId, "setMinWidth", value, unit) 2711 } 2712 2713 /** 2714 * Equivalent to calling [android.widget.TextView.setMinWidth]. 2715 * 2716 * @param viewId The id of the target view 2717 * @param resId The id of a dimension resource for the minimum width of the TextView. 2718 */ 2719 @RequiresApi(31) 2720 @JvmStatic 2721 public fun RemoteViews.setTextViewMinWidthDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2722 Api31Impl.setIntDimen(this, viewId, "setMinWidth", resId) 2723 } 2724 2725 /** 2726 * Equivalent to calling [android.widget.TextView.setMinWidth]. 2727 * 2728 * @param viewId The id of the target view 2729 * @param resId The id of a dimension attribute for the minimum width of the TextView. 2730 */ 2731 @RequiresApi(31) 2732 @JvmStatic 2733 public fun RemoteViews.setTextViewMinWidthDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2734 Api31Impl.setIntDimenAttr(this, viewId, "setMinWidth", resId) 2735 } 2736 2737 /** 2738 * Equivalent to calling [android.widget.TextView.setPaintFlags]. 2739 * 2740 * @param viewId The id of the target view 2741 * @param flags The flags for the text paint. 2742 */ 2743 @JvmStatic 2744 public fun RemoteViews.setTextViewPaintFlags(@IdRes viewId: Int, flags: Int) { 2745 setInt(viewId, "setPaintFlags", flags) 2746 } 2747 2748 /** 2749 * Equivalent to calling [android.widget.TextView.setSelectAllOnFocus]. 2750 * 2751 * @param viewId The id of the target view 2752 * @param selectAllOnFocus Whether to select all text when the TextView is focused. 2753 */ 2754 @JvmStatic 2755 public fun RemoteViews.setTextViewSelectAllOnFocus( 2756 @IdRes viewId: Int, 2757 selectAllOnFocus: Boolean 2758 ) { 2759 setBoolean(viewId, "setSelectAllOnFocus", selectAllOnFocus) 2760 } 2761 2762 /** 2763 * Equivalent to calling [android.widget.TextView.setSingleLine]. 2764 * 2765 * @param viewId The id of the target view 2766 * @param singleLine Whether the TextView is single-line. 2767 */ 2768 @JvmStatic 2769 public fun RemoteViews.setTextViewSingleLine(@IdRes viewId: Int, singleLine: Boolean) { 2770 setBoolean(viewId, "setSingleLine", singleLine) 2771 } 2772 2773 /** 2774 * Equivalent to calling [android.widget.TextView.setText]. 2775 * 2776 * @param viewId The id of the target view 2777 * @param resId A string resource for the text. 2778 */ 2779 @JvmStatic 2780 public fun RemoteViews.setTextViewText(@IdRes viewId: Int, @StringRes resId: Int) { 2781 // Note: TextView.setText(int) can be used to do this on any API instead of needing the 2782 // setCharSequence method added in API 31. 2783 setInt(viewId, "setText", resId) 2784 } 2785 2786 /** 2787 * Equivalent to calling [android.widget.TextView.setText]. 2788 * 2789 * @param viewId The id of the target view 2790 * @param resId A string attribute for the text. 2791 */ 2792 @RequiresApi(31) 2793 @JvmStatic 2794 public fun RemoteViews.setTextViewTextAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2795 Api31Impl.setCharSequenceAttr(this, viewId, "setText", resId) 2796 } 2797 2798 /** 2799 * Equivalent to calling [android.widget.TextView.setTextColor]. 2800 * 2801 * @param viewId The id of the target view 2802 * @param color The text color to use. 2803 */ 2804 @JvmStatic 2805 public fun RemoteViews.setTextViewTextColor(@IdRes viewId: Int, @ColorInt color: Int) { 2806 setTextColor(viewId, color) 2807 } 2808 2809 /** 2810 * Equivalent to calling [android.widget.TextView.setTextColor]. 2811 * 2812 * @param viewId The id of the target view 2813 * @param colors The text colors to use. 2814 */ 2815 @RequiresApi(31) 2816 @JvmStatic 2817 public fun RemoteViews.setTextViewTextColor(@IdRes viewId: Int, colors: ColorStateList) { 2818 Api31Impl.setColorStateList(this, viewId, "setTextColor", colors) 2819 } 2820 2821 /** 2822 * Equivalent to calling [android.widget.TextView.setTextColor]. 2823 * 2824 * @param viewId The id of the target view 2825 * @param notNight The text colors to use when night mode is not active. 2826 * @param night The text colors to use when night mode is active. 2827 */ 2828 @RequiresApi(31) 2829 @JvmStatic 2830 public fun RemoteViews.setTextViewTextColor( 2831 @IdRes viewId: Int, 2832 notNight: ColorStateList, 2833 night: ColorStateList 2834 ) { 2835 Api31Impl.setColorStateList(this, viewId, "setTextColor", notNight, night) 2836 } 2837 2838 /** 2839 * Equivalent to calling [android.widget.TextView.setTextColor]. 2840 * 2841 * @param viewId The id of the target view 2842 * @param notNight The text color to use when night mode is not active. 2843 * @param night The text color to use when night mode is active. 2844 */ 2845 @RequiresApi(31) 2846 @JvmStatic 2847 public fun RemoteViews.setTextViewTextColor( 2848 @IdRes viewId: Int, 2849 @ColorInt notNight: Int, 2850 @ColorInt night: Int 2851 ) { 2852 Api31Impl.setColorInt(this, viewId, "setTextColor", notNight, night) 2853 } 2854 2855 /** 2856 * Equivalent to calling [android.widget.TextView.setTextColor]. 2857 * 2858 * @param viewId The id of the target view 2859 * @param resId The resource id for the text color. 2860 */ 2861 @RequiresApi(31) 2862 @JvmStatic 2863 public fun RemoteViews.setTextViewTextColorResource(@IdRes viewId: Int, @ColorRes resId: Int) { 2864 // Note: As both setTextColor(int) and setTextColor(ColorStateList) exist, we could cal 2865 // either setColor or setColorStateList. As both methods are valid if the color resource is 2866 // a single color, but only setColorStateList is valid if the resource is a color state 2867 // list, we call setColorStateList and don't provide an alternative wrapper for setColor. 2868 Api31Impl.setColorStateList(this, viewId, "setTextColor", resId) 2869 } 2870 2871 /** 2872 * Equivalent to calling [android.widget.TextView.setTextColor]. 2873 * 2874 * @param viewId The id of the target view 2875 * @param resId The attribute id for the text color. 2876 */ 2877 @RequiresApi(31) 2878 @JvmStatic 2879 public fun RemoteViews.setTextViewTextColorAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2880 // Note: As both setTextColor(int) and setTextColor(ColorStateList) exist, we could call 2881 // either setColorAttr or setColorStateListAttr. As both methods are valid if the color 2882 // attribute is a single color, but only setColorStateList is valid if the attribute is a 2883 // color state list, we call setColorStateList and don't provide an alternative wrapper for 2884 // setColor. 2885 Api31Impl.setColorStateListAttr(this, viewId, "setTextColor", resId) 2886 } 2887 2888 /** 2889 * Equivalent to calling [android.widget.TextView.setTextScaleX]. 2890 * 2891 * @param viewId The id of the target view 2892 * @param size The horizontal scale factor. 2893 */ 2894 @JvmStatic 2895 public fun RemoteViews.setTextViewTextScaleX(@IdRes viewId: Int, size: Float) { 2896 setFloat(viewId, "setTextScaleX", size) 2897 } 2898 2899 /** 2900 * Equivalent to calling [android.widget.TextView.setTextSize]. 2901 * 2902 * @param viewId The id of the target view 2903 * @param resId The id of a dimension resource for the text size. 2904 */ 2905 @RequiresApi(31) 2906 @JvmStatic 2907 public fun RemoteViews.setTextViewTextSizeDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2908 Api31Impl.setIntDimen(this, viewId, "setTextSize", resId) 2909 } 2910 2911 /** 2912 * Equivalent to calling [android.widget.TextView.setTextSize]. 2913 * 2914 * @param viewId The id of the target view 2915 * @param resId The id of a dimension attribute for the text size. 2916 */ 2917 @RequiresApi(31) 2918 @JvmStatic 2919 public fun RemoteViews.setTextViewTextSizeDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2920 Api31Impl.setIntDimenAttr(this, viewId, "setTextSize", resId) 2921 } 2922 2923 /** 2924 * Equivalent to calling [android.widget.TextView.setWidth]. 2925 * 2926 * @param viewId The id of the target view 2927 * @param pixels The width of the TextView, in pixels. 2928 */ 2929 @JvmStatic 2930 public fun RemoteViews.setTextViewWidth(@IdRes viewId: Int, @Px pixels: Int) { 2931 setInt(viewId, "setWidth", pixels) 2932 } 2933 2934 /** 2935 * Equivalent to calling [android.widget.TextView.setWidth]. 2936 * 2937 * @param viewId The id of the target view 2938 * @param value The width of the TextView. 2939 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 2940 */ 2941 @RequiresApi(31) 2942 @JvmStatic 2943 public fun RemoteViews.setTextViewWidth(@IdRes viewId: Int, value: Float, unit: Int) { 2944 Api31Impl.setIntDimen(this, viewId, "setWidth", value, unit) 2945 } 2946 2947 /** 2948 * Equivalent to calling [android.widget.TextView.setWidth]. 2949 * 2950 * @param viewId The id of the target view 2951 * @param resId The id of a dimension resource for the width of the TextView. 2952 */ 2953 @RequiresApi(31) 2954 @JvmStatic 2955 public fun RemoteViews.setTextViewWidthDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 2956 Api31Impl.setIntDimen(this, viewId, "setWidth", resId) 2957 } 2958 2959 /** 2960 * Equivalent to calling [android.widget.TextView.setWidth]. 2961 * 2962 * @param viewId The id of the target view 2963 * @param resId The id of a dimension attribute for the width of the TextView. 2964 */ 2965 @RequiresApi(31) 2966 @JvmStatic 2967 public fun RemoteViews.setTextViewWidthDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 2968 Api31Impl.setIntDimenAttr(this, viewId, "setWidth", resId) 2969 } 2970 2971 /** 2972 * Equivalent to calling [android.view.View.setAlpha]. 2973 * 2974 * @param viewId The id of the target view 2975 * @param alpha The opacity of the view. 2976 */ 2977 @RequiresApi(31) 2978 @JvmStatic 2979 public fun RemoteViews.setViewAlpha(@IdRes viewId: Int, alpha: Float) { 2980 requireSdk(31, "setAlpha") 2981 setFloat(viewId, "setAlpha", alpha) 2982 } 2983 2984 /** 2985 * Equivalent to calling [android.view.View.setBackgroundColor]. 2986 * 2987 * @param viewId The id of the target view 2988 * @param color The color of the background. 2989 */ 2990 @JvmStatic 2991 public fun RemoteViews.setViewBackgroundColor(@IdRes viewId: Int, @ColorInt color: Int) { 2992 setInt(viewId, "setBackgroundColor", color) 2993 } 2994 2995 /** 2996 * Equivalent to calling [android.view.View.setBackgroundColor]. 2997 * 2998 * @param viewId The id of the target view 2999 * @param notNight The color of the background when night mode is not active. 3000 * @param night The color of the background when night mode is active. 3001 */ 3002 @RequiresApi(31) 3003 @JvmStatic 3004 public fun RemoteViews.setViewBackgroundColor( 3005 @IdRes viewId: Int, 3006 @ColorInt notNight: Int, 3007 @ColorInt night: Int 3008 ) { 3009 Api31Impl.setColorInt(this, viewId, "setBackgroundColor", notNight, night) 3010 } 3011 3012 /** 3013 * Equivalent to calling [android.view.View.setBackgroundColor]. 3014 * 3015 * @param viewId The id of the target view 3016 * @param resId A color resource for the background. 3017 */ 3018 @JvmStatic 3019 public fun RemoteViews.setViewBackgroundColorResource( 3020 @IdRes viewId: Int, 3021 @ColorRes resId: Int 3022 ) { 3023 if (Build.VERSION.SDK_INT >= 31) { 3024 Api31Impl.setColor(this, viewId, "setBackgroundColor", resId) 3025 } else { 3026 // It's valid to pass @ColorRes to Context.getDrawable, it will return a ColorDrawable. 3027 setInt(viewId, "setBackgroundResource", resId) 3028 } 3029 } 3030 3031 /** 3032 * Equivalent to calling [android.view.View.setBackgroundColor]. 3033 * 3034 * @param viewId The id of the target view 3035 * @param resId A color attribute for the background. 3036 */ 3037 @RequiresApi(31) 3038 @JvmStatic 3039 public fun RemoteViews.setViewBackgroundColorAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3040 Api31Impl.setColorAttr(this, viewId, "setBackgroundColor", resId) 3041 } 3042 3043 /** 3044 * Equivalent to calling [android.view.View.setBackgroundResource]. 3045 * 3046 * @param viewId The id of the target view 3047 * @param resId The identifier of the resource, or 0 to remove the background. 3048 */ 3049 @JvmStatic 3050 public fun RemoteViews.setViewBackgroundResource(@IdRes viewId: Int, @DrawableRes resId: Int) { 3051 setInt(viewId, "setBackgroundResource", resId) 3052 } 3053 3054 /** 3055 * Equivalent to calling [android.view.View.setBackgroundTintList]. 3056 * 3057 * @param viewId The id of the target view 3058 * @param blendMode The blending mode used to apply the tint, may be null to clear. 3059 */ 3060 @RequiresApi(31) 3061 @JvmStatic 3062 public fun RemoteViews.setViewBackgroundTintBlendMode( 3063 @IdRes viewId: Int, 3064 blendMode: BlendMode? 3065 ) { 3066 Api31Impl.setBlendMode(this, viewId, "setBackgroundTintBlendMode", blendMode) 3067 } 3068 3069 /** 3070 * Equivalent to calling [android.view.View.setBackgroundTintList]. 3071 * 3072 * @param viewId The id of the target view 3073 * @param tint The tint to apply, may be null to clear tint 3074 */ 3075 @RequiresApi(31) 3076 @JvmStatic 3077 public fun RemoteViews.setViewBackgroundTintList(@IdRes viewId: Int, tint: ColorStateList?) { 3078 Api31Impl.setColorStateList(this, viewId, "setBackgroundTintList", tint) 3079 } 3080 3081 /** 3082 * Equivalent to calling [android.view.View.setBackgroundTintList]. 3083 * 3084 * @param viewId The id of the target view 3085 * @param notNightTint The tint to apply when the UI is not in night mode. 3086 * @param nightTint The tint to apply when the UI is in night mode. 3087 */ 3088 @RequiresApi(31) 3089 @JvmStatic 3090 public fun RemoteViews.setViewBackgroundTintList( 3091 @IdRes viewId: Int, 3092 notNightTint: ColorStateList?, 3093 nightTint: ColorStateList? 3094 ) { 3095 Api31Impl.setColorStateList(this, viewId, "setBackgroundTintList", notNightTint, nightTint) 3096 } 3097 3098 /** 3099 * Equivalent to calling [android.view.View.setBackgroundTintList]. 3100 * 3101 * @param viewId The id of the target view 3102 * @param resId The resource id of the tint to apply. 3103 */ 3104 @RequiresApi(31) 3105 @JvmStatic 3106 public fun RemoteViews.setViewBackgroundTintList(@IdRes viewId: Int, @ColorRes resId: Int) { 3107 Api31Impl.setColorStateList(this, viewId, "setBackgroundTintList", resId) 3108 } 3109 3110 /** 3111 * Equivalent to calling [android.view.View.setBackgroundTintList]. 3112 * 3113 * @param viewId The id of the target view 3114 * @param resId The attribute of the tint to apply. 3115 */ 3116 @RequiresApi(31) 3117 @JvmStatic 3118 public fun RemoteViews.setViewBackgroundTintListAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3119 Api31Impl.setColorStateListAttr(this, viewId, "setBackgroundTintList", resId) 3120 } 3121 3122 /** 3123 * Equivalent to calling [android.view.View.setClipToOutline]. 3124 * 3125 * @param viewId The id of the target view 3126 * @param clipToOutline Whether the View's Outline should be used to clip the contents of the 3127 * View. 3128 */ 3129 @RequiresApi(31) 3130 @JvmStatic 3131 public fun RemoteViews.setViewClipToOutline(@IdRes viewId: Int, clipToOutline: Boolean) { 3132 requireSdk(31, "setClipToOutline") 3133 setBoolean(viewId, "setClipToOutline", clipToOutline) 3134 } 3135 3136 /** 3137 * Equivalent to calling [android.view.View.setContentDescription]. 3138 * 3139 * @param viewId The id of the target view 3140 * @param contentDescription The content description. 3141 */ 3142 @JvmStatic 3143 public fun RemoteViews.setViewContentDescription( 3144 @IdRes viewId: Int, 3145 contentDescription: CharSequence? 3146 ) { 3147 setCharSequence(viewId, "setContentDescription", contentDescription) 3148 } 3149 3150 /** 3151 * Equivalent to calling [android.view.View.setContentDescription]. 3152 * 3153 * @param viewId The id of the target view 3154 * @param resId The resource id for the content description. 3155 */ 3156 @RequiresApi(31) 3157 @JvmStatic 3158 public fun RemoteViews.setViewContentDescription(@IdRes viewId: Int, @StringRes resId: Int) { 3159 Api31Impl.setCharSequence(this, viewId, "setContentDescription", resId) 3160 } 3161 3162 /** 3163 * Equivalent to calling [android.view.View.setContentDescription]. 3164 * 3165 * @param viewId The id of the target view 3166 * @param resId The attribute id for the content description. 3167 */ 3168 @RequiresApi(31) 3169 @JvmStatic 3170 public fun RemoteViews.setViewContentDescriptionAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3171 Api31Impl.setCharSequenceAttr(this, viewId, "setContentDescription", resId) 3172 } 3173 3174 /** 3175 * Equivalent to calling [android.view.View.setElevation]. 3176 * 3177 * @param viewId The id of the target view 3178 * @param value The base elevation of this view. 3179 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 3180 */ 3181 @RequiresApi(31) 3182 @JvmStatic 3183 public fun RemoteViews.setViewElevationDimen(@IdRes viewId: Int, value: Float, unit: Int) { 3184 Api31Impl.setFloatDimen(this, viewId, "setElevation", value, unit) 3185 } 3186 3187 /** 3188 * Equivalent to calling [android.view.View.setElevation]. 3189 * 3190 * @param viewId The id of the target view 3191 * @param resId The id of a dimension resource for the base elevation of this view. 3192 */ 3193 @RequiresApi(31) 3194 @JvmStatic 3195 public fun RemoteViews.setViewElevationDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 3196 Api31Impl.setFloatDimen(this, viewId, "setElevation", resId) 3197 } 3198 3199 /** 3200 * Equivalent to calling [android.view.View.setElevation]. 3201 * 3202 * @param viewId The id of the target view 3203 * @param resId The id of a dimension attribute for the base elevation of this view. 3204 */ 3205 @RequiresApi(31) 3206 @JvmStatic 3207 public fun RemoteViews.setViewElevationDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3208 Api31Impl.setFloatDimenAttr(this, viewId, "setElevation", resId) 3209 } 3210 3211 /** 3212 * Equivalent to calling [android.view.View.setEnabled]. 3213 * 3214 * Note: setEnabled can only be called on TextView and its descendants from API 24, but is safe 3215 * to call on other Views on older SDKs using [RemoteViews.setBoolean] directly. 3216 * 3217 * @param viewId The id of the target view 3218 * @param enabled True if this view is enabled, false otherwise. 3219 */ 3220 @RequiresApi(24) 3221 @JvmStatic 3222 public fun RemoteViews.setViewEnabled(@IdRes viewId: Int, enabled: Boolean) { 3223 setBoolean(viewId, "setEnabled", enabled) 3224 } 3225 3226 /** 3227 * Equivalent to calling [android.view.View.setFocusable]. 3228 * 3229 * @param viewId The id of the target view 3230 * @param focusable If true, this view can receive the focus. 3231 */ 3232 @RequiresApi(31) 3233 @JvmStatic 3234 public fun RemoteViews.setViewFocusable(@IdRes viewId: Int, focusable: Boolean) { 3235 requireSdk(31, "setFocusable") 3236 setBoolean(viewId, "setFocusable", focusable) 3237 } 3238 3239 /** 3240 * Equivalent to calling [android.view.View.setFocusable]. 3241 * 3242 * @param viewId The id of the target view 3243 * @param focusable One of [android.view.View.NOT_FOCUSABLE], [android.view.View.FOCUSABLE], or 3244 * [android.view.View.FOCUSABLE_AUTO]. 3245 */ 3246 @RequiresApi(31) 3247 @JvmStatic 3248 public fun RemoteViews.setViewFocusable(@IdRes viewId: Int, focusable: Int) { 3249 requireSdk(31, "setFocusable") 3250 setInt(viewId, "setFocusable", focusable) 3251 } 3252 3253 /** 3254 * Equivalent to calling [android.view.View.setFocusedByDefault]. 3255 * 3256 * @param viewId The id of the target view 3257 * @param isFocusedByDefault true to set this view as the default-focus view, false otherwise. 3258 */ 3259 @RequiresApi(31) 3260 @JvmStatic 3261 public fun RemoteViews.setViewFocusedByDefault( 3262 @IdRes viewId: Int, 3263 isFocusedByDefault: Boolean 3264 ) { 3265 requireSdk(31, "setFocusedByDefault") 3266 setBoolean(viewId, "setFocusedByDefault", isFocusedByDefault) 3267 } 3268 3269 /** 3270 * Equivalent to calling [android.view.View.setFocusableInTouchMode]. 3271 * 3272 * @param viewId The id of the target view 3273 * @param focusableInTouchMode If true, this view can receive the focus while in touch mode. 3274 */ 3275 @RequiresApi(31) 3276 @JvmStatic 3277 public fun RemoteViews.setViewFocusableInTouchMode( 3278 @IdRes viewId: Int, 3279 focusableInTouchMode: Boolean 3280 ) { 3281 requireSdk(31, "setFocusableInTouchMode") 3282 setBoolean(viewId, "setFocusableInTouchMode", focusableInTouchMode) 3283 } 3284 3285 /** 3286 * Equivalent to calling [android.view.View.setForegroundTintBlendMode]. 3287 * 3288 * @param viewId The id of the target view 3289 * @param blendMode The blending mode used to apply the tint, may be null to clear. 3290 */ 3291 @RequiresApi(31) 3292 @JvmStatic 3293 public fun RemoteViews.setViewForegroundTintBlendMode( 3294 @IdRes viewId: Int, 3295 blendMode: BlendMode? 3296 ) { 3297 Api31Impl.setBlendMode(this, viewId, "setForegroundTintBlendMode", blendMode) 3298 } 3299 3300 /** 3301 * Equivalent to calling [android.view.View.setForegroundTintList]. 3302 * 3303 * @param viewId The id of the target view 3304 * @param tint The tint to apply, may be null to clear tint 3305 */ 3306 @RequiresApi(31) 3307 @JvmStatic 3308 public fun RemoteViews.setViewForegroundTintList(@IdRes viewId: Int, tint: ColorStateList?) { 3309 Api31Impl.setColorStateList(this, viewId, "setForegroundTintList", tint) 3310 } 3311 3312 /** 3313 * Equivalent to calling [android.view.View.setForegroundTintList]. 3314 * 3315 * @param viewId The id of the target view 3316 * @param notNightTint The tint to apply when the UI is not in night mode. 3317 * @param nightTint The tint to apply when the UI is in night mode. 3318 */ 3319 @RequiresApi(31) 3320 @JvmStatic 3321 public fun RemoteViews.setViewForegroundTintList( 3322 @IdRes viewId: Int, 3323 notNightTint: ColorStateList?, 3324 nightTint: ColorStateList? 3325 ) { 3326 Api31Impl.setColorStateList(this, viewId, "setForegroundTintList", notNightTint, nightTint) 3327 } 3328 3329 /** 3330 * Equivalent to calling [android.view.View.setForegroundTintList]. 3331 * 3332 * @param viewId The id of the target view 3333 * @param resId The resource id of the tint to apply. 3334 */ 3335 @RequiresApi(31) 3336 @JvmStatic 3337 public fun RemoteViews.setViewForegroundTintList(@IdRes viewId: Int, @ColorRes resId: Int) { 3338 Api31Impl.setColorStateList(this, viewId, "setForegroundTintList", resId) 3339 } 3340 3341 /** 3342 * Equivalent to calling [android.view.View.setForegroundTintList]. 3343 * 3344 * @param viewId The id of the target view 3345 * @param resId The attribute of the tint to apply. 3346 */ 3347 @RequiresApi(31) 3348 @JvmStatic 3349 public fun RemoteViews.setViewForegroundTintListAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3350 Api31Impl.setColorStateListAttr(this, viewId, "setForegroundTintList", resId) 3351 } 3352 3353 /** 3354 * Equivalent to calling [android.view.View.setLayoutDirection]. 3355 * 3356 * @param viewId The id of the target view 3357 * @param layoutDirection One of [android.view.View.LAYOUT_DIRECTION_LTR], 3358 * [android.view.View.LAYOUT_DIRECTION_RTL], [android.view.View.LAYOUT_DIRECTION_INHERIT], or 3359 * [android.view.View.LAYOUT_DIRECTION_LOCALE]. 3360 */ 3361 @JvmStatic 3362 public fun RemoteViews.setViewLayoutDirection(@IdRes viewId: Int, layoutDirection: Int) { 3363 requireSdk(17, "setLayoutDirection") 3364 setInt(viewId, "setLayoutDirection", layoutDirection) 3365 } 3366 3367 /** 3368 * Equivalent to calling [android.view.View.setMinimumHeight]. 3369 * 3370 * @param viewId The id of the target view 3371 * @param minHeight The minimum height the view will try to be, in pixels. 3372 */ 3373 @RequiresApi(24) 3374 @JvmStatic 3375 public fun RemoteViews.setViewMinimumHeight(@IdRes viewId: Int, @Px minHeight: Int) { 3376 requireSdk(24, "setMinimumHeight") 3377 setInt(viewId, "setMinimumHeight", minHeight) 3378 } 3379 3380 /** 3381 * Equivalent to calling [android.widget.TextView.setMinimumHeight]. 3382 * 3383 * @param viewId The id of the target view 3384 * @param value The minimum height the view will try to be. 3385 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 3386 */ 3387 @RequiresApi(31) 3388 @JvmStatic 3389 public fun RemoteViews.setViewMinimumHeight(@IdRes viewId: Int, value: Float, unit: Int) { 3390 Api31Impl.setIntDimen(this, viewId, "setMinimumHeight", value, unit) 3391 } 3392 3393 /** 3394 * Equivalent to calling [android.view.View.setMinimumHeight]. 3395 * 3396 * @param viewId The id of the target view 3397 * @param resId The id of a dimension resource for the minimum height the view will try to be. 3398 */ 3399 @RequiresApi(31) 3400 @JvmStatic 3401 public fun RemoteViews.setViewMinimumHeightDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 3402 Api31Impl.setIntDimen(this, viewId, "setMinimumHeight", resId) 3403 } 3404 3405 /** 3406 * Equivalent to calling [android.view.View.setMinimumHeight]. 3407 * 3408 * @param viewId The id of the target view 3409 * @param resId The id of a dimension attribute for the minimum height the view will try to be. 3410 */ 3411 @RequiresApi(31) 3412 @JvmStatic 3413 public fun RemoteViews.setViewMinimumHeightDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3414 Api31Impl.setIntDimenAttr(this, viewId, "setMinimumHeight", resId) 3415 } 3416 3417 /** 3418 * Equivalent to calling [android.widget.TextView.setMinimumWidth]. 3419 * 3420 * @param viewId The id of the target view 3421 * @param value The minimum width the view will try to be. 3422 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 3423 */ 3424 @RequiresApi(31) 3425 @JvmStatic 3426 public fun RemoteViews.setViewMinimumWidth(@IdRes viewId: Int, value: Float, unit: Int) { 3427 Api31Impl.setIntDimen(this, viewId, "setMinimumWidth", value, unit) 3428 } 3429 3430 /** 3431 * Equivalent to calling [android.view.View.setMinimumWidth]. 3432 * 3433 * @param viewId The id of the target view 3434 * @param resId The id of a dimension resource for the minimum width the view will try to be. 3435 */ 3436 @RequiresApi(31) 3437 @JvmStatic 3438 public fun RemoteViews.setViewMinimumWidthDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 3439 Api31Impl.setIntDimen(this, viewId, "setMinimumWidth", resId) 3440 } 3441 3442 /** 3443 * Equivalent to calling [android.view.View.setMinimumWidth]. 3444 * 3445 * @param viewId The id of the target view 3446 * @param resId The id of a dimension attribute for the minimum width the view will try to be. 3447 */ 3448 @RequiresApi(31) 3449 @JvmStatic 3450 public fun RemoteViews.setViewMinimumWidthDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3451 Api31Impl.setIntDimenAttr(this, viewId, "setMinimumWidth", resId) 3452 } 3453 3454 /** 3455 * Equivalent to calling [android.view.View.setPivotX]. 3456 * 3457 * @param viewId The id of the target view 3458 * @param pivotX The x location of the pivot point. 3459 */ 3460 @RequiresApi(31) 3461 @JvmStatic 3462 public fun RemoteViews.setViewPivotX(@IdRes viewId: Int, pivotX: Float) { 3463 requireSdk(31, "setPivotX") 3464 setFloat(viewId, "setPivotX", pivotX) 3465 } 3466 3467 /** 3468 * Equivalent to calling [android.view.View.setPivotY]. 3469 * 3470 * @param viewId The id of the target view 3471 * @param pivotY The y location of the pivot point. 3472 */ 3473 @RequiresApi(31) 3474 @JvmStatic 3475 public fun RemoteViews.setViewPivotY(@IdRes viewId: Int, pivotY: Float) { 3476 requireSdk(31, "setPivotY") 3477 setFloat(viewId, "setPivotY", pivotY) 3478 } 3479 3480 /** 3481 * Equivalent to calling [android.view.View.setRotation]. 3482 * 3483 * @param viewId The id of the target view 3484 * @param rotation The degrees of rotation. 3485 */ 3486 @RequiresApi(31) 3487 @JvmStatic 3488 public fun RemoteViews.setViewRotation(@IdRes viewId: Int, rotation: Float) { 3489 requireSdk(31, "setRotation") 3490 setFloat(viewId, "setRotation", rotation) 3491 } 3492 3493 /** 3494 * Equivalent to calling [android.view.View.setRotationX]. 3495 * 3496 * @param viewId The id of the target view 3497 * @param rotationX The degrees of X rotation. 3498 */ 3499 @RequiresApi(31) 3500 @JvmStatic 3501 public fun RemoteViews.setViewRotationX(@IdRes viewId: Int, rotationX: Float) { 3502 requireSdk(31, "setRotationX") 3503 setFloat(viewId, "setRotationX", rotationX) 3504 } 3505 3506 /** 3507 * Equivalent to calling [android.view.View.setRotationY]. 3508 * 3509 * @param viewId The id of the target view 3510 * @param rotationY The degrees of Y rotation. 3511 */ 3512 @RequiresApi(31) 3513 @JvmStatic 3514 public fun RemoteViews.setViewRotationY(@IdRes viewId: Int, rotationY: Float) { 3515 requireSdk(31, "setRotationY") 3516 setFloat(viewId, "setRotationY", rotationY) 3517 } 3518 3519 /** 3520 * Equivalent to calling [android.view.View.setScaleX]. 3521 * 3522 * @param viewId The id of the target view 3523 * @param scaleX The scaling factor. 3524 */ 3525 @RequiresApi(31) 3526 @JvmStatic 3527 public fun RemoteViews.setViewScaleX(@IdRes viewId: Int, scaleX: Float) { 3528 requireSdk(31, "setScaleX") 3529 setFloat(viewId, "setScaleX", scaleX) 3530 } 3531 3532 /** 3533 * Equivalent to calling [android.view.View.setScaleY]. 3534 * 3535 * @param viewId The id of the target view 3536 * @param scaleY The scaling factor. 3537 */ 3538 @RequiresApi(31) 3539 @JvmStatic 3540 public fun RemoteViews.setViewScaleY(@IdRes viewId: Int, scaleY: Float) { 3541 requireSdk(31, "setScaleY") 3542 setFloat(viewId, "setScaleY", scaleY) 3543 } 3544 3545 /** 3546 * Equivalent to calling [android.view.View.setScrollIndicators]. 3547 * 3548 * @param viewId The id of the target view 3549 * @param scrollIndicators A bitmask of indicators that should be enabled, or 0 to disable all 3550 * indicators. 3551 */ 3552 @RequiresApi(31) 3553 @JvmStatic 3554 public fun RemoteViews.setViewScrollIndicators(@IdRes viewId: Int, scrollIndicators: Int) { 3555 requireSdk(31, "setScrollIndicators") 3556 setInt(viewId, "setScrollIndicators", scrollIndicators) 3557 } 3558 3559 /** 3560 * Equivalent to calling [android.view.View.setStateDescription]. 3561 * 3562 * @param viewId The id of the target view 3563 * @param stateDescription The state description. 3564 */ 3565 @RequiresApi(30) 3566 @JvmStatic 3567 public fun RemoteViews.setViewStateDescription( 3568 @IdRes viewId: Int, 3569 stateDescription: CharSequence? 3570 ) { 3571 requireSdk(30, "setStateDescription") 3572 setCharSequence(viewId, "setStateDescription", stateDescription) 3573 } 3574 3575 /** 3576 * Equivalent to calling [android.view.View.setStateDescription]. 3577 * 3578 * @param viewId The id of the target view 3579 * @param resId The resource id for the state description. 3580 */ 3581 @RequiresApi(31) 3582 @JvmStatic 3583 public fun RemoteViews.setViewStateDescription(@IdRes viewId: Int, @StringRes resId: Int) { 3584 Api31Impl.setCharSequence(this, viewId, "setStateDescription", resId) 3585 } 3586 3587 /** 3588 * Equivalent to calling [android.view.View.setStateDescription]. 3589 * 3590 * @param viewId The id of the target view 3591 * @param resId The attribute id for the state description. 3592 */ 3593 @RequiresApi(31) 3594 @JvmStatic 3595 public fun RemoteViews.setViewStateDescriptionAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3596 Api31Impl.setCharSequenceAttr(this, viewId, "setStateDescription", resId) 3597 } 3598 3599 /** 3600 * Equivalent to calling [android.view.ViewStub.setInflatedId]. 3601 * 3602 * Note that ViewStub may be used in RemoteViews layouts as of API 16. 3603 * 3604 * @param viewId The id of the target view 3605 * @param inflatedId A positive integer used to identify the inflated view or 3606 * [android.view.View.NO_ID] if the inflated view should keep its id. 3607 */ 3608 @JvmStatic 3609 public fun RemoteViews.setViewStubInflatedId(@IdRes viewId: Int, inflatedId: Int) { 3610 requireSdk(16, "setInflatedId") 3611 setInt(viewId, "setInflatedId", inflatedId) 3612 } 3613 3614 /** 3615 * Equivalent to calling [android.view.ViewStub.setLayoutResource]. 3616 * 3617 * Note that ViewStub may be used in RemoteViews layouts as of API 16. 3618 * 3619 * @param viewId The id of the target view 3620 * @param layoutResource A valid layout resource identifier (different from 0). 3621 */ 3622 @JvmStatic 3623 public fun RemoteViews.setViewStubLayoutResource( 3624 @IdRes viewId: Int, 3625 @LayoutRes layoutResource: Int 3626 ) { 3627 requireSdk(16, "setLayoutResource") 3628 setInt(viewId, "setLayoutResource", layoutResource) 3629 } 3630 3631 /** 3632 * Equivalent to calling [android.widget.TextView.setTranslationX]. 3633 * 3634 * @param viewId The id of the target view 3635 * @param value The horizontal position of this view relative to its left position. 3636 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 3637 */ 3638 @RequiresApi(31) 3639 @JvmStatic 3640 public fun RemoteViews.setViewTranslationXDimen(@IdRes viewId: Int, value: Float, unit: Int) { 3641 Api31Impl.setFloatDimen(this, viewId, "setTranslationX", value, unit) 3642 } 3643 3644 /** 3645 * Equivalent to calling [android.view.View.setTranslationX]. 3646 * 3647 * @param viewId The id of the target view 3648 * @param resId The id of a dimension resource for the horizontal position of this view relative 3649 * to its left position. 3650 */ 3651 @RequiresApi(31) 3652 @JvmStatic 3653 public fun RemoteViews.setViewTranslationXDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 3654 Api31Impl.setFloatDimen(this, viewId, "setTranslationX", resId) 3655 } 3656 3657 /** 3658 * Equivalent to calling [android.view.View.setTranslationX]. 3659 * 3660 * @param viewId The id of the target view 3661 * @param resId The id of a dimension attribute for the horizontal position of this view 3662 * relative to its left position. 3663 */ 3664 @RequiresApi(31) 3665 @JvmStatic 3666 public fun RemoteViews.setViewTranslationXDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3667 Api31Impl.setFloatDimenAttr(this, viewId, "setTranslationX", resId) 3668 } 3669 3670 /** 3671 * Equivalent to calling [android.widget.TextView.setTranslationY]. 3672 * 3673 * @param viewId The id of the target view 3674 * @param value The vertical position of this view relative to its top position. 3675 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 3676 */ 3677 @RequiresApi(31) 3678 @JvmStatic 3679 public fun RemoteViews.setViewTranslationYDimen(@IdRes viewId: Int, value: Float, unit: Int) { 3680 Api31Impl.setFloatDimen(this, viewId, "setTranslationY", value, unit) 3681 } 3682 3683 /** 3684 * Equivalent to calling [android.view.View.setTranslationY]. 3685 * 3686 * @param viewId The id of the target view 3687 * @param resId The id of a dimension resource for the vertical position of this view relative 3688 * to its top position. 3689 */ 3690 @RequiresApi(31) 3691 @JvmStatic 3692 public fun RemoteViews.setViewTranslationYDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 3693 Api31Impl.setFloatDimen(this, viewId, "setTranslationY", resId) 3694 } 3695 3696 /** 3697 * Equivalent to calling [android.view.View.setTranslationY]. 3698 * 3699 * @param viewId The id of the target view 3700 * @param resId The id of a dimension attribute for the vertical position of this view relative 3701 * to its top position. 3702 */ 3703 @RequiresApi(31) 3704 @JvmStatic 3705 public fun RemoteViews.setViewTranslationYDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3706 Api31Impl.setFloatDimenAttr(this, viewId, "setTranslationY", resId) 3707 } 3708 3709 /** 3710 * Equivalent to calling [android.widget.TextView.setTranslationZ]. 3711 * 3712 * @param viewId The id of the target view 3713 * @param value The depth of this view relative to its elevation. 3714 * @param unit The unit for [value], e.g. [android.util.TypedValue.COMPLEX_UNIT_DIP]. 3715 */ 3716 @RequiresApi(31) 3717 @JvmStatic 3718 public fun RemoteViews.setViewTranslationZDimen(@IdRes viewId: Int, value: Float, unit: Int) { 3719 Api31Impl.setFloatDimen(this, viewId, "setTranslationZ", value, unit) 3720 } 3721 3722 /** 3723 * Equivalent to calling [android.view.View.setTranslationZ]. 3724 * 3725 * @param viewId The id of the target view 3726 * @param resId The id of a dimension resource for the depth of this view relative to its 3727 * elevation. 3728 */ 3729 @RequiresApi(31) 3730 @JvmStatic 3731 public fun RemoteViews.setViewTranslationZDimen(@IdRes viewId: Int, @DimenRes resId: Int) { 3732 Api31Impl.setFloatDimen(this, viewId, "setTranslationZ", resId) 3733 } 3734 3735 /** 3736 * Equivalent to calling [android.view.View.setTranslationZ]. 3737 * 3738 * @param viewId The id of the target view 3739 * @param resId The id of a dimension attribute for the depth of this view relative to its 3740 * elevation. 3741 */ 3742 @RequiresApi(31) 3743 @JvmStatic 3744 public fun RemoteViews.setViewTranslationZDimenAttr(@IdRes viewId: Int, @AttrRes resId: Int) { 3745 Api31Impl.setFloatDimenAttr(this, viewId, "setTranslationZ", resId) 3746 } 3747 3748 /** 3749 * Requires that the sdk is at least [minSdk] and throws with a helpful error message if it's 3750 * not. This will only occur if the user has ignored the @RequiresApi lint. This is used to 3751 * catch issues where the target method is not annotated with @RemotableViewMethod on the sdk, 3752 * but where the RemoteViews.set* method is available. If the RemoteViews.set* method is 3753 * unavailable, this function is unncessary since that call will fail. 3754 */ 3755 private fun requireSdk(minSdk: Int, method: String) { 3756 require(Build.VERSION.SDK_INT >= minSdk) { 3757 "$method is only available on SDK $minSdk and higher" 3758 } 3759 } 3760 3761 @RequiresApi(23) 3762 private object Api23Impl { 3763 @JvmStatic 3764 fun setIcon(rv: RemoteViews, @IdRes id: Int, method: String, icon: Icon?) { 3765 rv.setIcon(id, method, icon) 3766 } 3767 } 3768 3769 @RequiresApi(31) 3770 private object Api31Impl { 3771 @JvmStatic 3772 fun setBlendMode(rv: RemoteViews, @IdRes id: Int, method: String, mode: BlendMode?) { 3773 rv.setBlendMode(id, method, mode) 3774 } 3775 3776 @JvmStatic 3777 fun setCharSequence( 3778 rv: RemoteViews, 3779 @IdRes id: Int, 3780 method: String, 3781 @StringRes resId: Int 3782 ) { 3783 rv.setCharSequence(id, method, resId) 3784 } 3785 3786 @JvmStatic 3787 fun setCharSequenceAttr( 3788 rv: RemoteViews, 3789 @IdRes id: Int, 3790 method: String, 3791 @AttrRes resId: Int 3792 ) { 3793 rv.setCharSequenceAttr(id, method, resId) 3794 } 3795 3796 @JvmStatic 3797 fun setColor(rv: RemoteViews, @IdRes id: Int, method: String, @ColorRes resId: Int) { 3798 rv.setColor(id, method, resId) 3799 } 3800 3801 @JvmStatic 3802 fun setColorAttr(rv: RemoteViews, @IdRes id: Int, method: String, @AttrRes resId: Int) { 3803 rv.setColorAttr(id, method, resId) 3804 } 3805 3806 @JvmStatic 3807 fun setColorInt( 3808 rv: RemoteViews, 3809 @IdRes id: Int, 3810 method: String, 3811 @ColorInt notNight: Int, 3812 @ColorInt night: Int 3813 ) { 3814 rv.setColorInt(id, method, notNight, night) 3815 } 3816 3817 @JvmStatic 3818 fun setColorStateList( 3819 rv: RemoteViews, 3820 @IdRes id: Int, 3821 method: String, 3822 colorStateList: ColorStateList? 3823 ) { 3824 rv.setColorStateList(id, method, colorStateList) 3825 } 3826 3827 @JvmStatic 3828 fun setColorStateList( 3829 rv: RemoteViews, 3830 @IdRes id: Int, 3831 method: String, 3832 notNight: ColorStateList?, 3833 night: ColorStateList? 3834 ) { 3835 rv.setColorStateList(id, method, notNight, night) 3836 } 3837 3838 @JvmStatic 3839 fun setColorStateList( 3840 rv: RemoteViews, 3841 @IdRes id: Int, 3842 method: String, 3843 @ColorRes resId: Int 3844 ) { 3845 rv.setColorStateList(id, method, resId) 3846 } 3847 3848 @JvmStatic 3849 fun setColorStateListAttr( 3850 rv: RemoteViews, 3851 @IdRes id: Int, 3852 method: String, 3853 @AttrRes resId: Int 3854 ) { 3855 rv.setColorStateListAttr(id, method, resId) 3856 } 3857 3858 @JvmStatic 3859 fun setIcon( 3860 rv: RemoteViews, 3861 @IdRes id: Int, 3862 method: String, 3863 notNight: Icon?, 3864 night: Icon? 3865 ) { 3866 rv.setIcon(id, method, notNight, night) 3867 } 3868 3869 @JvmStatic 3870 fun setIntDimen(rv: RemoteViews, @IdRes id: Int, method: String, value: Float, unit: Int) { 3871 rv.setIntDimen(id, method, value, unit) 3872 } 3873 3874 @JvmStatic 3875 fun setIntDimen(rv: RemoteViews, @IdRes id: Int, method: String, @DimenRes resId: Int) { 3876 rv.setIntDimen(id, method, resId) 3877 } 3878 3879 @JvmStatic 3880 fun setIntDimenAttr(rv: RemoteViews, @IdRes id: Int, method: String, @AttrRes resId: Int) { 3881 rv.setIntDimenAttr(id, method, resId) 3882 } 3883 3884 @JvmStatic 3885 fun setFloatDimen( 3886 rv: RemoteViews, 3887 @IdRes id: Int, 3888 method: String, 3889 value: Float, 3890 unit: Int 3891 ) { 3892 rv.setFloatDimen(id, method, value, unit) 3893 } 3894 3895 @JvmStatic 3896 fun setFloatDimen(rv: RemoteViews, @IdRes id: Int, method: String, @DimenRes resId: Int) { 3897 rv.setFloatDimen(id, method, resId) 3898 } 3899 3900 @JvmStatic 3901 fun setFloatDimenAttr( 3902 rv: RemoteViews, 3903 @IdRes id: Int, 3904 method: String, 3905 @AttrRes resId: Int 3906 ) { 3907 rv.setFloatDimenAttr(id, method, resId) 3908 } 3909 } 3910 } 3911