List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java
private Dialog signOutDialog() { View.OnClickListener listener = new View.OnClickListener() { @Override/* w w w .j a va 2s. c om*/ public void onClick(View view) { switch (view.getId()) { case R.id.close_app: if (onDialogClickLisenter != null) onDialogClickLisenter.viewClick(StringConstant.tv_confirm); dismiss(); break; case R.id.stay_here: if (onDialogClickLisenter != null) onDialogClickLisenter.viewClick(StringConstant.tv_cancel); dismiss(); break; default: break; } } }; View convertView = LayoutInflater.from(mContext).inflate(R.layout.view_sign_out_dialog, null); TextView signOutButton = (TextView) convertView.findViewById(R.id.stay_here); TextView closeAppButton = (TextView) convertView.findViewById(R.id.close_app); signOutButton.setOnClickListener(listener); closeAppButton.setOnClickListener(listener); Dialog dialog = new Dialog(mContext, R.style.CustomDialog); dialog.setContentView(convertView); dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style); return dialog; }
From source file:pulseanddecibels.jp.yamatenki.activity.SplashActivity.java
private void displayUserLicenseAgreement() { final Dialog dialog = new Dialog(SplashActivity.this); // dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_license_agreement); dialog.setTitle(getString(R.string.text_license_agreement_title)); dialog.setCanceledOnTouchOutside(false); Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.yama_brown)); dialog.getWindow().setBackgroundDrawable(d); dialog.show();/*from w ww. j a v a2 s .co m*/ licenseAgreementDialogOpen = true; dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (!agreeButtonPressed) { licenseAgreementDialogOpen = false; settings.setAgreedToLicense(false); if (!databaseTaskRunning) { finish(); } } } }); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { licenseAgreementDialogOpen = false; settings.setAgreedToLicense(false); if (!databaseTaskRunning) { finish(); } } }); final Button agreeButton = (Button) dialog.findViewById(R.id.agree_button); agreeButton.setEnabled(false); agreeButton.setAlpha(.5f); agreeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { settings.setAgreedToLicense(true); agreeButtonPressed = true; dialog.dismiss(); if (!databaseTaskRunning) { startMainActivity(); } } }); final CheckBox agreementCheckbox = (CheckBox) dialog.findViewById(R.id.agreement_checkbox); agreementCheckbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CheckBox checkbox = (CheckBox) v; if (checkbox.isChecked()) { agreeButton.setAlpha(1.0f); agreeButton.setEnabled(true); } else { agreeButton.setAlpha(.5f); agreeButton.setEnabled(false); } } }); TextView agreementLabel = (TextView) dialog.findViewById(R.id.agreement_label); agreementLabel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { agreementCheckbox.setChecked(!agreementCheckbox.isChecked()); if (agreementCheckbox.isChecked()) { agreeButton.setAlpha(1.0f); agreeButton.setEnabled(true); } else { agreeButton.setAlpha(.5f); agreeButton.setEnabled(false); } } }); }
From source file:piuk.blockchain.android.ui.dialogs.RequestPasswordDialog.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final FragmentActivity activity = (FragmentActivity) getActivity(); final WalletApplication application = (WalletApplication) activity.getApplication(); final LayoutInflater inflater = LayoutInflater.from(activity); final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog)); if (passwordType == PasswordTypeSecond) dialog.setTitle(R.string.second_password_title); else if (passwordType == PasswordTypePrivateKey) dialog.setTitle(R.string.private_key_password_title); else//from w ww .j a va 2 s .c o m dialog.setTitle(R.string.main_password_title); final View view = inflater.inflate(R.layout.password_dialog, null); dialog.setView(view); final TextView passwordField = (TextView) view.findViewById(R.id.password_field); final TextView titleTextView = (TextView) view.findViewById(R.id.title_text_view); if (passwordType == PasswordTypeSecond) titleTextView.setText(R.string.second_password_text); else if (passwordType == PasswordTypePrivateKey) titleTextView.setText(R.string.private_key_password_text); else titleTextView.setText(R.string.main_password_text); final Button continueButton = (Button) view.findViewById(R.id.password_continue); continueButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { if (passwordType == PasswordTypeSecond) { if (passwordField.getText().toString().trim() == null || passwordField.getText().toString().trim().length() < 1) return; MyRemoteWallet wallet = application.getRemoteWallet(); String secondPassword = passwordField.getText().toString().trim(); if (wallet == null) { dismiss(); callback.onFail(); } if (wallet.validateSecondPassword(secondPassword)) { wallet.setTemporySecondPassword(secondPassword); dismiss(); callback.onSuccess(); } else { Toast.makeText(activity.getApplication(), R.string.password_incorrect, Toast.LENGTH_SHORT).show(); } } else if (passwordType == PasswordTypeMain) { if (passwordField.getText().toString().trim() == null || passwordField.getText().toString().trim().length() < 1) { callback.onFail(); } String localWallet = application.readLocalWallet(); if (!application.decryptLocalWallet(localWallet, passwordField.getText().toString().trim())) { callback.onFail(); return; } String password = passwordField.getText().toString().trim(); application.checkIfWalletHasUpdatedAndFetchTransactions(password, new SuccessCallback() { @Override public void onSuccess() { dismiss(); callback.onSuccess(); } @Override public void onFail() { dismiss(); callback.onFail(); } }); } else { if (passwordField.getText().toString().trim() == null || passwordField.getText().toString().trim().length() < 1) { callback.onFail(); } String localWallet = application.readLocalWallet(); if (!application.decryptLocalWallet(localWallet, passwordField.getText().toString().trim())) { callback.onFail(); return; } passwordResult = passwordField.getText().toString().trim(); dismiss(); callback.onSuccess(); } } catch (Exception e) { e.printStackTrace(); } } }); Dialog d = dialog.create(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.dimAmount = 0; lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; // lp.gravity = Gravity.BOTTOM; d.show(); d.getWindow().setAttributes(lp); d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); return d; }
From source file:piuk.blockchain.android.ui.dialogs.NewAccountDialog.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); final FragmentActivity activity = getActivity(); final LayoutInflater inflater = LayoutInflater.from(activity); final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog)) .setTitle(R.string.new_account_title); final View view = inflater.inflate(R.layout.new_account_dialog, null); dialog.setView(view);/*w w w . j a va 2 s. c om*/ final Button createButton = (Button) view.findViewById(R.id.create_button); final TextView password = (TextView) view.findViewById(R.id.password); final TextView password2 = (TextView) view.findViewById(R.id.password2); final TextView captcha = (TextView) view.findViewById(R.id.captcha); refreshCaptcha(view); createButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { final WalletApplication application = (WalletApplication) getActivity().getApplication(); if (password.getText().length() < 11 || password.getText().length() > 255) { Toast.makeText(application, R.string.new_account_password_length_error, Toast.LENGTH_LONG) .show(); return; } if (!password.getText().toString().equals(password2.getText().toString())) { Toast.makeText(application, R.string.new_account_password_mismatch_error, Toast.LENGTH_LONG) .show(); return; } if (captcha.getText().length() == 0) { Toast.makeText(application, R.string.new_account_no_kaptcha_error, Toast.LENGTH_LONG).show(); return; } final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.creating_account), true); progressDialog.show(); final Handler handler = new Handler(); new Thread() { @Override public void run() { try { try { application.generateNewWallet(); } catch (Exception e1) { throw new Exception("Error Generating Wallet"); } application.getRemoteWallet().setTemporyPassword(password.getText().toString()); if (!application.getRemoteWallet().remoteSave(captcha.getText().toString())) { throw new Exception("Unknown Error Inserting wallet"); } EventListeners.invokeWalletDidChange(); handler.post(new Runnable() { public void run() { try { progressDialog.dismiss(); dismiss(); Toast.makeText(getActivity().getApplication(), R.string.new_account_success, Toast.LENGTH_LONG).show(); PinEntryActivity.clearPrefValues(application); Editor edit = PreferenceManager .getDefaultSharedPreferences(application.getApplicationContext()) .edit(); edit.putString("guid", application.getRemoteWallet().getGUID()); edit.putString("sharedKey", application.getRemoteWallet().getSharedKey()); AbstractWalletActivity activity = (AbstractWalletActivity) getActivity(); if (edit.commit()) { application.checkWalletStatus(activity); } else { throw new Exception("Error saving preferences"); } } catch (Exception e) { e.printStackTrace(); application.clearWallet(); Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } }); } catch (final Exception e) { e.printStackTrace(); application.clearWallet(); handler.post(new Runnable() { public void run() { progressDialog.dismiss(); refreshCaptcha(view); captcha.setText(null); Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }); } } }.start(); } }); Dialog d = dialog.create(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.dimAmount = 0; lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; d.show(); d.getWindow().setAttributes(lp); d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); return d; }
From source file:com.tingtingapps.securesms.ConversationListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { final View view = inflater.inflate(R.layout.conversation_list_fragment, container, false); reminderView = (ReminderView) view.findViewById(R.id.reminder); list = (RecyclerView) view.findViewById(R.id.list); fab = (FloatingActionButton) view.findViewById(R.id.fab); list.setHasFixedSize(true);/*from w w w .ja va2 s.c o m*/ list.setLayoutManager(new LinearLayoutManager(getActivity())); Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK); int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); SharedPreferences sp1 = getActivity().getSharedPreferences("myPrefs", Activity.MODE_PRIVATE); int dayShowPopup = sp1.getInt("dayShowPopup", 0); /* //test data day = 7; dayShowPopup = 15; dayOfMonth = 26;*/ if (day == 7 && dayOfMonth != dayShowPopup) { SharedPreferences sp2 = getActivity().getSharedPreferences("myPrefs", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sp2.edit(); editor.putInt("dayShowPopup", dayOfMonth); editor.commit(); final Dialog dialogRating = new Dialog(getActivity()); dialogRating.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogRating.setContentView(R.layout.dlg_rating_sharing_donating); int height = 850; dialogRating.getWindow().setLayout(LinearLayout.LayoutParams.FILL_PARENT, height); dialogRating.setCancelable(true); dialogRating.show(); Button btnRate = (Button) dialogRating.findViewById(R.id.btn_rate); btnRate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context context = getActivity().getApplicationContext(); String packageName = context.getPackageName(); Intent intentRateApp = new Intent(Intent.ACTION_VIEW); intentRateApp.setData(Uri.parse("market://details?id=" + packageName)); startActivity(intentRateApp); } }); /*Button btnRemoveAds = (Button) dialogRating.findViewById(R.id.btn_remove_ads); btnRemoveAds.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intentInAppBilling = new Intent(getActivity(), InAppBillingActivity.class); startActivity(intentInAppBilling); } });*/ Button btnShare = (Button) dialogRating.findViewById(R.id.btn_share); btnShare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = getString(R.string.socail_share_body); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.socail_share_title)); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, getString(R.string.socail_share_via))); } }); Button btnClose = (Button) dialogRating.findViewById(R.id.btn_close); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialogRating.dismiss(); } }); } return view; }
From source file:au.gov.ga.worldwind.androidremote.client.Remote.java
protected void showVerticalExaggerationDialog() { Dialog dialog = new VerticalExaggerationDialog(this, currentExaggeration, communicator); dialog.setCanceledOnTouchOutside(true); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); lp.width = Math.min(metrics.widthPixels - 20, (int) (400 * metrics.density)); dialog.show();//from w w w . j ava 2 s . c om dialog.getWindow().setAttributes(lp); }
From source file:com.fbartnitzek.tasteemall.filter.AttributeFilterBaseDialogFragment.java
@NonNull @Override/*from www. j a v a 2 s . c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); Bundle bundle = getArguments(); if (bundle == null) { bundle = savedInstanceState; } if (bundle == null) { throw new RuntimeException("neither args nor savedInstance - should never happen..."); } mBaseEntity = bundle.getString(BASE_ENTITY); mAttributeName = bundle.getString(ATTRIBUTE_NAME); // nothing really works to restrict the size => TODO Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.CENTER); // dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); // WindowManager.LayoutParams p = window.getAttributes(); // Log.v(LOG_TAG, "onCreateDialog, p.verticalMargin=" + p.verticalMargin + ", " + "p.horizontalMargin = [" + p.horizontalMargin+ "]"); // p.height = getActivity().getResources().getDisplayMetrics().heightPixels / 2; // float vertMargin = p.verticalMargin; // p.verticalMargin = vertMargin + dpToPx(100); // p.y = prevY + dpToPx(100); // p.x = 150; // window.setAttributes(p); // fullscreen: height and width = -1 // Log.v(LOG_TAG, "onCreateDialog, p.width=" + p.width + ", " + "p.height = [" + p.height+ "]"); } return dialog; }
From source file:com.nbplus.vbroadlauncher.fragment.LoadIoTDevicesDialogFragmentStatus.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = new Dialog( getActivity()/*new ContextThemeWrapper(getActivity(), R.style.FullScreenDialog)*/); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setRetainInstance(true);// w w w. j a v a 2 s. com originalOrientation = getActivity().getRequestedOrientation(); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // fullscreen without statusbar dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); dialog.setCancelable(false); this.setCancelable(false); // disable back key dialog.setOnKeyListener(this); // set content view View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_iot_devices, null, false); dialog.setContentView(v); // grid view mGridView = (GridView) v.findViewById(R.id.iot_devices_grid); mGridView.setEmptyView(v.findViewById(android.R.id.empty)); // set button control mCloseButton = (ImageButton) v.findViewById(R.id.btn_close); mCloseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "onClick btnClose.."); ((BaseActivity) getActivity()).dismissProgressDialog(); Intent sendIntent = new Intent(); sendIntent.setAction(Constants.ACTION_IOT_DEVICE_LIST); sendIntent.putExtra(Constants.EXTRA_IOT_DEVICE_CANCELED, true); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(sendIntent); dismiss(); } }); mRefreshButton = (Button) v.findViewById(R.id.btn_refresh); mRefreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "onClick btnRefresh.."); ((BaseActivity) getActivity()).showProgressDialog(); IoTInterface.getInstance().getDevicesList(DeviceTypes.ALL, LoadIoTDevicesDialogFragmentStatus.this, true); mHandler.postDelayed(new Runnable() { @Override public void run() { ((BaseActivity) getActivity()).dismissProgressDialog(); } }, 6000); } }); mSendButton = (Button) v.findViewById(R.id.btn_send); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "onClick btnSend.."); ((BaseActivity) getActivity()).dismissProgressDialog(); showSyncAlertDialog(); } }); mGridView.setOnItemClickListener(this); return dialog; }
From source file:com.amazon.appstream.fireclient.ConnectDialogFragment.java
/** * Create callback; performs initial set-up. *//*w w w .j a v a 2s . c o m*/ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mEmpty.setAlpha(0); final Dialog connectDialog = new Dialog(getActivity()); connectDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); connectDialog.setCanceledOnTouchOutside(false); connectDialog.setCancelable(false); connectDialog.setContentView(R.layout.server_address); connectDialog.getWindow().setBackgroundDrawable(mEmpty); mAddressTitle = (TextView) connectDialog.findViewById(R.id.address_title); mAddressField = (TextView) connectDialog.findViewById(R.id.address); mTextEntryFields = connectDialog.findViewById(R.id.text_entry_fields); mProgressBar = (ProgressBar) connectDialog.findViewById(R.id.progress_bar); mUseHardware = (CheckBox) connectDialog.findViewById(R.id.hardware); mUseHardware.setChecked(false); final CheckBox useAppServerBox = (CheckBox) connectDialog.findViewById(R.id.appserver); useAppServerBox.setChecked(mUseAppServer); useAppServerBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (!mUseAppServer) { mDESServerAddress = mAddressField.getText().toString(); } } else { if (mUseAppServer) { mServerAddress = mAddressField.getText().toString(); } } mUseAppServer = isChecked; updateFields(); } }); mAppIdField = (TextView) connectDialog.findViewById(R.id.appid); mSpace1 = connectDialog.findViewById(R.id.space1); mSpace2 = connectDialog.findViewById(R.id.space2); mAppIdTitle = connectDialog.findViewById(R.id.appid_title); mUserIdTitle = connectDialog.findViewById(R.id.userid_title); if (mAppId != null) { mAppIdField.setText(mAppId); } mUserIdField = (TextView) connectDialog.findViewById(R.id.userid); if (mUsername != null) { mUserIdField.setText(mUsername); } mErrorMessageField = (TextView) connectDialog.findViewById(R.id.error_message); mReconnect = connectDialog.findViewById(R.id.reconnect_fields); mReconnectMessage = (TextView) connectDialog.findViewById(R.id.reconnect_message); final Button connectButton = (Button) connectDialog.findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onConnect(); } }); TextView.OnEditorActionListener listener = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_GO) { InputMethodManager imm = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mUserIdField.getWindowToken(), 0); onConnect(); } return true; } }; View.OnFocusChangeListener focusListener = new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { connectButton.setFocusableInTouchMode(false); } }; mAppIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnEditorActionListener(listener); updateFields(); if (mAddressField.getText().length() == 0) { mAddressField.requestFocus(); connectButton.setFocusableInTouchMode(false); } else { connectButton.requestFocus(); } if (mReconnectMessageString != null) { reconnecting(mReconnectMessageString); mReconnectMessageString = null; } return connectDialog; }
From source file:com.eu.inmite.android.lib.dialogs.BaseDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = new Dialog(getActivity(), R.style.SDL_Dialog); // custom dialog background final TypedArray a = getActivity().getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);/* w w w .j av a 2 s. co m*/ Drawable dialogBackground = a.getDrawable(R.styleable.DialogStyle_dialogBackground); a.recycle(); dialog.getWindow().setBackgroundDrawable(dialogBackground); return dialog; }