public class

UnitSelectionEditText

extends ScreenAdjustingEditText
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.EditText
         ↳ androidx.appcompat.widget.AppCompatEditText
           ↳ com.pspdfkit.ui.LocalizedEditText
             ↳ com.pspdfkit.ui.editor.ScreenAdjustingEditText
               ↳ com.pspdfkit.ui.editor.UnitSelectionEditText

Class Overview

Edit text with blocked selection to prevent user interacting with a unit label.

Summary

Nested Classes
interface UnitSelectionEditText.UnitSelectionListener Listener for unit values selection. 
[Expand]
Inherited Constants
From class android.widget.TextView
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
UnitSelectionEditText(Context context)
UnitSelectionEditText(Context context, AttributeSet attrs)
UnitSelectionEditText(Context context, AttributeSet attrs, int defStyle)
Public Methods
void focusCheck()
Checks if the view has the focus and select the editable value.
int getDefaultValue()
Returns default value.
int getMaximumValue()
Returns maximum value of the unit.
int getMinimumValue()
Returns minimum value of the unit.
String getUnitLabel()
Returns current unit label.
int getUnitLengthNotSelectable()
Gets length of the unit.
int getValue()
Gets current value.
int parseValue(String s)
Returns the parsed value of the unit.
void setDefaultValue(int defaultValue)
Sets default value of the unit.
void setMaximumValue(int maximumValue)
Sets maximum value of the unit.
void setMinimumValue(int minimumValue)
Sets minimum value of the unit.
void setTextToDefault()
Sets text to default value and notifies the #listener if not null.
void setTextToFormat(int value)
Sets text properly formatted according to #unitLabel.
void setUnitLabel(String unitLabel, int defaultValue, int minimumValue, int maximumValue, UnitSelectionEditText.UnitSelectionListener listener)
Sets unit label.
Protected Methods
void onSelectionChanged(int selStart, int selEnd)
[Expand]
Inherited Methods
From class com.pspdfkit.ui.editor.ScreenAdjustingEditText
From class androidx.appcompat.widget.AppCompatEditText
From class android.widget.EditText
From class android.widget.TextView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.view.accessibility.AccessibilityEventSource
From interface androidx.appcompat.widget.EmojiCompatConfigurationView
From interface androidx.core.view.OnReceiveContentViewBehavior
From interface androidx.core.view.TintableBackgroundView
From interface androidx.core.widget.TintableCompoundDrawablesView

Public Constructors

public UnitSelectionEditText (Context context)

public UnitSelectionEditText (Context context, AttributeSet attrs)

public UnitSelectionEditText (Context context, AttributeSet attrs, int defStyle)

Public Methods

public void focusCheck ()

Checks if the view has the focus and select the editable value.

public int getDefaultValue ()

Returns default value.

Returns
  • default value.

public int getMaximumValue ()

Returns maximum value of the unit.

Returns
  • maximum value.

public int getMinimumValue ()

Returns minimum value of the unit.

Returns
  • minimum value.

public String getUnitLabel ()

Returns current unit label.

Returns
  • current unit label.

public int getUnitLengthNotSelectable ()

Gets length of the unit.

Returns
  • length of the unit.

public int getValue ()

Gets current value.

public int parseValue (String s)

Returns the parsed value of the unit. Returns default value if the input is malformed. Returns maximum value if the input value is over the maximum value. Returns minimum value if the input value is under the minimum value.

Parameters
s Input value to parse. (For example "10 pt").
Returns
  • parsed value of the unit.

public void setDefaultValue (int defaultValue)

Sets default value of the unit.

Parameters
defaultValue default value of the unit.

public void setMaximumValue (int maximumValue)

Sets maximum value of the unit.

Parameters
maximumValue maximum value.

public void setMinimumValue (int minimumValue)

Sets minimum value of the unit.

Parameters
minimumValue minimum value of the unit.

public void setTextToDefault ()

Sets text to default value and notifies the #listener if not null.

public void setTextToFormat (int value)

Sets text properly formatted according to #unitLabel.

Parameters
value to format with #unitLabel.

public void setUnitLabel (String unitLabel, int defaultValue, int minimumValue, int maximumValue, UnitSelectionEditText.UnitSelectionListener listener)

Sets unit label.

Parameters
unitLabel Unit label format. This format string must contain "%d" or "%s" to substitute correct value during formatting. For example when using "%d pt" unit label text will be formatted as "10 pt".
defaultValue Default value of the unit label. Must be grater than 0.
minimumValue Maximum value allowed. Must be greater than 0 and less than or equal to defaultValue.
maximumValue Minimum value allowed. Must be greater than 0 and and greater than or equal to defaultValue.
listener Listener for text changes.

Protected Methods

protected void onSelectionChanged (int selStart, int selEnd)