use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class ZendeskAPI method getUserDataString.
private static String getUserDataString(Context context) {
String res = "\n\n\n";
User signedInUser = APIHelpers.getCacheUser(context);
boolean isAnonymousDomain = APIHelpers.getDomain(context).endsWith(BuildConfig.ANONYMOUS_SCHOOL_DOMAIN);
String versionNumber = "";
try {
versionNumber = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName + " (" + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode + ")";
} catch (Exception e) {
}
if (!isAnonymousDomain && signedInUser != null) {
res += "User ID : " + Long.toString(signedInUser.getId()) + "\n";
res += "User Name : " + signedInUser.getName() + "\n";
res += "Email : " + signedInUser.getEmail() + "\n";
res += "Hostname : " + APIHelpers.getDomain(context) + "\n";
res += "Version : " + versionNumber;
} else {
res += "Hostname : " + APIHelpers.getDomain(context) + "\n";
res += "Version : " + versionNumber;
}
return res;
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class ZendeskDialogStyled method saveZendeskTicket.
public void saveZendeskTicket() {
String comment = descriptionEditText.getText().toString();
String subject = subjectEditText.getText().toString();
if (comment.isEmpty() || subject.isEmpty()) {
Toast.makeText(getContext(), R.string.empty_feedback, Toast.LENGTH_LONG).show();
return;
}
// contact the user
if (fromLogin) {
if (emailAddressEditText.getText() != null && emailAddressEditText.getText().toString() != null) {
User user = new User();
user.setEmail(emailAddressEditText.getText().toString());
APIHelpers.setCacheUser(getActivity(), user);
}
}
final String email = APIHelpers.getCacheUser(getActivity()).getEmail();
String domain = APIHelpers.getDomain(getActivity());
if (domain == null) {
domain = DEFAULT_DOMAIN;
}
// add device info to comment
// try to get the version number and version code
PackageInfo pInfo = null;
String versionName = "";
int versionCode = 0;
try {
pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
versionName = pInfo.versionName;
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Utils.d(e.getMessage());
}
String deviceInfo = "";
deviceInfo += getString(R.string.device) + " " + Build.MANUFACTURER + " " + Build.MODEL + "\n" + getString(R.string.osVersion) + " " + Build.VERSION.RELEASE + "\n" + getString(R.string.versionNum) + ": " + versionName + " " + versionCode + "\n" + getString(R.string.zendesk_severityText) + " " + getUserSeveritySelectionTag() + "\n" + getString(R.string.utils_installDate) + " " + getInstallDateString() + "\n\n";
comment = deviceInfo + comment;
if (mUseDefaultDomain) {
ErrorReportAPI.postGenericErrorReport(subject, domain, email, comment, getUserSeveritySelectionTag(), new CanvasCallback<ErrorReportResult>((APIStatusDelegate) resultListener) {
@Override
public void firstPage(ErrorReportResult errorReportResult, LinkHeaders linkHeaders, Response response) {
resetCachedUser();
resultListener.onTicketPost();
}
@Override
public boolean onFailure(RetrofitError retrofitError) {
resetCachedUser();
resultListener.onTicketError();
return super.onFailure(retrofitError);
}
});
} else {
ErrorReportAPI.postErrorReport(subject, domain, email, comment, getUserSeveritySelectionTag(), new CanvasCallback<ErrorReportResult>((APIStatusDelegate) resultListener) {
@Override
public void cache(ErrorReportResult errorReportResult) {
resetCachedUser();
}
@Override
public void firstPage(ErrorReportResult errorReportResult, LinkHeaders linkHeaders, Response response) {
cache(errorReportResult);
resultListener.onTicketPost();
}
@Override
public boolean onFailure(RetrofitError retrofitError) {
resetCachedUser();
resultListener.onTicketError();
return super.onFailure(retrofitError);
}
});
}
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class StudentGridAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(R.layout.student_notes_grid_item, parent, false);
holder = new StudentHolder();
holder.avatar = (CircleImageView) row.findViewById(R.id.avatar);
holder.studentName = (TextView) row.findViewById(R.id.studentName);
row.setTag(holder);
} else {
holder = (StudentHolder) row.getTag();
}
User user = users.get(position);
holder.studentName.setText(user.getName());
Picasso.with(context).load(user.getAvatarURL()).centerCrop().fit().into(holder.avatar);
return row;
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class CourseListFragment method onRowClick.
@Override
public boolean onRowClick(CanvasContext item) {
Bundle bundle = new Bundle();
Section section = (Section) item;
section.getCourse_id();
CanvasContext course = courseGroupMap.get(section.getCourse_id());
bundle.putParcelable(Const.SECTION, item);
bundle.putParcelable(Const.COURSE, course);
bundle.putParcelableArrayList(Const.SECTION_PEOPLE, (ArrayList<User>) ((Section) item).getStudents());
if (nextFragment == Const.HOT_SEAT) {
StudentChooserFragment studentChooserFragment = new StudentChooserFragment();
studentChooserFragment.setArguments(bundle);
getParentActivity().swapFragment(studentChooserFragment, StudentChooserFragment.TAG);
} else if (nextFragment == Const.GUESS_WHO) {
GuessWhoFragment guessWhoFragment = new GuessWhoFragment();
guessWhoFragment.setArguments(bundle);
getParentActivity().swapFragment(guessWhoFragment, GuessWhoFragment.TAG);
} else if (nextFragment == Const.STUDENT_NOTES) {
StudentNotesFragment studentNotesFragment = new StudentNotesFragment();
studentNotesFragment.setArguments(bundle);
getParentActivity().swapFragment(studentNotesFragment, StudentNotesFragment.TAG);
}
return true;
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class StudentChooserFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getArguments() != null) {
Course course = getArguments().getParcelable(Const.COURSE);
courseName.setText(course.getName());
sectionPeople = getArguments().getParcelableArrayList(Const.SECTION_PEOPLE);
for (User user : sectionPeople) {
adapter.addItem(user);
}
if (adapter.getCount() == 0) {
showEmptyView();
emptyView.setText(getString(R.string.noStudents));
}
getParentActivity().setActionBarTitle(getString(R.string.studentChooser));
}
getCheckedState();
// initialize the text to speech engine
tts = new TextToSpeech(getActivity(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("error", "This Language is not supported");
} else {
tts.setLanguage(Locale.getDefault());
}
} else {
Log.e("error", "Initilization Failed!");
}
}
});
}
Aggregations