Attempt to fix view jitter when switching keyboards.
This commit is contained in:
parent
b4a34599d7
commit
aa2075c78f
5 changed files with 14 additions and 45 deletions
|
@ -16,11 +16,9 @@
|
|||
*/
|
||||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
|
@ -107,10 +105,6 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat {
|
|||
}
|
||||
|
||||
private void updateKeyboardState() {
|
||||
updateKeyboardState(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
private void updateKeyboardState(int previousHeight) {
|
||||
if (viewInset == 0) viewInset = getViewInset();
|
||||
|
||||
getWindowVisibleDisplayFrame(rect);
|
||||
|
@ -130,11 +124,7 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat {
|
|||
onKeyboardOpen(keyboardHeight);
|
||||
}
|
||||
} else if (keyboardOpen) {
|
||||
if (previousHeight == keyboardHeight) {
|
||||
onKeyboardClose();
|
||||
} else {
|
||||
postDelayed(() -> updateKeyboardState(keyboardHeight), 100);
|
||||
}
|
||||
onKeyboardClose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +149,6 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat {
|
|||
}
|
||||
}
|
||||
|
||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
||||
private int getViewInset() {
|
||||
try {
|
||||
Field attachInfoField = View.class.getDeclaredField("mAttachInfo");
|
||||
|
|
|
@ -253,11 +253,7 @@ class AddMessageDialogFragment : KeyboardEntryDialogFragment(R.layout.v2_media_a
|
|||
binding.hud.showSoftkey(binding.content.addAMessageInput)
|
||||
} else {
|
||||
requestedEmojiDrawer = true
|
||||
binding.hud.hideSoftkey(binding.content.addAMessageInput) {
|
||||
binding.hud.post {
|
||||
binding.hud.show(binding.content.addAMessageInput, emojiDrawerStub.get())
|
||||
}
|
||||
}
|
||||
binding.hud.show(binding.content.addAMessageInput, emojiDrawerStub.get())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.thoughtcrime.securesms.stories.viewer.reply.composer
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
|
@ -147,6 +145,10 @@ class StoryReplyComposer @JvmOverloads constructor(
|
|||
emojiDrawer.onCloseEmojiSearch()
|
||||
}
|
||||
|
||||
fun close() {
|
||||
inputAwareLayout.hideCurrentInput(input)
|
||||
}
|
||||
|
||||
private fun onEmojiToggleClicked() {
|
||||
if (!emojiDrawer.isInitialised) {
|
||||
callback?.onInitializeEmojiDrawer(emojiDrawer)
|
||||
|
@ -159,12 +161,8 @@ class StoryReplyComposer @JvmOverloads constructor(
|
|||
callback?.onHideEmojiKeyboard()
|
||||
} else {
|
||||
isRequestingEmojiDrawer = true
|
||||
inputAwareLayout.hideSoftkey(input) {
|
||||
inputAwareLayout.post {
|
||||
inputAwareLayout.show(input, emojiDrawer)
|
||||
emojiDrawer.post { callback?.onShowEmojiKeyboard() }
|
||||
}
|
||||
}
|
||||
inputAwareLayout.show(input, emojiDrawer)
|
||||
emojiDrawer.post { callback?.onShowEmojiKeyboard() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,22 +173,4 @@ class StoryReplyComposer @JvmOverloads constructor(
|
|||
fun onShowEmojiKeyboard() = Unit
|
||||
fun onHideEmojiKeyboard() = Unit
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun installIntoBottomSheet(context: Context, dialog: Dialog): StoryReplyComposer {
|
||||
val container: ViewGroup = dialog.findViewById(R.id.container)
|
||||
|
||||
val oldComposer: StoryReplyComposer? = container.findViewById(R.id.input)
|
||||
if (oldComposer != null) {
|
||||
return oldComposer
|
||||
}
|
||||
|
||||
val composer = StoryReplyComposer(context)
|
||||
|
||||
composer.id = R.id.input
|
||||
|
||||
container.addView(composer)
|
||||
return composer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,6 +338,10 @@ class StoryGroupReplyFragment :
|
|||
override fun onPageSelected(child: StoryViewsAndRepliesPagerParent.Child) {
|
||||
currentChild = child
|
||||
updateNestedScrolling()
|
||||
|
||||
if (currentChild != StoryViewsAndRepliesPagerParent.Child.REPLIES) {
|
||||
composer.close()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateNestedScrolling() {
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
<TextView
|
||||
android:id="@+id/empty_notice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/StoryGroupReplyFragment__no_replies_yet"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_bar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue