Search in sources :

Example 71 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Notes by lguipeng.

the class SettingFragment method showThemeChooseDialog.

@Override
public void showThemeChooseDialog() {
    AlertDialog.Builder builder = DialogUtils.makeDialogBuilder(activity);
    builder.setTitle(R.string.change_theme);
    Integer[] res = new Integer[] { R.drawable.red_round, R.drawable.brown_round, R.drawable.blue_round, R.drawable.blue_grey_round, R.drawable.yellow_round, R.drawable.deep_purple_round, R.drawable.pink_round, R.drawable.green_round };
    List<Integer> list = Arrays.asList(res);
    ColorsListAdapter adapter = new ColorsListAdapter(getActivity(), list);
    adapter.setCheckItem(ThemeUtils.getCurrentTheme(activity).getIntValue());
    GridView gridView = (GridView) LayoutInflater.from(activity).inflate(R.layout.colors_panel_layout, null);
    gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    gridView.setCacheColorHint(0);
    gridView.setAdapter(adapter);
    builder.setView(gridView);
    final AlertDialog dialog = builder.show();
    gridView.setOnItemClickListener((parent, view, position, id) -> {
        dialog.dismiss();
        settingPresenter.onThemeChoose(position);
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ColorsListAdapter(com.lguipeng.notes.adpater.ColorsListAdapter) GridView(android.widget.GridView)

Example 72 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Notes by lguipeng.

the class AboutActivity method showShareDialog.

private void showShareDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.ShareDialog);
    builder.setTitle(getString(R.string.share));
    final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(this);
    String[] array = getResources().getStringArray(R.array.share_dialog_text);
    adapter.add(new ShareListItem.Builder(this).content(array[0]).icon(R.drawable.ic_wx_logo).build());
    adapter.add(new ShareListItem.Builder(this).content(array[1]).icon(R.drawable.ic_wx_moments).build());
    adapter.add(new ShareListItem.Builder(this).content(array[2]).icon(R.drawable.ic_wx_collect).build());
    adapter.add(new ShareListItem.Builder(this).content(array[3]).icon(R.drawable.ic_sina_logo).build());
    adapter.add(new ShareListItem.Builder(this).content(array[4]).icon(R.drawable.ic_share_more).build());
    builder.setAdapter(adapter, (dialog, which) -> {
        switch(which) {
            case 0:
                shareToWeChatSession();
                break;
            case 1:
                shareToWeChatTimeline();
                break;
            case 2:
                shareToWeChatFavorite();
                break;
            case 3:
                shareToWeibo();
                break;
            default:
                share("", null);
        }
    });
    AlertDialog dialog = builder.create();
    Window window = dialog.getWindow();
    window.setGravity(Gravity.BOTTOM);
    WindowManager.LayoutParams lp = window.getAttributes();
    Display display = getWindowManager().getDefaultDisplay();
    Point out = new Point();
    display.getSize(out);
    lp.width = out.x;
    window.setAttributes(lp);
    View decorView = window.getDecorView();
    decorView.setBackgroundColor(getResources().getColor(R.color.window_background));
    dialog.setOnShowListener((dialog1 -> {
        Animator animator = ObjectAnimator.ofFloat(decorView, "translationY", decorView.getMeasuredHeight() / 1.5F, 0);
        animator.setDuration(200);
        animator.start();
    }));
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) Context(android.content.Context) SnackbarUtils(com.lguipeng.notes.utils.SnackbarUtils) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) Uri(android.net.Uri) WindowManager(android.view.WindowManager) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) Animator(android.animation.Animator) WXUtils(com.lguipeng.notes.utils.WXUtils) PackageInfo(android.content.pm.PackageInfo) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) SendMessageToWX(com.tencent.mm.sdk.modelmsg.SendMessageToWX) IWXAPI(com.tencent.mm.sdk.openapi.IWXAPI) WXMediaMessage(com.tencent.mm.sdk.modelmsg.WXMediaMessage) Menu(android.view.Menu) Display(android.view.Display) View(android.view.View) Bind(butterknife.Bind) TimeUtils(com.lguipeng.notes.utils.TimeUtils) WXWebpageObject(com.tencent.mm.sdk.modelmsg.WXWebpageObject) MaterialSimpleListAdapter(com.lguipeng.notes.adpater.MaterialSimpleListAdapter) WXAPIFactory(com.tencent.mm.sdk.openapi.WXAPIFactory) ShareListItem(com.lguipeng.notes.model.ShareListItem) ObjectAnimator(android.animation.ObjectAnimator) Point(android.graphics.Point) TextUtils(android.text.TextUtils) R(com.lguipeng.notes.R) Gravity(android.view.Gravity) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) BuildConfig(com.lguipeng.notes.BuildConfig) Toolbar(android.support.v7.widget.Toolbar) ActivityNotFoundException(android.content.ActivityNotFoundException) Bitmap(android.graphics.Bitmap) Window(android.view.Window) MaterialSimpleListAdapter(com.lguipeng.notes.adpater.MaterialSimpleListAdapter) Point(android.graphics.Point) View(android.view.View) TextView(android.widget.TextView) WindowManager(android.view.WindowManager) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) Display(android.view.Display)

Example 73 with Builder

use of android.support.v7.app.AlertDialog.Builder in project material-components-android by material-components.

the class BottomSheetDialogTest method showDialog.

private void showDialog() {
    Context context = activityTestRule.getActivity();
    mDialog = new BottomSheetDialog(context);
    AppCompatTextView text = new AppCompatTextView(context);
    StringBuilder builder = new StringBuilder();
    builder.append("It is fine today. ");
    text.setText(builder);
    mDialog.setContentView(text);
    mDialog.show();
}
Also used : Context(android.content.Context) AppCompatTextView(android.support.v7.widget.AppCompatTextView)

Example 74 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.

the class ReceiveExternalFilesActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(final int id) {
    final AlertDialog.Builder builder = new Builder(this);
    switch(id) {
        case DIALOG_NO_ACCOUNT:
            builder.setIcon(R.drawable.ic_warning);
            builder.setTitle(R.string.uploader_wrn_no_account_title);
            builder.setMessage(String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name)));
            builder.setCancelable(false);
            builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) {
                        // using string value since in API7 this
                        // constatn is not defined
                        // in API7 < this constatant is defined in
                        // Settings.ADD_ACCOUNT_SETTINGS
                        // and Settings.EXTRA_AUTHORITIES
                        Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
                        intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() });
                        startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                    } else {
                        // since in API7 there is no direct call for
                        // account setup, so we need to
                        // show our own AccountSetupAcricity, get
                        // desired results and setup
                        // everything for ourself
                        Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class);
                        startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                    }
                }
            });
            builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            });
            return builder.create();
        case DIALOG_MULTIPLE_ACCOUNT:
            Account[] accounts = mAccountManager.getAccountsByType(MainApp.getAccountType());
            CharSequence[] dialogItems = new CharSequence[accounts.length];
            OwnCloudAccount oca;
            for (int i = 0; i < dialogItems.length; ++i) {
                try {
                    oca = new OwnCloudAccount(accounts[i], this);
                    dialogItems[i] = oca.getDisplayName() + " @ " + DisplayUtils.convertIdn(accounts[i].name.substring(accounts[i].name.lastIndexOf("@") + 1), false);
                } catch (Exception e) {
                    Log_OC.w(TAG, "Couldn't read display name of account; using account name instead");
                    dialogItems[i] = DisplayUtils.convertIdn(accounts[i].name, false);
                }
            }
            builder.setTitle(R.string.common_choose_account);
            builder.setItems(dialogItems, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);
                    onAccountSet(mAccountWasRestored);
                    dialog.dismiss();
                    mAccountSelected = true;
                    mAccountSelectionShowing = false;
                }
            });
            builder.setCancelable(true);
            builder.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    mAccountSelectionShowing = false;
                    dialog.cancel();
                    finish();
                }
            });
            return builder.create();
        default:
            throw new IllegalArgumentException("Unknown dialog id: " + id);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) DialogInterface(android.content.DialogInterface) Builder(android.support.v7.app.AlertDialog.Builder) Builder(android.support.v7.app.AlertDialog.Builder) Intent(android.content.Intent) AccountAuthenticator(com.owncloud.android.authentication.AccountAuthenticator) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) SuppressLint(android.annotation.SuppressLint) NotFoundException(android.content.res.Resources.NotFoundException) AuthenticatorException(android.accounts.AuthenticatorException) OnClickListener(android.content.DialogInterface.OnClickListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 75 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.

the class ChangelogDialog method onCreateDialog.

/**
     * {@inheritDoc}
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    /// load the custom view to insert in the dialog, between title and 
    WebView webview = new WebView(getActivity());
    webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
    /// build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Dialog dialog = builder.setView(webview).setIcon(DisplayUtils.getSeasonalIconId()).setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).create();
    dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) AlertDialog(android.support.v7.app.AlertDialog) Dialog(android.app.Dialog) WebView(android.webkit.WebView)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10