From: Damyan Ivanov Date: Sat, 21 Sep 2019 08:40:58 +0000 (+0300) Subject: new transaction: show soft keyboard after choosing transaction date X-Git-Tag: v0.11.0~107 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=175d76e9e4473f2da2054c14c6bfc77bbf45844b;p=mobile-ledger.git new transaction: show soft keyboard after choosing transaction date --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java index abec8d6d..65794630 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java @@ -17,13 +17,16 @@ package net.ktnx.mobileledger.ui; +import android.app.Activity; import android.app.Dialog; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatDialogFragment; +import android.view.WindowManager; import android.widget.CalendarView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatDialogFragment; + import net.ktnx.mobileledger.R; import java.util.Calendar; @@ -96,9 +99,13 @@ public class DatePickerFragment extends AppCompatDialogFragment } else date.setText(String.format(Locale.US, "%d/%d/%d", year, month + 1, day)); - TextView description = Objects.requireNonNull(getActivity()) - .findViewById(R.id.new_transaction_description); - description.requestFocus(); + Activity activity = getActivity(); + if (activity == null) return; + + TextView description = activity.findViewById(R.id.new_transaction_description); + boolean tookFocus = description.requestFocus(); + if (tookFocus) activity.getWindow() + .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } @Override public void onSelectedDayChange(@NonNull CalendarView view, int year, int month,