Search in sources :

Example 1 with App

use of com.instructure.speedgrader.util.App in project instructure-android by instructure.

the class SubmissionWebViewFragment method initWebView.

public void initWebView(View rootView) {
    webView = (DocumentWebView) rootView.findViewById(R.id.documentWebView);
    webView.setVerticalScrollBarEnabled(true);
    webView.setHorizontalScrollBarEnabled(true);
    webView.requestFocusFromTouch();
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    webView.addJavascriptInterface(new JsObject(webView, loadingView), "CallToAnAndroidFunction");
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("?login_success=1")) {
                view.loadUrl(currentSubmission.getPreviewUrl());
                return true;
            } else if (url.contains("score_updated=1")) {
                getSubmissionAndUpdateRubric();
            } else {
                view.loadUrl(url);
            }
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (!isAdded()) {
                return;
            }
            if (!((App) getActivity().getApplication()).showStudentNames()) {
                view.loadUrl("javascript:" + "var css = document.createElement('style');" + "css.type = 'text/css';" + "css.innerHTML = '.quiz-header h2{ visibility: hidden !important; }';" + "document.getElementById('content').appendChild(css);");
            }
        }
    });
}
Also used : App(com.instructure.speedgrader.util.App) WebView(android.webkit.WebView) DocumentWebView(com.instructure.speedgrader.views.DocumentWebView) WebViewClient(android.webkit.WebViewClient)

Example 2 with App

use of com.instructure.speedgrader.util.App in project instructure-android by instructure.

the class StudentListView method initListView.

private void initListView(View popupView) {
    // get the listview inside our popupwindow and set our adapter to it
    mListView = (ListView) popupView.findViewById(R.id.studentList);
    mSubmissionsAdapter = new UserSubmissionsListAdapter(mActivity.getApplicationContext(), mSubmissionsList, mAssignment, mListView, ((App) mActivity.getApplication()).showStudentNames(), mListener);
    if (isSortByName) {
        mSubmissionsAdapter.sortSubmissionsByName(((App) mActivity.getApplication()).showUngradedStudentsFirst());
    } else {
        mSubmissionsAdapter.sortSubmissionsByGrade();
    }
    final ViewGroup header = (ViewGroup) LayoutInflater.from(mActivity).inflate(R.layout.student_list_headerview, mListView, false);
    final RelativeLayout row = (RelativeLayout) header.findViewById(R.id.row);
    final LinearLayout dropDown = (LinearLayout) header.findViewById(R.id.rowDropdown);
    final RadioGroup radioGroup = (RadioGroup) header.findViewById(R.id.radioGroup);
    final ImageView expandArrow = (ImageView) header.findViewById(R.id.expandArrow);
    final TextView sectionTitle = (TextView) header.findViewById(R.id.sectionTitle);
    row.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ExpandCollapseAnimation.setHeightForWrapContent(mActivity, dropDown);
            ExpandCollapseAnimation expandCollapseAnimation = new ExpandCollapseAnimation(dropDown, 200);
            expandCollapseAnimation.setAnimationListener(new Animation.AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    RotateAnimation rotationAnim;
                    if (dropDown.getHeight() < 50) {
                        // For some reason, onAnimatinoEnd is getting called slightly before the animation actually ends, causing the height to be a value something greater than 0.
                        // currently closed
                        rotationAnim = new RotateAnimation(180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                    } else {
                        // currently open
                        rotationAnim = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                    }
                    rotationAnim.setDuration(100);
                    rotationAnim.setFillAfter(true);
                    expandArrow.startAnimation(rotationAnim);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }
            });
            dropDown.startAnimation(expandCollapseAnimation);
        }
    });
    // Set our arrow to gray
    final Drawable d = CanvasContextColor.getColoredDrawable(mApplicationContext, R.drawable.ic_cv_arrow_down_fill, ContextCompat.getColor(mActivity.getApplicationContext(), R.color.lightGray));
    expandArrow.setImageDrawable(d);
    mListView.addHeaderView(header);
    mListView.setTextFilterEnabled(true);
    mListView.setAdapter(mSubmissionsAdapter);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // show the submission clicked
            dismiss();
            int positionInList = mSubmissionsAdapter.getPositionForSubmission((Submission) mListView.getItemAtPosition(position));
            mListener.onCurrentSubmission(positionInList);
        }
    });
    initSectionsRadioGroup(radioGroup, sectionTitle, header);
}
Also used : App(com.instructure.speedgrader.util.App) RadioGroup(android.widget.RadioGroup) Submission(com.instructure.canvasapi.model.Submission) UserSubmissionsListAdapter(com.instructure.speedgrader.adapters.UserSubmissionsListAdapter) ViewGroup(android.view.ViewGroup) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) RotateAnimation(android.view.animation.RotateAnimation) RelativeLayout(android.widget.RelativeLayout) ExpandCollapseAnimation(com.instructure.speedgrader.util.ExpandCollapseAnimation) ExpandCollapseAnimation(com.instructure.speedgrader.util.ExpandCollapseAnimation) Animation(android.view.animation.Animation) RotateAnimation(android.view.animation.RotateAnimation) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 3 with App

use of com.instructure.speedgrader.util.App in project instructure-android by instructure.

the class HomeActivity method initSettingsListeners.

public void initSettingsListeners() {
    final SwitchCompat hideNamesSwitch = (SwitchCompat) findViewById(R.id.sg_options_hideNames_switch);
    final SwitchCompat showUngradedFirstSwitch = (SwitchCompat) findViewById(R.id.sg_options_showUngradedFirst_switch);
    final SwitchCompat showUngradedCountSwitch = (SwitchCompat) findViewById(R.id.sg_options_viewUngradedCount_switch);
    final HelveticaTextView hideNamesLabel = (HelveticaTextView) findViewById(R.id.sg_options_hideNames);
    final HelveticaTextView showUngradedFirstLabel = (HelveticaTextView) findViewById(R.id.sg_options_showUngradedFirst);
    final HelveticaTextView viewUngradedCountLabel = (HelveticaTextView) findViewById(R.id.sg_options_viewUngradedCount);
    final ImageView pulse = (ImageView) findViewById(R.id.pulse);
    new TutorialUtils(HomeActivity.this, App.getPrefs(), pulse, TutorialUtils.TYPE.COLOR_CHANGING_DIALOG).setContent(getString(R.string.tutorial_tipHideStudentNames), getString(R.string.tutorial_tipHideStudentNamesMessage)).build();
    hideNamesLabel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            hideNamesSwitch.toggle();
        }
    });
    showUngradedFirstLabel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showUngradedFirstSwitch.toggle();
        }
    });
    viewUngradedCountLabel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showUngradedCountSwitch.toggle();
        }
    });
    // Set Switch defaults
    final App applicationManager = (App) getApplication();
    // Set Default values for our switches
    hideNamesSwitch.setChecked(applicationManager.showStudentNames());
    showUngradedFirstSwitch.setChecked(applicationManager.showUngradedStudentsFirst());
    showUngradedCountSwitch.setChecked(applicationManager.showUngradedCount());
    // set On check changed listeners
    hideNamesSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            applicationManager.setShowStudentNames(isChecked);
        }
    });
    showUngradedFirstSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            applicationManager.setShowUngradedStudentsFirst(isChecked);
        }
    });
    showUngradedCountSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            applicationManager.setShowUngradedCount(isChecked);
            if (getSupportFragmentManager().findFragmentById(R.id.content_frame) instanceof OnSettingsChangedListener) {
                ((OnSettingsChangedListener) getSupportFragmentManager().findFragmentById(R.id.content_frame)).onShowUngradedCountChanged(isChecked);
            }
        }
    });
}
Also used : App(com.instructure.speedgrader.util.App) OnSettingsChangedListener(com.instructure.speedgrader.interfaces.OnSettingsChangedListener) HelveticaTextView(com.instructure.speedgrader.views.HelveticaTextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) TutorialUtils(com.instructure.pandautils.utils.TutorialUtils) HelveticaTextView(com.instructure.speedgrader.views.HelveticaTextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 4 with App

use of com.instructure.speedgrader.util.App in project instructure-android by instructure.

the class DiscussionSubmissionFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflateLayout(inflater, container);
    setupViews(rootView);
    setupClickListeners();
    App applicationManager = (App) getActivity().getApplication();
    showStudentNames = applicationManager.showStudentNames();
    return rootView;
}
Also used : App(com.instructure.speedgrader.util.App) View(android.view.View) ListView(android.widget.ListView)

Example 5 with App

use of com.instructure.speedgrader.util.App in project instructure-android by instructure.

the class StudentListView method initSortSelector.

private void initSortSelector(View popupView) {
    final CheckedLinearLayout sortSwitch = (CheckedLinearLayout) popupView.findViewById(R.id.sortSelector);
    sortSwitch.setLeftAsChecked(isSortByName);
    sortSwitch.setLeftIndicatorText(mApplicationContext.getResources().getString(R.string.name));
    sortSwitch.setRightIndicatorText(mApplicationContext.getResources().getString(R.string.grade));
    sortSwitch.setCallbacks(new CheckedLinearLayout.OnSwitchListener() {

        @Override
        public void onSwitch(boolean isLeftChecked) {
            if (!isLeftChecked) {
                // !isLeftChecked == sort by Grade
                isSortByName = false;
                mSubmissionsAdapter.sortSubmissionsByGrade();
                mSubmissionsAdapter.notifyDataSetChanged();
                mListener.onSubmissionListUpdated();
            } else {
                // isLeftChecked == sort by Name
                isSortByName = true;
                mSubmissionsAdapter.sortSubmissionsByName(((App) mActivity.getApplication()).showUngradedStudentsFirst());
                mSubmissionsAdapter.notifyDataSetChanged();
                mListener.onSubmissionListUpdated();
            }
        }
    });
    // set tutorial
    ImageView pulse = (ImageView) popupView.findViewById(R.id.pulse);
    new TutorialUtils(mActivity, App.getPrefs(), pulse, TutorialUtils.TYPE.FILTER_BY_GRADE).setContent(mApplicationContext.getString(R.string.tutorial_tipSortStudentList), mApplicationContext.getString(R.string.tutorial_tipSortStudentListMessage)).build();
}
Also used : App(com.instructure.speedgrader.util.App) ImageView(android.widget.ImageView) TutorialUtils(com.instructure.pandautils.utils.TutorialUtils)

Aggregations

App (com.instructure.speedgrader.util.App)5 View (android.view.View)3 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 TutorialUtils (com.instructure.pandautils.utils.TutorialUtils)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 SearchView (android.support.v7.widget.SearchView)1 SwitchCompat (android.support.v7.widget.SwitchCompat)1 ViewGroup (android.view.ViewGroup)1 Animation (android.view.animation.Animation)1 RotateAnimation (android.view.animation.RotateAnimation)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 AdapterView (android.widget.AdapterView)1 CompoundButton (android.widget.CompoundButton)1 LinearLayout (android.widget.LinearLayout)1 RadioGroup (android.widget.RadioGroup)1 RelativeLayout (android.widget.RelativeLayout)1