Search in sources :

Example 1 with OnKeyListener

use of android.content.DialogInterface.OnKeyListener in project android by nextcloud.

the class IndeterminateProgressDialog method onCreateDialog.

/**
 * {@inheritDoc}
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // / create indeterminate progress dialog
    final ProgressDialog progressDialog = new ProgressDialog(getActivity(), R.style.ProgressDialogTheme);
    progressDialog.setIndeterminate(true);
    progressDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            ProgressBar v = progressDialog.findViewById(android.R.id.progress);
            v.getIndeterminateDrawable().setColorFilter(ThemeColorUtils.primaryAccentColor(getContext()), android.graphics.PorterDuff.Mode.MULTIPLY);
        }
    });
    // / set message
    int messageId = getArguments().getInt(ARG_MESSAGE_ID, R.string.placeholder_sentence);
    progressDialog.setMessage(getString(messageId));
    // / set cancellation behavior
    boolean cancelable = getArguments().getBoolean(ARG_CANCELABLE, false);
    if (!cancelable) {
        progressDialog.setCancelable(false);
        // disable the back button
        OnKeyListener keyListener = new OnKeyListener() {

            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                return keyCode == KeyEvent.KEYCODE_BACK;
            }
        };
        progressDialog.setOnKeyListener(keyListener);
    }
    return progressDialog;
}
Also used : KeyEvent(android.view.KeyEvent) DialogInterface(android.content.DialogInterface) OnKeyListener(android.content.DialogInterface.OnKeyListener) ProgressDialog(android.app.ProgressDialog) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull)

Example 2 with OnKeyListener

use of android.content.DialogInterface.OnKeyListener in project SmartMesh_Android by SmartMeshFoundation.

the class AddContactFriendsNewUI method initData.

@Override
protected void initData() {
    setTitle(getString(R.string.contact_friends));
    mList = new ArrayList<>();
    mContactListAdapter = new AddContactFriendsAdapter(mList, AddContactFriendsNewUI.this);
    mContactListAdapter.setContactListener(this);
    mListView.setAdapter(mContactListAdapter);
    contactReceiver = new RefreshContactReceiver();
    IntentFilter filter = new IntentFilter(Constants.ACTION_SELECT_CONTACT_REFRESH);
    filter.addAction(LoadDataService.ACTION_REFRESH_UNRECOMMENT);
    LocalBroadcastManager.getInstance(this).registerReceiver(contactReceiver, filter);
    mProgressDialog = LoadingDialog.showDialog(AddContactFriendsNewUI.this, null, null);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                isBack = true;
                Utils.exitActivityAndBackAnim(AddContactFriendsNewUI.this, true);
            }
            return false;
        }
    });
    mProgressDialog.show();
    new ContactThread().start();
}
Also used : KeyEvent(android.view.KeyEvent) IntentFilter(android.content.IntentFilter) DialogInterface(android.content.DialogInterface) OnKeyListener(android.content.DialogInterface.OnKeyListener) AddContactFriendsAdapter(com.lingtuan.firefly.contact.adapter.AddContactFriendsAdapter) SuppressLint(android.annotation.SuppressLint)

Example 3 with OnKeyListener

use of android.content.DialogInterface.OnKeyListener in project smartmodule by carozhu.

the class MyWebChromeHelper method onJsConfirm.

/**
 * 覆盖默认的window.confirm展示界面,避免title里显示为“:来自file:////”
 */
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
    builder.setTitle("lizongbo的Android webview测试confirm对话框").setMessage(message).setPositiveButton("确定", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            result.confirm();
        }
    }).setNeutralButton("取消", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            result.cancel();
        }
    });
    builder.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            result.cancel();
        }
    });
    // 屏蔽keycode等于84之类的按键,避免按键后导致对话框消息而页面无法再弹出对话框的问题
    builder.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            Log.v("onJsConfirm", "keyCode==" + keyCode + "event=" + event);
            return true;
        }
    });
    // 禁止响应按back键的事件
    // builder.setCancelable(false);
    AlertDialog dialog = builder.create();
    dialog.show();
    return true;
// return super.onJsConfirm(view, url, message, result);
}
Also used : AlertDialog(android.app.AlertDialog) KeyEvent(android.view.KeyEvent) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) OnKeyListener(android.content.DialogInterface.OnKeyListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 4 with OnKeyListener

use of android.content.DialogInterface.OnKeyListener in project smartmodule by carozhu.

the class MyWebChromeHelper method onJsPrompt.

/**
 * 覆盖默认的window.prompt展示界面,避免title里显示为“:来自file:////”
 * window.prompt('请输入您的域名地址', '618119.com');
 */
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
    builder.setTitle("lizongbo的Android webview测试prompt对话框").setMessage(message);
    final EditText et = new EditText(view.getContext());
    et.setSingleLine();
    et.setText(defaultValue);
    builder.setView(et);
    builder.setPositiveButton("确定", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            result.confirm(et.getText().toString());
        }
    }).setNeutralButton("取消", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            result.cancel();
        }
    });
    // 屏蔽keycode等于84之类的按键,避免按键后导致对话框消息而页面无法再弹出对话框的问题
    builder.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            Log.v("onJsPrompt", "keyCode==" + keyCode + "event=" + event);
            return true;
        }
    });
    // 禁止响应按back键的事件
    // builder.setCancelable(false);
    AlertDialog dialog = builder.create();
    dialog.show();
    return true;
// return super.onJsPrompt(view, url, message, defaultValue, result);
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) KeyEvent(android.view.KeyEvent) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) OnKeyListener(android.content.DialogInterface.OnKeyListener)

Example 5 with OnKeyListener

use of android.content.DialogInterface.OnKeyListener in project Android-DialogFragments by wada811.

the class AbstractDialogFragment method setOnKeyListener.

protected void setOnKeyListener(Dialog dialog) {
    useOnKeyListener = true;
    dialog.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return bindKeyListener(keyCode, event);
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) DialogInterface(android.content.DialogInterface) OnKeyListener(android.content.DialogInterface.OnKeyListener)

Aggregations

DialogInterface (android.content.DialogInterface)9 OnKeyListener (android.content.DialogInterface.OnKeyListener)9 KeyEvent (android.view.KeyEvent)9 AlertDialog (android.app.AlertDialog)4 OnClickListener (android.content.DialogInterface.OnClickListener)3 ProgressDialog (android.app.ProgressDialog)2 SuppressLint (android.annotation.SuppressLint)1 OnCancelListener (android.content.DialogInterface.OnCancelListener)1 OnDismissListener (android.content.DialogInterface.OnDismissListener)1 IntentFilter (android.content.IntentFilter)1 EditText (android.widget.EditText)1 ProgressBar (android.widget.ProgressBar)1 NonNull (androidx.annotation.NonNull)1 AddContactFriendsAdapter (com.lingtuan.firefly.contact.adapter.AddContactFriendsAdapter)1 QtiImsException (org.codeaurora.ims.QtiImsException)1