Hide keyboard on clicking connect (#103)

This commit is contained in:
Wv5twkFEKh54vo4tta9yu7dHa3 2020-04-10 16:12:03 +02:00 committed by GitHub
parent 2333e5ec11
commit 8af19cbd9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import android.content.SharedPreferences
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabsIntent
import com.h.pixeldroid.api.PixelfedAPI
@ -18,6 +19,7 @@ import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class LoginActivity : AppCompatActivity() {
private lateinit var OAUTH_SCHEME: String
@ -70,7 +72,8 @@ class LoginActivity : AppCompatActivity() {
} catch (e: IllegalArgumentException) {
return failedRegistration(getString(R.string.invalid_domain))
}
hideKeyboard()
loadingAnimation(true)
preferences.edit()
@ -79,6 +82,15 @@ class LoginActivity : AppCompatActivity() {
registerAppToServer("https://$normalizedDomain")
}
private fun hideKeyboard() {
val view = currentFocus
if (view != null) {
(getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).hideSoftInputFromWindow(
view.windowToken,
InputMethodManager.HIDE_NOT_ALWAYS
)
}
}
private fun normalizeDomain(domain: String): String {
var d = domain.replace("http://", "")

View File

@ -32,6 +32,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:imeOptions="actionDone"
android:inputType="textUri" />
<Button