protected boolean onAayaPrev() {
    // If the resource file changes the names of components this call will break notifying you that
    // you should fix the code
    boolean val = super.onAayaPrev();

    if (selectedSurahPartNumber > 1) {
      selectedSurahPartNumber--;
    } else if (selectedSurahPartNumber <= 1) {
      int i = 2; // because it is already at 1.
      InputStream inputStream;
      while ((inputStream =
              getClass()
                  .getResourceAsStream("/res/quran/" + selectedSurahNumber + "_" + i + ".xml"))
          != null) {
        i++;
      }
      inputStream = null;
      if (i == 2) // this means `selectedSurahNumber`_2.xml does not exist.
      {
        return val; // prev. is pressed on a surah with only 1 aaya file. No need to reload
      }
      selectedSurahPartNumber = i - 1;
    }
    final DefaultListModel defaultListModel = (DefaultListModel) aayaList.getModel();
    defaultListModel.removeAll();
    Vector resultVector = getAayaList(selectedSurahNumber, selectedSurahPartNumber);
    aayaList.setModel(new DefaultListModel(resultVector));
    aayaList.setRenderer(new AayaListRenderer());
    return val;
  }
  /**
   * Constructor of Invitation form. This form displays all the non-hike users and allow user to
   * send invitation to those users who are not on hike.
   */
  public FormInvitation() {

    getStyle().setBgColor(ColorCodes.selectContactBgGrey, true);

    // #if nokia2_0
    setTitle(LBL_INVITE_FRIENDS);
    // #endif

    setLayout(new BorderLayout());

    setScrollable(false);

    addComponent(BorderLayout.NORTH, searchTextArea);

    initCommands();

    searchTextArea.setTextChangedListener(this);

    inviteList = new List(inviteVector);
    inviteList.getStyle().setPadding(Component.LEFT, 0, true);
    inviteList.getSelectedStyle().setPadding(Component.LEFT, 0, true);
    inviteList.getStyle().setPadding(Component.RIGHT, 0, true);
    inviteList.getSelectedStyle().setPadding(Component.RIGHT, 0, true);
    inviteList.getStyle().setPadding(Component.BOTTOM, 0, true);
    inviteList.getSelectedStyle().setPadding(Component.BOTTOM, 0, true);
    inviteList.setRenderer(new InviteListRenderer());
    inviteList.addActionListener(
        new ActionListener() {
          boolean clicked = false;
          AddressBookEntry entry;

          public void actionPerformed(ActionEvent evt) {
            if (!clicked) {
              entry = (AddressBookEntry) inviteList.getSelectedItem();
              if (entry.getMsisdn() == null || entry.getPhoneNumber() == null) {
                return;
              }
              clicked = true;
              if (entry.getId().equals(UNKNOWN_CONTACT_ID)) {
                MqttManager.invite(entry.getName(), AppState.getNextMessageID());
              } else {
                MqttManager.invite(entry.getMsisdn(), AppState.getNextMessageID());
              }
              clicked = false;
              entry.setInvited(true);
              // flushReplace();
              revalidate();
            }
          }
        });

    addComponent(BorderLayout.CENTER, inviteList);
  }
 protected boolean initListModelListSurah(List cmp) {
   // If the resource file changes the names of components this call will break notifying you that
   // you should fix the code
   super.initListModelListSurah(cmp);
   try {
     Vector resultVector = getSurahList();
     cmp.setModel(new DefaultListModel(resultVector));
     cmp.setRenderer(new SurahListRenderer());
   } catch (Exception e) {
     Dialog.show(null, "initListModelListSurah excepption", "OK", null);
   }
   return true;
 }
  protected boolean onAayaNext() {
    // If the resource file changes the names of components this call will break notifying you that
    // you should fix the code
    boolean val = super.onAayaNext();
    InputStream inputStream =
        getClass()
            .getResourceAsStream(
                "/res/quran/" + selectedSurahNumber + "_" + selectedSurahPartNumber + 1 + ".xml");
    if (inputStream == null && selectedSurahPartNumber == 1) return val;
    else if (inputStream == null) selectedSurahPartNumber = 0;
    inputStream = null;
    selectedSurahPartNumber++;
    final DefaultListModel defaultListModel = (DefaultListModel) aayaList.getModel();
    defaultListModel.removeAll();
    Vector resultVector = getAayaList(selectedSurahNumber, selectedSurahPartNumber);
    aayaList.setModel(new DefaultListModel(resultVector));
    aayaList.setRenderer(new AayaListRenderer());

    return val;
  }
  /**
   * Constructor of privacy form. This form gives options user to delete or unlink account from the
   * device. Adding and initializing all components are done in this constructor.
   */
  public FormPrivacy() {

    getStyle().setBgColor(ColorCodes.settingsScreenBgGrey, true);

    // #if nokia2_0
    setTitle(LBL_PRIVACY);
    // #endif

    privacyVector.addElement(new PrivacyModel(LBL_DELETE_ACCOUNT, MSG_DELETE_ACCOUNT));
    privacyVector.addElement(new PrivacyModel(LBL_SIGNOUT, MSG_SIGNOUT_ACCOUNT));

    initCommands();

    // #if nokia1_1
    // #         Label privacyLabel = new Label(LBL_PRIVACY);
    // #         privacyLabel.getStyle().setBgTransparency(0, true);
    // #         privacyLabel.getStyle().setFgColor(0x808080, true);
    // #         privacyLabel.getStyle().setMargin(Component.TOP, 5, true);
    // #         addComponent(privacyLabel);
    // #endif

    setLayout(new BoxLayout(BoxLayout.Y_AXIS));

    final List privacyList = new List(privacyVector);
    privacyList.setFocusable(false);
    privacyList.setFocus(false);
    privacyList.getStyle().setPadding(Component.LEFT, 0, true);
    privacyList.getSelectedStyle().setPadding(Component.LEFT, 0, true);
    privacyList.getStyle().setPadding(Component.RIGHT, 0, true);
    privacyList.getSelectedStyle().setPadding(Component.RIGHT, 0, true);
    privacyList.getStyle().setPadding(Component.BOTTOM, 0, true);
    privacyList.getSelectedStyle().setPadding(Component.BOTTOM, 0, true);
    privacyList.getStyle().setBgColor(ColorCodes.settingsScreenListBgGrey, true);
    privacyList.getSelectedStyle().setBgColor(ColorCodes.settingsScreenListBgGrey, true);
    privacyList.getStyle().setBgTransparency(255, true);
    privacyList.getSelectedStyle().setBgTransparency(255, true);
    privacyList
        .getStyle()
        .setBorder(
            Border.createCompoundBorder(
                null,
                Border.createEtchedRaised(
                    ColorCodes.settingsScreenBorderGrey, ColorCodes.settingsScreenBorderShadow),
                null,
                null),
            true);
    privacyList
        .getSelectedStyle()
        .setBorder(
            Border.createCompoundBorder(
                null,
                Border.createEtchedRaised(
                    ColorCodes.settingsScreenBorderGrey, ColorCodes.settingsScreenBorderShadow),
                null,
                null),
            true);
    privacyList.setRenderer(new PrivacyListRenderer());
    privacyList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (!clicked) {
              clicked = true;

              switch (privacyList.getSelectedIndex()) {
                case 0:
                  showDialog(MSG_DELETE_ACCOUNT_CONFIRMATION, LBL_DELETE, LBL_CANCEL);
                  clicked = false;
                  break;

                case 1:
                  showDialog(MSG_SIGNOUT_ACCOUNT_CONFIRMATION, LBL_UNLINK, LBL_CANCEL);
                  clicked = false;
                  break;
              }
            }
          }
        });

    addComponent(privacyList);
  }