Search in sources :

Example 16 with User

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;
}
Also used : User(com.instructure.canvasapi.model.User)

Example 17 with User

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);
            }
        });
    }
}
Also used : User(com.instructure.canvasapi.model.User) LinkHeaders(com.instructure.canvasapi.utilities.LinkHeaders) PackageInfo(android.content.pm.PackageInfo) ErrorReportResult(com.instructure.canvasapi.model.ErrorReportResult) APIStatusDelegate(com.instructure.canvasapi.utilities.APIStatusDelegate) Response(retrofit.client.Response) PackageManager(android.content.pm.PackageManager) RetrofitError(retrofit.RetrofitError)

Example 18 with User

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;
}
Also used : User(com.instructure.canvasapi.model.User) LayoutInflater(android.view.LayoutInflater) Activity(android.app.Activity) TextView(android.widget.TextView) View(android.view.View) CircleImageView(de.hdodenhof.circleimageview.CircleImageView)

Example 19 with User

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;
}
Also used : User(com.instructure.canvasapi.model.User) Bundle(android.os.Bundle) CanvasContext(com.instructure.canvasapi.model.CanvasContext) Section(com.instructure.canvasapi.model.Section)

Example 20 with User

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!");
            }
        }
    });
}
Also used : User(com.instructure.canvasapi.model.User) Course(com.instructure.canvasapi.model.Course) TextToSpeech(android.speech.tts.TextToSpeech)

Aggregations

User (com.instructure.canvasapi.model.User)23 TextView (android.widget.TextView)4 Gson (com.google.gson.Gson)4 LinkHeaders (com.instructure.canvasapi.utilities.LinkHeaders)4 Response (retrofit.client.Response)4 Intent (android.content.Intent)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 Test (org.junit.Test)3 RetrofitError (retrofit.RetrofitError)3 PackageInfo (android.content.pm.PackageInfo)2 PackageManager (android.content.pm.PackageManager)2 Bundle (android.os.Bundle)2 Course (com.instructure.canvasapi.model.Course)2 Section (com.instructure.canvasapi.model.Section)2 Submission (com.instructure.canvasapi.model.Submission)2 CanvasRestAdapter (com.instructure.canvasapi.utilities.CanvasRestAdapter)2 UserCallback (com.instructure.canvasapi.utilities.UserCallback)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 RestAdapter (retrofit.RestAdapter)2