Beispiel #1
0
  public UserInput() {
    super(USE_ALL_WIDTH);

    userField =
        new CustomEditField(
            FIELD_LEFT | BasicEditField.NO_NEWLINE | BasicEditField.NO_SWITCHING_INPUT);
    fontSetting.setPoint(Font.PLAIN, 7);
    userField.setFont(fontSetting.getFont());
    userField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    add(userField);

    Bitmap icon = Bitmap.getBitmapResource("icon_user.png");
    if (Variables.smallScreen()) {
      int newWidth = icon.getWidth() * 320 / 480;
      int newHeight = icon.getHeight() * 240 / 360;
      icon = ImageUtils.resizeBitmap(icon, newWidth, newHeight);
    }
    userImage = new BitmapField(icon);
    userImage.setBackground(BackgroundFactory.createSolidBackground(0xf7f7f7));
    userImage.setBorder(
        BorderFactory.createSimpleBorder(
            new XYEdges(1, 1, 1, 1),
            new XYEdges(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY),
            Border.STYLE_SOLID));
    add(userImage);
  }
Beispiel #2
0
  public PassLockInput() {
    super(USE_ALL_WIDTH);

    passField =
        new CustomPasswordField("", "Password", 30, FIELD_LEFT | PasswordEditField.NO_NEWLINE);
    fontSetting.setPoint(Font.PLAIN, 7);
    passField.setFont(fontSetting.getFont());
    passField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    add(passField);

    Bitmap icon = Bitmap.getBitmapResource("icon_lock.png");
    if (Variables.smallScreen()) {
      int newWidth = icon.getWidth() * 320 / 480;
      int newHeight = icon.getHeight() * 240 / 360;
      icon = ImageUtils.resizeBitmap(icon, newWidth, newHeight);
    }
    passImage = new BitmapField(icon);
    passImage.setBackground(BackgroundFactory.createSolidBackground(0xf7f7f7));
    passImage.setBorder(
        BorderFactory.createSimpleBorder(
            new XYEdges(1, 1, 1, 1),
            new XYEdges(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY),
            Border.STYLE_SOLID));
    add(passImage);
  }
  public mkpyLabelLabelField(String title, String value, long style, int color, int backcolor) {
    super(
        HorizontalFieldManager.NO_HORIZONTAL_SCROLL
            | HorizontalFieldManager.NO_VERTICAL_SCROLL
            | HorizontalFieldManager.USE_ALL_WIDTH);

    lblTitle = new mkpyLabelField(title, style | BitmapField.FIELD_VCENTER, color, backcolor);
    lblTitle.setFont(this.getFont().derive(Font.BOLD));
    this.setBackground(BackgroundFactory.createSolidBackground(backcolor));
    this.add(lblTitle);
    lblValue =
        new mkpyLabelField(
            value, style | LabelField.FIELD_VCENTER | LabelField.ELLIPSIS, color, backcolor);
    this.add(lblValue);
  }
  /**
   * Applies a visual style to a Manager to make it appear like a distinct group.
   *
   * @param manager The Manager to transform.
   * @param title The title of the group. If null or empty, no label will be added.
   * @return Reference to the same Manager object that was passed as the manager parameter.
   */
  public static Manager makeGroup(Manager manager, String title) {
    if ((title != null) && (title != "")) {
      manager.add(createGroupLabel(title));
    }

    manager.setMargin(new XYEdges(3, 3, 0, 3));
    manager.setPadding(new XYEdges(5, 5, 5, 5));
    manager.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    manager.setBorder(
        BorderFactory.createBevelBorder(
            new XYEdges(2, 2, 2, 2),
            new XYEdges(
                COLOR_GROUP_BEZEL_OUTER,
                COLOR_GROUP_BEZEL_OUTER,
                COLOR_GROUP_BEZEL_OUTER,
                COLOR_GROUP_BEZEL_OUTER),
            new XYEdges(
                COLOR_GROUP_BEZEL_INNER,
                COLOR_GROUP_BEZEL_INNER,
                COLOR_GROUP_BEZEL_INNER,
                COLOR_GROUP_BEZEL_INNER)));

    return manager;
  }
Beispiel #5
0
  public SearchView(HomeScreen homeScreen) {
    this.homeScreen = homeScreen;
    manager =
        new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL) {
          public boolean keyChar(char c, int status, int time) {
            if (!searchField.isFocus()) {
              String oldText = searchField.getText();
              searchField.setFocus();
              String newText = c == Keypad.KEY_DELETE ? oldText : oldText + c;
              searchField.setText(newText.trim());
              return true;
            } else if (c == Keypad.KEY_ESCAPE) {
              if (searchField.getText().length() > 0) {
                searchField.setText("");
                return true;
              }
            }
            return super.keyChar(c, status, time);
          }
        };
    searchField =
        new BasicEditField(Field.USE_ALL_WIDTH) {
          public boolean navigationClick(int status, int time) {
            if (getText().trim().length() > 0) {
              SearchView.this.homeScreen.fireActionSearch();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public boolean keyChar(char c, int status, int time) {
            if (c == Keypad.KEY_ENTER) {
              if (getText().trim().length() > 0) {
                SearchView.this.homeScreen.fireActionSearch();
                return true;
              }
            } else if (getText().length() == 0 && c == Keypad.KEY_SPACE) {
              return true;
            }
            return super.keyChar(c, status, time);
          }

          public void paint(Graphics g) {
            if (getText().length() == 0) {
              g.setColor(0xbbbbbb);
              g.drawText(" Search", 0, 0);
            } else {
              g.setColor(0);
              super.paint(g);
            }
          }
        };

    // int defaultFontHeight = Font.getDefault().getHeight();
    // searchField.setFont(Font.getDefault().derive(Font.PLAIN, defaultFontHeight+8));
    Border border = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4));
    searchField.setBorder(border);
    searchField.setBackground(BackgroundFactory.createSolidBackground(0xffffff));
    manager.add(searchField);
    manager.add(new SeparatorField());

    // manager.setBackground(HomeScreen.mainBackground);
    listField =
        new ListField(0, Manager.USE_ALL_HEIGHT) {
          public boolean navigationClick(int status, int time) {
            if (SearchView.this.listData.size() > 0) {
              int index = getSelectedIndex();
              if (isMoreButton(index)) {
                increaseListFieldSize();
                invalidate();
                return true;
              }
              ProgramData data = (ProgramData) SearchView.this.listData.elementAt(index);
              data.isFavorite = !data.isFavorite;
              if (data.isFavorite) {
                FavoritePersistent.addFavorite(data.id);
                PIMEvent.addEvent(data);
              } else {
                FavoritePersistent.removeFavorite(data.id);
                PIMEvent.removeEvent(data);
              }
              invalidate();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public void paint(Graphics g) {
            int ty = getContentTop() + getContentHeight() / 2 - g.getFont().getHeight() / 2;
            if (ThaiTVSchedule.isFetching()) {
              ThaiTVSchedule.paintFetching(g, ty);
            } else if (this.getSize() < 1) {
              g.setColor(0);
              int x = (getWidth() - g.getFont().getAdvance("No data")) / 2;
              g.drawText("No data", x, ty);
            } else {
              super.paint(g);
            }
          }

          public boolean isFocusable() {
            return !ThaiTVSchedule.isFetching();
          }
        };
    // listField.setBackground(HomeScreen.mainBackground);
    listField.setRowHeight(ScheduleScreen.LIST_HEIGHT);
    listField.setCallback(this);
    listData = new Vector();
    listField.setSize(0);
    listField.setFont(Font.getDefault().derive(Font.PLAIN, 20));
    VerticalFieldManager _vfm =
        new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    _vfm.add(listField);
    manager.add(_vfm);

    // autoFocus();
  }