Search in sources :

Example 1 with AnalyticsRegistry

use of org.edx.mobile.module.analytics.AnalyticsRegistry in project edx-app-android by edx.

the class NavigationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    drawerNavigationBinding = DataBindingUtil.inflate(inflater, R.layout.drawer_navigation, container, false);
    if (config.isUserProfilesEnabled()) {
        if (null != profileImage) {
            loadProfileImage(profileImage, drawerNavigationBinding.profileImage);
        }
        if (profile != null && profile.username != null) {
            drawerNavigationBinding.profileImage.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    final BaseFragmentActivity act = (BaseFragmentActivity) getActivity();
                    act.closeDrawer();
                    if (!(act instanceof UserProfileActivity)) {
                        environment.getRouter().showUserProfileWithNavigationDrawer(getActivity(), profile.username);
                        if (!(act instanceof MyCoursesListActivity)) {
                            act.finish();
                        }
                    }
                }
            });
        }
    } else {
        drawerNavigationBinding.profileImage.setVisibility(View.GONE);
        drawerNavigationBinding.navigationHeaderLayout.setClickable(false);
        drawerNavigationBinding.navigationHeaderLayout.setForeground(null);
    }
    drawerNavigationBinding.drawerOptionMyCourses.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Activity act = getActivity();
            ((BaseFragmentActivity) act).closeDrawer();
            if (!(act instanceof MyCoursesListActivity)) {
                environment.getRouter().showMyCourses(act);
                act.finish();
            }
        }
    });
    if (environment.getConfig().getCourseDiscoveryConfig().isCourseDiscoveryEnabled()) {
        drawerNavigationBinding.drawerOptionFindCourses.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                AnalyticsRegistry analyticsRegistry = environment.getAnalyticsRegistry();
                analyticsRegistry.trackUserFindsCourses();
                FragmentActivity act = getActivity();
                ((BaseFragmentActivity) act).closeDrawer();
                if (!(act instanceof WebViewFindCoursesActivity || act instanceof NativeFindCoursesActivity)) {
                    environment.getRouter().showFindCourses(act);
                    // the student should be returned to the MyCourses screen
                    if (!(act instanceof MyCoursesListActivity)) {
                        act.finish();
                    }
                }
            }
        });
        if (config.getCourseDiscoveryConfig().isWebviewCourseDiscoveryEnabled()) {
            drawerNavigationBinding.drawerOptionFindCourses.setText(R.string.label_discover);
        } else {
            drawerNavigationBinding.drawerOptionFindCourses.setText(R.string.label_find_courses);
        }
    } else {
        drawerNavigationBinding.drawerOptionFindCourses.setVisibility(View.GONE);
    }
    drawerNavigationBinding.drawerOptionAccount.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            Activity act = getActivity();
            ((BaseFragmentActivity) act).closeDrawer();
            if (!(act instanceof AccountActivity)) {
                environment.getRouter().showAccountActivity(act);
                if (!(act instanceof MyCoursesListActivity)) {
                    act.finish();
                }
            }
        }
    });
    if (profile != null) {
        if (profile.name != null) {
            drawerNavigationBinding.nameTv.setText(profile.name);
            drawerNavigationBinding.nameTv.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.navigation_header, "username", profile.name));
        }
    }
    return drawerNavigationBinding.getRoot();
}
Also used : BaseFragmentActivity(org.edx.mobile.base.BaseFragmentActivity) FragmentActivity(android.support.v4.app.FragmentActivity) BaseFragmentActivity(org.edx.mobile.base.BaseFragmentActivity) OnClickListener(android.view.View.OnClickListener) UserProfileActivity(org.edx.mobile.profiles.UserProfileActivity) BaseFragmentActivity(org.edx.mobile.base.BaseFragmentActivity) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) AnalyticsRegistry(org.edx.mobile.module.analytics.AnalyticsRegistry) ImageView(android.widget.ImageView) View(android.view.View) UserProfileActivity(org.edx.mobile.profiles.UserProfileActivity)

Example 2 with AnalyticsRegistry

use of org.edx.mobile.module.analytics.AnalyticsRegistry in project edx-app-android by edx.

the class DownloadCompleteReceiver method handleDownloadCompleteIntent.

private void handleDownloadCompleteIntent(final Intent data) {
    if (data.hasExtra(DownloadManager.EXTRA_DOWNLOAD_ID)) {
        final long id = data.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
        if (id != -1) {
            AsyncTask.execute(new Runnable() {

                @Override
                public void run() {
                    logger.debug("Received download notification for id: " + id);
                    // check if download was SUCCESSFUL
                    NativeDownloadModel nm = environment.getDownloadManager().getDownload(id);
                    if (nm == null || nm.status != DownloadManager.STATUS_SUCCESSFUL) {
                        logger.debug("Download seems failed or cancelled for id : " + id);
                        environment.getDownloadManager().removeDownloads(id);
                        return;
                    } else {
                        logger.debug("Download successful for id : " + id);
                    }
                    // mark download as completed
                    environment.getStorage().markDownloadAsComplete(id, new DataCallback<VideoModel>() {

                        @Override
                        public void onResult(VideoModel result) {
                            if (result != null) {
                                DownloadEntry download = (DownloadEntry) result;
                                AnalyticsRegistry analyticsRegistry = environment.getAnalyticsRegistry();
                                analyticsRegistry.trackDownloadComplete(download.videoId, download.eid, download.lmsUrl);
                            }
                        }

                        @Override
                        public void onFail(Exception ex) {
                            logger.error(ex);
                        }
                    });
                }
            });
        }
    }
}
Also used : AnalyticsRegistry(org.edx.mobile.module.analytics.AnalyticsRegistry) NativeDownloadModel(org.edx.mobile.model.download.NativeDownloadModel) DataCallback(org.edx.mobile.module.db.DataCallback) VideoModel(org.edx.mobile.model.VideoModel) DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Example 3 with AnalyticsRegistry

use of org.edx.mobile.module.analytics.AnalyticsRegistry in project edx-app-android by edx.

the class BrowserUtil method openInBrowser.

private static void openInBrowser(FragmentActivity context, String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse(url));
    context.startActivity(intent);
    AnalyticsRegistry analyticsRegistry = environment.getAnalyticsRegistry();
    analyticsRegistry.trackBrowserLaunched(url);
}
Also used : Intent(android.content.Intent) AnalyticsRegistry(org.edx.mobile.module.analytics.AnalyticsRegistry)

Aggregations

AnalyticsRegistry (org.edx.mobile.module.analytics.AnalyticsRegistry)3 Activity (android.app.Activity)1 Intent (android.content.Intent)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 BaseFragmentActivity (org.edx.mobile.base.BaseFragmentActivity)1 VideoModel (org.edx.mobile.model.VideoModel)1 DownloadEntry (org.edx.mobile.model.db.DownloadEntry)1 NativeDownloadModel (org.edx.mobile.model.download.NativeDownloadModel)1 DataCallback (org.edx.mobile.module.db.DataCallback)1 UserProfileActivity (org.edx.mobile.profiles.UserProfileActivity)1