/** Creates a new instance of PrivacyForm */
  public PrivacyForm(Display display, PrivacyItem item, PrivacyList plist) {
    this.display = display;
    parentView = display.getCurrent();
    this.item = item;
    targetList = plist;

    textValue = new TextField(null, item.value, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(textValue);

    form.append(choiceAction);
    choiceAction.setSelectedIndex(item.action, true);

    form.append(choiseType);

    form.append(textValue);
    choiseType.setSelectedIndex(item.type, true);
    switchType();

    form.append(choiseStanzas);
    choiseStanzas.setSelectedFlags(item.stanzasSet);

    // form.append("Order: "+item.order);

    form.setItemStateListener(this);
    form.setCommandListener(this);
    form.addCommand(cmdOk);
    form.addCommand(cmdCancel);
    display.setCurrent(form);
  }
Beispiel #2
0
  /**
   * Display the connecting form to the user, let call set actions.
   *
   * @param action action to put in the form's title
   * @param name name to in the form's title
   * @param url URL of a JAD
   * @param size 0 if unknown, else size of object to download in K bytes
   * @param gaugeLabel label for progress gauge
   * @return displayed form
   */
  private Form displayProgressForm(
      String action, String name, String url, int size, String gaugeLabel) {
    Gauge progressGauge;
    StringItem urlItem;

    progressForm = new Form(null);

    progressForm.setTitle(action + " " + name);

    if (size <= 0) {
      progressGauge = new Gauge(gaugeLabel, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
    } else {
      progressGauge = new Gauge(gaugeLabel, false, size, 0);
    }

    progressGaugeIndex = progressForm.append(progressGauge);

    if (url == null) {
      urlItem = new StringItem("", "");
    } else {
      urlItem = new StringItem(Resource.getString(ResourceConstants.AMS_WEBSITE) + ": ", url);
    }

    progressUrlIndex = progressForm.append(urlItem);

    display.setCurrent(progressForm);
    lastDisplayChange = System.currentTimeMillis();

    return progressForm;
  }
  public ContactEdit(Display display, Contact c) {
    this.display = display;
    parentView = display.getCurrent();

    StaticData sd = StaticData.getInstance();
    roster = sd.roster;

    Vector groups = sd.roster.groups.getRosterGroupNames();
    cf = Config.getInstance();

    f = new Form(SR.MS_ADD_CONTACT); // locale

    tJid = new TextField(SR.MS_USER_JID, null, 150, TextField.EMAILADDR);

    tNick = new TextField("Name", null, 32, TextField.ANY); // locale
    tGroup = new TextField(SR.MS_GROUP, null, 32, TextField.ANY); // locale

    tGrpList = new ChoiceGroup(SR.MS_GROUP, ConstMIDP.CHOICE_POPUP);
    tTranspList = new ChoiceGroup(SR.MS_TRANSPORT, ConstMIDP.CHOICE_POPUP);

    tAskSubscrCheckBox = new ChoiceGroup(SR.MS_SUBSCRIPTION, ChoiceGroup.MULTIPLE); // locale
    tAskSubscrCheckBox.append(SR.MS_ASK_SUBSCRIPTION, null); // locale

    tGrpList.addCommand(cmdSet);
    tGrpList.setItemCommandListener(this);

    tTranspList.addCommand(cmdSet);
    tTranspList.setItemCommandListener(this);

    // Transport droplist
    tTranspList.append(sd.account.getServer(), null);
    for (Enumeration e = sd.roster.getHContacts().elements(); e.hasMoreElements(); ) {
      Contact ct = (Contact) e.nextElement();
      Jid transpJid = ct.jid;
      if (transpJid.isTransport()) tTranspList.append(transpJid.getBareJid(), null);
    }
    tTranspList.append(SR.MS_OTHER, null); // locale

    try {
      String jid;
      if (c instanceof MucContact) {
        jid = Jid.toBareJid(((MucContact) c).realJid);
      } else {
        jid = c.getBareJid();
      }
      // edit contact
      tJid.setString(jid);
      tNick.setString(c.nick);

      if (c instanceof MucContact) {
        c = null;
        throw new Exception();
      }

      if (c.getGroupType() != Groups.TYPE_NOT_IN_LIST
          && c.getGroupType() != Groups.TYPE_SEARCH_RESULT) {
        // edit contact
        f.setTitle(jid);
        cmdOk = new Command("Update", Command.OK, 1); // locale
        newContact = false;
      } else c = null; // adding not-in-list
    } catch (Exception e) {
      c = null;
    } // if MucContact does not contains realJid

    int sel = -1;
    ngroups = 0;
    String grpName = "";
    if (c != null) grpName = c.getGroup().name;

    if (groups != null) {
      ngroups = groups.size();
      for (int i = 0; i < ngroups; i++) {
        String gn = (String) groups.elementAt(i);
        tGrpList.append(gn, null);

        if (gn.equals(grpName)) sel = i;
      }
    }

    // if (sel==-1) sel=groups.size()-1;
    if (sel < 0) sel = 0;
    // tGroup.setString(group(sel));

    if (c == null) {
      f.append(tJid);
      f.append(tTranspList);
    }
    updateChoise(tJid.getString(), tTranspList);
    f.append(tNick);

    tGrpList.append(SR.MS_NEWGROUP, null);

    tGrpList.setSelectedIndex(sel, true);

    grpFIndex = f.append(tGrpList);

    if (newContact) {
      f.append(tAskSubscrCheckBox);
      tAskSubscrCheckBox.setSelectedIndex(0, true);
    }

    f.addCommand(cmdOk);
    f.addCommand(cmdCancel);

    f.setCommandListener(this);
    f.setItemStateListener(this);

    display.setCurrent(f);
  }
Beispiel #4
0
  public void commandAction(Command command, Displayable displayable) {
    if (command == camList) {
      controller.setCurrentScreen(this);
      controller.setCurrentScreen(this);
    }
    if (command == refreshList) {
      controller.showProgressBar();
      refreshCamList();
    }
    if (command == cmBack) {
      controller.getDisp().setCurrent(LiveCameras);
    }
    if (command == RefreshImage) {
      refreshImage();
    }
    if (command == viewImage) {

      refreshImage();
    }
    if (command == TrafOption) {
      if (this.getString(this.getSelectedIndex()).equals("Cameras")) {
        LiveCameras();

      } else if (this.getString(this.getSelectedIndex()).equals("Traffic Fines")) {

        if (VehicleNoForm == null) {

          VehicleNoForm = new Form("Traffic Fines");
          vehNo = new TextField("Vehicle Number", "", 100, TextField.ANY);

          VehicleNoForm.append(vehNo);
          VehicleNoForm.addCommand(Vehicleback);
          VehicleNoForm.addCommand(VehicleOk);

          VehicleNoForm.setCommandListener(this);
        }

        controller.setCurrentScreen(VehicleNoForm);

      } else {
        new Thread() {
          public void run() {
            getTrafficSpots();
          }
        }.start();
      }
    }
    if (command == bckMenu) {
      controller.MainMenu();
    }

    if (command == Vehicleback) {
      controller.setCurrentScreen(this);
    }
    if (command == VehicleOk) {
      if (vehNo.getString().equals("")) {

        controller.showAlert("Enter the vehicle number", 0, AlertType.ERROR);
      } else {

        controller.showProgressBar();
        new Thread() {
          public void run() {

            Downloader dwn = new Downloader(controller);
            String message =
                dwn.requestForData(
                    "http://125.17.140.50/notices/vehiclefinedetails.aspx?veh_no="
                        + vehNo.getString());
            vehNo.setString("");
            controller.showAlert(message, 0, AlertType.INFO);
          }
        }.start();

        new Thread() {
          public void run() {

            controller.setCurrentScreen(VehicleNoForm);
          }
        }.start();
      }
    }
  }
Beispiel #5
0
  public XDataForm(JabberDataBlock data, String id, String from) {
    this.id = id;
    this.from = from;

    cmdOk = new Command(SR.get(SR.MS_SEND), Command.OK /*Command.SCREEN*/, 1);
    cmdCancel = new Command(SR.get(SR.MS_BACK), Command.BACK, 99);
    // #ifdef DEBUG_CONSOLE
    // #         midlet.BombusQD.debug.add("captcha<<< " + data.toString(),10);
    // #endif

    JabberDataBlock challenge = data.findNamespace("captcha", "urn:xmpp:captcha");
    JabberDataBlock xdata = challenge.findNamespace("x", "jabber:x:data");
    JabberDataBlock oob = data.findNamespace("x", "jabber:x:oob");

    String url = oob.getChildBlockText("url");
    String title = xdata.getChildBlockText("title");

    Vector xData = xdata.getChildBlocks();

    if (null == title) title = "";

    f = new Form(title);
    items = new Vector(0);

    if (url.length() > 0) {
      TextField formItem = new TextField("URL", url, url.length(), TextField.UNEDITABLE);
      f.append(formItem);
    }

    XDataField field;
    String msgcid = "";

    int size = xData.size();
    for (int i = 0; i < size; ++i) {
      JabberDataBlock ch = (JabberDataBlock) xData.elementAt(i);

      if (ch.getTagName().equals("instructions")) {
        f.append(ch.getText());
        f.append("\n");
        continue;
      }
      ;
      if (!ch.getTagName().equals("field")) continue;

      field = new XDataField(ch);
      items.addElement(field);

      if (field.hidden) continue;

      if (field.media != null) msgcid = field.mediaUri.substring(4);
      f.append(field.formItem);
    }

    JabberDataBlock dataImage = data.findNamespace("data", "urn:xmpp:bob");
    String cid = dataImage.getAttribute("cid");
    if (cid.indexOf(msgcid) == 0) {
      try {
        byte[] bytes = Strconv.fromBase64(dataImage.getText());
        Image img = Image.createImage(bytes, 0, bytes.length);
        f.append(new ImageItem(null, img, Item.LAYOUT_CENTER, null));
      } catch (OutOfMemoryError eom) {
        // #ifdef DEBUG_CONSOLE
        // #                 midlet.BombusQD.debug.add("XDataForm OutOfMem",10);
        // #endif
      } catch (Exception e) {
      }
    }

    f.setCommandListener(this);
    f.addCommand(cmdOk);
    f.addCommand(cmdCancel);

    this.parentView = BombusQD.sd.canvas.getCanvas();
    BombusQD.setCurrentView(f);
  }