package com.philliphsu.bottomsheetpickers.view.numberpad;

import android.support.annotation.NonNull;

import com.philliphsu.bottomsheetpickers.view.LocaleModel;

import java.text.DateFormatSymbols;

/**
 * Provides the texts for buttons in the number pad.
 */
final class ButtonTextModel {
    private static final String[] NUMBERS_TEXTS = new String[10];
    private static final int[] ALT_DIGITS_00 = {0,0};
    private static final int[] ALT_DIGITS_30 = {3,0};

    static {
        for (int i = 0; i < 10; i++) {
            NUMBERS_TEXTS[i] = String.format("%d", i);
        }
    }

    private final String[] mAltButtonsTexts = new String[2];

    ButtonTextModel(@NonNull LocaleModel localeModel, boolean is24HourMode) {
        final String timeSeparator = localeModel.getTimeSeparator(is24HourMode);
        String leftAltText, rightAltText;
        if (is24HourMode) {
            leftAltText = String.format("%02d", 0);
            rightAltText = String.format("%02d", 30);
            leftAltText = localeModel.isLayoutRtl() ?
                    (leftAltText + timeSeparator) : (timeSeparator + leftAltText);
            rightAltText = localeModel.isLayoutRtl() ?
                    (rightAltText + timeSeparator) : (timeSeparator + rightAltText);
        } else {
            String[] amPm = new DateFormatSymbols().getAmPmStrings();
            // TODO: Get localized. Or get the same am/pm strings as the framework.
            leftAltText = amPm[0].length() > 2 ? "AM" : amPm[0];
            rightAltText = amPm[1].length() > 2 ? "PM" : amPm[1];
        }
        mAltButtonsTexts[0] = leftAltText;
        mAltButtonsTexts[1] = rightAltText;
    }

    /**
     * @return A string representing the digit.
     */
    static String text(int digit) {
        return NUMBERS_TEXTS[digit];
    }

    /**
     * @return The integer value of the given key's text.
     */
    static int digit(String text) {
        for (int i = 0; i < NUMBERS_TEXTS.length; i++) {
            if (NUMBERS_TEXTS[i].equals(text)) {
                return i;
            }
        }
        throw new IllegalArgumentException("Cannot convert \""+text+"\" to digit");
    }

    /**
     * @param leftOrRight left (0) or right (1)
     * @return A string for the left or right alt button.
     */
    String altText(int leftOrRight) {
        return mAltButtonsTexts[leftOrRight];
    }

    /**
     * @return The sequence of digits represented by the given alt key's text.
     */
    int[] altDigits(String altText) {
        if (mAltButtonsTexts[0].equals(altText)) {
            return ALT_DIGITS_00;
        } else if (mAltButtonsTexts[1].equals(altText)) {
            return ALT_DIGITS_30;
        }
        throw new IllegalArgumentException("Cannot convert \""+altText+"\" to alt digits");
    }
}

@@ -643,16 +643,57 @@
 ring%5B2%5D;
+%0A    private final boolean mIs24HourMode;
 %0A%0A    Bu
@@ -1693,24 +1693,62 @@
 ghtAltText;%0A
+        mIs24HourMode = is24HourMode;%0A
     %7D%0A%0A    /
@@ -2597,24 +2597,42 @@
         if (
+!mIs24HourMode %7C%7C 
 mAltButtonsT

Modify ButtonTextModel#altDigits() to account for 12-/24-hour mode.