Java Code Examples for android.app.Dialog

The following examples show how to use android.app.Dialog. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
protected void onPostCreate(Bundle bundle) {
	super.onPostCreate(bundle);

	showInfoDialog();
	checkUpdates();

	ChangeLog changeLog = new ChangeLog(this, Util.getPreferences(this));
	if(changeLog.isFirstRun()) {
		if(changeLog.isFirstRunEver()) {
			changeLog.updateVersionInPreferences();
		} else {
			Dialog log = changeLog.getLogDialog();
			if (log != null) {
				//log.show(); //For now we don't want to show changelog on first start after update, most users don't care about this. If they want to see it they can do that from the top right menu. Might change it back later depending on feedback.
			}
		}
	}
}
 
Example 2
Source Project: DeviceConnect-Android   Source File: ErrorDialogFragment.java    License: MIT License 6 votes vote down vote up
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    Bundle args = getArguments();
    if (args == null) {
        dismiss();
    }

    String title = args.getString(EXTRA_TITLE);
    if (title == null) {
        title = getString(R.string.dconnect_error_default_title);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(title);
    builder.setMessage(args.getString(EXTRA_MESSAGE));
    builder.setPositiveButton(R.string.activity_settings_close, (dialog, which) -> {
        dialog.dismiss();
    });
    return builder.create();
}
 
Example 3
Source Project: o2oa   Source File: DialogCreator.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static Dialog createDelConversationDialog(Context context,
                                                 View.OnClickListener listener, boolean isTop) {
    Dialog dialog = new Dialog(context, IdHelper.getStyle(context, "jmui_default_dialog_style"));
    View v = LayoutInflater.from(context).inflate(
            IdHelper.getLayout(context, "jmui_dialog_delete_conv"), null);
    dialog.setContentView(v);
    final LinearLayout deleteLl = (LinearLayout) v.findViewById(IdHelper
            .getViewID(context, "jmui_delete_conv_ll"));
    final LinearLayout top = (LinearLayout) v.findViewById(IdHelper
            .getViewID(context, "jmui_top_conv_ll"));
    TextView tv_top = (TextView) v.findViewById(IdHelper.getViewID(context, "tv_conv_top"));
    if (isTop) {
        tv_top.setText("会话置顶");
    } else {
        tv_top.setText("取消置顶");
    }

    deleteLl.setOnClickListener(listener);
    top.setOnClickListener(listener);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
}
 
Example 4
Source Project: Androzic   Source File: LocationInfo.java    License: GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
	builder.setTitle(getString(R.string.information_name));
	View view = getActivity().getLayoutInflater().inflate(R.layout.dlg_location_info, null);
	builder.setView(view);
	builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int whichButton)
		{
			LocationInfo.this.dismiss();
		}
	});
	updateLocationInfo(view);
	return builder.create();
}
 
Example 5
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    //PackageManager pm = super.getPackageManager();
    Vector<String> appNames = new Vector<String>();
    for (ApplicationInfo appInfo : applicationInfos)
    {
        appNames.add(new String(appInfo.name));
    }

    // converting Vector appNames to String[] appNamesStr
    String [] appNamesStr=appNames.toArray(new String[appNames.size()]);

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_select_controlled_app)
            .setItems(appNamesStr, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // The 'which' argument contains the index position
                    // of the selected item
                    mListener.onCtrlAppSelected(dialog, which);
                }
            });
    // Create the AlertDialog object and return it
    return builder.create();
}
 
Example 6
private void clearHistoryDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setTitle(getResources().getString(R.string.title_clear_history));
    Dialog dialog = builder.setMessage(getResources().getString(R.string.dialog_history))
        .setPositiveButton(getResources().getString(R.string.action_yes),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    clearHistory()
                        .subscribeOn(Schedulers.io())
                        .observeOn(Schedulers.main())
                        .subscribe(new CompletableOnSubscribe() {
                            @Override
                            public void onComplete() {
                                Utils.showSnackbar(getActivity(), R.string.message_clear_history);
                            }
                        });
                }
            })
        .setNegativeButton(getResources().getString(R.string.action_no), null).show();
    BrowserDialog.setDialogSize(mActivity, dialog);
}
 
Example 7
Source Project: fingen   Source File: FragmentAmountEdit.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    mAmountEditor.requestFocus();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mAmountEditor.getCabbage().getID() < 0) {
                    //show error
                    mAmountEditor.showCabbageError();
                } else {
                    mOnComplete.onComplete(mAmountEditor.getAmount().multiply(new BigDecimal((mAmountEditor.getType() > 0) ? 1 : -1)), mAmountEditor.getCabbage());
                    dismiss();
                }
            }
        });
    }
}
 
Example 8
Source Project: android-vision   Source File: OcrCaptureActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() throws SecurityException {
    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (cameraSource != null) {
        try {
            preview.start(cameraSource, graphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            cameraSource.release();
            cameraSource = null;
        }
    }
}
 
Example 9
Source Project: Focus   Source File: HelpDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("InflateParams")
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final View customView;
        try {
            customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_help_view, null);
        } catch (InflateException e) {
            throw new IllegalStateException("This device does not support Web Views.");
        }
        MaterialDialog dialog =
                new MaterialDialog.Builder(getActivity())
                        .theme(getArguments().getBoolean("dark_theme") ? Theme.DARK : Theme.LIGHT)
                        .title("帮助信息")
                        .customView(customView, false)
                        .positiveText(android.R.string.ok)
                        .build();

        final WebView webView = customView.findViewById(R.id.webview);
//        webView.loadData(this.content, "text/html", "UTF-8");
        WebViewUtil.LoadHtmlIntoWebView(webView,this.content,getActivity(),"");
        return dialog;
    }
 
Example 10
Source Project: drmips   Source File: DlgChangeLatency.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	super.onCreateDialog(savedInstanceState);

	Bundle args = getArguments();
	DrMIPSActivity activity = (DrMIPSActivity)getActivity();
	Component component = activity.getCPU().getComponent(args.getString("id", ""));
	txtLatency = new EditText(getActivity());
	txtLatency.setHint(R.string.latency);
	txtLatency.setInputType(InputType.TYPE_CLASS_NUMBER);
	if(savedInstanceState != null && savedInstanceState.containsKey("latency")) {
		txtLatency.setText(savedInstanceState.getString("latency"));
	}
	else {
		if(component != null) txtLatency.setText("" + component.getLatency());
	}

	return new AlertDialog.Builder(getActivity())
		.setTitle(getResources().getString(R.string.latency_of_x).replace("#1", args.getString("id", "")))
		.setView(txtLatency)
		.setPositiveButton(android.R.string.ok, this)
		.setNegativeButton(android.R.string.cancel, this)
		.create();
}
 
Example 11
Source Project: AndroidChromium   Source File: SignOutDialogFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mGaiaServiceType = AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE;
    if (getArguments() != null) {
        mGaiaServiceType = getArguments().getInt(
                SHOW_GAIA_SERVICE_TYPE_EXTRA, mGaiaServiceType);
    }

    String managementDomain = SigninManager.get(getActivity()).getManagementDomain();
    String message;
    if (managementDomain == null) {
        message = getActivity().getResources().getString(R.string.signout_message);
    } else {
        message = getActivity().getResources().getString(
                R.string.signout_managed_account_message, managementDomain);
    }

    return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setTitle(R.string.signout_title)
            .setPositiveButton(R.string.signout_dialog_positive_button, this)
            .setNegativeButton(R.string.cancel, this)
            .setMessage(message)
            .create();
}
 
Example 12
Source Project: PacketCaptureTool   Source File: CaptureActivity.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void showCapturingDialog()
{
	/* 创建新的对话框显示抓包状态 */
	dlgCapturing = new Dialog(CaptureActivity.this.getActivity());
	dlgCapturing.setContentView(R.layout.capture_dialog);
	dlgCapturing.setTitle(R.string.capturing);
	dlgCapturing.setCancelable(false);
    
    btnStopCapture = (Button)dlgCapturing.findViewById(R.id.btnStopCapture);
    btnStopCapture.setText(R.string.stop_capture);
    btnStopCapture.setOnClickListener(new OnBtnStopCaptureClickListener());
    
    txtvwCaptureAmount = (TextView)dlgCapturing.findViewById(R.id.txtvwCaptureAmount);
    
    /* 启动统计线程 */
    enCaptureStatus = CaptureStatus.STATUS_CAPTURING;
    new Thread(new StatisticThread()).start();
    
    dlgCapturing.show();
}
 
Example 13
/**
     * 点击完成按钮之后将图片的地址返回到上一个页面
     */
    private void returnDataAndClose(){
        AlbumBitmapCacheHelper.getInstance().clearCache();
        if (currentPicNums == 0){
            Toast.makeText(this, getString(R.string.not_choose_any_pick), Toast.LENGTH_SHORT).show();
            return;
        }
        StringBuilder sb = new StringBuilder();
        for (String model : picklist){
            sb.append(model+"\n");
        }
        TextView textview = new TextView(this);
        textview.setText(sb);
        Dialog dialog = new Dialog(this);
        dialog.setTitle("结果");
        dialog.setContentView(textview);
        dialog.show();
        if (picNums == 1)
            picklist.clear();
//        Intent data = new Intent();
//        data.putExtra("data", list);
//        setResult(RESULT_OK, data);
//        finish();
    }
 
Example 14
public void testButtons() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.findViewById(R.id.btn_buttons).performClick();
            activity.getSupportFragmentManager().executePendingTransactions();
        }
    });
    getInstrumentation().waitForIdleSync();
    Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
    assertNotNull(f);
    Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
    assertNotNull(d);
    View positive = d.findViewById(R.id.button_positive);
    assertNotNull(positive);
    final View negative = d.findViewById(R.id.button_negative);
    assertNotNull(negative);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            negative.performClick();
        }
    });
    getInstrumentation().waitForIdleSync();
}
 
Example 15
Source Project: EFRConnect-android   Source File: BrowserActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initLicenseDialog() {
    dialogLicense = new Dialog(this);
    dialogLicense.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialogLicense.setContentView(R.layout.dialog_about_silicon_labs_blue_gecko);
    WebView view = dialogLicense.findViewById(R.id.menu_item_license);
    Button closeButton = dialogLicense.findViewById(R.id.close_about_btn);

    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogLicense.dismiss();
        }
    });

    view.loadUrl(ABOUT_DIALOG_HTML_ASSET_FILE_PATH);
}
 
Example 16
Source Project: Helepolis   Source File: WifiAlertFragment.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	return new AlertDialog.Builder(getActivity())
			// Set Dialog Icon
			.setIcon(R.drawable.compatibility)
					// Set Dialog Title
			.setTitle("Wifi problem")
					// Set Dialog Message
			.setMessage("Active wifi connection not detected.")

					// Positive button
			.setPositiveButton("OK", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					// Do something else
				}
			}).create();

			/*		// Negative Button
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog,	int which) {
					// Do something else
				}
			}).create();*/
}
 
Example 17
Source Project: android   Source File: BaseGameUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Resolve a connection failure from {@link GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(ConnectionResult)}
 *
 * @param activity             the Activity trying to resolve the connection failure.
 * @param client               the GoogleAPIClient instance of the Activity.
 * @param result               the ConnectionResult received by the Activity.
 * @param requestCode          a request code which the calling Activity can use to identify the
 *                             result of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be
 *                             resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity, GoogleApiClient client,
    ConnectionResult result, int requestCode, String fallbackErrorMessage) {
  if (result.hasResolution()) {
    try {
      result.startResolutionForResult(activity, requestCode);
      return true;
    } catch (IntentSender.SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      client.connect();
      return false;
    }
  } else {
    // not resolvable... so show an error message
    int errorCode = result.getErrorCode();
    Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode, activity, requestCode);
    if (dialog != null) {
      dialog.show();
    } else {
      // no built-in dialog: show the fallback error message
      showAlert(activity, fallbackErrorMessage);
    }
    return false;
  }
}
 
Example 18
Source Project: KAM   Source File: ColorPreference.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
    View rootView = layoutInflater.inflate(R.layout.dash_dialog_colors, null);

    mColorGrid = (GridView) rootView.findViewById(R.id.color_grid);

    mColorGrid.setNumColumns(mPreference.mNumColumns);

    mColorGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> listView, View view,
                                int position, long itemId) {
            mPreference.setValue(mAdapter.getItem(position));
            selector.onColorSelected(mAdapter.getItem(position));
            dismiss();
        }
    });

    tryBindLists();

    return new AlertDialog.Builder(getActivity())
            .setView(rootView)
            .create();
}
 
Example 19
Source Project: Gizwits-SmartSocket_Android   Source File: DialogManager.java    License: MIT License 6 votes vote down vote up
/**
 * 删除对话框.
 *
 * @param ctx the ctx
 * @param r            右按钮监听器
 * @return the unbind dialog
 */
public static Dialog getUnbindDialog(final Activity ctx, OnClickListener r) {
	final Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog) {
	};
	LayoutInflater layoutInflater = LayoutInflater.from(ctx);
	View v = layoutInflater.inflate(R.layout.dialog_unbind, null);
	Button leftBtn = (Button) v.findViewById(R.id.left_btn);
	Button rightBtn = (Button) v.findViewById(R.id.right_btn);
	leftBtn.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View arg0) {
			dismissDialog(ctx, dialog);
		}
	});
	rightBtn.setOnClickListener(r);

	dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	dialog.setCanceledOnTouchOutside(false);
	dialog.setCancelable(false);
	dialog.setContentView(v);
	return dialog;
}
 
Example 20
Source Project: Chimee   Source File: FontChooserDialogFragment.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@SuppressLint("InflateParams")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View customView = inflater.inflate(R.layout.dialog_font_chooser, null);
    setupRecyclerView(customView);
    builder.setView(customView);
    return builder.create();
}
 
Example 21
Source Project: Orin   Source File: AbsTagEditorActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Dialog createDialog(@NonNull Context context) {
    return new MaterialDialog.Builder(context)
            .title(R.string.saving_changes)
            .cancelable(false)
            .progress(false, 0)
            .build();
}
 
Example 22
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setMessage(getString(R.string.sending));
    dialog.setIndeterminate(false);
    dialog.setCancelable(true);
    return dialog;
}
 
Example 23
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{

    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(R.string.select_number);
    ArrayAdapter<String> adapter = crateAdapter();
    builder.setAdapter(adapter, this);

    return builder.create();
}
 
Example 24
Source Project: SuntimesWidget   Source File: MoonDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowListener);
    return dialog;
}
 
Example 25
Source Project: ColorPickerDialog   Source File: PickerDialog.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setTitle(getTitle());
    return dialog;
}
 
Example 26
Source Project: MHViewer   Source File: TaskPreference.java    License: Apache License 2.0 5 votes vote down vote up
protected void onTaskEnd() {
    // Dismiss dialog
    Dialog dialog = getDialog();
    if (null != dialog) {
        dialog.dismiss();
    }
    // Clear async
    mTask = null;
    mTaskId = IntIdGenerator.INVALID_ID;
}
 
Example 27
Source Project: DialogUtil   Source File: Tool.java    License: Apache License 2.0 5 votes vote down vote up
private static void setTitleMessageStyle(final Dialog dialog,ConfigBean bean) {

        try {
            Field mAlert = AlertDialog.class.getDeclaredField("mAlert");
            mAlert.setAccessible(true);
            Object mAlertController = mAlert.get(dialog);


            Field mMessage = mAlertController.getClass().getDeclaredField("mMessageView");
            mMessage.setAccessible(true);
            TextView tvMessage = (TextView) mMessage.get(mAlertController);
            if(bean.msgTxtColor !=0){
                tvMessage.setTextColor(getColor(bean.context,bean.msgTxtColor));
            }
            if(bean.msgTxtSize !=0){
                tvMessage.setTextSize(bean.msgTxtSize);
            }

            Field titleView = mAlertController.getClass().getDeclaredField("mTitleView");
            titleView.setAccessible(true);
            TextView tvTitle = (TextView) titleView.get(mAlertController);
            if(bean.titleTxtColor !=0){
                tvTitle.setTextColor(getColor(bean.context,bean.titleTxtColor));
            }
            if(bean.titleTxtSize !=0){
                tvTitle.setTextSize(bean.titleTxtSize);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
Example 28
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View customView = getActivity().getLayoutInflater().inflate(R.layout.blur_dialog_dialog_fragment, null);
    TextView label = ((TextView) customView.findViewById(R.id.textView));
    label.setMovementMethod(LinkMovementMethod.getInstance());
    Linkify.addLinks(label, Linkify.WEB_URLS);
    builder.setView(customView);
    return builder.create();
}
 
Example 29
Source Project: iBeebo   Source File: SelectPictureDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    String[] items = {
            getString(R.string.get_the_last_picture), getString(R.string.take_camera), getString(R.string.select_pic)
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.select)).setItems(
            items,
            (DialogInterface.OnClickListener) getActivity());
    return builder.create();
}
 
Example 30
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dashboard_main);
    ButterKnife.bind(this);
    getActivityComponent().inject(this);
    setupDrawerContent(navigationView);
    dialog = new Dialog(this);

    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setHomeAsUpIndicator(R.drawable.ic_menu);
        ab.setDisplayHomeAsUpEnabled(true);
    }

    /**
     * Setting the Fragment in FrameLayout
     */
    if (savedInstanceState == null) {

        fragment = new WorkflowFragment();
        ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment,
                R.id.frame_container);

        navigationView.setCheckedItem(R.id.nav_workflows);
    }

    setNavHeader();
}