Example #1
0
  public void onLocationChanged(Location location) {
    // Logger.d(TAG, "onLocationChanged(" + location + ")");

    if (mGuide != null) {
      boolean bContinue = true;

      if (location != null) {
        bContinue = mGuide.actualizeState(location);
        mTargetName = mGuide.getTargetName();
        mAzimuthToTarget = mGuide.getAzimuthToTaget();
        mDistanceToTarget = mGuide.getDistanceToTarget();
      } else {
        bContinue = true;
        mTargetName = null;
        mAzimuthToTarget = 0.0f;
        mDistanceToTarget = 0.0f;
      }

      if (bContinue == true) {
        for (GuidingListener list : listeners) {
          list.receiveGuideEvent(mGuide, mTargetName, mAzimuthToTarget, mDistanceToTarget);
        }
      } else {
        A.getGuidingContent().guideStop();
      }
    }
  }
Example #2
0
  @Override
  public void receiveGuideEvent(
      Guide guide, String targetName, float azimuthToTarget, double distanceToTarget) {

    Guide g = A.getGuidingContent().getGuide();
    mOverlayGuidance.show(g != null);
    mOverlayGuidance.requestRedraw();
  }
Example #3
0
 @Override
 protected void onResume() {
   super.onResume();
   Settings.setCurrentActivity(this);
   mMapview.invalidate();
   mOverlayZones.requestRedraw();
   mOverlayPosition.requestRedraw();
   Guide g = A.getGuidingContent().getGuide();
   mOverlayGuidance.show(g != null);
   mOverlayGuidance.requestRedraw();
 }
Example #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMapview = new MapView(this);
    mMapview.setClickable(true);
    mMapview.setBuiltInZoomControls(true);

    mMapFile = getIntent().getStringExtra(MAPFILE);
    File file = new File(mMapFile);
    mMapview.setMapFile(file);
    setContentView(mMapview);

    // --- draw current position
    // Drawable marker = getResources().getDrawable(R.drawable.icon_gc_wherigo);

    mPaintVisibleZoneFill.setStyle(Paint.Style.FILL);
    mPaintVisibleZoneFill.setColor(Color.BLUE);
    mPaintVisibleZoneFill.setAlpha(64);

    mPaintVisibleZoneBorder.setStyle(Paint.Style.STROKE);
    mPaintVisibleZoneBorder.setColor(Color.BLUE);
    mPaintVisibleZoneBorder.setAlpha(128);
    mPaintVisibleZoneBorder.setStrokeWidth(3);

    // mOverlayGuidance = new OverlayGuidance();
    mMapview.getOverlays().add(mOverlayGuidance);
    Guide g = A.getGuidingContent().getGuide();
    mOverlayGuidance.show(g != null);
    mOverlayGuidance.requestRedraw();

    // mOverlayPosition = new OverlayPosition(this,mMapview);
    mMapview.getOverlays().add(mOverlayPosition);
    mOverlayPosition.requestRedraw();

    // mOverlayZones = new OverlayZones();
    mMapview.getOverlays().add(mOverlayZones);
    mOverlayZones.requestRedraw();
  }
Example #5
0
  public void onLocationChanged(Location location) {
    if ((mLocation == null)
        || (mLocation.getLongitude() != location.getLongitude())
        || (mLocation.getLatitude() != location.getLatitude())
        || (mLocation.getBearing() != location.getBearing())
        || (mLocation.getAccuracy() != location.getAccuracy())) {
      mLocation = location;

      // ----
      mOverlayPosition.onLocationChanged(location);
      mOverlayPosition.requestRedraw();

      if (mOverlayGuidance != null) {
        Guide g = A.getGuidingContent().getGuide();
        mOverlayGuidance.show(g != null);
        mOverlayGuidance.onLocationChanged(location);
        mOverlayGuidance.requestRedraw();
      }

      // center map
      mMapview.setCenter(new GeoPoint(mLocation.getLatitude(), mLocation.getLongitude()));
    }
  }
Example #6
0
  @Override
  public void onCreate() {
    super.onCreate();
    Log.d(TAG, "onCreate()");

    PreferenceUtils.SetContext(this);

    Configuration config = getBaseContext().getResources().getConfiguration();
    String lang = PreferenceUtils.getPrefString(R.string.pref_language);

    // Logger.d(TAG, "lang:" + lang + ", system:" + config.locale.getLanguage());
    if (!lang.equals("")
        && !lang.equals(Settings.VALUE_LANGUAGE_DEFAULT)
        && !config.locale.getLanguage().equals(lang)) {
      ArrayList<String> loc = StringToken.parse(lang, "_");
      if (loc.size() == 1) {
        locale = new Locale(lang);
      } else {
        locale = new Locale(loc.get(0), loc.get(1));
      }
      Locale.setDefault(locale);
      config.locale = locale;
      getBaseContext()
          .getResources()
          .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    }

    // register screen on/off receiver
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    mScreenReceiver = new ScreenReceiver();
    registerReceiver(mScreenReceiver, filter);

    // initialize root directory
    FileSystem.createRoot(APP_NAME);

    //
    A.registerApp((MainApplication) this);

    if (!(DIRS == null || DIRS.length == 0)) {

      // --- check file system
      if (FileSystem.createRoot(MainApplication.APP_NAME)) {
        // Logger.w(TAG, "FileSystem succesfully created!");
        // fileSystem created successfully
        for (int i = 0; i < DIRS.length; i++) {
          (new File(FileSystem.ROOT + DIRS[i])).mkdirs();
        }
        YaawpAppData.GetInstance().mFileSystemCheck = true;
      } else {
        YaawpAppData.GetInstance().mFileSystemCheck = false;
        // Logger.w(TAG, "FileSystem cannot be created!");

        /*
        UtilsGUI.showDialogError(CustomMain.this,
        		R.string.filesystem_cannot_create_root,
        		new DialogInterface.OnClickListener() {

        	@Override
        	public void onClick(DialogInterface dialog, int which) {
        		showDialogFinish(FINISH_EXIT_FORCE);
        	}
        });
        */
        return;
      }

      // --- check free space
      // check disk space (at least 5MB)
      StatFs stat = new StatFs(FileSystem.ROOT);
      long bytesFree = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
      long megFree = bytesFree / 1048576;
      // Logger.d(TAG, "megAvailable:" + megAvail + ", free:" + megFree);
      if (megFree > 0 && megFree < 5) {
        YaawpAppData.GetInstance().mFileSystemSpace = false;
        /*
        UtilsGUI.showDialogError(CustomMain.this,
        		getString(R.string.not_enough_disk_space_x, FileSystem.ROOT, megFree + "MB"),
        		new DialogInterface.OnClickListener() {

        	@Override
        	public void onClick(DialogInterface dialog, int which) {
        		showDialogFinish(FINISH_EXIT_FORCE);
        	}
        });
        */

        return;

      } else {
        YaawpAppData.GetInstance().mFileSystemSpace = true;
      }
    }

    // set location state
    LocationState.init(this);

    // start gps
    if (Utils.isPermissionAllowed(Manifest.permission.ACCESS_FINE_LOCATION)
        && Settings.getPrefBoolean(
            Settings.KEY_B_START_GPS_AUTOMATICALLY, Settings.DEFAULT_START_GPS_AUTOMATICALLY)) {
      LocationState.setGpsOn(this);
    } else {
      LocationState.setGpsOff(this);
      // TODO create a message in the list
    }

    // initialize DPI
    Utils.getDpPixels(this, 1.0f);

    // init openwig engine
    OpenWigHelper.SetDeviceId(PreferenceUtils.getPrefString(R.string.pref_wherigo_engine_deviceid));
    OpenWigHelper.SetPlatform(PreferenceUtils.getPrefString(R.string.pref_wherigo_engine_platform));
  }
  @Override
  public boolean onPreferenceChange(final Preference preference, final Object value) {
    boolean status = true;

    if (isPreference(preference, R.string.pref_highlight)) {
      PreferenceFunc.enableWakeLock();
      // TODO preference.setSummary( stringValue );
    } else if (isPreference(preference, R.string.pref_wherigo_engine_deviceid)) {
      OpenWigHelper.SetDeviceId(value.toString());
    } else if (isPreference(preference, R.string.pref_wherigo_engine_platform)) {
      OpenWigHelper.SetPlatform(value.toString());
    } else if (isPreference(preference, R.string.pref_sensors_compass_hardware)) {
      // TODO check if new value already persisted
      A.getRotator().manageSensors();
    } else if (isPreference(preference, R.string.pref_sensors_compass_auto_change)) {
      // TODO check if new value already persisted
      A.getRotator().manageSensors();
    } else if (isPreference(preference, R.string.pref_sensors_compass_auto_change_value)) {
      if (Utils.parseInt(value) <= 0) {
        ManagerNotify.toastShortMessage(R.string.invalid_value);
        status = false;
      }
    } else if (isPreference(preference, R.string.pref_language)) {
      // TODO activity.needRestart = true;
      return true;
    } else if (isPreference(preference, R.string.pref_cartridgelist_sorting)) {
      YaawpAppData.GetInstance().mRefreshCartridgeList = true;
    } else if (isPreference(preference, R.string.pref_cartridgelist_anywhere_first)) {
      YaawpAppData.GetInstance().mRefreshCartridgeList = true;
    } else if (isPreference(preference, R.string.pref_scan_external_storage)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_exclude_android_dir)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_exclude_hidden_dirs)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_exclude_whereyougo_dir)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_include_dropbox_dir)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_guiding_sound_type)) {
      int result = Utils.parseInt(value);
      if (result == PreferenceValues.GuidingWaypointSound.CUSTOM_SOUND) {
        // lastUsedPreference = (ListPreference) pref;
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType("audio/*");
        if (!Utils.isIntentAvailable(intent)) {
          intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
        }
        this.startActivityForResult(intent, REQUEST_GUIDING_WPT_SOUND);
        status = true; // don't set the preference yet
      }
    } else if (isPreference(preference, R.string.pref_guiding_sound_distance)) {
      int distance = Utils.parseInt(value);
      if (distance <= 0) {
        ManagerNotify.toastShortMessage(R.string.invalid_value);
        status = false;
      }
    }

    return status;
  }
 private static String getKey(final int prefKeyId) {
   return A.getApp().getString(prefKeyId);
 }
Example #9
0
 @Override
 public void guideStart() {
   Guide g = A.getGuidingContent().getGuide();
   mOverlayGuidance.show(g != null);
   mOverlayGuidance.requestRedraw();
 }
Example #10
0
 public void onStop() {
   super.onStop();
   LocationState.removeLocationChangeListener(this);
   A.getGuidingContent().removeGuidingListener(this);
   A.getRotator().removeListener(this);
 }
Example #11
0
 public void onStart() {
   super.onStart();
   LocationState.addLocationChangeListener(this);
   A.getGuidingContent().addGuidingListener(this);
   A.getRotator().addListener(this);
 }