Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added shared preferences to tell whether the user has seen intro slides #18

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ public interface SignInPresenter extends BasePresenter<SignInPresenter.View>,
interface View extends BaseView {
void startGoogleSignIn(GoogleApiClient googleApiClient);
void displaySignInError();
boolean hasSeenIntroSlides();
void goToUserTypeActivity();
void goToIntroSlides();
//TODO: remove
void showRetrievedData(String string);
}

void signIn();
void onSignInResult(GoogleSignInResult result);
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,37 +181,20 @@ public void onComplete(@NonNull Task<AuthResult> task) {
//Log.w(TAG, "signInWithCredential", task.getException());
mView.displaySignInError();
} else {
// retrieveAppInfoWithInteractor();
mView.goToIntroSlides();
goToNextActivity();
}
}
});
}

// private void retrieveAppInfoWithInteractor() {
// FirebaseDatabaseWrapper wrapper = new FirebaseDatabaseWrapper();
// GetFirebaseInfoInteractorImpl getFirebaseInfoInteractor =
// new GetFirebaseInfoInteractorImpl(mExecutor,
// mMainThread,
// this,
// wrapper.getInstance());
// getFirebaseInfoInteractor.execute();
// }

// @Override
// public void onDataReceived(PopulateInfos populateInfos) {
// String driverOne = populateInfos.getCareInfo().getCare(0).getCareTitle();
//
// // Stop loading and switch activities
// // Pass data to mainActivity for recyclerView propagation
//
// mView.showRetrievedData(driverOne);
// }

// @Override
// public void onDataReceiveFailed() {
// // Display some kind of error
// }
private void goToNextActivity() {
if(mView.hasSeenIntroSlides()) {
mView.goToUserTypeActivity();
} else {
mView.goToIntroSlides();
}
}

@Override
public void resume() {
SignInInteractorImpl interactor = new SignInInteractorImpl(mExecutor, mMainThread, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -41,7 +42,8 @@

public class SignInActivity extends AppCompatActivity implements SignInPresenter.View, View.OnClickListener {


private SharedPreferences mPreferences;
private static final String INTRO_SLIDES_PREF = "hasSeenIntroSlides";
private static final String TAG = "SignInActivity";
private static final int RC_SIGN_IN = 9001;
private SignInPresenter mPresenter;
Expand All @@ -54,8 +56,8 @@ protected void onCreate(Bundle savedInstanceState) {
mDefaultWebClientId = getString(R.string.default_web_client_id);
attachPresenter();
setupUi();

}

public void attachPresenter() {
mPresenter = (SignInPresenterImpl) getLastCustomNonConfigurationInstance();
if (mPresenter == null) {
Expand Down Expand Up @@ -161,10 +163,25 @@ public void hideProgressDialog() {
findViewById(R.id.progressBar).setVisibility(View.GONE);
}

@Override
public boolean hasSeenIntroSlides() {
mPreferences = getPreferences(MODE_PRIVATE);
return mPreferences.getBoolean(INTRO_SLIDES_PREF, false);
}

@Override
public void goToUserTypeActivity() {
startActivity(new Intent(this, UserTypeActivity.class));
finish();
}

@Override
public void goToIntroSlides() {
// Set hasSeenIntroSlides to true and go to slides
SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(INTRO_SLIDES_PREF, true);
editor.commit();
startActivity(new Intent(this, IntroSlidesGeneric.class));
//TODO create shared preferences for skipping intros if seen
finish();
}

Expand Down