public DataSchemaFieldDefinition(
      final String name,
      final DataAttributes attributes,
      final DataAttributeContext dataAttributeContext) {
    if (attributes == null) {
      throw new NullPointerException();
    }

    if (name == null) {
      throw new NullPointerException();
    }
    if (dataAttributeContext == null) {
      throw new NullPointerException();
    }
    this.name = name;
    this.type =
        (Class)
            attributes.getMetaAttribute(
                MetaAttributeNames.Core.NAMESPACE,
                MetaAttributeNames.Core.TYPE,
                Class.class,
                dataAttributeContext);
    this.displayName =
        (String)
            attributes.getMetaAttribute(
                MetaAttributeNames.Formatting.NAMESPACE,
                MetaAttributeNames.Formatting.LABEL,
                String.class,
                dataAttributeContext);

    final Object source =
        attributes.getMetaAttribute(
            MetaAttributeNames.Core.NAMESPACE,
            MetaAttributeNames.Core.SOURCE,
            String.class,
            dataAttributeContext);
    if (MetaAttributeNames.Core.SOURCE_VALUE_ENVIRONMENT.equals(source)) {
      icon = (IconLoader.getInstance().getPropertiesDataSetIcon());
    } else if (MetaAttributeNames.Core.SOURCE_VALUE_EXPRESSION.equals(source)) {
      icon = (IconLoader.getInstance().getFunctionIcon());
    } else if (MetaAttributeNames.Core.SOURCE_VALUE_PARAMETER.equals(source)) {
      icon = (IconLoader.getInstance().getParameterIcon());
    } else if (MetaAttributeNames.Core.SOURCE_VALUE_TABLE.equals(source)) {
      icon = (IconLoader.getInstance().getDataSetsIcon());
    } else {
      icon = (IconLoader.getInstance().getGenericSquare());
    }
  }
  /**
   * Processes LAUNCH_BROWSER proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processLaunchBrowser(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process LaunchBrowser");

    TextMessage confirmMsg = new TextMessage();
    IconId iconId = null;
    String url = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.URL, ctlvs);
    if (ctlv != null) {
      try {
        byte[] rawValue = ctlv.getRawValue();
        int valueIndex = ctlv.getValueIndex();
        int valueLen = ctlv.getLength();
        if (valueLen > 0) {
          url = GsmAlphabet.gsm8BitUnpackedToString(rawValue, valueIndex, valueLen);
        } else {
          url = null;
        }
      } catch (IndexOutOfBoundsException e) {
        throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
      }
    }

    // parse alpha identifier.
    ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs);
    confirmMsg.text = ValueParser.retrieveAlphaId(ctlv);

    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
      confirmMsg.iconSelfExplanatory = iconId.selfExplanatory;
    }

    // parse command qualifier value.
    LaunchBrowserMode mode;
    switch (cmdDet.commandQualifier) {
      case 0x00:
      default:
        mode = LaunchBrowserMode.LAUNCH_IF_NOT_ALREADY_LAUNCHED;
        break;
      case 0x02:
        mode = LaunchBrowserMode.USE_EXISTING_BROWSER;
        break;
      case 0x03:
        mode = LaunchBrowserMode.LAUNCH_NEW_BROWSER;
        break;
    }

    mCmdParams = new LaunchBrowserParams(cmdDet, confirmMsg, url, mode);

    if (iconId != null) {
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  /**
   * Processes EVENT_NOTIFY message from baseband.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   */
  private boolean processEventNotify(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process EventNotify");

    TextMessage textMsg = new TextMessage();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs);
    textMsg.text = ValueParser.retrieveAlphaId(ctlv);

    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
      textMsg.iconSelfExplanatory = iconId.selfExplanatory;
    }

    textMsg.responseNeeded = false;
    mCmdParams = new DisplayTextParams(cmdDet, textMsg);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  /**
   * Processes PLAY_TONE proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.t
   * @throws ResultException
   */
  private boolean processPlayTone(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process PlayTone");

    Tone tone = null;
    TextMessage textMsg = new TextMessage();
    Duration duration = null;
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TONE, ctlvs);
    if (ctlv != null) {
      // Nothing to do for null objects.
      if (ctlv.getLength() > 0) {
        try {
          byte[] rawValue = ctlv.getRawValue();
          int valueIndex = ctlv.getValueIndex();
          int toneVal = rawValue[valueIndex];
          tone = Tone.fromInt(toneVal);
        } catch (IndexOutOfBoundsException e) {
          throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
        }
      }
    }
    // parse alpha identifier
    ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs);
    if (ctlv != null) {
      textMsg.text = ValueParser.retrieveAlphaId(ctlv);
    }
    // parse tone duration
    ctlv = searchForTag(ComprehensionTlvTag.DURATION, ctlvs);
    if (ctlv != null) {
      duration = ValueParser.retrieveDuration(ctlv);
    }
    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
      textMsg.iconSelfExplanatory = iconId.selfExplanatory;
    }

    boolean vibrate = (cmdDet.commandQualifier & 0x01) != 0x00;

    textMsg.responseNeeded = false;
    mCmdParams = new PlayToneParams(cmdDet, textMsg, tone, duration, vibrate);

    if (iconId != null) {
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
Пример #5
0
 private MacroDescriptor create(
     final MacroKey macroKey,
     final String displayName,
     final String description,
     final Form form) {
   return MacroDescriptor.create()
       .key(macroKey)
       .displayName(displayName)
       .description(description)
       .form(form)
       .icon(IconLoader.loadIcon(this.getClass(), MACRO_DESCRIPTORS_FOLDER, macroKey.getName()))
       .build();
 }
  /**
   * Processes SETUP_CALL proactive command from the SIM card.
   *
   * @param cmdDet Command Details object retrieved from the proactive command object
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   */
  private boolean processSetupCall(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {
    CatLog.d(this, "process SetupCall");

    Iterator<ComprehensionTlv> iter = ctlvs.iterator();
    ComprehensionTlv ctlv = null;
    // User confirmation phase message.
    TextMessage confirmMsg = new TextMessage();
    // Call set up phase message.
    TextMessage callMsg = new TextMessage();
    IconId confirmIconId = null;
    IconId callIconId = null;

    // get confirmation message string.
    ctlv = searchForNextTag(ComprehensionTlvTag.ALPHA_ID, iter);
    confirmMsg.text = ValueParser.retrieveAlphaId(ctlv);

    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      confirmIconId = ValueParser.retrieveIconId(ctlv);
      confirmMsg.iconSelfExplanatory = confirmIconId.selfExplanatory;
    }

    // get call set up message string.
    ctlv = searchForNextTag(ComprehensionTlvTag.ALPHA_ID, iter);
    if (ctlv != null) {
      callMsg.text = ValueParser.retrieveAlphaId(ctlv);
    }

    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      callIconId = ValueParser.retrieveIconId(ctlv);
      callMsg.iconSelfExplanatory = callIconId.selfExplanatory;
    }

    mCmdParams = new CallSetupParams(cmdDet, confirmMsg, callMsg);

    if (confirmIconId != null || callIconId != null) {
      mIconLoadState = LOAD_MULTI_ICONS;
      int[] recordNumbers = new int[2];
      recordNumbers[0] = confirmIconId != null ? confirmIconId.recordNumber : -1;
      recordNumbers[1] = callIconId != null ? callIconId.recordNumber : -1;

      mIconLoader.loadIcons(recordNumbers, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  /**
   * Processes DISPLAY_TEXT proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processDisplayText(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process DisplayText");

    TextMessage textMsg = new TextMessage();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TEXT_STRING, ctlvs);
    if (ctlv != null) {
      textMsg.text = ValueParser.retrieveTextString(ctlv);
    }
    // If the tlv object doesn't exist or the it is a null object reply
    // with command not understood.
    if (textMsg.text == null) {
      throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
    }

    ctlv = searchForTag(ComprehensionTlvTag.IMMEDIATE_RESPONSE, ctlvs);
    if (ctlv != null) {
      textMsg.responseNeeded = false;
    }
    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
      textMsg.iconSelfExplanatory = iconId.selfExplanatory;
    }
    // parse tone duration
    ctlv = searchForTag(ComprehensionTlvTag.DURATION, ctlvs);
    if (ctlv != null) {
      textMsg.duration = ValueParser.retrieveDuration(ctlv);
    }

    // Parse command qualifier parameters.
    textMsg.isHighPriority = (cmdDet.commandQualifier & 0x01) != 0;
    textMsg.userClear = (cmdDet.commandQualifier & 0x80) != 0;

    mCmdParams = new DisplayTextParams(cmdDet, textMsg);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  /**
   * Processes GET_INKEY proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processGetInkey(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process GetInkey");

    Input input = new Input();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TEXT_STRING, ctlvs);
    if (ctlv != null) {
      input.text = ValueParser.retrieveTextString(ctlv);
    } else {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }
    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
    }

    // parse duration
    ctlv = searchForTag(ComprehensionTlvTag.DURATION, ctlvs);
    if (ctlv != null) {
      input.duration = ValueParser.retrieveDuration(ctlv);
    }

    input.minLen = 1;
    input.maxLen = 1;

    input.digitOnly = (cmdDet.commandQualifier & 0x01) == 0;
    input.ucs2 = (cmdDet.commandQualifier & 0x02) != 0;
    input.yesNo = (cmdDet.commandQualifier & 0x04) != 0;
    input.helpAvailable = (cmdDet.commandQualifier & 0x80) != 0;
    input.echo = true;

    mCmdParams = new GetInputParams(cmdDet, input);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  /**
   * Processes SET_UP_IDLE_MODE_TEXT proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processSetUpIdleModeText(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process SetUpIdleModeText");

    TextMessage textMsg = new TextMessage();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TEXT_STRING, ctlvs);
    if (ctlv != null) {
      textMsg.text = ValueParser.retrieveTextString(ctlv);
    }

    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
      textMsg.iconSelfExplanatory = iconId.selfExplanatory;
    }

    /*
     * If the tlv object doesn't contain text and the icon is not self
     * explanatory then reply with command not understood.
     */

    if (textMsg.text == null && iconId != null && !textMsg.iconSelfExplanatory) {
      throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
    }

    mCmdParams = new DisplayTextParams(cmdDet, textMsg);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  private boolean processBIPClient(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {
    AppInterface.CommandType commandType = AppInterface.CommandType.fromInt(cmdDet.typeOfCommand);
    if (commandType != null) {
      CatLog.d(this, "process " + commandType.name());
    }

    TextMessage textMsg = new TextMessage();
    IconId iconId = null;
    ComprehensionTlv ctlv = null;
    boolean has_alpha_id = false;

    // parse alpha identifier
    ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs);
    if (ctlv != null) {
      textMsg.text = ValueParser.retrieveAlphaId(ctlv);
      CatLog.d(this, "alpha TLV text=" + textMsg.text);
      has_alpha_id = true;
    }

    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
      textMsg.iconSelfExplanatory = iconId.selfExplanatory;
    }

    textMsg.responseNeeded = false;
    mCmdParams = new BIPClientParams(cmdDet, textMsg, has_alpha_id);

    if (iconId != null) {
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
Пример #11
0
  public View() {
    // Create the the components
    mainPanel = new JPanel(new MigLayout());
    beginDate = new JLabel("Begin date:");
    endDate = new JLabel("End date:");
    calBegin = new JDateChooser();
    calEnd = new JDateChooser();
    mainMenu = new JMenuBar();
    file = new JMenu("File");
    save = new JMenuItem("Save");
    load = new JMenuItem("Load");
    weekly = new JRadioButton("Weekly");
    fortnightly = new JRadioButton("Fortnightly");
    monthly = new JRadioButton("Monthly");
    yearly = new JRadioButton("Yearly");
    timeFrame = new ButtonGroup();
    startAmount = new JLabel("Starting amount:");
    goal = new JLabel("Goal amount:");
    payPeriod = new JLabel("Payment period:");
    tfStartAmount = new JTextField();
    tfGoal = new JTextField();
    amountUpdate = new JTable();
    amountToSave = new JLabel("Amount to save each pay day in order to reach your target is: ");
    tfAmountToSave = new JTextField();
    apply = new JButton("Apply");

    // Add the radio buttons to the group
    timeFrame.add(weekly);
    timeFrame.add(fortnightly);
    timeFrame.add(monthly);
    timeFrame.add(yearly);

    // Chart demo
    CategoryDataset dataset = LineGraph.createSampleDataset();
    JFreeChart chart = LineGraph.createChart(dataset);
    chartPanel = new ChartPanel(chart);

    // Set the main layout
    setLayout(new MigLayout());

    // Create a menu bar
    setJMenuBar(mainMenu);
    mainMenu.add(file);
    file.add(save);
    file.add(load);

    // Set up table with scrollPane
    JScrollPane amountTable = new JScrollPane(amountUpdate);

    // Add all the stuff to the main panel
    mainPanel.add(beginDate, "split 2");
    mainPanel.add(calBegin, "align left, wrap");
    mainPanel.add(endDate, "split 2");
    mainPanel.add(calEnd, "align left, Wrap");
    mainPanel.add(startAmount, "split 2");
    mainPanel.add(tfStartAmount, "grow, wrap");
    mainPanel.add(goal, "align right, split");
    mainPanel.add(tfGoal, "grow, wrap");
    mainPanel.add(payPeriod);
    mainPanel.add(weekly, "cell 0 4");
    mainPanel.add(fortnightly, "cell 0 4");
    mainPanel.add(monthly, "cell 0 4");
    mainPanel.add(yearly, "cell 0 4, wrap");
    mainPanel.add(amountToSave, "split 2");
    mainPanel.add(tfAmountToSave, "grow");
    mainPanel.add(apply, "south");
    mainPanel.add(amountTable, "south");

    // Set the group buttons to a default
    weekly.setSelected(true);

    // Add the panels to the main panel
    add(mainPanel);
    add(chartPanel);

    // Load the icons
    setIconImages(IconLoader.getIcons());

    // Frame stuff
    setTitle("Budget");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    pack();
    setLocationRelativeTo(null); // Loads the window in the center	
  }
  /**
   * Processes SELECT_ITEM proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processSelectItem(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process SelectItem");

    Menu menu = new Menu();
    IconId titleIconId = null;
    ItemsIconId itemsIconId = null;
    Iterator<ComprehensionTlv> iter = ctlvs.iterator();

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs);
    if (ctlv != null) {
      menu.title = ValueParser.retrieveAlphaId(ctlv);
    }

    while (true) {
      ctlv = searchForNextTag(ComprehensionTlvTag.ITEM, iter);
      if (ctlv != null) {
        menu.items.add(ValueParser.retrieveItem(ctlv));
      } else {
        break;
      }
    }

    // We must have at least one menu item.
    if (menu.items.size() == 0) {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }

    ctlv = searchForTag(ComprehensionTlvTag.ITEM_ID, ctlvs);
    if (ctlv != null) {
      // CAT items are listed 1...n while list start at 0, need to
      // subtract one.
      menu.defaultItem = ValueParser.retrieveItemId(ctlv) - 1;
    }

    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      mIconLoadState = LOAD_SINGLE_ICON;
      titleIconId = ValueParser.retrieveIconId(ctlv);
      menu.titleIconSelfExplanatory = titleIconId.selfExplanatory;
    }

    ctlv = searchForTag(ComprehensionTlvTag.ITEM_ICON_ID_LIST, ctlvs);
    if (ctlv != null) {
      mIconLoadState = LOAD_MULTI_ICONS;
      itemsIconId = ValueParser.retrieveItemsIconId(ctlv);
      menu.itemsIconSelfExplanatory = itemsIconId.selfExplanatory;
    }

    boolean presentTypeSpecified = (cmdDet.commandQualifier & 0x01) != 0;
    if (presentTypeSpecified) {
      if ((cmdDet.commandQualifier & 0x02) == 0) {
        menu.presentationType = PresentationType.DATA_VALUES;
      } else {
        menu.presentationType = PresentationType.NAVIGATION_OPTIONS;
      }
    }
    menu.softKeyPreferred = (cmdDet.commandQualifier & 0x04) != 0;
    menu.helpAvailable = (cmdDet.commandQualifier & 0x80) != 0;

    mCmdParams = new SelectItemParams(cmdDet, menu, titleIconId != null);

    // Load icons data if needed.
    switch (mIconLoadState) {
      case LOAD_NO_ICON:
        return false;
      case LOAD_SINGLE_ICON:
        mloadIcon = true;
        mIconLoader.loadIcon(titleIconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
        break;
      case LOAD_MULTI_ICONS:
        int[] recordNumbers = itemsIconId.recordNumbers;
        if (titleIconId != null) {
          // Create a new array for all the icons (title and items).
          recordNumbers = new int[itemsIconId.recordNumbers.length + 1];
          recordNumbers[0] = titleIconId.recordNumber;
          System.arraycopy(
              itemsIconId.recordNumbers, 0, recordNumbers, 1, itemsIconId.recordNumbers.length);
        }
        mloadIcon = true;
        mIconLoader.loadIcons(recordNumbers, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
        break;
    }
    return true;
  }
  /**
   * Processes GET_INPUT proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processGetInput(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process GetInput");

    Input input = new Input();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TEXT_STRING, ctlvs);
    if (ctlv != null) {
      input.text = ValueParser.retrieveTextString(ctlv);
    } else {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }

    ctlv = searchForTag(ComprehensionTlvTag.RESPONSE_LENGTH, ctlvs);
    if (ctlv != null) {
      try {
        byte[] rawValue = ctlv.getRawValue();
        int valueIndex = ctlv.getValueIndex();
        input.minLen = rawValue[valueIndex] & 0xff;
        input.maxLen = rawValue[valueIndex + 1] & 0xff;
      } catch (IndexOutOfBoundsException e) {
        throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
      }
    } else {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }

    ctlv = searchForTag(ComprehensionTlvTag.DEFAULT_TEXT, ctlvs);
    if (ctlv != null) {
      input.defaultText = ValueParser.retrieveTextString(ctlv);
    }
    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
    }

    input.digitOnly = (cmdDet.commandQualifier & 0x01) == 0;
    input.ucs2 = (cmdDet.commandQualifier & 0x02) != 0;
    input.echo = (cmdDet.commandQualifier & 0x04) == 0;
    input.packed = (cmdDet.commandQualifier & 0x08) != 0;
    input.helpAvailable = (cmdDet.commandQualifier & 0x80) != 0;

    // Truncate the maxLen if it exceeds the max number of chars that can
    // be encoded. Limit depends on DCS in Command Qualifier.
    if (input.ucs2 && input.maxLen > MAX_UCS2_CHARS) {
      CatLog.d(
          this, "UCS2: received maxLen = " + input.maxLen + ", truncating to " + MAX_UCS2_CHARS);
      input.maxLen = MAX_UCS2_CHARS;
    } else if (!input.packed && input.maxLen > MAX_GSM7_DEFAULT_CHARS) {
      CatLog.d(
          this,
          "GSM 7Bit Default: received maxLen = "
              + input.maxLen
              + ", truncating to "
              + MAX_GSM7_DEFAULT_CHARS);
      input.maxLen = MAX_GSM7_DEFAULT_CHARS;
    }

    mCmdParams = new GetInputParams(cmdDet, input);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
Пример #14
0
  public void detatilaleart(
      final String Title,
      String Synopsis,
      final Double Price,
      final String imagepath,
      final String category,
      String pageno,
      String languages,
      final String currency,
      final String cat[]) {
    dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    final String bookname = Title;
    final String image = imagepath;
    final String cur = currency;
    final Double price = Price;
    this.Category = cat;

    // tell the Dialog to use the dialog.xml as it's layout description
    dialog.setContentView(R.layout.detaildialog);
    dialog.setCanceledOnTouchOutside(false);
    downloadProgressBar = (ProgressBar) dialog.findViewById(R.id.progress_bar);

    TextView categorytext = (TextView) dialog.findViewById(R.id.textcategory);
    categorytext.setText(category);

    String lang = "Language :-" + "\n" + languages;
    TextView langtext = (TextView) dialog.findViewById(R.id.textlanguages);
    langtext.setText(lang);

    TextView pages = (TextView) dialog.findViewById(R.id.textpagecount);
    pages.setText(pageno);

    TextView txt = (TextView) dialog.findViewById(R.id.text);

    String upToNCharacters = Synopsis.substring(0, Math.min(Synopsis.length(), 230));
    txt.setText(upToNCharacters);
    TextView name = (TextView) dialog.findViewById(R.id.bookname);
    name.setText(Title);
    TextView pricetext = (TextView) dialog.findViewById(R.id.pricetext);
    pricetext.setText("$" + Price);

    imageView = (ImageView) dialog.findViewById(R.id.image);
    imageView.setImageResource(R.drawable.cover);

    Log.e("image path", "http://next.mangoreader.com" + imagepath);

    iconloader.DisplayImage(imagepath, imageView);

    ImageView closeimage = (ImageView) dialog.findViewById(R.id.closebutton);
    closeimage.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            dialog.dismiss();

            final String id = prefs1.getString("id", null);
            Log.e("IDDDD", "" + id);
            Log.e("book name", bookname);
            Log.e("currency", "" + currency);
            Log.e("path", "" + imagepath);
            Log.e("price", Double.toString(price));
          }
        });

    Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);

    dialogButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {

            final String userName = prefs.getString("username", "null");
            final String authToken = prefs.getString("auth_token", "null");
            final String id = prefs1.getString("id", null);

            if (prefs.contains("username")) {

              NetworkHandler.getInstance().init();
              BookDownloadRequest request =
                  new BookDownloadRequest(StoreBooks.this, id, userName, authToken);
              request.setNetworkResponseHandler((StoreBooks.this));
              NetworkHandler.getInstance().addRequest(request);
              //	dialog.dismiss();

              BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
              Bitmap bitmap = drawable.getBitmap();

              ByteArrayOutputStream stream = new ByteArrayOutputStream();
              bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
              byte[] byteArray = stream.toByteArray();

              bookdata = new Bookdata();
              bookdata.setBookName(bookname);
              bookdata.setId(id);
              bookdata.setImagepath(image);
              bookdata.setPrice(Double.toString(price));
              bookdata.setCurrency(currency);
              bookdata.setImage(byteArray);
              bookdata.setCat(cat);

              Log.e("cat array length", "" + cat.length);

            } else {
              dialog.dismiss();
              Intent intent = new Intent(StoreBooks.this, LoginScreen.class);
              startActivity(intent);
              Toast.makeText(StoreBooks.this, "Please Login", Toast.LENGTH_SHORT).show();
            }
          }
        });

    dialog.show();
  }