@@ -0,0 +1,2988 @@
+/*%0A * Copyright (C) 2020 The Android Open Source Project%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0Apackage com.google.android.exoplayer2.text.span;%0A%0Aimport static java.lang.annotation.RetentionPolicy.SOURCE;%0A%0Aimport androidx.annotation.IntDef;%0Aimport java.lang.annotation.Documented;%0Aimport java.lang.annotation.Retention;%0A%0A/**%0A * A styling span for ruby text.%0A *%0A * %3Cp%3EThe text covered by this span is known as the %22base text%22, and the ruby text is stored in%0A * %7B@link #rubyText%7D.%0A *%0A * %3Cp%3EMore information on %3Ca href=%22https://en.wikipedia.org/wiki/Ruby_character%22%3Eruby characters%3C/a%3E%0A * and %3Ca href=%22https://developer.android.com/guide/topics/text/spans%22%3Espan styling%3C/a%3E.%0A */%0A// NOTE: There's no Android layout support for rubies, so this span currently doesn't extend any%0A// styling superclasses (e.g. MetricAffectingSpan). The only way to render these rubies is to%0A// extract the spans and do the layout manually.%0A// TODO: Consider adding support for parenthetical text to be used when rendering doesn't support%0A// rubies (e.g. HTML %3Crp%3E tag).%0Apublic final class RubySpan %7B%0A%0A  /** The ruby position is unknown. */%0A  public static final int POSITION_UNKNOWN = -1;%0A%0A  /**%0A   * The ruby text should be positioned above the base text.%0A   *%0A   * %3Cp%3EFor vertical text it should be positioned to the right, same as CSS's %3Ca%0A   * href=%22https://developer.mozilla.org/en-US/docs/Web/CSS/ruby-position%22%3Eruby-position%3C/a%3E.%0A   */%0A  public static final int POSITION_OVER = 1;%0A%0A  /**%0A   * The ruby text should be positioned below the base text.%0A   *%0A   * %3Cp%3EFor vertical text it should be positioned to the left, same as CSS's %3Ca%0A   * href=%22https://developer.mozilla.org/en-US/docs/Web/CSS/ruby-position%22%3Eruby-position%3C/a%3E.%0A   */%0A  public static final int POSITION_UNDER = 2;%0A%0A  /**%0A   * The possible positions of the ruby text relative to the base text.%0A   *%0A   * %3Cp%3EOne of:%0A   *%0A   * %3Cul%3E%0A   *   %3Cli%3E%7B@link #POSITION_UNKNOWN%7D%0A   *   %3Cli%3E%7B@link #POSITION_OVER%7D%0A   *   %3Cli%3E%7B@link #POSITION_UNDER%7D%0A   * %3C/ul%3E%0A   */%0A  @Documented%0A  @Retention(SOURCE)%0A  @IntDef(%7BPOSITION_UNKNOWN, POSITION_OVER, POSITION_UNDER%7D)%0A  public @interface Position %7B%7D%0A%0A  /** The ruby text, i.e. the smaller explanatory characters. */%0A  public final String rubyText;%0A%0A  /** The position of the ruby text relative to the base text. */%0A  @Position public final int position;%0A%0A  public RubySpan(String rubyText, @Position int position) %7B%0A    this.rubyText = rubyText;%0A    this.position = position;%0A  %7D%0A%7D%0A

Add RubySpan