Search in sources :

Example 1 with IDialogCallback

use of org.edx.mobile.view.dialog.IDialogCallback in project edx-app-android by edx.

the class BaseWebViewFindCoursesActivity method showEnrollErrorMessage.

private void showEnrollErrorMessage(final String courseId, final boolean emailOptIn) {
    if (isActivityStarted()) {
        Map<String, String> dialogMap = new HashMap<String, String>();
        dialogMap.put("message_1", getString(R.string.enrollment_failure));
        dialogMap.put("yes_button", getString(R.string.try_again));
        dialogMap.put("no_button", getString(R.string.label_cancel));
        EnrollmentFailureDialogFragment failureDialogFragment = EnrollmentFailureDialogFragment.newInstance(dialogMap, new IDialogCallback() {

            @Override
            public void onPositiveClicked() {
                onClickEnroll(courseId, emailOptIn);
            }

            @Override
            public void onNegativeClicked() {
            }
        });
        failureDialogFragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
        failureDialogFragment.show(getSupportFragmentManager(), "dialog");
        failureDialogFragment.setCancelable(false);
    }
}
Also used : HashMap(java.util.HashMap) EnrollmentFailureDialogFragment(org.edx.mobile.view.dialog.EnrollmentFailureDialogFragment) IDialogCallback(org.edx.mobile.view.dialog.IDialogCallback)

Example 2 with IDialogCallback

use of org.edx.mobile.view.dialog.IDialogCallback in project edx-app-android by edx.

the class BrowserUtil method open.

/**
 * Opens given URL in native browser.
 * If app is running on zero-rated network, confirm the user if they really want to proceed
 * browsing the non-zero-rated content.
 * Otherwise, confirms the user as they are leaving the app to browse external contents.
 *
 * @param activity
 * @param url
 */
public static void open(final FragmentActivity activity, final String url) {
    if (TextUtils.isEmpty(url) || activity == null) {
        logger.warn("cannot open URL in browser, either URL or activity parameter is NULL");
        return;
    }
    if (url.startsWith("/")) {
        // use API host as the base URL for relative paths
        String absoluteUrl = String.format("%s%s", environment.getConfig().getApiHostURL(), url);
        logger.debug(String.format("opening relative path URL: %s", absoluteUrl));
        openInBrowser(activity, absoluteUrl);
        return;
    }
    // verify if the app is running on zero-rated mobile data?
    if (NetworkUtil.isConnectedMobile(activity) && NetworkUtil.isOnZeroRatedNetwork(activity, environment.getConfig())) {
        // check if this URL is a white-listed URL, anything outside the white-list is EXTERNAL LINK
        if (ConfigUtil.isWhiteListedURL(url, environment.getConfig())) {
            // this is white-listed URL
            logger.debug(String.format("opening white-listed URL: %s", url));
            openInBrowser(activity, url);
        } else {
            // for non-white-listed URLs
            // inform user they may get charged for browsing this URL
            IDialogCallback callback = new IDialogCallback() {

                @Override
                public void onPositiveClicked() {
                    openInBrowser(activity, url);
                }

                @Override
                public void onNegativeClicked() {
                }
            };
            MediaConsentUtils.showLeavingAppDataDialog(activity, callback);
        }
    } else {
        logger.debug(String.format("non-zero rated network, opening URL: %s", url));
        openInBrowser(activity, url);
    }
}
Also used : IDialogCallback(org.edx.mobile.view.dialog.IDialogCallback)

Example 3 with IDialogCallback

use of org.edx.mobile.view.dialog.IDialogCallback in project edx-app-android by edx.

the class VideoDownloadHelper method downloadVideos.

public void downloadVideos(final List<? extends HasDownloadEntry> model, final FragmentActivity activity, final DownloadManagerCallback callback) {
    if (model == null || model.isEmpty()) {
        return;
    }
    IDialogCallback dialogCallback = new IDialogCallback() {

        @Override
        public void onPositiveClicked() {
            startDownloadVideos(model, activity, callback);
        }

        @Override
        public void onNegativeClicked() {
            callback.showInfoMessage(activity.getString(R.string.wifi_off_message));
            EventBus.getDefault().post(new BulkVideosDownloadCancelledEvent());
        }
    };
    MediaConsentUtils.requestStreamMedia(activity, dialogCallback);
}
Also used : BulkVideosDownloadCancelledEvent(org.edx.mobile.module.storage.BulkVideosDownloadCancelledEvent) IDialogCallback(org.edx.mobile.view.dialog.IDialogCallback)

Example 4 with IDialogCallback

use of org.edx.mobile.view.dialog.IDialogCallback in project edx-app-android by edx.

the class VideoDownloadHelper method showDownloadSizeExceedDialog.

// Dialog fragment to display message to user regarding
private void showDownloadSizeExceedDialog(final ArrayList<DownloadEntry> de, final int noOfDownloads, final FragmentActivity activity, final DownloadManagerCallback callback) {
    Map<String, String> dialogMap = new HashMap<String, String>();
    dialogMap.put("title", activity.getString(R.string.download_exceed_title));
    dialogMap.put("message_1", activity.getString(R.string.download_exceed_message));
    downloadFragment = DownloadSizeExceedDialog.newInstance(dialogMap, new IDialogCallback() {

        @Override
        public void onPositiveClicked() {
            if (!de.isEmpty()) {
                startDownload(de, activity, callback);
                final DownloadEntry downloadEntry = de.get(0);
                analyticsRegistry.trackSubSectionBulkVideoDownload(downloadEntry.getSectionName(), downloadEntry.getChapterName(), downloadEntry.getEnrollmentId(), noOfDownloads);
                EventBus.getDefault().post(new BulkVideosDownloadStartedEvent());
            }
        }

        @Override
        public void onNegativeClicked() {
            // updateList();
            downloadFragment.dismiss();
            EventBus.getDefault().post(new BulkVideosDownloadCancelledEvent());
        }
    });
    downloadFragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
    downloadFragment.show(activity.getSupportFragmentManager(), "dialog");
    downloadFragment.setCancelable(false);
}
Also used : HashMap(java.util.HashMap) BulkVideosDownloadCancelledEvent(org.edx.mobile.module.storage.BulkVideosDownloadCancelledEvent) IDialogCallback(org.edx.mobile.view.dialog.IDialogCallback) HasDownloadEntry(org.edx.mobile.model.course.HasDownloadEntry) DownloadEntry(org.edx.mobile.model.db.DownloadEntry) BulkVideosDownloadStartedEvent(org.edx.mobile.module.storage.BulkVideosDownloadStartedEvent)

Example 5 with IDialogCallback

use of org.edx.mobile.view.dialog.IDialogCallback in project edx-app-android by edx.

the class EmailUtil method openEmailClient.

public static void openEmailClient(final FragmentActivity activityContext, final String to, final String subject, final String email, Config config) {
    // verify if the app is running on zero-rated mobile data?
    if (NetworkUtil.isConnectedMobile(activityContext) && NetworkUtil.isOnZeroRatedNetwork(activityContext, config)) {
        // inform user they may get charged for sending email
        IDialogCallback callback = new IDialogCallback() {

            @Override
            public void onPositiveClicked() {
                sendEmailIntent(activityContext, to, subject, email);
            }

            @Override
            public void onNegativeClicked() {
            }
        };
        MediaConsentUtils.showLeavingAppDataDialog(activityContext, callback);
    } else {
        sendEmailIntent(activityContext, to, subject, email);
    }
}
Also used : IDialogCallback(org.edx.mobile.view.dialog.IDialogCallback)

Aggregations

IDialogCallback (org.edx.mobile.view.dialog.IDialogCallback)6 HashMap (java.util.HashMap)2 BulkVideosDownloadCancelledEvent (org.edx.mobile.module.storage.BulkVideosDownloadCancelledEvent)2 HasDownloadEntry (org.edx.mobile.model.course.HasDownloadEntry)1 DownloadEntry (org.edx.mobile.model.db.DownloadEntry)1 PrefManager (org.edx.mobile.module.prefs.PrefManager)1 BulkVideosDownloadStartedEvent (org.edx.mobile.module.storage.BulkVideosDownloadStartedEvent)1 EnrollmentFailureDialogFragment (org.edx.mobile.view.dialog.EnrollmentFailureDialogFragment)1 NetworkCheckDialogFragment (org.edx.mobile.view.dialog.NetworkCheckDialogFragment)1