use of ca.etsmtl.applets.etsmobile.util.ProfilManager in project ETSMobile-Android2 by ApplETS.
the class ApplicationManager method deconnexion.
public static void deconnexion(final Activity activity) {
final Editor editor = PreferenceManager.getDefaultSharedPreferences(activity).edit();
editor.clear();
editor.commit();
// Enlever le profil de la DB SQLite
new ProfilManager(activity).removeProfil();
new NoteManager(activity).remove();
AccountManager accountManager = AccountManager.get(activity);
Account[] accounts = accountManager.getAccountsByType(Constants.ACCOUNT_TYPE);
for (int index = 0; index < accounts.length; index++) {
accountManager.removeAccount(accounts[index], null, null);
}
ApplicationManager.userCredentials = null;
Intent intent = new Intent(activity, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(intent);
new Thread(new Runnable() {
@Override
public void run() {
activity.finish();
}
}).start();
}
use of ca.etsmtl.applets.etsmobile.util.ProfilManager in project ETSMobile-Android2 by ApplETS.
the class ProfilFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup v = (ViewGroup) inflater.inflate(R.layout.fragment_profil, container, false);
super.onCreateView(inflater, v, savedInstanceState);
((MainActivity) getActivity()).setTitle(getFragmentTitle());
loadingView.showLoadingView();
dataManager.getDataFromSignet(SignetMethods.INFO_ETUDIANT, ApplicationManager.userCredentials, this, "");
dataManager.getDataFromSignet(SignetMethods.LIST_PROGRAM, ApplicationManager.userCredentials, this, "");
listViewProfile = (ListView) v.findViewById(R.id.listview_profile);
listViewProfile.setAdapter(profileAdapter);
profilManager = new ProfilManager(getActivity());
AnalyticsHelper.getInstance(getActivity()).sendScreenEvent(getClass().getSimpleName());
return v;
}
use of ca.etsmtl.applets.etsmobile.util.ProfilManager in project ETSMobile-Android2 by ApplETS.
the class MainActivity method initDrawer.
private void initDrawer() {
boolean isUserLoggedIn = ApplicationManager.userCredentials != null;
String studentName = "";
String codeUniversel = "";
ProfilManager profilManager = new ProfilManager(this);
Etudiant etudiant = profilManager.getEtudiant();
if (etudiant != null) {
String prenom = etudiant.prenom != null ? etudiant.prenom.trim() : "";
String nom = etudiant.nom != null ? etudiant.nom.trim() : "";
studentName = prenom + " " + nom;
codeUniversel = etudiant.codePerm != null ? etudiant.codePerm : "";
}
headerResult = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.ets_background_grayscale).withSelectionListEnabledForSingleProfile(false).addProfiles(new ProfileDrawerItem().withName(codeUniversel).withEmail(studentName).withSelectedTextColor(ContextCompat.getColor(this, R.color.red)).withIcon(R.drawable.ic_user).withSelectable(isUserLoggedIn)).withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean current) {
goToFragment(new ProfilFragment(), ProfilFragment.class.getName());
return false;
}
}).build();
DrawerBuilder drawerBuilder = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult).withSelectedItem(isUserLoggedIn ? TODAY_FRAGMENT : ABOUT_FRAGMENT).withDisplayBelowStatusBar(true).withShowDrawerOnFirstLaunch(true).addDrawerItems(new ExpandableDrawerItem().withName(R.string.menu_section_1_moi).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_1_ajd).withIdentifier(TODAY_FRAGMENT).withIcon(R.drawable.ic_ico_aujourdhui).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_horaire).withIdentifier(SCHEDULE_FRAGMENT).withIcon(R.drawable.ic_ico_schedule).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_notes).withIdentifier(COURSE_FRAGMENT).withIcon(R.drawable.ic_ico_notes).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_2_moodle).withIdentifier(MOODLE_FRAGMENT).withIcon(R.drawable.ic_moodle_icon_small).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_monETS).withIdentifier(MONETS_FRAGMENT).withIcon(R.drawable.ic_monets).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_bandwith).withIdentifier(BANDWIDTH_FRAGMENT).withIcon(R.drawable.ic_ico_internet)).withIsExpanded(true), new ExpandableDrawerItem().withName(R.string.menu_section_2_ets).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_2_news).withIdentifier(NEWS_FRAGMENT).withIcon(R.drawable.ic_ico_news), new SecondaryDrawerItem().withName(R.string.menu_section_2_events).withIdentifier(EVENTS_FRAGMENT).withIcon(R.drawable.ic_event_available), new SecondaryDrawerItem().withName(R.string.menu_section_2_bottin).withIdentifier(DIRECTORY_FRAGMENT).withIcon(R.drawable.ic_ico_bottin), new SecondaryDrawerItem().withName(R.string.menu_section_2_biblio).withIdentifier(LIBRARY_FRAGMENT).withIcon(R.drawable.ic_ico_library), new SecondaryDrawerItem().withName(R.string.menu_section_2_securite).withIdentifier(SECURITY_FRAGMENT).withIcon(R.drawable.ic_ico_security)), new ExpandableDrawerItem().withName(R.string.menu_section_3_applets).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_3_apps).withIdentifier(ACHIEVEMENTS_FRAGMENT).withIcon(R.drawable.ic_star_60x60), new SecondaryDrawerItem().withName(R.string.menu_section_3_about).withIdentifier(ABOUT_FRAGMENT).withIcon(R.drawable.ic_logo_icon_final), new SecondaryDrawerItem().withName(R.string.menu_section_3_comms).withIdentifier(COMMENTS_FRAGMENT).withIcon(R.drawable.ic_ico_comment), new SecondaryDrawerItem().withName(R.string.menu_section_3_sponsors).withIdentifier(SPONSOR_FRAGMENT).withIcon(R.drawable.ic_ico_partners), new SecondaryDrawerItem().withName(R.string.menu_section_3_faq).withIdentifier(FAQ_FRAGMENT).withIcon(R.drawable.ic_ico_faq)));
if (isUserLoggedIn)
drawerBuilder.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.action_logout).withIdentifier(LOGOUT).withTextColorRes(R.color.red));
else
drawerBuilder.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.action_login).withIdentifier(LOGIN));
drawerBuilder.withOnDrawerItemClickListener(drawerItemClickListener);
drawerBuilder.build();
}
Aggregations