Merge pull request #4411 from asdoi/dialog_keyboard

Close keyboard when dialogs were dismissed
This commit is contained in:
H. Lehmann 2020-09-14 16:57:18 +02:00 committed by GitHub
commit b7b63d7d31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -80,7 +80,7 @@
<activity
android:name=".activity.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|density|uiMode|keyboard|navigation"
android:windowSoftInputMode="stateHidden"
android:windowSoftInputMode="stateAlwaysHidden"
android:launchMode="singleTask"
android:label="@string/app_name">
</activity>

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@ -137,6 +138,7 @@ public class SleepTimerDialog extends DialogFragment {
if (controller != null) {
controller.setSleepTimer(time);
}
closeKeyboard(content);
} catch (NumberFormatException e) {
e.printStackTrace();
Snackbar.make(content, R.string.time_dialog_invalid_input, Snackbar.LENGTH_LONG).show();
@ -153,4 +155,9 @@ public class SleepTimerDialog extends DialogFragment {
timeDisplay.setVisibility(controller.sleepTimerActive() ? View.VISIBLE : View.GONE);
time.setText(Converter.getDurationStringLong((int) controller.getSleepTimerTimeLeft()));
}
private void closeKeyboard(View content) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(content.getWindowToken(), 0);
}
}