Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 660d7fc4 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Make DynamicDrawableSpan#ALIGN_CENTER public API

Bug: 123340905
Test: make update-api
Test: atest DynamicDrawableSpanTest
Change-Id: I0951091710a46434425359b148a9e7ea0adbc3d1
parent 5c9cd687
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47477,6 +47477,7 @@ package android.text.style {
    method public int getVerticalAlignment();
    field public static final int ALIGN_BASELINE = 1; // 0x1
    field public static final int ALIGN_BOTTOM = 0; // 0x0
    field public static final int ALIGN_CENTER = 2; // 0x2
    field protected final int mVerticalAlignment;
  }
+22 −6
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.text.style;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -25,6 +28,7 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;

import java.lang.annotation.Retention;
import java.lang.ref.WeakReference;

/**
@@ -80,10 +84,21 @@ public abstract class DynamicDrawableSpan extends ReplacementSpan {
    /**
     * A constant indicating that this span should be vertically centered between
     * the top and the lowest descender.
     * @hide
     */
    public static final int ALIGN_CENTER = 2;

    /**
     * Defines acceptable alignment types.
     * @hide
     */
    @Retention(SOURCE)
    @IntDef(prefix = { "ALIGN_" }, value = {
            ALIGN_BOTTOM,
            ALIGN_BASELINE,
            ALIGN_CENTER
    })
    public @interface AlignmentType {}

    protected final int mVerticalAlignment;

    @UnsupportedAppUsage
@@ -100,17 +115,18 @@ public abstract class DynamicDrawableSpan extends ReplacementSpan {
    /**
     * Creates a {@link DynamicDrawableSpan} based on a vertical alignment.\
     *
     * @param verticalAlignment one of {@link #ALIGN_BOTTOM} or {@link #ALIGN_BASELINE}
     * @param verticalAlignment one of {@link #ALIGN_BOTTOM}, {@link #ALIGN_BASELINE} or
     *                          {@link #ALIGN_CENTER}
     */
    protected DynamicDrawableSpan(int verticalAlignment) {
    protected DynamicDrawableSpan(@AlignmentType int verticalAlignment) {
        mVerticalAlignment = verticalAlignment;
    }

    /**
     * Returns the vertical alignment of this span, one of {@link #ALIGN_BOTTOM} or
     * {@link #ALIGN_BASELINE}.
     * Returns the vertical alignment of this span, one of {@link #ALIGN_BOTTOM},
     * {@link #ALIGN_BASELINE} or {@link #ALIGN_CENTER}.
     */
    public int getVerticalAlignment() {
    public @AlignmentType int getVerticalAlignment() {
        return mVerticalAlignment;
    }