disable hardware keyboard shortcuts when an EditText is focused

This commit is contained in:
asdoi 2020-11-06 18:08:59 +01:00 committed by ByteHamster
parent 29f46d97c0
commit 1e14cacf89
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -542,6 +543,11 @@ public class MainActivity extends CastEnabledActivity {
//Hardware keyboard support
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
View currentFocus = getCurrentFocus();
if (currentFocus instanceof EditText) {
return super.onKeyUp(keyCode, event);
}
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
Integer customKeyCode = null;

View File

@ -12,6 +12,7 @@ import android.view.KeyEvent;
import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.EditText;
import android.widget.ImageView;
import androidx.appcompat.view.menu.ActionMenuItem;
@ -489,6 +490,11 @@ public class VideoplayerActivity extends MediaplayerActivity {
//Hardware keyboard support
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
View currentFocus = getCurrentFocus();
if (currentFocus instanceof EditText) {
return super.onKeyUp(keyCode, event);
}
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {