Skip to content

Commit

Permalink
when user press back key,fist close the menu,then back
Browse files Browse the repository at this point in the history
  • Loading branch information
UFreedom committed Sep 21, 2016
1 parent b0b48f8 commit 7ef3c02
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/src/main/java/io/github/loopX/XAlarm/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import io.github.loopX.XAlarm.view.UnlockTypeMenuLayout;
import io.github.loopX.XAlarm.view.YummyTextView;

import static android.os.Build.VERSION_CODES.M;

public class MainActivity extends BaseActivity implements View.OnClickListener, DragMenuLayout.DragMenuStateListener {

private static final String TAG = "ywp.MainActivity";
Expand Down Expand Up @@ -427,7 +429,7 @@ private void setLeftMenuStatus() {
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= M) {
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
mWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
mWindow.setStatusBarColor(getColor(R.color.loopX_1_50_alpha));
Expand All @@ -445,6 +447,20 @@ public void onWindowFocusChanged(boolean hasFocus) {

}



@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_BACK){
if (loopXDragMenuLayout.getMenuStatus() == DragMenuLayout.MenuStatus.Open){
loopXDragMenuLayout.closeMenuWithAnimation();
return true;
}
}
return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
Expand Down

0 comments on commit 7ef3c02

Please sign in to comment.