android.content.DialogInterface Java Examples

The following examples show how to use android.content.DialogInterface. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EBrowserActivity.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #2
Source File: MainActivity.java    From Paddle-Lite-Demo with 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 #3
Source File: DialogUtil.java    From xposed-rimet with 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
Source File: DatabaseCleanupTask.java    From budget-watch with GNU General Public License v3.0 6 votes vote down vote up
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 #5
Source File: JzvdStd.java    From imsdk-android with 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 #6
Source File: HCActivity.java    From stynico with 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 #7
Source File: MainActivity.java    From camerakit-android with 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 #8
Source File: ChoiceablePickerDialogFragment.java    From RxAndroidBootstrap with Apache License 2.0 6 votes vote down vote up
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 #9
Source File: CameraBridgeViewBase.java    From FaceRecognitionApp with GNU General Public License v2.0 6 votes vote down vote up
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 #10
Source File: AddTask.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
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 #11
Source File: Exceptions.java    From SystemUITuner2 with 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 #12
Source File: WebServiceClient.java    From GravityBox with 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 #13
Source File: DialogUtils.java    From AcDisplay with 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 #14
Source File: BaseActivity.java    From Dashboard with 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 #15
Source File: RedBookPresenter.java    From YImagePicker with 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 #16
Source File: ColorPickerPreference.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@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 #17
Source File: ActivityWithTimeline.java    From media-for-mobile with 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 #18
Source File: CertificateExportActivity.java    From Plumble with GNU General Public License v3.0 6 votes vote down vote up
@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 #19
Source File: AboutFragment.java    From SimpleAdapterDemo with 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 File: ForgotPasswordDialog.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialogInterface, int which) {
    switch (which) {
        case AlertDialog.BUTTON_POSITIVE:
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
            prefs.edit().remove(Constants.PREFERENCE_ENC_SEED).apply();
            getDialog().dismiss();
            Intent intent = new Intent(getActivity().getIntent());
            getActivity().startActivityForResult(intent, Constants.REQUEST_CODE_LOGIN);
    }
}
 
Example #21
Source File: WebViewActivity.java    From ByWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 长按图片事件处理
 */
private boolean handleLongImage() {
    final WebView.HitTestResult hitTestResult = webView.getHitTestResult();
    // 如果是图片类型或者是带有图片链接的类型
    if (hitTestResult.getType() == WebView.HitTestResult.IMAGE_TYPE ||
            hitTestResult.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        // 弹出保存图片的对话框
        new AlertDialog.Builder(WebViewActivity.this)
                .setItems(new String[]{"查看大图", "保存图片到相册"}, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        String picUrl = hitTestResult.getExtra();
                        //获取图片
                        Log.e("picUrl", picUrl);
                        switch (which) {
                            case 0:
                                break;
                            case 1:
                                break;
                            default:
                                break;
                        }
                    }
                })
                .show();
        return true;
    }
    return false;
}
 
Example #22
Source File: Notification.java    From jpHolo with 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);
}
 
Example #23
Source File: OAlert.java    From framework with 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 #24
Source File: FriendActivity.java    From repay-android with 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 #25
Source File: WalletActivity.java    From xmrwallet with 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 #26
Source File: CandidateView.java    From sinovoice-pathfinder with 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 #27
Source File: CreateFileFragment.java    From FireFiles with 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 #28
Source File: ChannelCommentsFragment.java    From lbry-android with 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 #29
Source File: PreferencesActivity.java    From Klyph with 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 #30
Source File: AboutDialogFragment.java    From MonsterHunter4UDatabase with MIT License 5 votes vote down vote up
@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {

		final TextView message = new TextView(getActivity());

		final SpannableString s = new SpannableString(getActivity().getText(
				R.string.about_message));
		Linkify.addLinks(s, Linkify.WEB_URLS);
	
		message.setText(s);
		message.setMovementMethod(LinkMovementMethod.getInstance());
		;
		message.setPadding(20, 10, 20, 10);
		message.setTextSize(18);

		return new AlertDialog.Builder(getActivity())
				.setTitle(R.string.about)
//				.setPositiveButton(R.string.alert_rate, //TODO Update when the app has a launch page.
//						new DialogInterface.OnClickListener() {
//							public void onClick(DialogInterface dialog, int id) {
//						        Intent intent = new Intent();
//						        intent.setAction(Intent.ACTION_VIEW);
//						        intent.addCategory(Intent.CATEGORY_BROWSABLE);
//						        intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.daviancorp.android.mh3udatabase"));
//						        startActivity(intent);
//								dialog.dismiss();
//							}
//						})
				.setNegativeButton(R.string.alert_button,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								dialog.dismiss();
							}
						})
				.setView(message).create();

	}