示例#1
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();
 }
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == REQUEST_GUIDING_WPT_SOUND) {
     if (resultCode == Activity.RESULT_OK && data != null) {
       Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
       if (uri != null) {
         Preference preference = findPreference(R.string.pref_guiding_sound_type);
         // String key = preference.getKey();
         // PreferenceManager.getDefaultSharedPreferences( this ).edit().putInt( key,
         // PreferenceValues.GuidingWaypointSound.CUSTOM_SOUND );
         // PreferenceManager.getDefaultSharedPreferences( this ).edit().putString( key+"_uri",
         // uri.toString() );
         // Settings.setPrefInt( getKey(R.string.pref_guiding_sound_type),
         // PreferenceValues.GuidingWaypointSound.CUSTOM_SOUND );
         Settings.setPrefString(
             Settings.VALUE_GUIDING_WAYPOINT_SOUND_CUSTOM_SOUND_URI, uri.toString());
       }
     }
   }
 }
示例#3
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));
  }