List of usage examples for android.app AlertDialog getWindow
public @Nullable Window getWindow()
From source file:com.SecUpwN.AIMSICD.service.AimsicdService.java
void setSilentSmsStatus(boolean state) { mTypeZeroSmsDetected = state;/*from www . ja v a 2 s . c om*/ setNotification(); if (state) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.sms_message).setTitle(R.string.sms_title); AlertDialog alert = builder.create(); alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); alert.show(); mTypeZeroSmsDetected = false; } }
From source file:com.SecUpwN.AIMSICD.service.AimsicdService.java
private void enableLocationServices() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.location_error_message).setTitle(R.string.location_error_title) .setPositiveButton(R.string.text_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent gpsSettings = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); gpsSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(gpsSettings); }/*from ww w . j av a 2 s. c om*/ }).setNegativeButton(R.string.text_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setCellTracking(false); } }); AlertDialog alert = builder.create(); alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); alert.show(); }
From source file:com.justone.android.main.MainActivity.java
public void userFirstTips() { @SuppressWarnings("deprecation") SharedPreferences preferences = getSharedPreferences("count", MODE_WORLD_READABLE); int count = preferences.getInt("count", 0); // /* w w w. j a va 2 s .c o m*/ if (count == 0) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.first_tips, (ViewGroup) findViewById(R.id.first_tips)); final AlertDialog dialog = new AlertDialog.Builder(this).setView(layout).show(); layout.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { dialog.dismiss(); return true; } }); dialog.getWindow().setLayout(650, 650); } Editor editor = preferences.edit(); // editor.putInt("count", ++count); // editor.commit(); }
From source file:de.spiritcroc.ownlog.ui.fragment.TagItemEditFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(activity); final View view = activity.getLayoutInflater().inflate(R.layout.tag_edit_item, null); mEditTagName = (EditText) view.findViewById(R.id.name_edit); mEditTagDescription = (EditText) view.findViewById(R.id.description_edit); boolean restoredValues = restoreValues(savedInstanceState); builder.setTitle(mAddItem ? R.string.title_tag_item_add : R.string.title_tag_item_edit).setView(view) .setPositiveButton(R.string.dialog_ok, null) .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { @Override/* www .j av a2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { // Only dismiss (and hide keyboard) hideKeyboard(); } }); if (!mAddItem) { builder.setNeutralButton(R.string.dialog_delete, null); } final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { saveChanges(); } }); if (!mAddItem) { alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { promptDelete(); } }); } } }); if (!restoredValues) { // Edit text requires user interaction, so show keyboard alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); if (mAddItem) { initValues(); } else { loadContent(); } } return alertDialog; }
From source file:org.proto.led.lightlist.LightsListActivity.java
public void alertEditTextKeyboardShown() { // creating the EditText widget programatically final EditText editText = new EditText(this); // create the AlertDialog as final final AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Group name").setTitle("Group") .setView(editText)//w w w. j ava 2 s.c om // Set the action buttons .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { createAndStoreGroup(editText.getText().toString()); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // removes the AlertDialog in the screen } }).create(); // set the focus change listener of the EditText // this part will make the soft keyboard automaticall visible editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); dialog.show(); }
From source file:org.catrobat.catroid.ui.dialogs.NewSpriteDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_object, null); setupPaintroidButton(dialogView);/*from www . j a va2 s .c om*/ setupGalleryButton(dialogView); setupCameraButton(dialogView); setupMediaLibraryButton(dialogView); AlertDialog dialog = null; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(R.string.new_sprite_dialog_title); if (wizardStep == DialogWizardStep.STEP_1) { dialog = createDialogStepOne(dialogBuilder); } else if (wizardStep == DialogWizardStep.STEP_2) { dialog = createDialogStepTwo(dialogBuilder); } dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (handleOkButton()) { dialog.dismiss(); } } }); } }); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return dialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { dialogView = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_new_object, null);//from w w w . j av a2s .c o m setupPaintroidButton(dialogView); setupGalleryButton(dialogView); setupCameraButton(dialogView); AlertDialog dialog = null; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.new_sprite_dialog_title); if (wizardStep == DialogWizardStep.STEP_1) { dialog = createDialogStepOne(dialogBuilder); } else if (wizardStep == DialogWizardStep.STEP_2) { dialog = createDialogStepTwo(dialogBuilder); } dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (handleOkButton()) { dialog.dismiss(); } } }); } }); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return dialog; }
From source file:com.github.nutomic.pegasus.activities.AreaList.java
/** * Show an AlertDialog to edit the name of an area. * /*from w ww. ja v a2s . com*/ * @param area ID of the area to rename. */ private void renameArea(final long id, String name) { final Database db = Database.getInstance(this); final EditText input = new EditText(this); input.setText(name); input.setSingleLine(); AlertDialog alert = new AlertDialog.Builder(this).setTitle(R.string.arealist_rename).setView(input) .setPositiveButton(android.R.string.ok, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { new UpdateTask() { @Override protected Long doInBackground(Void... params) { // Don't rename default area. if (id != AreaColumns.AREA_DEFAULT) { ContentValues cv = new ContentValues(); cv.put(AreaColumns.NAME, input.getText().toString()); db.getWritableDatabase().update(AreaColumns.TABLE_NAME, cv, AreaColumns._ID + " = ?", new String[] { Long.toString(id) }); } return null; } }.execute((Void) null); } }).setNegativeButton(android.R.string.cancel, null).create(); alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); alert.show(); input.selectAll(); }
From source file:de.spiritcroc.ownlog.ui.fragment.ImportLogFragment.java
private void loadImportDb(String passwd) { if (mDbHelper == null) { mDbHelper = new ExternalDbReadHelper(mImportFiles.logDbFile.getAbsolutePath()); }//from ww w .ja v a 2s. c o m SQLiteDatabase db = null; try { db = mDbHelper.getReadableDatabase(passwd); } catch (SQLiteException e) { e.printStackTrace(); } catch (DbHelper.UnsupportedUpgradeException e) { Log.w(TAG, "Import: unsupported upgrade from " + e.oldVersion); // Unsupported db version: notify user and close activity invalidImport(); // No more prompting for password return; } if (db != null) { new LoadBackupTask(db).execute(); } else { // Prompt for password final Activity activity = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(activity); final View view = activity.getLayoutInflater().inflate(R.layout.dialog_request_password, null); final EditText editPassword = (EditText) view.findViewById(R.id.edit_password); final AlertDialog alertDialog = builder.setTitle(R.string.import_dialog_request_password).setView(view) .setCancelable(false) .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { loadImportDb(editPassword.getText().toString()); } }).setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.finish(); mDbHelper.close(); } }).show(); // Edit text requires user interaction, so show keyboard alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } }
From source file:org.rssin.android.NavigationDrawerManageFiltersFragment.java
/** * Open dialog to create new filter//from ww w . j av a2 s . c o m * For the moment, we temporarily disable rotating because we can't get it working otherwise. * Possible feature: make rotating possible */ public void openAddDialog() { //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); AlertDialog.Builder alert = new AlertDialog.Builder(rootView.getContext()); alert.setTitle(getString(R.string.filters_action_add)); alert.setMessage(getString(R.string.filter_settings_title)); final EditText input = new EditText(rootView.getContext()); input.setFocusable(true); input.requestFocus(); AlertDialog dialog = alert.setView(input).setPositiveButton(getResources().getString(R.string.button_apply), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); try { Filter f = new Filter(value); filtersList.getFilters().add(f); filtersList.save(); filterAdapter.notifyDataSetChanged(); openFilterSettings(f); } catch (Exception e) { Frontend.error(rootView.getContext(), R.string.error_save_filters, e); } //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }).setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }).create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.show(); }