Exemple #1
0
  public GuiSetupGui(ShareNavDisplayable parent, boolean initialSetup) {
    super(Locale.get("guisetupgui.GUIOptions") /*GUI Options*/);
    this.parent = parent;
    this.initialSetup = initialSetup;
    try {
      long mem = Configuration.getPhoneAllTimeMaxMemory();
      if (mem == 0) {
        mem = Runtime.getRuntime().totalMemory();
      }
      mem = mem / 1024;
      memField =
          new TextField(
              Locale.get("guisetupgui.DefineMaxMem") /*Define maxMem (kbyte)*/,
              Long.toString(mem),
              8,
              TextField.DECIMAL);
      append(memField);
      String[] imenu = new String[7];
      imenu[0] = Locale.get("guisetupgui.UseIconMenu") /*Use icon menu*/;
      imenu[1] = Locale.get("guisetupgui.UseSetupIconMenu") /*Use icon menu for settings*/;
      imenu[2] = Locale.get("guisetupgui.FullscreenIconMenu") /*Fullscreen icon menu*/;
      imenu[3] = Locale.get("guisetupgui.SplitscreenIconMenu") /*Split screen icon menu*/;
      imenu[4] = Locale.get("guisetupgui.LargeTabButtons") /*Large tab buttons*/;
      imenu[5] = Locale.get("guisetupgui.IconsMappedOnKeys") /*Icons mapped on keys*/;
      // imenu[5] = Locale.get("guisetupgui.OptimiseForRouting")/*Optimise for routing*/;
      imenu[6] =
          Locale.get("guisetupgui.FavoritesInRouteIconMenu") /*Favorites in route icon menu*/;
      imenuOpts =
          new ChoiceGroup(
              Locale.get("guisetupgui.IconMenu") /*Icon Menu:*/, Choice.MULTIPLE, imenu, null);
      imenuOpts.setSelectedIndex(
          0, Configuration.getCfgBitSavedState(Configuration.CFGBIT_ICONMENUS));
      imenuOpts.setSelectedIndex(
          1, Configuration.getCfgBitSavedState(Configuration.CFGBIT_ICONMENUS_SETUP));
      imenuOpts.setSelectedIndex(
          2, Configuration.getCfgBitSavedState(Configuration.CFGBIT_ICONMENUS_FULLSCREEN));
      imenuOpts.setSelectedIndex(
          3, Configuration.getCfgBitSavedState(Configuration.CFGBIT_ICONMENUS_SPLITSCREEN));
      imenuOpts.setSelectedIndex(
          4, Configuration.getCfgBitSavedState(Configuration.CFGBIT_ICONMENUS_BIG_TAB_BUTTONS));
      imenuOpts.setSelectedIndex(
          5, Configuration.getCfgBitState(Configuration.CFGBIT_ICONMENUS_MAPPED_ICONS));
      // imenuOpts.setSelectedIndex(5,
      //		Configuration.getCfgBitSavedState(Configuration.CFGBIT_ICONMENUS_ROUTING_OPTIMIZED));
      imenuOpts.setSelectedIndex(
          6, Configuration.getCfgBitSavedState(Configuration.CFGBIT_FAVORITES_IN_ROUTE_ICON_MENU));
      append(imenuOpts);

      if (Configuration.getHasPointerEvents()) {
        String[] touch = new String[4];
        int i = 0;
        touch[i++] = Locale.get("guisetupgui.longMapTap");
        touch[i++] = Locale.get("guisetupgui.doubleMapTap");
        touch[i++] = Locale.get("guisetupgui.singleMapTap");
        touch[i++] = Locale.get("guisetupgui.clickableMarkers");
        mapTapFeatures =
            new ChoiceGroup(
                Locale.get("guisetupgui.MapTapFeatures") /*Map Touch Features*/,
                Choice.MULTIPLE,
                touch,
                null);
        i = 0;
        mapTapFeatures.setSelectedIndex(
            i++, Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_LONG));
        mapTapFeatures.setSelectedIndex(
            i++, Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_DOUBLE));
        mapTapFeatures.setSelectedIndex(
            i++, Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_SINGLE));
        mapTapFeatures.setSelectedIndex(
            i++, Configuration.getCfgBitState(Configuration.CFGBIT_CLICKABLE_MAPOBJECTS));
        append(mapTapFeatures);
      }

      // search options
      int iMax = 3;
      if (Configuration.getHasPointerEvents()) {
        iMax++;
      }
      // #if polish.android
      iMax++;
      // #endif
      String[] search = null;
      search = new String[iMax];
      int searchnum = 0;
      search[searchnum++] = Locale.get("guisetupgui.scroll") /*Scroll result under cursor*/;
      search[searchnum++] = Locale.get("guisetupgui.scrollall") /*Scroll all results*/;
      if (Configuration.getHasPointerEvents()) {
        search[searchnum++] = Locale.get("guisetupgui.numberkeypad") /*Enable virtual keypad*/;
      }
      search[searchnum++] =
          Locale.get(
              "guisetupgui.SuppressSearchWarning") /*Suppress warning about exceeding max results*/;
      // #if polish.android
      search[searchnum++] =
          Locale.get("guisetupgui.ShowNativeKeyboard") /*Show native keyboard in search*/;
      // #endif
      searchSettings =
          new ChoiceGroup(
              Locale.get("guisetupgui.searchopts") /*Search options:*/,
              Choice.MULTIPLE,
              search,
              null);
      /* only display search settings available on the device */
      // maximum search option entries
      searchnum = 0;
      searchSettings.setSelectedIndex(
          searchnum++, Configuration.getCfgBitSavedState(Configuration.CFGBIT_TICKER_ISEARCH));
      searchSettings.setSelectedIndex(
          searchnum++, Configuration.getCfgBitSavedState(Configuration.CFGBIT_TICKER_ISEARCH_ALL));
      if (Configuration.getHasPointerEvents()) {
        searchSettings.setSelectedIndex(
            searchnum++,
            Configuration.getCfgBitSavedState(Configuration.CFGBIT_SEARCH_TOUCH_NUMBERKEYPAD));
      }
      searchSettings.setSelectedIndex(
          searchnum++,
          Configuration.getCfgBitSavedState(Configuration.CFGBIT_SUPPRESS_SEARCH_WARNING));
      // #if polish.android
      searchSettings.setSelectedIndex(
          searchnum++,
          Configuration.getCfgBitSavedState(Configuration.CFGBIT_SEARCH_SHOW_NATIVE_KEYBOARD));
      // #endif
      append(searchSettings);
      String[] searchLayout = new String[2];
      searchLayout[0] = Locale.get("guidiscover.SearchWholeNames") /*Search for whole names*/;
      searchLayout[1] = Locale.get("guidiscover.SearchWords") /*Search for words*/;
      searchLayoutGroup =
          new ChoiceGroup(
              Locale.get("guidiscover.SearchStyle") /*Search style*/,
              Choice.EXCLUSIVE,
              searchLayout,
              null);
      searchLayoutGroup.setSelectedIndex(
          Configuration.getCfgBitSavedState(Configuration.CFGBIT_WORD_ISEARCH) ? 1 : 0, true);
      append(searchLayoutGroup);

      int searchMax = Configuration.getSearchMax();
      searchField =
          new TextField(
              Locale.get("guisetupgui.DefineMaxSearch") /*Max # of search results*/,
              Integer.toString(searchMax),
              8,
              TextField.DECIMAL);
      append(searchField);

      float dist = Configuration.getPoiSearchDistance();
      poiSearchDistance =
          new TextField(
              Locale.get("guisetupgui.PoiDistance") /*POI Distance: */,
              Float.toString(dist),
              8,
              TextField.ANY);
      append(poiSearchDistance);

      String[] otherSettings = new String[1];
      otherSettings[0] =
          Locale.get("guisetupgui.ExitWithBackButton") /* Back button exits application*/;
      otherGroup =
          new ChoiceGroup(
              Locale.get("guisetupgui.otherOptions") /* Other options */,
              Choice.MULTIPLE,
              otherSettings,
              null);
      otherGroup.setSelectedIndex(
          0,
          Configuration.getCfgBitSavedState(
              Configuration.CFGBIT_EXIT_APPLICATION_WITH_BACK_BUTTON));
      append(otherGroup);

      addCommand(CMD_SAVE);
      addCommand(CMD_CANCEL);

      // Set up this Displayable to listen to command events
      setCommandListener(this);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }