Example #1
0
  /**
   * Check if the user has been logged in when he retrieved the data.
   *
   * @param page
   * @return <code>true</code> if user is logged in, <code>false</code> otherwise
   */
  public static boolean getLoginStatus(final String page) {
    if (StringUtils.isBlank(page)) {
      Log.e("Login.checkLogin: No page given");
      return false;
    }

    setActualStatus(cgeoapplication.getInstance().getString(R.string.init_login_popup_ok));

    // on every page except login page
    setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME));
    if (isActualLoginStatus()) {
      setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???"));
      setActualCachesFound(
          Integer.parseInt(
              BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0")
                  .replaceAll("[,.]", "")));
      Settings.setMemberStatus(
          BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, null));
      if (page.contains(GCConstants.MEMBER_STATUS_RENEW)) {
        Settings.setMemberStatus(GCConstants.MEMBER_STATUS_PM);
      }
      return true;
    }

    // login page
    setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME_LOGIN_PAGE));
    if (isActualLoginStatus()) {
      setActualUserName(Settings.getUsername());
      // number of caches found is not part of this page
      return true;
    }

    setActualStatus(cgeoapplication.getInstance().getString(R.string.init_login_popup_failed));
    return false;
  }
Example #2
0
 /*
  * (non-Javadoc)
  *
  * @see cgeo.geocaching.test.mock.MockedCache#isOwn()
  */
 @Override
 public boolean isOwn() {
   if ("Tom03".equals(Settings.getUsername())) {
     return true;
   }
   return super.isOwn();
 }