Ejemplo n.º 1
0
 public Font GetFont(String opt1, String opt2, Font previous) {
   Font newfont = previous;
   int actual = -1;
   int pstyle = previous.getStyle();
   int psize = previous.getHeight();
   FontFamily fontFamily[] = FontFamily.getFontFamilies();
   for (int x = 0; x < fontFamily.length; x++) {
     if (fontFamily[x].getName().equalsIgnoreCase(opt1)) {
       actual = x;
       break;
     }
   }
   if (actual == -1) {
     for (int x = 0; x < fontFamily.length; x++) {
       if (fontFamily[x].getName().equalsIgnoreCase(opt2)) {
         actual = x;
         break;
       }
     }
   }
   if (actual == -1) {
     newfont = Font.getDefault().derive(pstyle, psize);
   } else {
     newfont = fontFamily[actual].getFont(pstyle, psize);
   }
   return newfont;
 }
Ejemplo n.º 2
0
public class Layout extends UserInterface {

  UiApplication theApp;
  Strings strings;

  FontFamily fontFamily[] = FontFamily.getFontFamilies();

  Background bkg_splash = null;
  Background bkg_main = null;
  Bitmap splash = null;
  Bitmap main = null;
  Bitmap btn = null;
  String logo = "img/logo.png";
  String button = "img/button_notext1_off.png";
  String button_on = "img/button_notext1_on.png";
  String friends = "img/button_notext2_off.png";
  String friends_on = "img/button_notext2_on.png";
  String defSplash = "img/splash_360x480.png";
  String blank = "img/blank.png";

  public Layout(CMainScreen c) {
    super(c);
    UiApplication ui = UiApplication.getUiApplication();
    theApp = (UiApplication) ui;
    strings = new Strings();
    setUpAssets();
  }

  public void setUpAssets() {
    int w = Display.getWidth();
    int h = Display.getHeight();
    String res = w + "x" + h;
    System.out.println("res__________" + res);
    splash = Bitmap.getBitmapResource("img/splash_" + res + ".png");
    main = Bitmap.getBitmapResource("img/bkg_main.jpg");
    btn = Bitmap.getBitmapResource(button);
    if (splash == null) {
      splash = Bitmap.getBitmapResource(defSplash);
    }
    bkg_splash = BackgroundFactory.createBitmapBackground(splash);
    bkg_main = BackgroundFactory.createBitmapBackground(main);
  }

  public Manager splashScreen(Manager parent) {
    VerticalFieldManager fm_MainHolder =
        new VerticalFieldManager(
            Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL) {
          public int getPreferredWidth() {
            return Display.getWidth();
          }

          public int getPreferredHeight() {
            return Display.getHeight();
          }

          protected void sublayout(int width, int height) {
            width = getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };
    Background back = bkg_splash;
    fm_MainHolder.setBackground(back);
    parent.add(fm_MainHolder);
    return fm_MainHolder;
  }

  public Manager mainScreen(Manager parent) {
    CInterface ci = new CInterface();
    final int columnHeight0 = (int) ((Display.getHeight() / 2));
    final int columnHeight1 = (int) (Display.getHeight() / 2);
    final int btnw = (int) ((float) Display.getWidth() * .75);
    final EncodedImage buttonoff =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(button), btnw);
    final EncodedImage buttonon =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(button_on), btnw);
    final EncodedImage friendsoff =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(friends), btnw);
    final EncodedImage friendson =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(friends_on), btnw);
    int imagew = (int) ((float) Display.getWidth() * .75);
    Bitmap blankbmp = Bitmap.getBitmapResource(blank);

    VerticalFieldManager fm_MainHolder =
        new VerticalFieldManager(
            Manager.USE_ALL_WIDTH
                | Manager.USE_ALL_HEIGHT
                | Manager.NO_HORIZONTAL_SCROLL
                | Manager.NO_VERTICAL_SCROLL) {
          public int getPreferredWidth() {
            return Display.getWidth();
          }

          public int getPreferredHeight() {
            return Display.getHeight();
          }

          protected void sublayout(int width, int height) {
            width = getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };
    Background back = bkg_main;
    fm_MainHolder.setBackground(back);

    // MAIN LOGO
    HorizontalFieldManager lgo =
        new HorizontalFieldManager(
            Manager.NO_VERTICAL_SCROLL
                | Manager.NO_HORIZONTAL_SCROLL
                | Manager.FIELD_HCENTER
                | Manager.FIELD_VCENTER
                | Manager.USE_ALL_WIDTH) {
          public int getPreferredHeight() {
            return columnHeight0;
          }

          protected void sublayout(int width, int height) {
            width = super.getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };
    BitmapField img =
        ci.WriteSimpleImage(
            lgo, logo, BitmapField.FIELD_VCENTER | BitmapField.FIELD_HCENTER, imagew, "");
    fm_MainHolder.add(lgo);

    // BUTTON HOLDER
    VerticalFieldManager vfmButton =
        new VerticalFieldManager(
            Manager.FIELD_HCENTER | Manager.FIELD_VCENTER | Manager.USE_ALL_WIDTH) {
          public int getPreferredHeight() {
            return columnHeight1;
          }

          public int getPreferredWidth() {
            return Display.getWidth();
          }

          protected void sublayout(int width, int height) {
            width = getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };

    final BitmapField bmFieldSpan = new BitmapField(blankbmp, BitmapField.NON_FOCUSABLE);

    CustomButtonField cbfFriends =
        new CustomButtonField(
            btnw,
            strings.getString("invite_friends"),
            friendsoff.getBitmap(),
            friendson.getBitmap(),
            Field.FOCUSABLE | Field.FIELD_HCENTER | Field.FIELD_VCENTER) {
          protected boolean navigationClick(int status, int time) {
            c.action_callback("web_friends", "", "");
            return true;
          }
        };

    CustomButtonField cbfButton =
        new CustomButtonField(
            btnw,
            strings.getString("read_qr"),
            buttonoff.getBitmap(),
            buttonon.getBitmap(),
            Field.FOCUSABLE | Field.FIELD_HCENTER | Field.FIELD_VCENTER) {
          protected boolean navigationClick(int status, int time) {
            c.action_callback("qr_start", "", "");
            return true;
          }
        };

    vfmButton.add(cbfButton);
    vfmButton.add(bmFieldSpan);
    vfmButton.add(cbfFriends);
    fm_MainHolder.add(vfmButton);

    parent.add(fm_MainHolder);
    return fm_MainHolder;
  }

  public void construct_makescrollable_attache(Manager parent) {
    parent.add(new NullField(NullField.FOCUSABLE));
  }
}
  CitationScreen6(Citation _c) {
    c = _c;

    String cNumberString = Integer.toString(c.Number);
    /*
            CustomLabelField lf = new CustomLabelField("OREGON UNIFORM CITATION: #" + cNumberString, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
            lf.setBackgroundColor(0x00194E84);
            lf.setTextColor(0x00ffffff);
            FontFamily fontFamily0[] = FontFamily.getFontFamilies();
            Font font = fontFamily0[1].getFont(FontFamily.CBTF_FONT, 14);
            lf.setFont(font);

            add(lf);
    */
    LabelField lf0 =
        new LabelField(
            "OREGON UNIFORM CITATION: #" + cNumberString,
            LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER) {
          protected void paintBackground(net.rim.device.api.ui.Graphics g) {
            g.clear();
            g.getColor();
            g.setColor(Color.GREEN);
            g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
            g.setColor(Color.WHITE);
          }
        };
    FontFamily fontFamily0[] = FontFamily.getFontFamilies();
    Font font0 = fontFamily0[1].getFont(FontFamily.CBTF_FONT, 14);
    lf0.setFont(font0);
    setTitle(lf0);
    add(new SeparatorField());
    /*
          CustomLabelField lf1 = new CustomLabelField("************* INCIDENT ATTRIBUTES **************", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
          lf1.setBackgroundColor(Color.LIGHTGREY);
          lf1.setTextColor(Color.BLUE);

          FontFamily fontFamily[] = FontFamily.getFontFamilies();
          Font font1 = fontFamily[1].getFont(FontFamily.CBTF_FONT, 14);
          lf1.setFont(font1);
          add(lf1);
    */
    LabelField lf3 =
        new LabelField(
            "********* INCIDENT ATTRIBUTES **********",
            LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER) {
          protected void paintBackground(net.rim.device.api.ui.Graphics g) {
            g.clear();
            g.getColor();
            g.setColor(Color.GREEN);
            g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
            g.setColor(Color.WHITE);
          }
        };
    FontFamily fontFamily3[] = FontFamily.getFontFamilies();
    Font font3 = fontFamily3[1].getFont(FontFamily.CBTF_FONT, 14);
    lf3.setFont(font0);
    add(lf3);
    add(new SeparatorField());

    // --------------

    // CheckboxField
    field_accident = new CheckboxField("Accident", false);
    add(field_accident);

    // CheckboxField
    field_radar = new CheckboxField("Radar", false);
    add(field_radar);

    // CheckboxField
    field_jail_booking = new CheckboxField("Jail Booking", false);
    add(field_jail_booking);

    // CheckboxField
    field_paced = new CheckboxField("Paced", false);
    add(field_paced);

    // CheckboxField
    field_school_zone = new CheckboxField("School Zone", false);
    add(field_school_zone);

    // CheckboxField
    field_alcohol = new CheckboxField("Alcohol", false);
    add(field_alcohol);

    add(new SeparatorField());

    // EditField
    field_vbfi = new EditField("VBFI: ", "");
    add(field_vbfi);

    // ObjectChoiceField
    String choicestrs1[] = {
      "5MPH", "10MPH", "15MPH", "20MPH", "25MPH", "30MPH", "35MPH", "40MPH", "45MPH", "50MPH",
      "55MPH", "60MPH", "65MPH", "70MPH", "75MPH", "80MPH"
    };
    field_speed_limit = new ObjectChoiceField("Speed Limit: ", choicestrs1, 0);
    add(field_speed_limit);

    // EditField
    field_alleged_speed = new EditField("Alleged Speed: ", "");
    add(field_alleged_speed);

    add(new SeparatorField());

    // ButtonField row - set all buttons at the bottom row of the form
    HorizontalFieldManager navButtonManager = new HorizontalFieldManager();

    // ButtonField
    ButtonField btn_prev;
    btn_prev = new ButtonField("Prev", ButtonField.CONSUME_CLICK);
    btn_prev.setChangeListener(new ButtonListener6(this, c));
    navButtonManager.add(btn_prev);

    ButtonField btn_next;
    btn_next = new ButtonField("Next", ButtonField.CONSUME_CLICK);
    btn_next.setChangeListener(new ButtonListener6(this, c));
    navButtonManager.add(btn_next);

    add(navButtonManager);

    add(new SeparatorField());

    addMenuItem(saveItem6);
    addMenuItem(getItem6);

    restoreUIFieldsFromCitation();
  }