From a6cc7e95ca16f82fe2b95b2815ef383d924ad845 Mon Sep 17 00:00:00 2001 From: Josue Leon Sarkis Date: Wed, 24 Apr 2024 17:40:45 -0600 Subject: [PATCH] feat: support showing keyboard programmatically (#104) --- .github/workflows/pull-request.yml | 2 +- .../SocialSecurityNumberFragment.kt | 4 ++-- lib/build.gradle | 8 +++++++- .../main/java/com/basistheory/android/view/TextElement.kt | 7 +++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 783f56a0..eb2fb011 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: run: ./gradlew testDebugUnitTest acceptance: - runs-on: macos-latest + runs-on: macos-13 strategy: matrix: diff --git a/example/src/main/java/com/basistheory/android/example/view/social_security_number/SocialSecurityNumberFragment.kt b/example/src/main/java/com/basistheory/android/example/view/social_security_number/SocialSecurityNumberFragment.kt index 05eacbd8..94ba41c5 100644 --- a/example/src/main/java/com/basistheory/android/example/view/social_security_number/SocialSecurityNumberFragment.kt +++ b/example/src/main/java/com/basistheory/android/example/view/social_security_number/SocialSecurityNumberFragment.kt @@ -31,8 +31,8 @@ class SocialSecurityNumberFragment : Fragment() { return binding.root } - private fun autofill() { - binding.socialSecurityNumber.setText("234567890") + private fun autofill() { + binding.socialSecurityNumber.setText("234567890") } private fun tokenize() = diff --git a/lib/build.gradle b/lib/build.gradle index 4cad2da6..048e87ae 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -79,7 +79,7 @@ dependencies { implementation 'com.google.code.gson:gson:2.10.1' testImplementation 'junit:junit:4.13.2' testImplementation 'pl.pragmatists:JUnitParams:1.1.1' - testImplementation 'org.robolectric:robolectric:4.10.3' + testImplementation 'org.robolectric:robolectric:4.12.1' testImplementation 'io.strikt:strikt-core:0.34.1' testImplementation 'io.mockk:mockk:1.13.8' testImplementation("com.squareup.okhttp3:mockwebserver:4.11.0") @@ -95,5 +95,11 @@ configurations.configureEach { } details.useVersion("2.2") } + if (details.requested.module.toString() == 'org.bouncycastle:bcprov-jdk18on') { + details.artifactSelection { + it.selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null) + } + details.useVersion("1.78") + } } } \ No newline at end of file diff --git a/lib/src/main/java/com/basistheory/android/view/TextElement.kt b/lib/src/main/java/com/basistheory/android/view/TextElement.kt index 8f819956..634f55c7 100644 --- a/lib/src/main/java/com/basistheory/android/view/TextElement.kt +++ b/lib/src/main/java/com/basistheory/android/view/TextElement.kt @@ -23,9 +23,11 @@ import android.view.View.OnTouchListener import android.view.ViewGroup import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputConnection +import android.view.inputmethod.InputMethodManager import android.widget.FrameLayout import androidx.annotation.RequiresApi import androidx.appcompat.widget.AppCompatEditText +import androidx.core.content.getSystemService import androidx.core.content.res.ResourcesCompat import androidx.core.os.bundleOf import com.basistheory.android.R @@ -156,6 +158,11 @@ open class TextElement @JvmOverloads constructor( ) } + fun showKeyboard(flags: Int) { + val imm = context.getSystemService() + imm!!.showSoftInput(_editText, flags) + } + fun getDrawables(): Array { return _editText.compoundDrawables }