/**
   * Called after @FXML annotated fields are injected and so is used to update the view with the
   * data built in the constructor.
   *
   * <p>Retrieves history and achievement information from the account to build the charts and set
   * the text for attribute and username labels.
   *
   * <p>First displays the user's workout activity in the last seven days but the user is allowed to
   * switch between last 30 days/ last 7 days charts
   */
  @FXML
  private void initialize() {

    // build the series from the workout history information
    workoutHistoryLog = HistoryAnalyser.getDailyWorkoutHistoryFromCurrentAccount();
    makeWeekSeriesFromAccountHistory();
    makeMonthSeriesFromAccountHistory();

    // ----------------------------------------------------------//
    // Character attributes and avatar
    // Get the authenticated and up to date account and get its attributes
    Account account = Main.account;
    attributes = account.getCharacterAttributes();

    // ----------------------------------------------------------//
    // Progress charts

    // immediately remove the line chart that displays the last 30 days of workout activity from
    // view
    monthLineChart.setVisible(false);

    // add the series to their charts
    weekBarChart.getData().add(seriesW);
    monthLineChart.getData().add(seriesM);

    // manage the toggling feature between month and weekRadios
    radioGroup = new ToggleGroup();
    monthRadio.setToggleGroup(radioGroup);
    weekRadio.setToggleGroup(radioGroup);
    // Initially set week radio to selected
    weekRadio.setSelected(true);

    showAccountAttributes();

    showAvatarInStackPane();

    showAchievementsInListView();
  }
示例#2
0
  /**
   * Generates X-GOOGLE-TOKEN response by communication with http://www.google.com (algorithm from
   * MGTalk/NetworkThread.java)
   *
   * @param userName
   * @param passwd
   * @return
   */
  public String responseXGoogleToken() {
    try {
      String firstUrl =
          "https://www.google.com:443/accounts/ClientAuth?Email="
              + Strconv.unicodeToUTF(account.getUserName())
              + "%40"
              + account.getServer()
              + "&Passwd="
              + Strconv.unicodeToUTF(account.getPassword())
              + "&PersistentCookie=false&source=bombusqd";

      // log.addMessage("Connecting to www.google.com");
      // #if Android
      // #            URL url = new URL(firstUrl);
      // #            HttpsURLConnection c = (HttpsURLConnection) url.openConnection();
      // #            InputStream is = c.getInputStream();
      // #else
      HttpsConnection c = (HttpsConnection) Connector.open(firstUrl);
      InputStream is = c.openInputStream();
      // #endif

      String sid = readLine(is);
      if (!sid.startsWith("SID=")) {
        throw new SecurityException(SR.get(SR.MS_LOGIN_FAILED));
      }

      String lsid = readLine(is);

      String secondUrl =
          "https://www.google.com:443/accounts/IssueAuthToken?"
              + sid
              + "&"
              + lsid
              + "&service=mail&Session=true";
      is.close();
      // #if Android
      // #            url = new URL(secondUrl);
      // #            c = (HttpsURLConnection) url.openConnection();
      // #            is = c.getInputStream();
      // #else
      c.close();
      c = null;
      c = (HttpsConnection) Connector.open(secondUrl);
      is = c.openInputStream();
      // #endif
      String token = "\0" + Strconv.unicodeToUTF(account.getUserName()) + "\0" + readLine(is);
      is.close();
      // #if !Android
      c.close();
      // #endif
      return Strconv.toBase64(token);

    } catch (javax.microedition.pki.CertificateException e) {
      throw new SecurityException(e.getMessage());
    } catch (SecurityException e) {
      throw e;
    } catch (Exception e) {
      // #ifdef DEBUG
      // #             e.printStackTrace();
      // #endif
      // listener.loginFailed("Google token error");
    }
    return null;
  }