Exemple #1
0
  @Override
  public void onCreate() {
    try {
      final ViewConfiguration config = ViewConfiguration.get(this);
      final Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
      menuKeyField.setAccessible(true);
      menuKeyField.setBoolean(config, false);
    } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException ignored) {
    }

    // Set language to English if the user decided so.
    initApplicationLocale(Settings.useEnglish());

    // ensure initialization of lists
    DataStore.getLists();

    // Check if Google Play services is available
    if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this)
        == ConnectionResult.SUCCESS) {
      isGooglePlayServicesAvailable = true;
    }
    Log.i(
        "Google Play services are " + (isGooglePlayServicesAvailable ? "" : "not ") + "available");
    final Sensors sensors = Sensors.getInstance();
    sensors.setupGeoDataObservables(Settings.useGooglePlayServices(), Settings.useLowPowerMode());
    sensors.setupDirectionObservable(Settings.useLowPowerMode());

    // Attempt to acquire an initial location before any real activity happens.
    sensors
        .geoDataObservable(true)
        .subscribeOn(RxUtils.looperCallbacksScheduler)
        .first()
        .subscribe();
  }
Exemple #2
0
  /**
   * Searches the view port on the live map with Strategy.AUTO
   *
   * @param viewport Area to search
   * @param tokens Live map tokens
   */
  @NonNull
  public static SearchResult searchByViewport(final Viewport viewport, final MapTokens tokens) {
    final int speed =
        (int) Sensors.getInstance().currentGeo().getSpeed() * 60 * 60 / 1000; // in km/h
    LivemapStrategy strategy = Settings.getLiveMapStrategy();
    if (strategy == LivemapStrategy.AUTO) {
      strategy = speed >= 30 ? LivemapStrategy.FAST : LivemapStrategy.DETAILED;
    }

    final SearchResult result = searchByViewport(viewport, tokens, strategy);

    if (Settings.isDebug()) {
      final StringBuilder text =
          new StringBuilder(Formatter.SEPARATOR)
              .append(strategy.getL10n())
              .append(Formatter.SEPARATOR)
              .append(Units.getSpeed(speed));
      result.setUrl(result.getUrl() + text);
    }

    return result;
  }