Java Code Examples for android.support.v7.app.AlertDialog#BUTTON_POSITIVE

The following examples show how to use android.support.v7.app.AlertDialog#BUTTON_POSITIVE . 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: delion   File: OMADownloadHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
Example 2
/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
Example 3
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) { 

        String username = mUsernameET.getText().toString();
        String password = mPasswordET.getText().toString();

        // Proceed with the authentication
        mHandler.proceed(username, password);

    } else if (which == AlertDialog.BUTTON_NEGATIVE) {
        mWebView.stopLoading();
        ((AuthenticatorActivity)getActivity()).doNegativeAuthenticatioDialogClick();
    }

    dialog.dismiss();
}
 
Example 4
Source Project: 365browser   File: OMADownloadHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
Example 5
Source Project: delion   File: OMADownloadHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Shows a dialog to ask whether user wants to open the nextURL.
 *
 * @param omaInfo Information about the OMA content.
 */
private void showNextUrlDialog(OMAInfo omaInfo) {
    if (omaInfo.isValueEmpty(OMA_NEXT_URL)) {
        return;
    }
    final String nextUrl = omaInfo.getValue(OMA_NEXT_URL);
    final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl));
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
                intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
                intent.setPackage(mContext.getPackageName());
                activity.startActivity(intent);
            }
        }
    };
    new AlertDialog.Builder(activity)
            .setTitle(R.string.open_url_post_oma_download)
            .setPositiveButton(R.string.ok, clickListener)
            .setNegativeButton(R.string.cancel, clickListener)
            .setMessage(nextUrl)
            .setCancelable(false)
            .show();
}
 
Example 6
Source Project: delion   File: SignOutDialogFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        AccountManagementScreenHelper.logEvent(
                ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT, mGaiaServiceType);

        mSignOutClicked = true;
        SignOutDialogListener targetFragment = (SignOutDialogListener) getTargetFragment();
        targetFragment.onSignOutClicked();
    }
}
 
Example 7
@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 8
@Override
public void onClick(DialogInterface dialogInterface, int which) {
    switch (which) {
        case AlertDialog.BUTTON_POSITIVE:
            shareQRCode(getActivity(), bitmap);
            getDialog().dismiss();
    }
}
 
Example 9
/**
 * Shows a dialog to ask whether user wants to open the nextURL.
 *
 * @param omaInfo Information about the OMA content.
 */
private void showNextUrlDialog(OMAInfo omaInfo) {
    if (omaInfo.isValueEmpty(OMA_NEXT_URL)) {
        return;
    }
    final String nextUrl = omaInfo.getValue(OMA_NEXT_URL);
    final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl));
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
                intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
                intent.setPackage(mContext.getPackageName());
                activity.startActivity(intent);
            }
        }
    };
    new AlertDialog.Builder(activity)
            .setTitle(R.string.open_url_post_oma_download)
            .setPositiveButton(R.string.ok, clickListener)
            .setNegativeButton(R.string.cancel, clickListener)
            .setMessage(nextUrl)
            .setCancelable(false)
            .show();
}
 
Example 10
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        AccountManagementScreenHelper.logEvent(
                ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT, mGaiaServiceType);

        mSignOutClicked = true;
        SignOutDialogListener targetFragment = (SignOutDialogListener) getTargetFragment();
        targetFragment.onSignOutClicked();
    }
}
 
Example 11
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        String password =
                ((TextView)(getDialog().findViewById(R.id.share_password)))
                        .getText().toString();

        if (password.length() <= 0) {
            Toast.makeText(
                    getActivity(),
                    R.string.share_link_empty_password,
                    Toast.LENGTH_LONG).show();
            return;
        }

        if (mCreateShare) {
            // Share the file
            ((FileActivity) getActivity()).getFileOperationsHelper().
                    shareFileViaLink(mFile, password);

        } else {
            // updat existing link
            ((FileActivity) getActivity()).getFileOperationsHelper().
                    setPasswordToShareViaLink(mFile, password);
        }
    }
}
 
Example 12
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        String newFolderName = 
                ((TextView)(getDialog().findViewById(R.id.user_input)))
                    .getText().toString().trim();
        
        if (newFolderName.length() <= 0) {
            Toast.makeText(
                    getActivity(),
                    R.string.filename_empty, 
                    Toast.LENGTH_LONG).show();
            return;
        }
        boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()).
                getFileOperationsHelper().isVersionWithForbiddenCharacters();

        if (!FileUtils.isValidName(newFolderName, serverWithForbiddenChars)) {
            int messageId = 0;
            if (serverWithForbiddenChars) {
                messageId = R.string.filename_forbidden_charaters_from_server;
            } else {
                messageId = R.string.filename_forbidden_characters;
            }
            Toast.makeText(getActivity(), messageId, Toast.LENGTH_LONG).show();

            return;
        }
        
        String path = mParentFolder.getRemotePath();
        path += newFolderName + OCFile.PATH_SEPARATOR;
        ((ComponentsGetter)getActivity()).
            getFileOperationsHelper().createFolder(path, false);
    }
}
 
Example 13
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        String newFileName = 
            ((TextView)(getDialog().findViewById(R.id.user_input)))
                .getText().toString().trim();
        
        if (newFileName.length() <= 0) {
            Toast.makeText(
                    getActivity(),
                    R.string.filename_empty, 
                    Toast.LENGTH_LONG).show();
            return;
        }

        boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()).
                getFileOperationsHelper().isVersionWithForbiddenCharacters();

        if (!FileUtils.isValidName(newFileName, serverWithForbiddenChars)) {
            int messageId = 0;
            if (serverWithForbiddenChars) {
                messageId = R.string.filename_forbidden_charaters_from_server;
            } else {
                messageId = R.string.filename_forbidden_characters;
            }
            Toast.makeText(getActivity(), messageId, Toast.LENGTH_LONG).show();
            return;
        }

        ((ComponentsGetter)getActivity()).getFileOperationsHelper().
                renameFile(mTargetFile, newFileName);

    }
}
 
Example 14
Source Project: 365browser   File: OMADownloadHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Shows a dialog to ask whether user wants to open the nextURL.
 *
 * @param omaInfo Information about the OMA content.
 */
private void showNextUrlDialog(OMAInfo omaInfo) {
    if (omaInfo.isValueEmpty(OMA_NEXT_URL)) {
        return;
    }
    final String nextUrl = omaInfo.getValue(OMA_NEXT_URL);
    final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl));
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
                intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
                intent.setPackage(mContext.getPackageName());
                activity.startActivity(intent);
            }
        }
    };
    new AlertDialog.Builder(activity)
            .setTitle(R.string.open_url_post_oma_download)
            .setPositiveButton(R.string.ok, clickListener)
            .setNegativeButton(R.string.cancel, clickListener)
            .setMessage(nextUrl)
            .setCancelable(false)
            .show();
}
 
Example 15
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        AccountManagementScreenHelper.logEvent(
                ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT, mGaiaServiceType);

        mSignOutClicked = true;
        SignOutDialogListener targetFragment = (SignOutDialogListener) getTargetFragment();
        targetFragment.onSignOutClicked();
    }
}
 
Example 16
@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which) {
        case AlertDialog.BUTTON_POSITIVE:
            mSeparateFiles = false;
            break;
        case AlertDialog.BUTTON_NEUTRAL:
            mIsCanceled = true;
            break;
    }
    mIsChosen = true;
}
 
Example 17
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null || mImportantDomains == null || mFaviconURLs == null) {
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                // Return our deselected domains.
                Intent data = new Intent();
                String[] deselectedDomains = mDeselectedDomains.toArray(new String[0]);
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains);
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
Example 18
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
Example 19
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}