-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase flexibility of ForageElement hierarchy
This is the third step in the public ecommerce repo that needs to take place in order to make sharing code between the private pos repo and this repo pain free; all while allowing for both repos to evolve independently. This hierarchy will make it easy to keep ecom things in the ecom-ForagePinEditText and pos things in the pos-ForagePINEditText Signed-off-by: Devin Morgan <[email protected]>
- Loading branch information
1 parent
6458699
commit 08b79c4
Showing
17 changed files
with
703 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
forage-android/src/main/java/com/joinforage/forage/android/core/ui/VaultWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.joinforage.forage.android.core.ui | ||
|
||
import android.content.Context | ||
import android.graphics.Typeface | ||
import android.util.AttributeSet | ||
import android.util.TypedValue | ||
import android.view.View | ||
import android.widget.FrameLayout | ||
import com.joinforage.forage.android.core.services.VaultType | ||
import com.joinforage.forage.android.core.services.vault.AbstractVaultSubmitter | ||
import com.joinforage.forage.android.core.services.telemetry.Log | ||
import com.joinforage.forage.android.core.ui.element.ForagePinElement | ||
import com.joinforage.forage.android.core.ui.element.SimpleElementListener | ||
import com.joinforage.forage.android.core.ui.element.StatefulElementListener | ||
import com.joinforage.forage.android.core.ui.element.state.PinElementState | ||
import com.joinforage.forage.android.core.ui.element.state.PinElementStateManager | ||
|
||
internal abstract class VaultWrapper @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : FrameLayout(context, attrs, defStyleAttr) { | ||
abstract var typeface: Typeface? | ||
|
||
// mutable references to event listeners. We use mutable | ||
// references because the implementations of our vaults | ||
// require that we are only able to ever pass a single | ||
// monolithic event within init call. This is mutability | ||
// allows us simulate setting and overwriting a listener | ||
// with every set call | ||
internal abstract val manager: PinElementStateManager | ||
abstract val vaultType: VaultType | ||
|
||
abstract fun clearText() | ||
|
||
abstract fun setTextColor(textColor: Int) | ||
abstract fun setTextSize(textSize: Float) | ||
abstract fun setHint(hint: String) | ||
abstract fun setHintTextColor(hintTextColor: Int) | ||
abstract fun getTextElement(): View | ||
abstract fun showKeyboard() | ||
|
||
abstract fun getVaultSubmitter( | ||
foragePinElement: ForagePinElement, | ||
logger: Log | ||
) : AbstractVaultSubmitter | ||
|
||
fun getThemeAccentColor(context: Context): Int { | ||
val outValue = TypedValue() | ||
context.theme.resolveAttribute(android.R.attr.colorAccent, outValue, true) | ||
return outValue.data | ||
} | ||
|
||
fun setOnFocusEventListener(l: SimpleElementListener) { | ||
manager.setOnFocusEventListener(l) | ||
} | ||
|
||
fun setOnBlurEventListener(l: SimpleElementListener) { | ||
manager.setOnBlurEventListener(l) | ||
} | ||
|
||
fun setOnChangeEventListener(l: StatefulElementListener<PinElementState>) { | ||
manager.setOnChangeEventListener(l) | ||
} | ||
} |
Oops, something went wrong.