Search in sources :

Example 1 with AvatarView

use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.

the class NavigationDrawerActivity method handleUserSettingsChange.

protected void handleUserSettingsChange() {
    if (TranSappAccountManager.isLoggedIn()) {
        AvatarView imageView = navigationView.getHeaderView(0).findViewById(R.id.drawer_header_user_image);
        TranSappAccountManager.getCurrentAccount().currentUser.loadImage(imageView);
    }
}
Also used : AvatarView(agency.tango.android.avatarview.views.AvatarView)

Example 2 with AvatarView

use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.

the class NavigationDrawerActivity method handleLoginStatus.

protected void handleLoginStatus() {
    MenuItem accountItem = navigationView.getMenu().findItem(R.id.navigation_item_account);
    View header = navigationView.getHeaderView(0);
    if (TranSappAccountManager.isLoggedIn()) {
        accountItem.setTitle(R.string.my_account);
        accountItem.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_account_circle_24dp));
        TextView nameView = header.findViewById(R.id.drawer_header_user_name);
        nameView.setText(TranSappAccountManager.getCurrentAccount().getName());
        nameView.setVisibility(View.VISIBLE);
        AvatarView imageView = header.findViewById(R.id.drawer_header_user_image);
        TranSappAccountManager.getCurrentAccount().currentUser.loadImage(imageView);
        imageView.setVisibility(View.VISIBLE);
    } else {
        accountItem.setTitle(R.string.log_in);
        accountItem.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_lock_24dp));
        header.findViewById(R.id.drawer_header_user_name).setVisibility(View.GONE);
        header.findViewById(R.id.drawer_header_user_image).setVisibility(View.GONE);
    }
}
Also used : AvatarView(agency.tango.android.avatarview.views.AvatarView) MenuItem(android.view.MenuItem) TextView(android.widget.TextView) NavigationView(android.support.design.widget.NavigationView) AvatarView(agency.tango.android.avatarview.views.AvatarView) View(android.view.View) TextView(android.widget.TextView)

Example 3 with AvatarView

use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.

the class AccountSettingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_user_settings);
    currentAccount = TranSappAccountManager.getCurrentAccount();
    int level = currentAccount.currentUser.level.getLevelPosition();
    serverUserAvatarId = currentAccount.currentUser.avatarId;
    serverShowImageAsAvatar = !currentAccount.currentUser.showAvatar;
    userAvatarId = serverUserAvatarId;
    showImageAsAvatar = serverShowImageAsAvatar;
    RecyclerView userGridView = findViewById(R.id.activity_account_settings_user_avatar_grid_view);
    userGridView.setLayoutManager(new GridLayoutManager(this, 4));
    editText = findViewById(R.id.nickname_edit_text);
    editText.setText(currentAccount.currentUser.nickname);
    findViewById(R.id.level_layout).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startActivity(new Intent(AccountSettingsActivity.this, LevelActivity.class));
        }
    });
    TextView levelName = findViewById(R.id.level_name);
    levelName.setText(currentAccount.currentUser.level.getLevelName());
    levelName.setTextColor(ContextCompat.getColor(this, currentAccount.currentUser.level.getLevelTextColor()));
    ImageView levelImage = findViewById(R.id.level_image);
    levelImage.setColorFilter(ContextCompat.getColor(this, currentAccount.currentUser.level.getLevelStarColor()));
    AvatarView imageView = findViewById(R.id.avatar_image);
    currentAccount.currentUser.loadImage(imageView);
    Log.d("SettingsActivity", "creating grid");
    GridAvatarAdapter userAdapter = new GridAvatarAdapter(AvatarLists.USER_AVATARS, new GridAvatarAdapter.AvatarClickListener() {

        @Override
        public void onNewAvatarSelected(int serverId) {
            userAvatarId = serverId;
        }
    }, level, serverUserAvatarId);
    Log.d("SettingsActivity", "setting grid");
    userGridView.setAdapter(userAdapter);
    Log.d("SettingsActivity", "grid ready");
    Switch switchShowImage = findViewById(R.id.activity_account_settings_switch_button);
    switchShowImage.setChecked(serverShowImageAsAvatar);
    switchShowImage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            showImageAsAvatar = isChecked;
        }
    });
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) AvatarView(agency.tango.android.avatarview.views.AvatarView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridAvatarAdapter(cl.smartcities.isci.transportinspector.adapters.GridAvatarAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) AvatarView(agency.tango.android.avatarview.views.AvatarView) Switch(android.widget.Switch) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CompoundButton(android.widget.CompoundButton)

Example 4 with AvatarView

use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.

the class NicknameFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.activity_account_nickname_fragment, container, false);
    AvatarView userPicture = view.findViewById(R.id.user_image);
    final SocialMediaAccount account = SocialMediaAccount.getCurrentAccount();
    if (account == null) {
        getActivity().finish();
        return view;
    }
    account.loadImage(userPicture);
    View submitButton = view.findViewById(R.id.submit_button);
    final EditText nicknameEditText = view.findViewById(R.id.nickname_edit_text);
    submitButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final String nickname = nicknameEditText.getText().toString();
            if (nickname.length() == 0) {
                Toast.makeText(getContext(), "Debes ingresar un nickname", Toast.LENGTH_SHORT).show();
            } else if (nickname.length() > 30) {
                Toast.makeText(getContext(), "Ingresa un nick con menos de 30 caracteres", Toast.LENGTH_SHORT).show();
            } else {
                final ProgressDialog dialog = new ProgressDialog(getActivity());
                dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                dialog.setMessage("Iniciando Sesión");
                dialog.setCanceledOnTouchOutside(false);
                dialog.show();
                TranSappAccountManager.loginWithTransapp(new AccountLogInListener() {

                    @Override
                    public void onAccountReady(TranSappAccount account) {
                        loginCallback.onTranSappLogin();
                        dialog.dismiss();
                    }

                    @Override
                    public void onError(ServerStatusCode error) {
                        dialog.dismiss();
                        if (error.getErrorCode() == ServerStatusCode.SERVER_ERROR || error.getErrorCode() == ServerStatusCode.INTERNAL_SERVER_ERROR || error.getErrorCode() == ServerStatusCode.PARSE_ERROR || error.getErrorCode() == ServerStatusCode.INVALID_SESSION_TOKEN) {
                            Toast.makeText(TranSappApplication.getAppContext(), "No se pudo iniciar sesión con TranSapp", Toast.LENGTH_SHORT).show();
                        }
                    }
                }, nickname, account);
            }
        }
    });
    return view;
}
Also used : EditText(android.widget.EditText) SocialMediaAccount(cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialMediaAccount) TranSappAccount(cl.smartcities.isci.transportinspector.gamification.transappUser.TranSappAccount) AvatarView(agency.tango.android.avatarview.views.AvatarView) ServerStatusCode(cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode) ProgressDialog(android.app.ProgressDialog) AvatarView(agency.tango.android.avatarview.views.AvatarView) View(android.view.View) AccountLogInListener(cl.smartcities.isci.transportinspector.gamification.ui.listener.AccountLogInListener)

Aggregations

AvatarView (agency.tango.android.avatarview.views.AvatarView)4 View (android.view.View)3 TextView (android.widget.TextView)2 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1 NavigationView (android.support.design.widget.NavigationView)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MenuItem (android.view.MenuItem)1 CompoundButton (android.widget.CompoundButton)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 Switch (android.widget.Switch)1 GridAvatarAdapter (cl.smartcities.isci.transportinspector.adapters.GridAvatarAdapter)1 SocialMediaAccount (cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialMediaAccount)1 TranSappAccount (cl.smartcities.isci.transportinspector.gamification.transappUser.TranSappAccount)1 AccountLogInListener (cl.smartcities.isci.transportinspector.gamification.ui.listener.AccountLogInListener)1 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)1