Java Code Examples for android.content.DialogInterface.OnKeyListener

The following examples show how to use android.content.DialogInterface.OnKeyListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Androzic   Source File: Splash.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void showEula()
{
	final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
	boolean hasBeenShown = prefs.getBoolean(getString(R.string.app_eulaaccepted), false);
	if (hasBeenShown == false)
	{
		final SpannableString message = new SpannableString(Html.fromHtml(getString(R.string.app_eula).replace("/n", "<br/>")));
		Linkify.addLinks(message, Linkify.WEB_URLS);

		AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(getString(R.string.app_name)).setIcon(R.drawable.icon).setMessage(message)
				.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialogInterface, int i)
					{
						prefs.edit().putBoolean(getString(R.string.app_eulaaccepted), true).commit();
						wait = false;
						dialogInterface.dismiss();
					}
				}).setOnKeyListener(new OnKeyListener() {
					@Override
					public boolean onKey(DialogInterface dialoginterface, int keyCode, KeyEvent event)
					{
						return !(keyCode == KeyEvent.KEYCODE_HOME);
					}
				}).setCancelable(false);

		AlertDialog d = builder.create();

		d.show();
		// Make the textview clickable. Must be called after show()
		((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
	}
	else
	{
		wait = false;
	}
}
 
Example 2
Source Project: FimiX8-RE   Source File: X8UpdateHintController.java    License: MIT License 4 votes vote down vote up
public void showUpdateDialog() {
    if (UpdateUtil.getUpfireDtos().size() > 0) {
        SPStoreManager.getInstance().saveInt(HostConstants.SP_KEY_UPDATE_CHECK, 1);
        if (UpdateUtil.isForceUpdate()) {
            this.dialogManagerUpdate = new X8DoubleCustomDialog(this.context, this.context.getString(R.string.x8_update_fw_title), this.context.getString(R.string.x8_update_tip), this.context.getString(R.string.fimi_sdk_update_now), this.context.getString(R.string.fimi_sdk_update_return), new onDialogButtonClickListener() {
                public void onLeft() {
                    X8UpdateHintController.this.dialogManagerUpdate.dismiss();
                    X8UpdateHintController.this.context.startActivity(new Intent(X8UpdateHintController.this.context, X8UpdateDetailActivity.class));
                }

                public void onRight() {
                    X8UpdateHintController.this.context.finish();
                }
            });
            this.dialogManagerUpdate.setCanceledOnTouchOutside(false);
            this.dialogManagerUpdate.setOnKeyListener(new OnKeyListener() {
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    if (keyCode != 4 || event.getRepeatCount() == 0) {
                    }
                    return true;
                }
            });
            if (!this.context.isFinishing()) {
                this.dialogManagerUpdate.show();
                return;
            }
            return;
        }
        this.dialogManagerUpdate = new X8DoubleCustomDialog(this.context, this.context.getString(R.string.x8_update_fw_title), this.context.getString(R.string.x8_update_tip), this.context.getString(R.string.fimi_sdk_update_ignore), this.context.getString(R.string.fimi_sdk_update_now), new onDialogButtonClickListener() {
            public void onLeft() {
                X8UpdateHintController.this.dialogManagerUpdate.dismiss();
            }

            public void onRight() {
                X8UpdateHintController.this.dialogManagerUpdate.dismiss();
                X8UpdateHintController.this.context.startActivity(new Intent(X8UpdateHintController.this.context, X8UpdateDetailActivity.class));
            }
        });
        this.dialogManagerUpdate.setCanceledOnTouchOutside(false);
        if (!this.context.isFinishing()) {
            this.dialogManagerUpdate.show();
        }
    }
}
 
Example 3
@NonNull
@Override
public MaterialAlertDialogBuilder setOnKeyListener(@Nullable OnKeyListener onKeyListener) {
  return (MaterialAlertDialogBuilder) super.setOnKeyListener(onKeyListener);
}
 
Example 4
public PreferenceDialogBuilder setOnKeyListener(OnKeyListener onKeyListener) {
    mBuilder.setOnKeyListener(onKeyListener);
    return this;
}
 
Example 5
public PreferenceDialogBuilder setOnKeyListener(OnKeyListener onKeyListener) {
    mBuilder.setOnKeyListener(onKeyListener);
    return this;
}
 
Example 6
Source Project: gokit-android   Source File: GosDeviceControlActivity.java    License: MIT License 4 votes vote down vote up
/**
 * 初始化控件.
 */
private void initViews() {
	tvColorText = (TextView) findViewById(R.id.tvColorText);
	llColor = (LinearLayout) findViewById(R.id.ll_color);
	swRed = (Switch) findViewById(R.id.sw_red);
	swInfrared = (Switch) findViewById(R.id.sw_infrared);
	tvRed = (TextView) findViewById(R.id.tv_red);
	tvGreen = (TextView) findViewById(R.id.tv_green);
	tvBlue = (TextView) findViewById(R.id.tv_blue);
	tvSpeed = (TextView) findViewById(R.id.tv_speed);
	tvTemplate = (TextView) findViewById(R.id.tv_template);
	tvHumidity = (TextView) findViewById(R.id.tv_humidity);
	sbRed = (SeekBar) findViewById(R.id.sb_red);
	sbGreen = (SeekBar) findViewById(R.id.sb_green);
	sbBlue = (SeekBar) findViewById(R.id.sb_blue);
	sbSpeed = (SeekBar) findViewById(R.id.sb_speed);

	redadd = (ImageView) findViewById(R.id.redadd);
	redsub = (ImageView) findViewById(R.id.redsub);
	greenadd = (ImageView) findViewById(R.id.greenadd);
	greensub = (ImageView) findViewById(R.id.greensub);
	blueadd = (ImageView) findViewById(R.id.blueadd);
	bluesub = (ImageView) findViewById(R.id.bluesub);
	speedadd = (ImageView) findViewById(R.id.speedadd);
	speedsub = (ImageView) findViewById(R.id.speedsub);

	String waitingText = (String) getText(R.string.waiting_device_ready);
	setProgressDialog(waitingText, true, false);
	progressDialog.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

			if (keyCode == KeyEvent.KEYCODE_BACK) {
				if (progressDialog.isShowing()) {
					GosDeviceControlActivity.this.finish();
					return true;
				}
			}

			return false;
		}
	});
}
 
Example 7
/**
 * Sets the listener, which should be notified, when a key has been dispatched to the
 * preference's dialog.
 *
 * @param listener
 *         The listener, which should be set, as an instance of the type {@link OnKeyListener}
 *         or null, if no listener should be notified
 */
public final void setOnKeyListener(@Nullable final OnKeyListener listener) {
    onKeyListener = listener;
}