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);");
}
}
});
}
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);
}
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);
}
}
});
}
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;
}
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();
}
Aggregations