コード例 #1
0
ファイル: GuidingContent.java プロジェクト: kratz00/YAAWP
  public void guideStart(Guide guide) {
    this.mGuide = guide;

    // set location listener
    LocationState.addLocationChangeListener(this);
    // call one onLocationChange, to update actual values imediately
    onLocationChanged(LocationState.getLocation());
    // Logger.d(TAG, "X");
    Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                try {
                  while (mGuide != null) {
                    if (PreferenceItems.getGuidingSound()) {
                      mGuide.manageDistanceSoundsBeeping(mDistanceToTarget);
                    }
                    Thread.sleep(100); // kann man das nicht reduzieren??? 200,300,500,700???
                  }
                } catch (Exception e) {
                  Logger.e(TAG, "guideStart(" + mGuide + ")", e);
                }
              }
            });
    thread.start();

    for (GuidingListener list : listeners) {
      list.guideStart();
    }
  }
コード例 #2
0
ファイル: GuidingContent.java プロジェクト: kratz00/YAAWP
  public void guideStop() {
    this.mGuide = null;

    LocationState.removeLocationChangeListener(this);

    for (GuidingListener list : listeners) {
      list.guideStop();
    }
  }
コード例 #3
0
ファイル: MainApplication.java プロジェクト: kratz00/YAAWP
 @Override
 public void onReceive(Context context, Intent intent) {
   if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
     // Logger.v(TAG, "ACTION_SCREEN_OFF");
     mScreenOff = true;
   } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
     // Logger.v(TAG, "ACTION_SCREEN_ON");
     LocationState.onScreenOn(false);
     mScreenOff = false;
   }
 }
コード例 #4
0
ファイル: MainApplication.java プロジェクト: kratz00/YAAWP
  @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));
  }
コード例 #5
0
ファイル: GuidingContent.java プロジェクト: kratz00/YAAWP
 public void addGuidingListener(GuidingListener listener) {
   this.listeners.add(listener);
   // actualize data and send event to new listener
   onLocationChanged(LocationState.getLocation());
 }
コード例 #6
0
 public void onStop() {
   super.onStop();
   LocationState.removeLocationChangeListener(this);
   A.getGuidingContent().removeGuidingListener(this);
   A.getRotator().removeListener(this);
 }
コード例 #7
0
 public void onStart() {
   super.onStart();
   LocationState.addLocationChangeListener(this);
   A.getGuidingContent().addGuidingListener(this);
   A.getRotator().addListener(this);
 }