Open keyboard when we open contact selection from blocked preference.
This commit is contained in:
parent
2dace38d43
commit
06aada20c1
4 changed files with 37 additions and 1 deletions
|
@ -65,6 +65,10 @@ public class BlockedUsersActivity extends PassphraseRequiredActivity implements
|
|||
//noinspection CodeBlock2Expr
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(() -> {
|
||||
viewSwitcher.setDisplayedChild(getSupportFragmentManager().getBackStackEntryCount());
|
||||
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
|
||||
contactFilterToolbar.focusAndShowKeyboard();
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.core.widget.TextViewCompat;
|
|||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.views.DarkOverflowToolbar;
|
||||
|
||||
public final class ContactFilterToolbar extends DarkOverflowToolbar {
|
||||
|
@ -125,6 +126,10 @@ public final class ContactFilterToolbar extends DarkOverflowToolbar {
|
|||
attributes.recycle();
|
||||
}
|
||||
|
||||
public void focusAndShowKeyboard() {
|
||||
ViewUtil.focusAndShowKeyboard(searchText);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
searchText.setText("");
|
||||
notifyListener();
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
@ -51,6 +52,32 @@ public final class ViewUtil {
|
|||
private ViewUtil() {
|
||||
}
|
||||
|
||||
public static void focusAndShowKeyboard(@NonNull View view) {
|
||||
view.requestFocus();
|
||||
if (view.hasWindowFocus()) {
|
||||
showTheKeyboardNow(view);
|
||||
} else {
|
||||
view.getViewTreeObserver().addOnWindowFocusChangeListener(new ViewTreeObserver.OnWindowFocusChangeListener() {
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
showTheKeyboardNow(view);
|
||||
view.getViewTreeObserver().removeOnWindowFocusChangeListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void showTheKeyboardNow(@NonNull View view) {
|
||||
if (view.isFocused()) {
|
||||
view.post(() -> {
|
||||
InputMethodManager inputMethodManager = ServiceUtil.getInputMethodManager(view.getContext());
|
||||
inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBackground(final @NonNull View v, final @Nullable Drawable drawable) {
|
||||
v.setBackground(drawable);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
android:layout_marginTop="29dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/BlockedUsersActivity__blocked_users"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Subtitle"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2.Bold"
|
||||
android:textColor="?colorAccent"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
Loading…
Add table
Reference in a new issue