示例#1
0
  /** Restart the receiving, when we are back on line. */
  @Override
  protected void onResume() {
    super.onResume();

    this.setRequestedOrientation(Preferences.getRequestedScreenOrientation(this));

    if (this.mNeedDataState) {
      this.onResumeForDataStateChangedListener();
    }

    this.mMenuVoiceEnabled = Preferences.getMenuVoiceEnabled(this);
  }
示例#2
0
文件: OSBMap.java 项目: wjb/AndRoad
 protected void showAddPOIDialog() {
   if (Preferences.getOSMAccountUsername(this).length() == 0) {
     showDialog(DIALOG_INPUT_OSM_ACCOUNT_INFO);
   } else {
     showPOICategorySelectorActivity();
   }
 }
示例#3
0
文件: OSBMap.java 项目: wjb/AndRoad
  /** Called when the activity is first created. */
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    Log.d(Constants.DEBUGTAG, "OnCREATE");
    super.onCreate(savedInstanceState);

    applyZoomButtonListeners();
    applyQuickButtonListeners();
    applyMapViewLongPressListener();

    /* Check if this is the first start, or a configuration-change. */
    if (savedInstanceState == null) {
      final GeoPoint location = super.getLastKnownLocation(true);
      if (location == null
          || Math.abs(location.getLatitudeE6()) <= 100
          || Math.abs(location.getLongitudeE6()) <= 100) {
        this.mOSMapView.getController().setZoom(3);
      } else {
        this.mOSMapView.getController().setZoom(13);
        this.mOSMapView.getController().setCenter(location);
      }
      /* Init the First bug-query a bit delayed, until the mapview offers a correct bounding-box. */
      new Handler()
          .postDelayed(
              new Runnable() {
                public void run() {
                  refreshVisibleBugs();
                }
              },
              1000);

      if (Preferences.getShowOSBInstructions(this)) {
        showDialog(DIALOG_SHOW_INSTRUCTIONS);
      }
    }
  }
示例#4
0
文件: OSBMap.java 项目: wjb/AndRoad
  @Override
  protected void onSetupContentView() {
    this.setContentView(R.layout.osbmap);
    super.mOSMapView = (MapView) findViewById(R.id.map_osbmap);

    this.mIbtnCommentWrite = (ImageButton) this.findViewById(R.id.ibtn_osbmap_comment_write);
    this.mIbtnRefresh = (ImageButton) this.findViewById(R.id.ibtn_osbmap_refresh);
    this.mIbtnAdd = (ImageButton) this.findViewById(R.id.ibtn_osbmap_add);
    this.mIbtnAddCancel = (ImageButton) this.findViewById(R.id.ibtn_osbmap_add_cancel);

    this.mScaleIndicatorView = new ScaleBarOverlay(this);
    if (Preferences.getUnitSystem(this) == UnitSystem.IMPERIAL) {
      this.mScaleIndicatorView.setImperial();
    } else {
      this.mScaleIndicatorView.setMetric();
    }
    this.mScaleIndicatorView.setScaleBarOffset(
        getResources().getDisplayMetrics().widthPixels / 2
            - getResources().getDisplayMetrics().xdpi / 2,
        10);

    this.mIbtnCommentWrite.setEnabled(false);

    final OverlayManager overlaymanager = this.mOSMapView.getOverlayManager();
    this.mOSBOverlay = new OSMMapViewOSBOverlay(this, this.mBugOverlayItems, this);
    this.mOSBOverlay.setFocusItemsOnTap(false);

    overlaymanager.add(this.mScaleIndicatorView);
    overlaymanager.add(this.mMyLocationOverlay = new SimpleLocationOverlay(this));

    overlaymanager.add(this.mOSBOverlay);
    /* Add AddBugOverlay after OSBOverlay to give it a higher zOrder. */
    overlaymanager.add(
        this.mAddBugCrosshairOverlay = new OSMMapViewCrosshairOverlay(this, Color.BLACK, 2, 17));
    this.mAddBugCrosshairOverlay.setEnabled(false);

    super.mOSMapView.invalidate();
  }
示例#5
0
 /** Called when the activity is first created. */
 protected void onCreate(final Bundle icicle, final boolean aNeedDataState) {
   super.onCreate(icicle);
   this.mMenuVoiceEnabled = Preferences.getMenuVoiceEnabled(this);
   this.mNeedDataState = aNeedDataState;
 }
示例#6
0
文件: OSBMap.java 项目: wjb/AndRoad
  private void showAddFTPCDialog() {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final FrameLayout fl = (FrameLayout) inflater.inflate(R.layout.dlg_osb_add_ftpc, null);

    final EditText etMail = (EditText) fl.findViewById(R.id.et_dlg_osb_add_ftpc_mail);
    final EditText etPostcode1 = (EditText) fl.findViewById(R.id.et_dlg_osb_add_ftpc_postcode1);
    final EditText etPostcode2 = (EditText) fl.findViewById(R.id.et_dlg_osb_add_ftpc_postcode2);

    etMail.setText(Preferences.getFTPCConfirmationMail(this));
    etPostcode1.setSelectAllOnFocus(true);
    etPostcode2.setSelectAllOnFocus(true);

    new AlertDialog.Builder(this)
        .setView(fl)
        .setTitle(R.string.dlg_osb_add_ftpc_title)
        .setPositiveButton(
            R.string.save,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(final DialogInterface d, final int which) {
                final String mail = etMail.getText().toString();

                /* TODO Add simple Email-Matcher. */
                if (mail.length() == 0) {
                  Toast.makeText(
                          OSBMap.this,
                          R.string.dlg_osb_ftpc_mail_invalid_comment,
                          Toast.LENGTH_LONG)
                      .show();
                  return;
                }

                /* Store email for next use. */
                Preferences.saveFTPCConfirmationMail(OSBMap.this, mail);

                final String postcode1 = etPostcode1.getText().toString();
                final String postcode2 = etPostcode2.getText().toString();
                final String postcode = postcode1 + " " + postcode2;

                if (postcode.length() == 0
                    || !PostcodeUK_BS7776Matcher.doesMatchUKPostcode_BS_7666(postcode)) {
                  Toast.makeText(
                          OSBMap.this,
                          R.string.dlg_osb_ftpc_postcode_invalid_comment,
                          Toast.LENGTH_LONG)
                      .show();
                  return;
                }

                Toast.makeText(OSBMap.this, R.string.please_wait_a_moment, Toast.LENGTH_LONG)
                    .show();
                new Thread(
                        new Runnable() {
                          @Override
                          public void run() {
                            try {
                              final boolean success =
                                  FTPCRequester.submitPostcode(
                                      OSBMap.this.mOSMapView.getMapCenter(),
                                      postcode1,
                                      postcode2,
                                      mail);
                              if (success) {
                                runOnUiThread(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        Toast.makeText(
                                                OSBMap.this,
                                                R.string.dlg_osb_add_ftpc_success,
                                                Toast.LENGTH_LONG)
                                            .show();
                                      }
                                    });
                              } else {
                                runOnUiThread(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        Toast.makeText(
                                                OSBMap.this,
                                                R.string.dlg_osb_add_ftpc_failed,
                                                Toast.LENGTH_LONG)
                                            .show();
                                      }
                                    });
                              }
                            } catch (final Exception e) {
                              Exceptor.e(
                                  "Error submitting FreeThePostcode-Postcode.", e, OSBMap.this);
                            }
                          }
                        })
                    .start();

                d.dismiss();
              }
            })
        .setNegativeButton(
            R.string.cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(final DialogInterface d, final int which) {
                d.dismiss();
              }
            })
        .create()
        .show();
  }