Merge pull request #974 from Naveen3Singh/fix_ime_inset

Apply IME insets on scroll view
This commit is contained in:
Tibor Kaputa 2023-06-09 23:04:50 +02:00 committed by GitHub
commit e9da5e7ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 11 deletions

View File

@ -120,7 +120,8 @@
android:configChanges="orientation" android:configChanges="orientation"
android:exported="true" android:exported="true"
android:parentActivityName=".activities.MainActivity" android:parentActivityName=".activities.MainActivity"
android:theme="@style/TranslucentTheme"> android:theme="@style/TranslucentTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.EDIT" />

View File

@ -18,8 +18,12 @@ import android.telephony.PhoneNumberUtils
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.widget.* import android.widget.EditText
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.widget.doAfterTextChanged import androidx.core.widget.doAfterTextChanged
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog
@ -39,16 +43,29 @@ import com.simplemobiletools.contacts.pro.dialogs.CustomLabelDialog
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
import com.simplemobiletools.contacts.pro.dialogs.MyDatePickerDialog import com.simplemobiletools.contacts.pro.dialogs.MyDatePickerDialog
import com.simplemobiletools.contacts.pro.dialogs.SelectGroupsDialog import com.simplemobiletools.contacts.pro.dialogs.SelectGroupsDialog
import com.simplemobiletools.contacts.pro.extensions.* import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.helpers.* import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri
import com.simplemobiletools.contacts.pro.extensions.showContactSourcePicker
import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER
import com.simplemobiletools.contacts.pro.helpers.IS_FROM_SIMPLE_CONTACTS
import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL
import com.simplemobiletools.contacts.pro.helpers.KEY_NAME
import kotlinx.android.synthetic.main.activity_edit_contact.* import kotlinx.android.synthetic.main.activity_edit_contact.*
import kotlinx.android.synthetic.main.item_edit_address.view.* import kotlinx.android.synthetic.main.item_edit_address.view.contact_address
import kotlinx.android.synthetic.main.item_edit_email.view.* import kotlinx.android.synthetic.main.item_edit_address.view.contact_address_type
import kotlinx.android.synthetic.main.item_edit_group.view.* import kotlinx.android.synthetic.main.item_edit_email.view.contact_email
import kotlinx.android.synthetic.main.item_edit_im.view.* import kotlinx.android.synthetic.main.item_edit_email.view.contact_email_type
import kotlinx.android.synthetic.main.item_edit_phone_number.view.* import kotlinx.android.synthetic.main.item_edit_group.view.contact_group
import kotlinx.android.synthetic.main.item_edit_website.view.* import kotlinx.android.synthetic.main.item_edit_group.view.contact_group_remove
import kotlinx.android.synthetic.main.item_event.view.* import kotlinx.android.synthetic.main.item_edit_im.view.contact_im
import kotlinx.android.synthetic.main.item_edit_im.view.contact_im_type
import kotlinx.android.synthetic.main.item_edit_phone_number.view.contact_number
import kotlinx.android.synthetic.main.item_edit_phone_number.view.contact_number_type
import kotlinx.android.synthetic.main.item_edit_phone_number.view.default_toggle_icon
import kotlinx.android.synthetic.main.item_edit_website.view.contact_website
import kotlinx.android.synthetic.main.item_event.view.contact_event
import kotlinx.android.synthetic.main.item_event.view.contact_event_remove
import kotlinx.android.synthetic.main.item_event.view.contact_event_type
class EditContactActivity : ContactActivity() { class EditContactActivity : ContactActivity() {
private val INTENT_TAKE_PHOTO = 1 private val INTENT_TAKE_PHOTO = 1
@ -86,6 +103,7 @@ class EditContactActivity : ContactActivity() {
} }
contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
setupInsets()
setupMenu() setupMenu()
val action = intent.action val action = intent.action
@ -289,6 +307,17 @@ class EditContactActivity : ContactActivity() {
} }
} }
private fun setupInsets() {
contact_wrapper.setOnApplyWindowInsetsListener { _, insets ->
val windowInsets = WindowInsetsCompat.toWindowInsetsCompat(insets)
val imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime())
contact_scrollview.run {
setPadding(paddingLeft, paddingTop, paddingRight, imeInsets.bottom)
}
insets
}
}
private fun setupMenu() { private fun setupMenu() {
(contact_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight (contact_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
contact_toolbar.menu.apply { contact_toolbar.menu.apply {

View File

@ -10,6 +10,7 @@
android:id="@+id/contact_scrollview" android:id="@+id/contact_scrollview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="none" android:scrollbars="none"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">