session-android/src/org/thoughtcrime/securesms/BaseActivity.java

29 lines
855 B
Java
Raw Normal View History

package org.thoughtcrime.securesms;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.view.KeyEvent;
public abstract class BaseActivity extends FragmentActivity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return isKeyCodeWorkaroundRequired(keyCode) || super.onKeyDown(keyCode, event);
}
@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
if (isKeyCodeWorkaroundRequired(keyCode)) {
openOptionsMenu();
return true;
}
return super.onKeyUp(keyCode, event);
}
public static boolean isKeyCodeWorkaroundRequired(int keyCode) {
return (keyCode == KeyEvent.KEYCODE_MENU) &&
(Build.VERSION.SDK_INT == 16) &&
("LGE".equalsIgnoreCase(Build.MANUFACTURER));
}
}