Class PdfPasswordView
-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback
,android.view.KeyEvent.Callback
,android.view.ViewManager
,android.view.ViewParent
,android.view.accessibility.AccessibilityEventSource
,com.pspdfkit.ui.FloatingHintEditText.EditTextListener
public class PdfPasswordView extends LinearLayoutCompat implements FloatingHintEditText.EditTextListener
Password view used when accessing password protected documents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
PdfPasswordView.OnPasswordSubmitListener
Listener for entered password being submitted.
-
Field Summary
Fields Modifier and Type Field Description public int
color
public int
hintColor
public int
floatingHintColor
public int
errorColor
public int
iconResourceId
public boolean
isIconTintingEnabled
-
Constructor Summary
Constructors Constructor Description PdfPasswordView(Context context)
PdfPasswordView(Context context, AttributeSet attrs)
PdfPasswordView(Context context, AttributeSet attrs, int defStyleAttr)
-
Method Summary
Modifier and Type Method Description int
getColor()
Returns the password view color (input field, underline, icon tint). void
setColor(@ColorInt() int color)
Sets the password view color (input field, underline, icon tint). int
getHintColor()
Returns input field hint color. void
setHintColor(@ColorInt() int hintColor)
Sets input field hint color. int
getFloatingHintColor()
Returns the text color for the password view's floating hint. void
setFloatingHintColor(@ColorInt() int floatingHintColor)
Sets the text color for the password view's floating hint. int
getErrorColor()
Returns color used as primary one in case of incorrect password entry. void
setErrorColor(@ColorInt() int errorColor)
Sets color used as primary one in case of incorrect password entry. int
getIconResourceId()
Returns icon displayed above the input field. void
setIconResourceId(@DrawableRes() int iconResourceId)
Sets icon displayed above the input field. boolean
isIconTintingEnabled()
Returns whether tinting of the password view icon is enabled or not. void
setIconTintingEnabled(boolean iconTintingEnabled)
Sets whether tinting of the password view icon is enabled or not. void
showPasswordError()
Shake view and tint with error code. String
getPassword()
Returns currently entered password. void
onKeyPress(int keyCode, KeyEvent event)
Called when there is a key press event void
onErrorDismissed()
Called when user proceeds typing in after there was an error shown. void
afterTextChanged(Editable s)
Called after each Editable text change. void
setVisibility(int visibility)
IBinder
getWindowToken()
void
onWindowFocusChanged(boolean hasWindowFocus)
void
setOnPasswordSubmitListener(@Nullable() PdfPasswordView.OnPasswordSubmitListener listener)
Configure listener for listening for password entry. -
-
Constructor Detail
-
PdfPasswordView
PdfPasswordView(Context context)
-
PdfPasswordView
PdfPasswordView(Context context, AttributeSet attrs)
-
PdfPasswordView
PdfPasswordView(Context context, AttributeSet attrs, int defStyleAttr)
-
-
Method Detail
-
getColor
@ColorInt() int getColor()
Returns the password view color (input field, underline, icon tint).
- Returns:
Primary password view color.
-
setColor
void setColor(@ColorInt() int color)
Sets the password view color (input field, underline, icon tint).
- Parameters:
color
- Primary password view color.
-
getHintColor
@ColorInt() int getHintColor()
Returns input field hint color.
- Returns:
Input field hint text color.
-
setHintColor
void setHintColor(@ColorInt() int hintColor)
Sets input field hint color.
- Parameters:
hintColor
- Input field hint text color.
-
getFloatingHintColor
@ColorInt() int getFloatingHintColor()
Returns the text color for the password view's floating hint.
- Returns:
Floating hint color.
-
setFloatingHintColor
void setFloatingHintColor(@ColorInt() int floatingHintColor)
Sets the text color for the password view's floating hint.
- Parameters:
floatingHintColor
- Floating hint color.
-
getErrorColor
@ColorInt() int getErrorColor()
Returns color used as primary one in case of incorrect password entry.
- Returns:
Color used to tint text and iconResourceId on incorrect password.
-
setErrorColor
void setErrorColor(@ColorInt() int errorColor)
Sets color used as primary one in case of incorrect password entry.
- Parameters:
errorColor
- Color used to tint text and iconResourceId on incorrect password.
-
getIconResourceId
@DrawableRes() int getIconResourceId()
Returns icon displayed above the input field.
- Returns:
Input field icon's resource drawable.
-
setIconResourceId
void setIconResourceId(@DrawableRes() int iconResourceId)
Sets icon displayed above the input field. Setting this to -1 is equivalent to setting it to @null in the theme.
- Parameters:
iconResourceId
- Input field icon's resource drawable.
-
isIconTintingEnabled
boolean isIconTintingEnabled()
Returns whether tinting of the password view icon is enabled or not.
- Returns:
true
if tinting is enabled, orfalse
if the used icon won't be tinted. Defaults totrue
.
-
setIconTintingEnabled
void setIconTintingEnabled(boolean iconTintingEnabled)
Sets whether tinting of the password view icon is enabled or not.
- Parameters:
iconTintingEnabled
-true
if tinting is enabled, orfalse
if the used icon won't be tinted.
-
showPasswordError
void showPasswordError()
Shake view and tint with error code.
-
getPassword
@NonNull() String getPassword()
Returns currently entered password.
- Returns:
Password string currently entered into the text box, or empty string if there's no input.
-
onKeyPress
void onKeyPress(int keyCode, KeyEvent event)
Called when there is a key press event
- Parameters:
keyCode
- code for a pressed keyevent
- event for key press
-
onErrorDismissed
void onErrorDismissed()
Called when user proceeds typing in after there was an error shown.
-
afterTextChanged
void afterTextChanged(Editable s)
Called after each Editable text change.
- Parameters:
s
- Editable with change event.
-
setVisibility
void setVisibility(int visibility)
-
getWindowToken
IBinder getWindowToken()
-
onWindowFocusChanged
void onWindowFocusChanged(boolean hasWindowFocus)
-
setOnPasswordSubmitListener
void setOnPasswordSubmitListener(@Nullable() PdfPasswordView.OnPasswordSubmitListener listener)
Configure listener for listening for password entry. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
listener
- OnPasswordSubmitListener that should be notified, ornull
to clear the listener.
-
-
-
-