Open keyboard when we open contact selection from blocked preference.

fork-5.53.8
Alex Hart 2020-11-12 13:39:38 -04:00 zatwierdzone przez GitHub
rodzic 2dace38d43
commit 06aada20c1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 37 dodań i 1 usunięć

Wyświetl plik

@ -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()

Wyświetl plik

@ -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();

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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"