Java Code Examples for android.content.DialogInterface

The following examples show how to use android.content.DialogInterface. 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
Source Project: camerakit-android   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    if (item.getItemId() == R.id.main_menu_about) {
        AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
                .setTitle(R.string.about_dialog_title)
                .setMessage(R.string.about_dialog_message)
                .setNeutralButton("Dismiss", null)
                .show();

        dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(Color.parseColor("#91B8CC"));
        dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setText(Html.fromHtml("<b>Dismiss</b>"));
        return true;
    }

    if (item.getItemId() == R.id.main_menu_gallery) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
        startActivity(intent);
        return true;
    }

    return false;
}
 
Example 2
protected void onPreExecute()
{
    progress = new ProgressDialog(activity);
    progress.setTitle(R.string.cleaning);

    progress.setOnDismissListener(new DialogInterface.OnDismissListener()
    {
        @Override
        public void onDismiss(DialogInterface dialog)
        {
            DatabaseCleanupTask.this.cancel(true);
        }
    });

    progress.show();
}
 
Example 3
Source Project: xposed-rimet   Source File: DialogUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void showDialog(Context context, String title, String message,
                              String positive, DialogInterface.OnClickListener positiveLister,
                              String negative, DialogInterface.OnClickListener negativeLister, boolean cancel) {

    if (context == null
            || TextUtils.isEmpty(message)
            || TextUtils.isEmpty(positive)) {
        // 不进行处理
        return;
    }

    AlertDialog dialog = new AlertDialog.Builder(context)
            .setTitle(title)
            .setMessage(message)
            .setCancelable(cancel)
            .setPositiveButton(positive, positiveLister)
            .setNegativeButton(negative, negativeLister)
            .create();

    // 显示提示
    dialog.show();
}
 
Example 4
protected void setupMultiChoiceDialog(AlertDialog.Builder builder) {
    final List<Choiceable> availableItems = getAvailableItems();

    final ItemPrinter<Choiceable> ip = getItemPrinter();
    CharSequence[] items = new CharSequence[availableItems.size()];
    boolean[] checked = new boolean[availableItems.size()];
    for (int i = 0; i < availableItems.size(); ++i) {
        items[i] = ip.print(getItemAt(i));
        if (selectedItems.get(i) != null) {
            checked[i] = true;
        } else {
            checked[i] = false;
        }
    }

    builder.setMultiChoiceItems(items, checked, new DialogInterface.OnMultiChoiceClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) selectedItems.put(which, getItemAt(which));
            else selectedItems.delete(which);
        }
    });
}
 
Example 5
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 6
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDatabase = new PlumbleSQLiteDatabase(this);
    mCertificates = mDatabase.getCertificates();

    CharSequence[] labels = new CharSequence[mCertificates.size()];
    for (int i = 0; i < labels.length; i++) {
        labels[i] = mCertificates.get(i).getName();
    }

    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setTitle(R.string.pref_export_certificate_title);
    adb.setItems(labels, this);
    adb.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
    adb.show();
}
 
Example 7
Source Project: GravityBox   Source File: WebServiceClient.java    License: Apache License 2.0 6 votes vote down vote up
public WebServiceClient(Context context, WebServiceTaskListener<T> listener) {
    mContext = context;
    mListener = listener;
    if (mContext == null || mListener == null) { 
        throw new IllegalArgumentException();
    }

    mProgressDialog = new ProgressDialog(mContext);
    mProgressDialog.setMessage(mContext.getString(R.string.wsc_please_wait));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dlgInterface) {
            abortTaskIfRunning();
        }
    });

    mHash = getAppSignatureHash(mContext);
}
 
Example 8
Source Project: AcDisplay   Source File: DialogUtils.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void setTypeface(TypefaceHelper helper, AlertDialog alertDialog, String typefaceName, int style) {
    Button positive = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    Button negative = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    Button neutral = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
    TextView message = (TextView) alertDialog.findViewById(android.R.id.message);
    if (positive != null) {
        helper.setTypeface(positive, typefaceName, style);
    }
    if (negative != null) {
        helper.setTypeface(negative, typefaceName, style);
    }
    if (neutral != null) {
        helper.setTypeface(neutral, typefaceName, style);
    }
    if (message != null) {
        helper.setTypeface(message, typefaceName, style);
    }
}
 
Example 9
Source Project: YImagePicker   Source File: RedBookPresenter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 选择超过数量限制提示
 *
 * @param context  上下文
 * @param maxCount 最大数量
 */
@Override
public void overMaxCountTip(Context context, int maxCount) {
    if (context == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage("最多选择" + maxCount + "个文件");
    builder.setPositiveButton(R.string.picker_str_sure,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
    AlertDialog dialog = builder.create();
    dialog.show();
}
 
Example 10
private final void loadResError() {
    AlertDialog.Builder dia = new AlertDialog.Builder(this);
    ResoureFinder finder = ResoureFinder.getInstance();
    dia.setTitle(finder.getString(this, "browser_dialog_error"));
    dia.setMessage(finder.getString(this, "browser_init_error"));
    dia.setCancelable(false);
    dia.setPositiveButton(finder.getString(this, "confirm"),
            new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                    Process.killProcess(Process.myPid());
                }
            });
    dia.create();
    dia.show();
}
 
Example 11
Source Project: media-for-mobile   Source File: ActivityWithTimeline.java    License: Apache License 2.0 6 votes vote down vote up
public void showMessageBox(String message, DialogInterface.OnClickListener listener) {

        if (message == null) {
            message = "";
        }

        if (listener == null) {
            listener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            };
        }

        AlertDialog.Builder b = new AlertDialog.Builder(this);
        b.setMessage(message);
        b.setPositiveButton("OK", listener);
        AlertDialog d = b.show();

        ((TextView) d.findViewById(android.R.id.message)).setGravity(Gravity.CENTER);
    }
 
Example 12
@Override
protected void onClick() {
	ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
		.with(getContext())
		.setTitle(pickerTitle)
		.initialColor(selectedColor)
		.wheelType(wheelType)
		.density(density)
		.setPositiveButton(pickerButtonOk, new ColorPickerClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int selectedColorFromPicker, Integer[] allColors) {
				setValue(selectedColorFromPicker);
			}
		})
		.setNegativeButton(pickerButtonCancel, null);

	if (!alphaSlider && !lightSlider) builder.noSliders();
	else if (!alphaSlider) builder.lightnessSliderOnly();
	else if (!lightSlider) builder.alphaSliderOnly();


	builder
		.build()
		.show();
}
 
Example 13
Source Project: Dashboard   Source File: BaseActivity.java    License: MIT License 6 votes vote down vote up
public void getzooper(View view)

    {
        final AlertDialog.Builder menuAleart = new AlertDialog.Builder(this);
        final String[] menuList = {"AMAZON APP STORE", "GOOGLE PLAY STORE"};
        menuAleart.setItems(menuList, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                switch (item) {
                    case 0:
                        boolean installed = appInstalledOrNot("com.amazon.venezia");
                        if (installed) {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("amzn://apps/android?p=org.zooper.zwpro")));
                        } else {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.amazon.com/gp/mas/dl/android?p=org.zooper.zwpro")));
                        }
                        break;
                    case 1:
                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=org.zooper.zwpro")));
                        break;
                }
            }
        });
        AlertDialog menuDrop = menuAleart.create();
        menuDrop.show();
    }
 
Example 14
Source Project: SystemUITuner2   Source File: Exceptions.java    License: MIT License 6 votes vote down vote up
public void secureSettings(Activity activity, final Context appContext, Exception e, String page) { //exception function for a Secure Settings problem
    Log.e(page, e.getMessage()); //log the error
    e.printStackTrace();

    if (!activity.isDestroyed()) {
        new AlertDialog.Builder(activity) //show a dialog with the error and prompt user to set up permissions again
                .setIcon(alertRed)
                .setTitle(Html.fromHtml("<font color='#ff0000'>" + activity.getResources().getText(R.string.error) + "</font>"))
                .setMessage(activity.getResources().getText(R.string.perms_not_set) + "\n\n\"" + e.getMessage() + "\"\n\n" + activity.getResources().getText(R.string.prompt_setup))
                .setPositiveButton(activity.getResources().getText(R.string.yes), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(appContext, SetupActivity.class);
                        intent.addFlags(intent.FLAG_ACTIVITY_NEW_TASK);
                        appContext.startActivity(intent);
                    }
                })
                .setNegativeButton(activity.getResources().getText(R.string.no), null)
                .show();
    }
}
 
Example 15
private void showProjectContextMenu() {
	AlertDialog.Builder builder = new AlertDialog.Builder(this);
	final ArrayList<String> labels = new ArrayList<String>();
	labels.addAll(labelsInTaskbagAndText());

	if (labels.size() == 0) {
		onHelpClick();
		return;
	}

	builder.setItems(labels.toArray(new String[0]), new OnClickListener() {
		@Override
		public void onClick(DialogInterface arg0, int which) {
			replaceTextAtSelection(labels.get(which) + " ");
		}
	});

	// Create the AlertDialog
	AlertDialog dialog = builder.create();
	dialog.setTitle(R.string.addcontextproject);
	dialog.show();
}
 
Example 16
Source Project: Paddle-Lite-Demo   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
        new AlertDialog.Builder(MainActivity.this)
                .setTitle("Permission denied")
                .setMessage("Click to force quit the app, then open Settings->Apps & notifications->Target " +
                        "App->Permissions to grant all of the permissions.")
                .setCancelable(false)
                .setPositiveButton("Exit", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        MainActivity.this.finish();
                    }
                }).show();
    }
}
 
Example 17
Source Project: imsdk-android   Source File: JzvdStd.java    License: MIT License 6 votes vote down vote up
@Override
public void showWifiDialog() {
    super.showWifiDialog();
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setMessage(getResources().getString(R.string.tips_not_wifi));
    builder.setPositiveButton(getResources().getString(R.string.tips_not_wifi_confirm), (dialog, which) -> {
        dialog.dismiss();
        replayTextView.setVisibility(GONE);
        startVideo();
        WIFI_TIP_DIALOG_SHOWED = true;
    });
    builder.setNegativeButton(getResources().getString(R.string.tips_not_wifi_cancel), (dialog, which) -> {
        dialog.dismiss();
        clearFloatScreen();
    });
    builder.setOnCancelListener(DialogInterface::dismiss);
    builder.create().show();
}
 
Example 18
Source Project: stynico   Source File: HCActivity.java    License: MIT License 6 votes vote down vote up
public void showEditTextDialog(Context context, String title, final int itemPosition)
   {
final EditText edit=new EditText(context);
//设置只能输入小数
edit.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
edit.setText(items.get(itemPosition).get("delay") + "");
new AlertDialog.Builder(context)
    .setTitle(title)
    .setView(edit)
    .setPositiveButton("确定", 
    new DialogInterface.OnClickListener(){
	@Override
	public void onClick(DialogInterface p1, int p2)
	{
	    // TODO: Implement this method
	    items.get(itemPosition).put("delay", edit.getText().toString());
	    adapter.notifyDataSetChanged();
	}
    })
    .setNegativeButton("取消", null).show();
   }
 
Example 19
Source Project: SimpleAdapterDemo   Source File: AboutFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void showNewVersionDialog(String content, final String fileName) {
    if (getActivity() == null)
        return;

    new AlertDialog.Builder(getActivity())
            .setTitle("新版本提示")
            .setMessage(content)
            .setPositiveButton("更新", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String url = BuildConfig.BASE_URL + BuildConfig.DOWNLOAD_URL;
                    Uri uri = Uri.parse(String.format(Locale.CHINA, url, fileName));
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(intent);

                }
            })
            .setNegativeButton("知道了", null)
            .show();
}
 
Example 20
Source Project: Klyph   Source File: PreferencesActivity.java    License: MIT License 5 votes vote down vote up
private void handleSetNotifications()
{
	SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
	SharedPreferences.Editor editor = sharedPreferences.edit();

	@SuppressWarnings("deprecation") CheckBoxPreference cpref = (CheckBoxPreference) findPreference("preference_notifications");

	pendingAnnounce = false;
	final Session session = Session.getActiveSession();

	List<String> permissions = session.getPermissions();
	if (!permissions.containsAll(PERMISSIONS))
	{
		pendingAnnounce = true;
		editor.putBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS, false);
		editor.commit();
		cpref.setChecked(false);

		AlertUtil.showAlert(this, R.string.preferences_notifications_permissions_title, R.string.preferences_notifications_permissions_message,
				R.string.ok, new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which)
					{
						requestPublishPermissions(session);
					}
				}, R.string.cancel, null);
		return;
	}

	editor.putBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS, true);
	editor.commit();
	cpref.setChecked(true);

	startOrStopNotificationsServices();

	if (sharedPreferences.getBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS_BIRTHDAY, false) == true)
		KlyphService.startBirthdayService();
}
 
Example 21
Source Project: social-app-android   Source File: BaseActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showWarningDialog(String message, DialogInterface.OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(message);
    builder.setPositiveButton(R.string.button_ok, listener);
    builder.show();
}
 
Example 22
Source Project: Lanmitm   Source File: RadioDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Builder setRadio4(int radioText, boolean checked,
		DialogInterface.OnClickListener listener) {
	this.radioText3 = (String) context.getText(radioText);
	this.radioClickListener3 = listener;
	this.radioCheck3 = checked;
	return this;
}
 
Example 23
public void init(AttributeSet attrs) {
    // We create a fake dialog which dims the screen and we display the expandable menu as content
    mDialog = new Dialog(getContext(), android.R.style.Theme_Translucent_NoTitleBar);
    mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    WindowManager.LayoutParams lp = mDialog.getWindow().getAttributes();
    lp.dimAmount = dimAmount;
    mDialog.getWindow().setAttributes(lp);

    mButtonMenu = new ExpandableButtonMenu(getContext(), attrs);
    mButtonMenu.setButtonMenuParentOverlay(this);

    mDialog.setContentView(mButtonMenu);
    mDialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            setVisibility(View.INVISIBLE);
            mButtonMenu.toggle();
        }
    });

    // Catch events when keyboard button are clicked. Used to dismiss the menu
    // on 'back' button
    mDialog.setOnKeyListener(this);

    // Clicking this view will expand the button menu
    setOnClickListener(this);

}
 
Example 24
Source Project: TestChat   Source File: CommonSubscriber.java    License: Apache License 2.0 5 votes vote down vote up
private void initLoadDialog() {
        if (mContextSoftReference.get() != null) {
                mDialog = new ProgressDialog(mContextSoftReference.get());
                mDialog.setMessage("正在加载..........请稍候..........");
                mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                                dialog.cancel();
                                unsubscribe();
                        }
                });
        }
}
 
Example 25
Source Project: 10000sentences   Source File: WordsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void removeWord(final WordAnnotation word) {
    DialogUtils.showYesNoButton(
            (Activity) this.getContext(),
            getContext().getString(R.string.remove_word_from_annotation),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int which) {
                    if (which == Dialog.BUTTON_POSITIVE) {
                        annotationService.removeWordToAnnotation(annotation, word);
                        remove(word);
                        notifyDataSetChanged();
                    }
                }
            });
}
 
Example 26
Source Project: letv   Source File: MyDownloadActivity.java    License: Apache License 2.0 5 votes vote down vote up
public void onDoBatchDelete() {
    if (isSelectAll()) {
        DialogUtil.showDialog(this, getBatchDelDialogTitle(), "", "", null, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (MyDownloadActivity.this.getCurrentBatchDelFragment() != null) {
                    MyDownloadActivity.this.getCurrentBatchDelFragment().onDoBatchDelete();
                }
                dialog.dismiss();
            }
        });
    } else if (getCurrentBatchDelFragment() != null) {
        getCurrentBatchDelFragment().onDoBatchDelete();
    }
}
 
Example 27
Source Project: ghwatch   Source File: WatchedRepositoriesActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void showServerCommunicationErrorAllertDialog(LoadingStatus loadingStatus, boolean showStaledDataWarning) {
  StringBuilder sb = new StringBuilder();
  sb.append(getString(loadingStatus.getResId()));
  if (showStaledDataWarning) {
    sb.append("\n").append(getString(R.string.message_staled_data));
  }
  AlertDialog.Builder builder = new AlertDialog.Builder(this);
  builder.setMessage(sb).setCancelable(true).setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int id) {
    }
  });

  builder.create().show();
}
 
Example 28
Source Project: react-native-GPay   Source File: DatePickerDialogFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onDismiss(DialogInterface dialog) {
  super.onDismiss(dialog);
  if (mOnDismissListener != null) {
    mOnDismissListener.onDismiss(dialog);
  }
}
 
Example 29
Source Project: OpenHub   Source File: EditLabelDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void show() {
    dialog.show();
    dialog.getButton(DialogInterface.BUTTON_POSITIVE)
            .setOnClickListener(v -> {
                if(validateLabel()){
                    updateOrCreateLabel();
                    dialog.dismiss();
                }
            });
}
 
Example 30
Source Project: fritz-examples   Source File: CameraConnectionFragment.java    License: MIT License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Activity activity = getActivity();
    return new AlertDialog.Builder(activity)
            .setMessage(getArguments().getString(ARG_MESSAGE))
            .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialogInterface, final int i) {
                            activity.finish();
                        }
                    })
            .create();
}
 
Example 31
/**
 * Callback for the result from requesting permissions. This method
 * is invoked for every call on {@link #requestPermissions(String[], int)}.
 * <p>
 * <strong>Note:</strong> It is possible that the permissions request interaction
 * with the user is interrupted. In this case you will receive empty permissions
 * and results arrays which should be treated as a cancellation.
 * </p>
 *
 * @param requestCode  The request code passed in {@link #requestPermissions(String[], int)}.
 * @param permissions  The requested permissions. Never null.
 * @param grantResults The grant results for the corresponding permissions
 *                     which is either {@link PackageManager#PERMISSION_GRANTED}
 *                     or {@link PackageManager#PERMISSION_DENIED}. Never null.
 * @see #requestPermissions(String[], int)
 */
@Override
public void onRequestPermissionsResult(int requestCode,
                                       @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {
    if (requestCode != RC_HANDLE_CAMERA_PERM) {
        Log.d(TAG, "Got unexpected permission result: " + requestCode);
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        return;
    }

    if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        Log.d(TAG, "Camera permission granted - initialize the camera source");
        // we have permission, so create the camerasource
        boolean autoFocus = getIntent().getBooleanExtra(EXTRA_AUTO_FOCUS,false);
        boolean useFlash = getIntent().getBooleanExtra(EXTRA_USE_FLASH, false);
        createCameraSource(autoFocus, useFlash);
        return;
    }

    Log.e(TAG, "Permission not granted: results len = " + grantResults.length +
            " Result code = " + (grantResults.length > 0 ? grantResults[0] : "(empty)"));

    DialogInterface.OnClickListener listener = (dialog, id) -> finish();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.app_name)
            .setMessage(R.string.no_camera_permission)
            .setPositiveButton(R.string.action_ok, listener)
            .show();
}
 
Example 32
Source Project: TextFiction   Source File: LibraryAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	if (which == DialogInterface.BUTTON_POSITIVE) {
		FileUtil.deleteGame(deleteMe);
		remove(deleteMe);
		notifyDataSetChanged();
	}
}
 
Example 33
Source Project: rcloneExplorer   Source File: FilePropertiesDialog.java    License: MIT License 5 votes vote down vote up
@Override
public void onDismiss(DialogInterface dialog) {
    super.onDismiss(dialog);
    for (AsyncTask asyncTask : asyncTasks) {
        if (asyncTask != null) {
            asyncTask.cancel(true);
        }
    }
}
 
Example 34
Source Project: lbry-android   Source File: ChannelCommentsFragment.java    License: MIT License 5 votes vote down vote up
private void validateAndCheckPostComment(double amount) {
    String comment = Helper.getValue(inputComment.getText());
    Claim channel = (Claim) commentChannelSpinner.getSelectedItem();

    if (Helper.isNullOrEmpty(comment)) {
        showError(getString(R.string.please_enter_comment));
        return;
    }
    if (channel == null || Helper.isNullOrEmpty(channel.getClaimId())) {
        showError(getString(R.string.please_select_channel));
        return;
    }
    if (Lbry.walletBalance == null || amount > Lbry.walletBalance.getAvailable().doubleValue()) {
        showError(getString(R.string.insufficient_balance));
        return;
    }

    Context context = getContext();
    if (context != null) {
        String titleText = getResources().getQuantityString(
                R.plurals.post_and_tip,
                amount == 1 ? 1 : 2,
                Helper.LBC_CURRENCY_FORMAT.format(amount));
        String confirmText = getResources().getQuantityString(
                R.plurals.confirm_post_comment,
                amount == 1 ? 1 : 2,
                Helper.LBC_CURRENCY_FORMAT.format(amount),
                claim.getTitleOrName());
        AlertDialog.Builder builder = new AlertDialog.Builder(context).
                setTitle(titleText).
                setMessage(confirmText)
                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        postComment(amount);
                    }
                }).setNegativeButton(R.string.no, null);
        builder.show();
    }
}
 
Example 35
Source Project: FireFiles   Source File: CreateFileFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());

    final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
    final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
    Utils.tintWidget(text1);

    String title = getArguments().getString(EXTRA_DISPLAY_NAME);
    if(!TextUtils.isEmpty(title)) {
        text1.setText(title);
        text1.setSelection(title.length());
    }
    builder.setTitle(R.string.menu_create_file);
    builder.setView(view);

    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String displayName = text1.getText().toString();
            final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
            String extension = FileUtils.getExtFromFilename(displayName);
            final DocumentsActivity activity = (DocumentsActivity) getActivity();
            final DocumentInfo cwd = activity.getCurrentDirectory();
            new CreateFileTask(activity, cwd,
                    TextUtils.isEmpty(extension) ? mimeType : extension, displayName).executeOnExecutor(
                    ProviderExecutor.forAuthority(cwd.authority));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
Example 36
Source Project: sinovoice-pathfinder   Source File: CandidateView.java    License: MIT License 5 votes vote down vote up
/**
     * ��ʼ��¼��dialog
     */
    private void initAsrDialog() {
        mRecorderDialog = new JTAsrRecorderDialog(mService, asrListener);
        Window window = mRecorderDialog.getWindow();
        window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
//        window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
        mRecorderDialog.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if(TextUtils.isEmpty(mAsrResult)){
                    return;
                }
                
                Message msg = mHandler.obtainMessage(Pathfinder.MSG_WHAT_ASR_RESULT, mAsrResult);
                mHandler.sendMessage(msg);
                mAsrResult = "";
            }
        });

        JTAsrRecogParams asrRecogParams = new JTAsrRecogParams();
        asrRecogParams.setCapKey(SysConfig.CAPKEY_ASR);
        asrRecogParams
                .setAudioFormat(HciCloudAsr.HCI_ASR_AUDIO_FORMAT_PCM_16K16BIT);
        asrRecogParams.setMaxSeconds("60");
        asrRecogParams.setAddPunc("yes");

        // ��ȡ�ֻ�������,�����ֻ�����������ѹ����ʽ
        int cpuCoreNum = getNumCores();
        if (cpuCoreNum > 1) {
            asrRecogParams.setEncode(HciCloudAsr.HCI_ASR_ENCODE_SPEEX);
        } else {
            asrRecogParams.setEncode(HciCloudAsr.HCI_ASR_ENCODE_ALAW);
        }
        
        mRecorderDialog.setParams(asrRecogParams);
    }
 
Example 37
Source Project: xmrwallet   Source File: WalletActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void onWalletDetails() {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    final Bundle extras = new Bundle();
                    extras.putString(GenerateReviewFragment.REQUEST_TYPE, GenerateReviewFragment.VIEW_TYPE_WALLET);

                    if (needVerifyIdentity) {
                        Helper.promptPassword(WalletActivity.this, getWallet().getName(), true, new Helper.PasswordAction() {
                            @Override
                            public void action(String walletName, String password, boolean fingerprintUsed) {
                                replaceFragment(new GenerateReviewFragment(), null, extras);
                                needVerifyIdentity = false;
                            }
                        });
                    } else {
                        replaceFragment(new GenerateReviewFragment(), null, extras);
                    }

                    break;
                case DialogInterface.BUTTON_NEGATIVE:
                    // do nothing
                    break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(getString(R.string.details_alert_message))
            .setPositiveButton(getString(R.string.details_alert_yes), dialogClickListener)
            .setNegativeButton(getString(R.string.details_alert_no), dialogClickListener)
            .show();
}
 
Example 38
Source Project: repay-android   Source File: FriendActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.repaid:
            if (mFriend.getDebt().compareTo(BigDecimal.ZERO) != 0) {
                AlertDialog.Builder clearDebtDialog = new AlertDialog.Builder(this);
                clearDebtDialog.setTitle(R.string.debt_repaid_title);
                clearDebtDialog.setItems(R.array.debt_repaid_items, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 0) {
                            clearAllDebts();
                        } else if (which == 1) {
                            clearPartialDebt();
                        }
                    }
                });
                clearDebtDialog.show();
            } else {
                Toast.makeText(this, "No debts to clear", Toast.LENGTH_SHORT).show();
            }
            break;

        default:
            break;
    }

}
 
Example 39
Source Project: framework   Source File: OAlert.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static void inputDialog(Context context, String title, final OnUserInputListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    int margin = OResource.dimen(context, R.dimen.default_8dp);
    params.setMargins(margin, margin, margin, margin);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setLayoutParams(params);
    linearLayout.setPadding(margin, margin, margin, margin);
    final EditText edtInput = new EditText(context);
    edtInput.setLayoutParams(params);
    edtInput.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    if (listener != null) {
        listener.onViewCreated(edtInput);
    }
    linearLayout.addView(edtInput);
    builder.setView(linearLayout);
    if (title != null)
        builder.setTitle(title);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (TextUtils.isEmpty(edtInput.getText())) {
                edtInput.setError("Field required");
                edtInput.requestFocus();
            } else {
                if (listener != null) {
                    listener.onUserInputted(edtInput.getText());
                }
            }
        }
    });
    builder.setNegativeButton("Cancel", null);
    builder.create().show();
}
 
Example 40
Source Project: jpHolo   Source File: Notification.java    License: MIT License 5 votes vote down vote up
/**
 * Show the progress dialog.
 *
 * @param title     Title of the dialog
 * @param message   The message of the dialog
 */
public synchronized void progressStart(final String title, final String message) {
    if (this.progressDialog != null) {
        this.progressDialog.dismiss();
        this.progressDialog = null;
    }
    final Notification notification = this;
    final CordovaInterface cordova = this.cordova;
    Runnable runnable = new Runnable() {
        public void run() {
            notification.progressDialog = new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            notification.progressDialog.setTitle(title);
            notification.progressDialog.setMessage(message);
            notification.progressDialog.setCancelable(true);
            notification.progressDialog.setMax(100);
            notification.progressDialog.setProgress(0);
            notification.progressDialog.setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                        public void onCancel(DialogInterface dialog) {
                            notification.progressDialog = null;
                        }
                    });
            notification.progressDialog.show();
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}