anitab-org / powerup-android

PowerUp is an educational choose-your-own-adventure game that utilizes a users uploaded curriculum to empower pre-adolescents to take charge of their reproductive health. This is the Android version of the game.
GNU General Public License v2.0
117 stars 429 forks source link

Avatar does not reset to default avatar room #997

Closed Rimjhim28 closed 6 years ago

Rimjhim28 commented 6 years ago

Description

The avatar does not reset to default one with default options (hair, eyes, clothes) in avatar room. This eventually leads to app crash if the device's screen is turned off. There are errors in writing in database that needs to be handled properly.

Mocks

videotogif_2018 02 14_12 50 53

Acceptance Criteria

Update

Definition of Done

Estimation

2 hours

I would like to work on the issue

geekanamika commented 6 years ago

@Rimjhim28 Isn't this the wanted behaviour ? We're using saved data to create default avatar in code. I took it as a implementation of code to use user's favourite avatar look.

Rimjhim28 commented 6 years ago

@geekanamika This is not the expected implementation. The avatar items should set to default values after each click on "NEW GAME" If we look into older version of app there was code snippet to do so in Avatar Activity onCreate():

eye=1;
skin=1;
hair=1;
cloth=1;

With the integration of FInal Avatar Screen during GCI a preference manager was implemented by the participant to check if the Avatar was previously customized to set the user's selected options otherwise to set to default values.

if (!hasPreviouslyCustomized) {
            SharedPreferences.Editor edit = prefs.edit();
            edit.putBoolean(getString(R.string.preferences_has_previously_customized), Boolean.TRUE);
            edit.apply();
            eye=1;
            skin=1;
            hair=1;
            cloth=1;
        } else {
            eye=getmDbHandler().getAvatarEye();
            skin=getmDbHandler().getAvatarSkin();
            hair=getmDbHandler().getAvatarHair();
            cloth=getmDbHandler().getAvatarCloth();
            //Other to set the items on Avatar
        }

The problem here is the if-else block never goes to settin to default values because PreferenceManager isn't working as expected. I intend to replace this PreferenceManager with a static variable in SessionHistory.java to check for previous customization.

Rimjhim28 commented 6 years ago

@m-murad @saurabhjn76 please approve the issue.

m-murad commented 6 years ago

please share the logs of the crash.

Rimjhim28 commented 6 years ago

crash

@m-murad Here's the crash log. This basically happens when the screen is switched of. Though I am not very sure if this happens beacause of this issue but it was not present before. May be a diffrerent issue can be created to handle the game when the screen goes off.

Rimjhim28 commented 6 years ago

@m-murad Can I proceed with this issue. Should I create another one for crash?

m-murad commented 6 years ago

@Rimjhim28 You can send a PR for this

Rimjhim28 commented 6 years ago

ThankYou @m-murad!! Will be sending a PR soon.