mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
remove deprecated API from view component
commit_hash:822c1a382ad7a944959c6172bf647022e5b7f5fd
This commit is contained in:
@@ -1005,7 +1005,6 @@
|
||||
"client/android/div/jacoco.excludes":"divkit/public/client/android/div/jacoco.excludes",
|
||||
"client/android/div/lint.xml":"divkit/public/client/android/div/lint.xml",
|
||||
"client/android/div/proguard-rules.pro":"divkit/public/client/android/div/proguard-rules.pro",
|
||||
"client/android/div/src/main/java/androidx/appcompat/widget/LinearLayoutWithCenteredDividers.kt":"divkit/public/client/android/div/src/main/java/androidx/appcompat/widget/LinearLayoutWithCenteredDividers.kt",
|
||||
"client/android/div/src/main/java/androidx/recyclerview/widget/DivLinearLayoutManager.kt":"divkit/public/client/android/div/src/main/java/androidx/recyclerview/widget/DivLinearLayoutManager.kt",
|
||||
"client/android/div/src/main/java/com/yandex/div/core/DecodeBase64ImageTask.kt":"divkit/public/client/android/div/src/main/java/com/yandex/div/core/DecodeBase64ImageTask.kt",
|
||||
"client/android/div/src/main/java/com/yandex/div/core/Div2Context.kt":"divkit/public/client/android/div/src/main/java/com/yandex/div/core/Div2Context.kt",
|
||||
|
||||
-18
@@ -46,12 +46,6 @@ public interface DivTypefaceProvider {
|
||||
return DivTypefaceProvider.super.getTypefaceFor(weight);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Typeface getRegularLegacy() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -93,16 +87,4 @@ public interface DivTypefaceProvider {
|
||||
return getBold();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns typeface for text elements that require regular font.
|
||||
* Also includes italic variant. To be used only in legacy elements.
|
||||
*
|
||||
* @deprecated Use {@link #getRegular()} instead for non-italic font.
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
default Typeface getRegularLegacy() {
|
||||
return getRegular();
|
||||
}
|
||||
}
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package androidx.appcompat.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.util.AttributeSet
|
||||
|
||||
@Deprecated(
|
||||
message = "for backward compat only",
|
||||
replaceWith = ReplaceWith("com.yandex.div.core.widget.LinearContainerLayout")
|
||||
)
|
||||
open class LinearLayoutWithCenteredDividers @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayoutCompat(context, attrs, defStyleAttr) {
|
||||
|
||||
override fun drawHorizontalDivider(canvas: Canvas, top: Int) = drawDivider(
|
||||
canvas,
|
||||
paddingLeft + dividerPadding,
|
||||
top,
|
||||
width - paddingRight - dividerPadding,
|
||||
top + dividerDrawable.intrinsicHeight
|
||||
)
|
||||
|
||||
override fun drawVerticalDivider(canvas: Canvas, left: Int) = drawDivider(
|
||||
canvas,
|
||||
left,
|
||||
paddingTop + dividerPadding,
|
||||
left + dividerDrawable.intrinsicWidth,
|
||||
height - paddingBottom - dividerPadding
|
||||
)
|
||||
|
||||
private fun drawDivider(canvas: Canvas, left: Int, top: Int, right: Int, bottom: Int) =
|
||||
dividerDrawable.run {
|
||||
val centerHorizontal = (left + right) / 2f
|
||||
val centerVertical = (top + bottom) / 2f
|
||||
val halfWidth = intrinsicWidth / 2f
|
||||
val halfHeight = intrinsicHeight / 2f
|
||||
setBounds((centerHorizontal - halfWidth).toInt(), (centerVertical - halfHeight).toInt(),
|
||||
(centerHorizontal + halfWidth).toInt(), (centerVertical + halfHeight).toInt())
|
||||
draw(canvas)
|
||||
}
|
||||
}
|
||||
@@ -76,20 +76,6 @@ public class DivActionHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the given URI.
|
||||
* Call super implementation to automatically handle internal div schemes when overriding.
|
||||
*
|
||||
* @param uri URI to handle
|
||||
* @param view calling DivView
|
||||
* @return TRUE if uri was handled
|
||||
*/
|
||||
@CallSuper
|
||||
@Deprecated
|
||||
public boolean handleUri(@NonNull Uri uri, @NonNull DivViewFacade view) {
|
||||
return handleActionUrl(uri, view, view.getExpressionResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the given div action.
|
||||
* Call super implementation to automatically handle internal div schemes when overriding.
|
||||
@@ -325,7 +311,7 @@ public class DivActionHandler {
|
||||
* @param view calling DivView
|
||||
* @return TRUE if uri was handled
|
||||
*/
|
||||
public final boolean handleActionUrl(@Nullable Uri uri, @NonNull DivViewFacade view) {
|
||||
public boolean handleActionUrl(@Nullable Uri uri, @NonNull DivViewFacade view) {
|
||||
return handleActionUrl(uri, view, view.getExpressionResolver());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,28 +15,12 @@ public interface DivTooltipRestrictor {
|
||||
/**
|
||||
* Allows all tooltips.
|
||||
*/
|
||||
DivTooltipRestrictor STUB = ((anchor, tooltip) -> true);
|
||||
DivTooltipRestrictor STUB = ((div2View, anchor, tooltip, multiple) -> true);
|
||||
|
||||
/**
|
||||
* Called when handling div-action://show_tooltip
|
||||
*/
|
||||
@Deprecated
|
||||
boolean canShowTooltip(@NonNull View anchor, @NonNull DivTooltip tooltip);
|
||||
|
||||
/**
|
||||
* Called when handling div-action://show_tooltip
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean canShowTooltip(@NonNull Div2View div2View, @NonNull View anchor, @NonNull DivTooltip tooltip) {
|
||||
return canShowTooltip(anchor, tooltip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when handling div-action://show_tooltip
|
||||
*/
|
||||
default boolean canShowTooltip(@NonNull Div2View div2View, @NonNull View anchor, @NonNull DivTooltip tooltip, boolean multiple) {
|
||||
return canShowTooltip(div2View, anchor, tooltip);
|
||||
}
|
||||
boolean canShowTooltip(@NonNull Div2View div2View, @NonNull View anchor, @NonNull DivTooltip tooltip, boolean multiple);
|
||||
|
||||
@Nullable
|
||||
default DivTooltipShownCallback getTooltipShownCallback() {
|
||||
@@ -47,32 +31,15 @@ public interface DivTooltipRestrictor {
|
||||
* Notifies host about shown tooltip.
|
||||
*/
|
||||
interface DivTooltipShownCallback {
|
||||
/**
|
||||
* Called when tooltip becomes visible to user.
|
||||
*/
|
||||
@Deprecated
|
||||
default void onDivTooltipShown(@NonNull View anchor, @NonNull DivTooltip tooltip) {}
|
||||
|
||||
/**
|
||||
* Called when tooltip becomes visible to user.
|
||||
*/
|
||||
default void onDivTooltipShown(@NonNull Div2View div2View, @NonNull View anchor, @NonNull DivTooltip tooltip) {
|
||||
onDivTooltipShown(anchor, tooltip);
|
||||
}
|
||||
void onDivTooltipShown(@NonNull Div2View div2View, @NonNull View anchor, @NonNull DivTooltip tooltip);
|
||||
|
||||
/**
|
||||
* Called when tooltip is dismissed.
|
||||
*/
|
||||
@Deprecated
|
||||
default void onDivTooltipDismissed(@NonNull View anchor, @NonNull DivTooltip tooltip) {}
|
||||
|
||||
/**
|
||||
* Called when tooltip is dismissed.
|
||||
*/
|
||||
default void onDivTooltipDismissed(@NonNull Div2View div2View,
|
||||
@NonNull View anchor,
|
||||
@NonNull DivTooltip tooltip) {
|
||||
onDivTooltipDismissed(anchor, tooltip);
|
||||
}
|
||||
void onDivTooltipDismissed(@NonNull Div2View div2View, @NonNull View anchor, @NonNull DivTooltip tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,24 +21,12 @@ import com.yandex.div.json.expressions.ExpressionResolver;
|
||||
@PublicApi
|
||||
public interface DivViewFacade {
|
||||
|
||||
/**
|
||||
* Method for div builders to allow DivView to control image loads.
|
||||
* @param loadReference not started image load reference
|
||||
* @param targetView view, that loaded image. Used to link reference
|
||||
* @deprecated Use {@link DivViewFacade#addLoadReference(LoadReference, View)}
|
||||
*/
|
||||
@Deprecated()
|
||||
default void addImageLoadReference(@NonNull LoadReference loadReference, @NonNull View targetView) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for loading. Now it used for images
|
||||
* @param loadReference not started image load reference
|
||||
* @param targetView view, that loaded. Used to link reference
|
||||
*/
|
||||
default void addLoadReference(@NonNull LoadReference loadReference, @NonNull View targetView) {
|
||||
addImageLoadReference(loadReference, targetView);
|
||||
}
|
||||
void addLoadReference(@NonNull LoadReference loadReference, @NonNull View targetView);
|
||||
|
||||
/**
|
||||
* @param config Setter for DivConfig
|
||||
|
||||
@@ -1032,11 +1032,11 @@ class Div2View private constructor(
|
||||
}
|
||||
|
||||
override fun handleUri(uri: Uri) {
|
||||
if (actionHandler?.handleUri(uri, this) == true) {
|
||||
if (actionHandler?.handleActionUrl(uri, this) == true) {
|
||||
return
|
||||
}
|
||||
|
||||
div2Component.actionHandler.handleUri(uri, this)
|
||||
div2Component.actionHandler.handleActionUrl(uri, this)
|
||||
}
|
||||
|
||||
override fun setConfig(viewConfig: DivViewConfig) {
|
||||
|
||||
@@ -2,11 +2,9 @@ package com.yandex.div.core.view2.divs
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.Base64
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -27,7 +25,6 @@ import com.yandex.div.core.util.ImageRepresentation
|
||||
import com.yandex.div.core.view2.BindingContext
|
||||
import com.yandex.div.core.view2.DivViewBinder
|
||||
import com.yandex.div.core.view2.divs.widgets.DivVideoView
|
||||
import com.yandex.div.internal.KLog
|
||||
import com.yandex.div.json.expressions.ExpressionResolver
|
||||
import com.yandex.div2.DivVideo
|
||||
import com.yandex.div2.DivVideoScale
|
||||
@@ -226,18 +223,6 @@ fun DivVideo.createSource(resolver: ExpressionResolver): List<DivVideoSource> {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Will be removed in future releases")
|
||||
fun DivVideo.createPreview(resolver: ExpressionResolver): Bitmap? {
|
||||
val base64String = preview?.evaluate(resolver) ?: return null
|
||||
val imageBytes = try {
|
||||
Base64.decode(base64String, Base64.DEFAULT)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
KLog.d("Div") { "Bad base-64 image preview" }
|
||||
return null
|
||||
}
|
||||
return BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
|
||||
}
|
||||
|
||||
private class PreviewImageView(context: Context) : AppCompatImageView(context) {
|
||||
|
||||
init {
|
||||
|
||||
-41
@@ -75,44 +75,3 @@ data class ViewPreCreationProfile(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Use ViewPreCreationProfile")
|
||||
fun FixedPreCreationProfile(
|
||||
textCapacity: Int = 20,
|
||||
imageCapacity: Int = 20,
|
||||
gifImageCapacity: Int = 3,
|
||||
overlapContainerCapacity: Int = 8,
|
||||
linearContainerCapacity: Int = 12,
|
||||
wrapContainerCapacity: Int = 4,
|
||||
gridCapacity: Int = 4,
|
||||
galleryCapacity: Int = 6,
|
||||
pagerCapacity: Int = 2,
|
||||
tabCapacity: Int = 2,
|
||||
stateCapacity: Int = 4,
|
||||
customCapacity: Int = 2,
|
||||
indicatorCapacity: Int = 2,
|
||||
sliderCapacity: Int = 2,
|
||||
inputCapacity: Int = 2,
|
||||
selectCapacity: Int = 2,
|
||||
videoCapacity: Int = 2,
|
||||
switchCapacity: Int = 2
|
||||
): ViewPreCreationProfile = ViewPreCreationProfile.unconstrained(
|
||||
textCapacity = textCapacity,
|
||||
imageCapacity = imageCapacity,
|
||||
gifImageCapacity = gifImageCapacity,
|
||||
overlapContainerCapacity = overlapContainerCapacity,
|
||||
linearContainerCapacity = linearContainerCapacity,
|
||||
wrapContainerCapacity = wrapContainerCapacity,
|
||||
gridCapacity = gridCapacity,
|
||||
galleryCapacity = galleryCapacity,
|
||||
pagerCapacity = pagerCapacity,
|
||||
tabCapacity = tabCapacity,
|
||||
stateCapacity = stateCapacity,
|
||||
customCapacity = customCapacity,
|
||||
indicatorCapacity = indicatorCapacity,
|
||||
sliderCapacity = sliderCapacity,
|
||||
inputCapacity = inputCapacity,
|
||||
selectCapacity = selectCapacity,
|
||||
videoCapacity = videoCapacity,
|
||||
switchCapacity = switchCapacity
|
||||
)
|
||||
|
||||
@@ -75,7 +75,7 @@ fun divConfiguration(
|
||||
.enablePermanentDebugPanel(
|
||||
flagPreferenceProvider.getExperimentFlag(Experiment.PERMANENT_DEBUG_PANEL_ENABLED)
|
||||
)
|
||||
.tooltipRestrictor { _, _ -> true }
|
||||
.tooltipRestrictor { _, _, _, _ -> true }
|
||||
.divDownloader(DemoDivDownloader())
|
||||
.typefaceProvider(YandexSansDivTypefaceProvider(activity))
|
||||
.additionalTypefaceProviders(mapOf("display" to YandexSansDisplayDivTypefaceProvider(activity)))
|
||||
@@ -134,18 +134,22 @@ fun divContext(
|
||||
}
|
||||
|
||||
open class DemoDivActionHandler(private val uriHandlerDivkit: DivkitDemoUriHandler) : DivActionHandler() {
|
||||
override fun handleUri(uri: Uri, view: DivViewFacade): Boolean {
|
||||
if (super.handleUri(uri, view)) {
|
||||
override fun handleActionUrl(uri: Uri?, view: DivViewFacade): Boolean {
|
||||
if (super.handleActionUrl(uri, view)) {
|
||||
return true
|
||||
}
|
||||
|
||||
KLog.d(TAG) { "layoutId=${view.divTag.id}" }
|
||||
return uriHandlerDivkit.handleUri(uri)
|
||||
return if (uri == null) {
|
||||
false
|
||||
} else {
|
||||
uriHandlerDivkit.handleUri(uri)
|
||||
}
|
||||
}
|
||||
|
||||
override fun handleAction(action: DivAction, view: DivViewFacade, resolver: ExpressionResolver): Boolean {
|
||||
return super.handleAction(action, view, resolver) || action.url != null &&
|
||||
handleUri(action.url!!.evaluate(resolver), view)
|
||||
handleActionUrl(action.url?.evaluate(resolver), view)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
-8
@@ -26,12 +26,4 @@ class YandexSansDivTypefaceProvider @Inject constructor(
|
||||
override fun getBold(): Typeface {
|
||||
return ResourcesCompat.getFont(context, R.font.ys_text_bold) ?: Typeface.DEFAULT
|
||||
}
|
||||
|
||||
override fun getRegularLegacy(): Typeface {
|
||||
/**
|
||||
* |ya_regular| includes both regular and italic variant.
|
||||
* It is used in rich text in legacy divs.
|
||||
*/
|
||||
return ResourcesCompat.getFont(context, R.font.ya_regular) ?: Typeface.DEFAULT
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user