Java Code Examples for org.eyeseetea.malariacare.LoginActivity

The following are top voted examples for showing how to use org.eyeseetea.malariacare.LoginActivity. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: EDSApp   File: AssessCompulsoryIncompleteTest.java   Source Code and License 6 votes vote down vote up
@Test
public void assessCompulsoryIncomplete() {
    //GIVEN
    if(LoginActivity.class.equals(SDKTestUtils.getActivityInstance().getClass())) {
        login(HNQIS_DEV_CI, TEST_USERNAME_WITH_PERMISSION, TEST_PASSWORD_WITH_PERMISSION);
        waitForPull(DEFAULT_WAIT_FOR_PULL);
    }
    startSurvey(SDKTestUtils.TEST_FACILITY_1_IDX, SDKTestUtils.TEST_IMCI);
    fillSurvey(12, "Yes");

    //WHEN
    Long idSurvey = SDKTestUtils.markAsCompleteCompulsory();
    Log.d(TAG, "Session user ->" + Session.getUser());
    Survey survey = Survey.findById(idSurvey);

    //THEN
    onView(withText(R.string.accept)).perform(click());
    assertTrue(survey.isInProgress());
}
 
Example 2
Project: malariapp   File: AssessCompulsoryIncompleteTest.java   Source Code and License 6 votes vote down vote up
@Test
public void assessCompulsoryIncomplete() {
    //GIVEN
    if(LoginActivity.class.equals(SDKTestUtils.getActivityInstance().getClass())) {
        login(HNQIS_DEV_CI, TEST_USERNAME_WITH_PERMISSION, TEST_PASSWORD_WITH_PERMISSION);
        waitForPull(DEFAULT_WAIT_FOR_PULL);
    }
    startSurvey(SDKTestUtils.TEST_FACILITY_1_IDX, SDKTestUtils.TEST_IMCI);
    fillSurvey(12, "Yes");

    //WHEN
    Long idSurvey = SDKTestUtils.markAsCompleteCompulsory();
    Log.d(TAG, "Session user ->" + Session.getUser());
    Survey survey = Survey.findById(idSurvey);

    //THEN
    onView(withText(R.string.accept)).perform(click());
    assertTrue(survey.isInProgress());
}
 
Example 3
Project: pictureapp   File: LogoutAndLoginRequiredOnPreferenceClickListener.java   Source Code and License 6 votes vote down vote up
private void logout() {
    Log.d(TAG, "Logging out...");
    AuthenticationManager authenticationManager = new AuthenticationManager(settingsActivity);
    LogoutUseCase logoutUseCase = new LogoutUseCase(authenticationManager);

    logoutUseCase.execute(new LogoutUseCase.Callback() {
        @Override
        public void onLogoutSuccess() {
            Intent loginIntent = new Intent(settingsActivity, LoginActivity.class);
            settingsActivity.finish();
            settingsActivity.startActivity(loginIntent);
        }

        @Override
        public void onLogoutError(String message) {
            Log.e(TAG, message);
        }
    });
}
 
Example 4
Project: pictureapp   File: LoginRequiredOnPreferenceClickListener.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    if (!settingsActivity.getIntent().getBooleanExtra(SettingsActivity.IS_LOGIN_DONE, false)
            || preference.getKey().equals(PreferencesState.getInstance().getContext().getString(R.string.dhis_url))) {
        //if is not logged the pull of data is required.
        PreferencesState.getInstance().setMetaDataDownload(true);
        //only in laos y cambodiates
        PreferencesState.getInstance().setPullDataAfterMetadata(true);

        Intent loginIntent = new Intent(settingsActivity, LoginActivity.class);
        loginIntent.putExtra(LoginActivity.PULL_REQUIRED, true);


        settingsActivity.startActivity(loginIntent);
    }
    return true;
}
 
Example 5
Project: pictureapp   File: PushServiceStrategy.java   Source Code and License 6 votes vote down vote up
public void logout() {
    IAuthenticationManager authenticationManager;
    LogoutUseCase logoutUseCase;
    authenticationManager = new AuthenticationManager(mPushService);
    logoutUseCase = new LogoutUseCase(authenticationManager);
    AlarmPushReceiver.cancelPushAlarm(mPushService);
    logoutUseCase.execute(new LogoutUseCase.Callback() {
        @Override
        public void onLogoutSuccess() {
            if (!EyeSeeTeaApplication.getInstance().isAppWentToBg()) {
                Intent loginIntent = new Intent(mPushService, LoginActivity.class);
                loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mPushService.startActivity(loginIntent);
            }
        }

        @Override
        public void onLogoutError(String message) {
            Log.d(TAG, message);
        }
    });
}
 
Example 6
Project: pictureapp   File: LogoutAndLoginRequiredOnPreferenceClickListener.java   Source Code and License 6 votes vote down vote up
private void logout() {
    Log.d(TAG, "Logging out...");
    AuthenticationManager authenticationManager = new AuthenticationManager(settingsActivity);
    LogoutUseCase logoutUseCase = new LogoutUseCase(authenticationManager);
    AlarmPushReceiver.cancelPushAlarm(settingsActivity);
    logoutUseCase.execute(new LogoutUseCase.Callback() {
        @Override
        public void onLogoutSuccess() {
            Intent loginIntent = new Intent(settingsActivity, LoginActivity.class);
            settingsActivity.finish();
            settingsActivity.startActivity(loginIntent);
        }

        @Override
        public void onLogoutError(String message) {
            Log.e(TAG, message);
        }
    });
}
 
Example 7
Project: EDSApp   File: AssessCompulsoryTest.java   Source Code and License 5 votes vote down vote up
@Test
public void assessCompulsoryComplete() {
    //GIVEN
    if(LoginActivity.class.equals(SDKTestUtils.getActivityInstance().getClass())) {
        login(HNQIS_DEV_CI, TEST_USERNAME_WITH_PERMISSION, TEST_PASSWORD_WITH_PERMISSION);
        waitForPull(DEFAULT_WAIT_FOR_PULL);
    }
    startSurvey(SDKTestUtils.TEST_FACILITY_1_IDX, SDKTestUtils.TEST_IMCI);
    fillCompulsorySurvey(13, "Yes");

    //WHEN
    Espresso.pressBack();
    //select continue later and go to assess
    onView(withText(R.string.dialog_continue_later_option)).perform(click());

    //THEN
    onView(withText(R.string.dashboard_info_ready_to_upload)).check(matches(isDisplayed()));


    //WHEN
    Long idSurvey = SDKTestUtils.editSurvey();
    IdlingResource idlingResource = new ElapsedTimeIdlingResource(5 * 1000);
    Espresso.registerIdlingResources(idlingResource);
    Espresso.pressBack();
    Espresso.unregisterIdlingResources(idlingResource);
    //select complete survey on exit
    onView(withText(R.string.dialog_complete_option)).perform(click());
    //confirm(are you sure?)
    onView(withText(android.R.string.yes)).perform(click());
    //info dialog
    onView(withText(android.R.string.ok)).perform(click());

    //THEN
    //then: Survey is pushed (UID)
    Log.d(TAG, "Session user ->" + Session.getUser());
    Survey survey = waitForPush(SDKTestUtils.DEFAULT_WAIT_FOR_PUSH, idSurvey);
    assertTrue(survey.isCompleted() || survey.isSent());
}
 
Example 8
Project: EDSApp   File: PullErrorTest.java   Source Code and License 5 votes vote down vote up
@Test
public void pullWithOutPermissionDoesNotPull() {

    //GIVEN
    login(HNQIS_DEV_CI, TEST_USERNAME_NO_PERMISSION, TEST_PASSWORD_NO_PERMISSION);
    //WHEN
    waitForPull(DEFAULT_WAIT_FOR_PULL);
    //THEN
    assertEquals(LoginActivity.class, SDKTestUtils.getActivityInstance().getClass());
}
 
Example 9
Project: EDSApp   File: PullCancelTest.java   Source Code and License 5 votes vote down vote up
@Test
public void pullCancelledReturnsLogin() {

    //GIVEN
    login(HNQIS_DEV_CI, TEST_USERNAME_WITH_PERMISSION, TEST_PASSWORD_WITH_PERMISSION);

    //WHEN
    onView(withText(android.R.string.cancel)).perform(click());

    //THEN
    assertEquals(LoginActivity.class,SDKTestUtils.getActivityInstance().getClass());
}
 
Example 10
Project: malariapp   File: AssessCompulsoryTest.java   Source Code and License 5 votes vote down vote up
@Test
public void assessCompulsoryComplete() {
    //GIVEN
    if(LoginActivity.class.equals(SDKTestUtils.getActivityInstance().getClass())) {
        login(HNQIS_DEV_CI, TEST_USERNAME_WITH_PERMISSION, TEST_PASSWORD_WITH_PERMISSION);
        waitForPull(DEFAULT_WAIT_FOR_PULL);
    }
    startSurvey(SDKTestUtils.TEST_FACILITY_1_IDX, SDKTestUtils.TEST_IMCI);
    fillCompulsorySurvey(13, "Yes");

    //WHEN
    Espresso.pressBack();
    //select continue later and go to assess
    onView(withText(R.string.dialog_continue_later_option)).perform(click());

    //THEN
    onView(withText(R.string.dashboard_info_ready_to_upload)).check(matches(isDisplayed()));


    //WHEN
    Long idSurvey = SDKTestUtils.editSurvey();
    IdlingResource idlingResource = new ElapsedTimeIdlingResource(5 * 1000);
    Espresso.registerIdlingResources(idlingResource);
    Espresso.pressBack();
    Espresso.unregisterIdlingResources(idlingResource);
    //select complete survey on exit
    onView(withText(R.string.dialog_complete_option)).perform(click());
    //confirm(are you sure?)
    onView(withText(android.R.string.yes)).perform(click());
    //info dialog
    onView(withText(android.R.string.ok)).perform(click());

    //THEN
    //then: Survey is pushed (UID)
    Log.d(TAG, "Session user ->" + Session.getUser());
    Survey survey = waitForPush(SDKTestUtils.DEFAULT_WAIT_FOR_PUSH, idSurvey);
    assertTrue(survey.isCompleted() || survey.isSent());
}
 
Example 11
Project: malariapp   File: PullErrorTest.java   Source Code and License 5 votes vote down vote up
@Test
public void pullWithOutPermissionDoesNotPull() {

    //GIVEN
    login(HNQIS_DEV_CI, TEST_USERNAME_NO_PERMISSION, TEST_PASSWORD_NO_PERMISSION);
    //WHEN
    waitForPull(DEFAULT_WAIT_FOR_PULL);
    //THEN
    assertEquals(LoginActivity.class, SDKTestUtils.getActivityInstance().getClass());
}
 
Example 12
Project: malariapp   File: PullCancelTest.java   Source Code and License 5 votes vote down vote up
@Test
public void pullCancelledReturnsLogin() {

    //GIVEN
    login(HNQIS_DEV_CI, TEST_USERNAME_WITH_PERMISSION, TEST_PASSWORD_WITH_PERMISSION);

    //WHEN
    onView(withText(android.R.string.cancel)).perform(click());

    //THEN
    assertEquals(LoginActivity.class,SDKTestUtils.getActivityInstance().getClass());
}
 
Example 13
Project: pictureapp   File: BaseActivityStrategy.java   Source Code and License 5 votes vote down vote up
public void logout() {
    mLogoutUseCase.execute(new LogoutUseCase.Callback() {
        @Override
        public void onLogoutSuccess() {
            mBaseActivity.finishAndGo(LoginActivity.class);
        }

        @Override
        public void onLogoutError(String message) {
            Log.d(TAG, message);
        }
    });
}
 
Example 14
Project: pictureapp   File: LoginActivityStrategy.java   Source Code and License 5 votes vote down vote up
@Override
public void finishAndGo() {
    loginActivity.onFinishLoading(null);
    if (loginActivity.getIntent().getBooleanExtra(LoginActivity.PULL_REQUIRED, false)) {
        loginActivity.startActivity(new Intent(loginActivity, ProgressActivity.class));
    } else {
        Intent intent = new Intent(loginActivity, SettingsActivity.class);

        intent.putExtra(SettingsActivity.IS_LOGIN_DONE, true);

        loginActivity.startActivity(intent);
    }

    loginActivity.finish();
}
 
Example 15
Project: pictureapp   File: LoginActivityStrategy.java   Source Code and License 5 votes vote down vote up
public LoginActivityStrategy(LoginActivity loginActivity) {
    super(loginActivity);
    IPullController pullController = new PullController(loginActivity);
    IAsyncExecutor asyncExecutor = new AsyncExecutor();
    IMainExecutor mainExecutor = new UIThreadExecutor();

    mPullUseCase = new PullUseCase(pullController, asyncExecutor, mainExecutor);
}
 
Example 16
Project: pictureapp   File: LoginActivityStrategy.java   Source Code and License 5 votes vote down vote up
@Override
public void finishAndGo() {
    loginActivity.onFinishLoading(null);
    if (loginActivity.getIntent().getBooleanExtra(LoginActivity.PULL_REQUIRED, false)) {
        loginActivity.startActivity(new Intent(loginActivity, ProgressActivity.class));
    } else {
        Intent intent = new Intent(loginActivity, SettingsActivity.class);

        intent.putExtra(SettingsActivity.IS_LOGIN_DONE, true);

        loginActivity.startActivity(intent);
    }

    loginActivity.finish();
}
 
Example 17
Project: malariapp   File: LoginActivityStrategy.java   Source Code and License 4 votes vote down vote up
public LoginActivityStrategy(LoginActivity loginActivity) {
    this.loginActivity = loginActivity;
}
 
Example 18
Project: pictureapp   File: SplashActivityStrategy.java   Source Code and License 4 votes vote down vote up
@Override
public void finishAndGo() {
    super.finishAndGo(LoginActivity.class);
}
 
Example 19
Project: pictureapp   File: DashboardActivityStrategy.java   Source Code and License 4 votes vote down vote up
public static void onLogoutSuccess() {
    DashboardActivity.dashboardActivity.finishAndGo(LoginActivity.class);
}
 
Example 20
Project: pictureapp   File: LoginActivityStrategy.java   Source Code and License 4 votes vote down vote up
public LoginActivityStrategy(LoginActivity loginActivity) {
    super(loginActivity);
}
 
Example 21
Project: pictureapp   File: ALoginActivityStrategy.java   Source Code and License 4 votes vote down vote up
public ALoginActivityStrategy(LoginActivity loginActivity) {
    this.loginActivity = loginActivity;
}
 
Example 22
Project: pictureapp   File: LoginActivityStrategy.java   Source Code and License 4 votes vote down vote up
public LoginActivityStrategy(LoginActivity loginActivity) {
    super(loginActivity);
}
 
Example 23
Project: pictureapp   File: SplashActivityStrategy.java   Source Code and License 4 votes vote down vote up
@Override
public void finishAndGo() {
    super.finishAndGo(LoginActivity.class);
}
 
Example 24
Project: pictureapp   File: DashboardActivityStrategy.java   Source Code and License 4 votes vote down vote up
public static void onLogoutSuccess() {
    DashboardActivity.dashboardActivity.finishAndGo(LoginActivity.class);
}
 
Example 25
Project: pictureapp   File: BaseActivityStrategy.java   Source Code and License 4 votes vote down vote up
private void showLogin() {
    Intent loginIntent = new Intent(mBaseActivity, LoginActivity.class);
    loginIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    mBaseActivity.startActivity(loginIntent);
}
 
Example 26
Project: pictureapp   File: SettingsActivityStrategy.java   Source Code and License 4 votes vote down vote up
private void showLogin() {
    Intent loginIntent = new Intent(settingsActivity, LoginActivity.class);
    loginIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    settingsActivity.startActivity(loginIntent);
}
 
Example 27
Project: pictureapp   File: LoginActivityStrategy.java   Source Code and License 4 votes vote down vote up
public LoginActivityStrategy(LoginActivity loginActivity) {
    super(loginActivity);
}