Esempio n. 1
0
  /** @param view */
  public static void showSoftKeyboard(final View view) {
    if (view == null) {
      return;
    }

    final Runnable action =
        new Runnable() {
          @Override
          public void run() {
            final InputMethodManager imm =
                (InputMethodManager)
                    view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
          }
        };

    final View.OnFocusChangeListener restoreOnFocusChangeListener = view.getOnFocusChangeListener();

    final View.OnFocusChangeListener temporaryOnFocusChangeListener =
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(final View v, final boolean hasFocus) {
            view.setOnFocusChangeListener(restoreOnFocusChangeListener);
            view.postDelayed(action, 25);
          }
        };

    view.setOnFocusChangeListener(temporaryOnFocusChangeListener);
    view.requestFocus();
  }
Esempio n. 2
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
 /**
  * Establishes the parent view for this view. Seize this moment to cache the AWT Container I'm in.
  */
 public void setParent(View parent) {
   super.setParent(parent);
   fContainer = parent != null ? getContainer() : null;
   if (parent == null && fComponent != null) {
     fComponent.getParent().remove(fComponent);
     fComponent = null;
   }
 }
Esempio n. 4
0
  public void showDetails(Equipment equipment) {
    equip = equipment;
    View view;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      view = getActivity().findViewById(R.id.detail_frag);
    } else {
      view = getActivity().findViewById(R.id.main_frame);
      Button button = (Button) view.findViewById(R.id.closeButton);
      button.setVisibility(View.VISIBLE);
    }

    TextView textIt_no = (TextView) view.findViewById(R.id.it_no2);
    TextView textType = (TextView) view.findViewById(R.id.type2);
    TextView textBrand = (TextView) view.findViewById(R.id.brand2);
    TextView textModel = (TextView) view.findViewById(R.id.model2);
    TextView textE_id = (TextView) view.findViewById(R.id.e_id);
    TextView textDescription = (TextView) view.findViewById(R.id.description);
    TextView textAquired = (TextView) view.findViewById(R.id.aquired);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
    } else {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
    }
    textIt_no.setText("Item nr: \t\t\t\t" + equipment.getIt_no());
    textType.setText("Type: \t\t\t\t\t" + equipment.getType());
    textBrand.setText("Brand: \t\t\t\t" + equipment.getBrand());
    textModel.setText("Model: \t\t\t\t" + equipment.getModel());
    textE_id.setText("Equipment ID: \t" + equipment.getE_id());
    textDescription.setText("Description: \t" + equipment.getDescription());
    textAquired.setText("Aquired: \t\t\t" + equipment.getAquired());

    downloadImageThread();

    ImageView image = (ImageView) view.findViewById(R.id.equipment_image);
    image.setImageBitmap(bitmap);
  }
  private boolean needToSplit(DrawContext dc, Sector sector) {
    Vec4[] corners = sector.computeCornerPoints(dc.getGlobe(), dc.getVerticalExaggeration());
    Vec4 centerPoint = sector.computeCenterPoint(dc.getGlobe(), dc.getVerticalExaggeration());

    View view = dc.getView();
    double d1 = view.getEyePoint().distanceTo3(corners[0]);
    double d2 = view.getEyePoint().distanceTo3(corners[1]);
    double d3 = view.getEyePoint().distanceTo3(corners[2]);
    double d4 = view.getEyePoint().distanceTo3(corners[3]);
    double d5 = view.getEyePoint().distanceTo3(centerPoint);

    double minDistance = d1;
    if (d2 < minDistance) minDistance = d2;
    if (d3 < minDistance) minDistance = d3;
    if (d4 < minDistance) minDistance = d4;
    if (d5 < minDistance) minDistance = d5;

    double cellSize =
        (Math.PI * sector.getDeltaLatRadians() * dc.getGlobe().getRadius()) / 20; // TODO

    return !(Math.log10(cellSize) <= (Math.log10(minDistance) - this.splitScale));
  }
  /** My attributes may have changed. */
  public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    if (DEBUG) System.out.println("ImageView: changedUpdate begin...");
    super.changedUpdate(e, a, f);
    float align = getVerticalAlignment();

    int height = fHeight;
    int width = fWidth;

    initialize(getElement());

    boolean hChanged = fHeight != height;
    boolean wChanged = fWidth != width;
    if (hChanged || wChanged || getVerticalAlignment() != align) {
      if (DEBUG) System.out.println("ImageView: calling preferenceChanged");
      getParent().preferenceChanged(this, hChanged, wChanged);
    }
    if (DEBUG) System.out.println("ImageView: changedUpdate end; valign=" + getVerticalAlignment());
  }
Esempio n. 7
0
  /** @param view */
  public static void hideSoftKeyboard(final View view) {
    if (view == null) {
      return;
    }

    final Runnable action =
        new Runnable() {
          @Override
          public void run() {
            final InputMethodManager imm =
                (InputMethodManager)
                    view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(
                view.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
          }
        };

    view.postDelayed(action, 25);
  }
Esempio n. 8
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.content_list_item, null);
      }
      TextView titleTextView = (TextView) view.findViewById(R.id.list_item_title);
      TextView stateTextView = (TextView) view.findViewById(R.id.list_item_state);
      TextView downTextView = (TextView) view.findViewById(R.id.list_item_downbar);
      Button downloadButton = (Button) view.findViewById(R.id.list_item_download_button);
      Button uploadButton = (Button) view.findViewById(R.id.list_item_upload_button);

      LocationInfo info = mInfoList.get(position);
      String titleText = info.title;
      String stateText = "";

      if (titleText.length() > 30) titleText = titleText.substring(0, 28) + "...";

      synchronized (mLoaderMap) {
        if (mLoaderMap.containsKey(info.title)) {
          LoaderState loader = mLoaderMap.get(info.title);
          if (loader.state < 100) stateText = String.format(Locale.ENGLISH, "%d%%", loader.state);
          else if (loader.state == 100) stateText = String.format(Locale.ENGLISH, "Done!");
          else stateText = String.format(Locale.ENGLISH, "Failed!");
        }
      }

      if (info.localVersion < 0) titleText += " (?)";
      else {
        if (info.localModified)
          titleText += String.format(Locale.ENGLISH, " (v. %d+)", info.localVersion);
        else titleText += String.format(Locale.ENGLISH, " (v. %d)", info.localVersion);
      }

      String mapFile = NavigineApp.Settings.getString("map_file", "");
      if (mapFile.equals(info.archiveFile)) {
        titleTextView.setTypeface(null, Typeface.BOLD);
        view.setBackgroundColor(Color.parseColor("#590E0E"));
      } else {
        titleTextView.setTypeface(null, Typeface.NORMAL);
        view.setBackgroundColor(Color.BLACK);
      }

      titleTextView.setText(titleText);
      stateTextView.setText(stateText);

      if (info.localModified) {
        downloadButton.setVisibility(View.GONE);
        uploadButton.setVisibility(View.VISIBLE);
        downTextView.setText("Version is modified. Upload?");
      } else if (info.serverVersion > info.localVersion) {
        downloadButton.setVisibility(View.VISIBLE);
        uploadButton.setVisibility(View.GONE);
        String downText =
            String.format(Locale.ENGLISH, "Version available: %d", info.serverVersion);
        downTextView.setText(downText);
      } else {
        downloadButton.setVisibility(View.INVISIBLE);
        uploadButton.setVisibility(View.GONE);
        downTextView.setText("Version is up to date");
      }

      downloadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startDownload(position);
            }
          });

      uploadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startUpload(position);
            }
          });

      return view;
    }
Esempio n. 9
0
 public Double getCurrentAltitude() {
   View view = this.getWWd().getView();
   return view != null ? view.getEyePosition().getElevation() : null;
 }
Esempio n. 10
0
  /**
   * @param restore Ignored unless no views are open
   * @param newView Open a new view?
   * @param newPlainView Open a new plain view?
   * @param parent The client's parent directory
   * @param args A list of files. Null entries are ignored, for convinience
   * @since jEdit 4.2pre1
   */
  public static Buffer handleClient(
      boolean restore, boolean newView, boolean newPlainView, String parent, String[] args) {
    // we have to deal with a huge range of possible border cases here.
    if (jEdit.getFirstView() == null) {
      // coming out of background mode.
      // no views open.
      // no buffers open if args empty.

      boolean hasBufferArgs = false;

      for (String arg : args) {
        if (arg != null) {
          hasBufferArgs = true;
          break;
        }
      }

      boolean restoreFiles =
          restore
              && jEdit.getBooleanProperty("restore")
              && (!hasBufferArgs || jEdit.getBooleanProperty("restore.cli"));

      View view = PerspectiveManager.loadPerspective(restoreFiles);

      Buffer buffer = jEdit.openFiles(view, parent, args);

      if (view == null) {
        if (buffer == null) buffer = jEdit.getFirstBuffer();
        jEdit.newView(null, buffer);
      } else if (buffer != null) view.setBuffer(buffer, false);

      return buffer;
    } else if (newPlainView) {
      // no background mode, and opening a new view
      Buffer buffer = jEdit.openFiles(null, parent, args);
      if (buffer == null) buffer = jEdit.getFirstBuffer();
      jEdit.newView(null, buffer, true);
      return buffer;
    } else if (newView) {
      // no background mode, and opening a new view
      Buffer buffer = jEdit.openFiles(null, parent, args);
      if (buffer == null) buffer = jEdit.getFirstBuffer();
      jEdit.newView(jEdit.getActiveView(), buffer, false);
      return buffer;
    } else {
      // no background mode, and reusing existing view
      View view = jEdit.getActiveView();

      Buffer buffer = jEdit.openFiles(view, parent, args);

      // Hack done to fix bringing the window to the front.
      // At least on windows, Frame.toFront() doesn't cut it.
      // Remove the isWindows check if it's broken under other
      // OSes too.
      if (jEdit.getBooleanProperty("server.brokenToFront")) view.setState(java.awt.Frame.ICONIFIED);

      // un-iconify using JDK 1.3 API
      view.setState(java.awt.Frame.NORMAL);
      view.requestFocus();
      view.toFront();
      // In some platforms (e.g. Windows), only setAlwaysOnTop works
      if (!view.isAlwaysOnTop()) {
        view.setAlwaysOnTop(true);
        view.setAlwaysOnTop(false);
      }
      return buffer;
    }
  } // }}}