110 lines
3.9 KiB
Java
110 lines
3.9 KiB
Java
package androidx.appcompat.view.menu;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.os.IBinder;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import androidx.appcompat.R$layout;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import androidx.appcompat.view.menu.MenuPresenter;
|
|
|
|
/* loaded from: classes.dex */
|
|
class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, MenuPresenter.Callback {
|
|
private MenuBuilder a;
|
|
private AlertDialog b;
|
|
ListMenuPresenter c;
|
|
private MenuPresenter.Callback d;
|
|
|
|
public MenuDialogHelper(MenuBuilder menuBuilder) {
|
|
this.a = menuBuilder;
|
|
}
|
|
|
|
public void a(IBinder iBinder) {
|
|
MenuBuilder menuBuilder = this.a;
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(menuBuilder.e());
|
|
this.c = new ListMenuPresenter(builder.b(), R$layout.abc_list_menu_item_layout);
|
|
this.c.a(this);
|
|
this.a.a(this.c);
|
|
builder.a(this.c.a(), this);
|
|
View i = menuBuilder.i();
|
|
if (i != null) {
|
|
builder.a(i);
|
|
} else {
|
|
builder.a(menuBuilder.g());
|
|
builder.a(menuBuilder.h());
|
|
}
|
|
builder.a(this);
|
|
this.b = builder.a();
|
|
this.b.setOnDismissListener(this);
|
|
WindowManager.LayoutParams attributes = this.b.getWindow().getAttributes();
|
|
attributes.type = 1003;
|
|
if (iBinder != null) {
|
|
attributes.token = iBinder;
|
|
}
|
|
attributes.flags |= 131072;
|
|
this.b.show();
|
|
}
|
|
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
this.a.a((MenuItemImpl) this.c.a().getItem(i), 0);
|
|
}
|
|
|
|
@Override // android.content.DialogInterface.OnDismissListener
|
|
public void onDismiss(DialogInterface dialogInterface) {
|
|
this.c.a(this.a, true);
|
|
}
|
|
|
|
@Override // android.content.DialogInterface.OnKeyListener
|
|
public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
|
|
Window window;
|
|
View decorView;
|
|
KeyEvent.DispatcherState keyDispatcherState;
|
|
View decorView2;
|
|
KeyEvent.DispatcherState keyDispatcherState2;
|
|
if (i == 82 || i == 4) {
|
|
if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() == 0) {
|
|
Window window2 = this.b.getWindow();
|
|
if (window2 != null && (decorView2 = window2.getDecorView()) != null && (keyDispatcherState2 = decorView2.getKeyDispatcherState()) != null) {
|
|
keyDispatcherState2.startTracking(keyEvent, this);
|
|
return true;
|
|
}
|
|
} else if (keyEvent.getAction() == 1 && !keyEvent.isCanceled() && (window = this.b.getWindow()) != null && (decorView = window.getDecorView()) != null && (keyDispatcherState = decorView.getKeyDispatcherState()) != null && keyDispatcherState.isTracking(keyEvent)) {
|
|
this.a.a(true);
|
|
dialogInterface.dismiss();
|
|
return true;
|
|
}
|
|
}
|
|
return this.a.performShortcut(i, keyEvent, 0);
|
|
}
|
|
|
|
public void a() {
|
|
AlertDialog alertDialog = this.b;
|
|
if (alertDialog != null) {
|
|
alertDialog.dismiss();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter.Callback
|
|
public void a(MenuBuilder menuBuilder, boolean z) {
|
|
if (z || menuBuilder == this.a) {
|
|
a();
|
|
}
|
|
MenuPresenter.Callback callback = this.d;
|
|
if (callback != null) {
|
|
callback.a(menuBuilder, z);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter.Callback
|
|
public boolean a(MenuBuilder menuBuilder) {
|
|
MenuPresenter.Callback callback = this.d;
|
|
if (callback != null) {
|
|
return callback.a(menuBuilder);
|
|
}
|
|
return false;
|
|
}
|
|
}
|