2015-02-08 13:53:12 -08:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.os.Build;
|
2015-02-10 15:33:57 -08:00
|
|
|
import android.os.Build.VERSION;
|
|
|
|
import android.os.Build.VERSION_CODES;
|
2015-02-08 13:53:12 -08:00
|
|
|
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) {
|
2015-02-10 15:33:57 -08:00
|
|
|
return (keyCode == KeyEvent.KEYCODE_MENU && isMenuWorkaroundRequired()) || super.onKeyDown(keyCode, event);
|
2015-02-08 13:53:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
|
2015-02-10 15:33:57 -08:00
|
|
|
if (keyCode == KeyEvent.KEYCODE_MENU && isMenuWorkaroundRequired()) {
|
2015-02-08 13:53:12 -08:00
|
|
|
openOptionsMenu();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.onKeyUp(keyCode, event);
|
|
|
|
}
|
|
|
|
|
2015-02-10 15:33:57 -08:00
|
|
|
public static boolean isMenuWorkaroundRequired() {
|
2015-02-12 13:16:03 -08:00
|
|
|
return VERSION.SDK_INT < VERSION_CODES.KITKAT &&
|
|
|
|
VERSION.SDK_INT > VERSION_CODES.GINGERBREAD_MR1 &&
|
2015-02-10 15:33:57 -08:00
|
|
|
("LGE".equalsIgnoreCase(Build.MANUFACTURER) || "E6710".equalsIgnoreCase(Build.DEVICE));
|
2015-02-08 13:53:12 -08:00
|
|
|
}
|
|
|
|
}
|