/**
   * This is an overrided call of text change. This method gets called on every text change in the
   * search box.
   *
   * @param textArea
   * @param previousText
   * @param currentText
   */
  public void onTextChange(
      PatchedTextArea textArea, String previousText, final String currentText) {
    if (!(Display.getInstance().getCurrent() instanceof FormInvitation)) {
      return;
    }
    Log.v(TAG, " ************* testing PatchedTextArea " + currentText);
    Log.v(TAG, " ************* String Length  " + currentText.length());
    final int index = currentText.lastIndexOf(';');

    Log.v(TAG, " ************* Last Index " + index);
    if (index > 0) {
      UIHelper.runOnLwuitUiThread(
          new Runnable() {
            public void run() {
              searchContactlist(currentText.substring(index + 1));
            }
          });

      Log.v(TAG, " ************* Last Character " + currentText.substring(index));
    } else {
      UIHelper.runOnLwuitUiThread(
          new Runnable() {
            public void run() {
              searchContactlist(currentText);
            }
          });
    }

    if (!inviteVector.isEmpty()) {
      inviteList.setSelectedIndex(0);
      inviteList.repaint();
    }
  }
  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;
  }
  protected void beforeGUI1(Form f) {
    try {
      HttpCon con12 = new HttpCon(null, PropertyClass.ServerUrl + "Allfrends");
      con12.SetContype(false, true, true);
      Thread t = new Thread(con12);
      synchronized (t) {
        t.start();
        t.wait();
      }
      final String bf[] = Splitter.Split(con12.getValue().toString(), "-");
      System.out.println(bf);
      final List l = (List) findByName("studentlist", f);

      for (int i = 0; i < bf.length - 1; i++) {

        l.addItem(Splitter.Split(bf[i], "/")[0]);
      }

      l.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
              frndid = Splitter.Split(bf[l.getSelectedIndex()], "/")[1];
              showForm("Userprofile", null);
            }
          });

    } catch (Exception e) {
      System.out.println(e);
    }

    super.beforeGUI1(f);
  }
Example #4
0
  protected void execute(final Form f) {
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    f.setScrollable(false);
    list = new List(RENDERED_CONTENT);
    list.setFixedSelection(List.FIXED_NONE_CYCLIC);
    list.setSmoothScrolling(true);
    list.getStyle().setBgTransparency(0);
    renderers = new ListCellRenderer[RENDERED_CONTENT.length];
    renderers[0] = new AlternateImageRenderer();
    renderers[1] = new WidgetRenderer();
    renderers[2] = new AlternateColorRenderer();
    renderers[3] = new DefaultListCellRenderer();
    renderers[4] = new FishEyeRenderer();
    list.setListCellRenderer(renderers[0]);
    list.addActionListener(this);

    Label l = new Label("Press \"Select\" to update:");
    l.getStyle().setBgTransparency(100);
    f.addComponent(l);
    f.addComponent(list);
    l = new Label("Try Applying Renderer To Menu");
    l.getStyle().setBgTransparency(100);
    f.addComponent(l);
    f.addCommand(
        new Command("Set To Menu") {

          public void actionPerformed(ActionEvent ev) {
            f.setMenuCellRenderer(list.getRenderer());
          }
        });
  }
 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 void exitSurah(Form f) {
   // If the resource file changes the names of components this call will break notifying you that
   // you should fix the code
   super.exitSurah(f);
   try {
     List list = findListSurah(f);
     final DefaultListModel defaultListModel = (DefaultListModel) list.getModel();
     defaultListModel.removeAll();
     selectSurah = null;
   } catch (Exception e) {
     e.printStackTrace();
     Dialog.show(null, "exitSurah Exception", "OK", null);
   }
 }
 protected void exitAaya(Form f) {
   // If the resource file changes the names of components this call will break notifying you that
   // you should fix the code
   super.exitAaya(f);
   try {
     List list = findListAaya(f);
     final DefaultListModel defaultListModel = (DefaultListModel) list.getModel();
     defaultListModel.removeAll();
     aayaList = null;
     selectedSurahPartNumber = 1;
   } catch (Exception e) {
     Dialog.show(null, "exit Aaya exception", "OK", null);
   }
 }
  /**
   * 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 void onSurah_ListSurahAction(Component c, ActionEvent event) {
    // If the resource file changes the names of components this call will break notifying you that
    // you should fix the code
    super.onSurah_ListSurahAction(c, event);
    try {
      List l = (List) c;
      String name = (String) l.getSelectedItem();
      selectedSurahNumber = Integer.parseInt(name.substring(0, name.indexOf(".")));

      if (selectSurah != null) {
        selectSurah.released();
      } else {
        Dialog.show(null, "selectSurah null", "OK", null);
      }
      name = null;
    } catch (Exception e) {
      Dialog.show(null, "onSurah_ListSurahAction excepption", "OK", null);
    }
  }
 private void populateToDoList(String searchTerm) {
   toDoList.setModel(new DefaultListModel());
   try {
     String[] pimListNames = pim.listPIMLists(PIM.TODO_LIST);
     for (int i = 0; i < pimListNames.length; ++i) {
       ContactList cl =
           (ContactList) pim.openPIMList(PIM.TODO_LIST, PIM.READ_ONLY, pimListNames[i]);
       Enumeration items = cl.items(searchTerm);
       while (items.hasMoreElements()) {
         Contact c = (Contact) items.nextElement();
         toDoList.addItem(c.getString(Contact.FORMATTED_NAME, 0));
       }
     }
   } catch (PIMException ex) {
     ex.printStackTrace();
   }
   if (toDoList.getModel().getSize() == 0) {
     toDoList.addItem("No matches");
   }
 }
  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;
  }
 protected boolean initListModelListAaya(List cmp) {
   // If the resource file changes the names of components this call will break notifying you that
   // you should fix the code
   super.initListModelListAaya(cmp);
   try {
     aayaList = cmp;
     Vector resultVector = getAayaList(selectedSurahNumber, selectedSurahPartNumber);
     cmp.setModel(new DefaultListModel(resultVector));
     //            cmp.setRenderer(new AayaListRenderer());
   } catch (Exception e) {
     Dialog.show(null, "initListModelListAaya excepption", "OK", null);
   }
   return true;
 }
  /**
   * This method is called on onTextChangeListener() of the search box. This method will show only
   * the filtered contacts to the user.
   *
   * @param string
   */
  private void searchContactlist(String string) {
    String searchString = string.trim();
    if (!TextUtils.isEmpty(searchString)) {
      inviteVector.removeAllElements();
      String validatedNum = Validator.validatePhoneString(searchString);
      if (validatedNum != null) {
        boolean isValidLength =
            validatedNum.length() - (AppState.getUserDetails().getCountryCode().length() + 1)
                    >= CharLimit.PHONE_NUMBER_MIN
                && validatedNum.length() <= CharLimit.PHONE_NUMBER_MAX;
        String msisdn = isValidLength ? UNKNOWN_CONTACT_INVITE_MESSAGE : UNKNOWN_CONTACT_NAME;
        String name = isValidLength ? validatedNum : searchString;
        String phone = isValidLength ? validatedNum : null;
        AddressBookEntry addressBookentry =
            new AddressBookEntry(UNKNOWN_CONTACT_ID, phone, name, msisdn, false);
        inviteVector.addElement(addressBookentry);
      }

      Vector list = AddressBookList.getInstance().getInviteList();
      Enumeration enums = list.elements();
      while (enums.hasMoreElements()) {
        AddressBookEntry entry = (AddressBookEntry) enums.nextElement();
        String contactName = entry.getName().toUpperCase();
        String contactNumber = entry.getMsisdn();
        searchString = searchString.toUpperCase();
        if (contactName.indexOf(searchString) >= 0 || contactNumber.indexOf(searchString) >= 0) {
          inviteVector.addElement(entry);
        }
      }
    } else {
      inviteVector.removeAllElements();
      Vector list = AddressBookList.getInstance().getInviteList();
      Enumeration enums = list.elements();
      while (enums.hasMoreElements()) {
        AddressBookEntry entry = (AddressBookEntry) enums.nextElement();
        inviteVector.addElement(entry);
      }
    }
    // flushReplace();
    revalidate();
    inviteList.setShouldCalcPreferredSize(true);
  }
  public Form getResources() {
    if (frmResources == null) {
      frmResources = new Form("Resources");

      List list = new List();
      list.addItem("uno");
      list.addItem("due");
      list.addItem("tre");
      list.addItem("quattro");
      list.addItem("cinque");
      list.addItem("sei");
      frmResources.addComponent(list);

      ComboBox comboBox = new ComboBox(list.getModel());
      frmResources.addComponent(comboBox);
      frmResources.addCommand(mBackCommand);
      frmResources.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmResources;
  }
Example #15
0
 public void actionPerformed(ActionEvent evt) {
   int newSelected = ((List) evt.getSource()).getSelectedIndex();
   list.setListCellRenderer(renderers[newSelected]);
   list.requestFocus();
   list.getParent().revalidate();
 }
  /**
   * 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);
  }
Example #17
0
 /**
  * Sets the list items as selected / not selected based on the indices in an array.
  *
  * @param indices Array containing the selected indices.
  */
 public void setSelectedIndices(int[] indices) {
   if (indices.length > 0) {
     list.setSelectedIndex(indices[0]);
   }
 }
Example #18
0
 /**
  * Returns an array containing the indices of selected list items
  *
  * @return Array containing the selected indices.
  */
 public int[] getSelectedIndices() {
   return new int[] {list.getSelectedIndex()};
 }