コード例 #1
0
ファイル: OsmandSettings.java プロジェクト: Boris-de/Osmand
  public ITileSource getTileSourceByName(String tileName, boolean warnWhenSelected) {
    if (tileName == null || tileName.length() == 0) {
      return null;
    }
    List<TileSourceTemplate> knownTemplates = TileSourceManager.getKnownSourceTemplates();
    File tPath = extendOsmandPath(ResourceManager.TILES_PATH);
    File dir = new File(tPath, tileName);
    if (!dir.exists()) {
      TileSourceTemplate ret = checkAmongAvailableTileSources(dir, knownTemplates);
      if (ret != null) {
        return ret;
      }
      // try to find among other templates
      ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates());
      if (ret != null) {
        return ret;
      }
    } else if (tileName.endsWith(SQLiteTileSource.EXT)) {
      return new SQLiteTileSource(dir, knownTemplates);
    } else if (dir.isDirectory() && !dir.getName().startsWith(".")) {
      TileSourceTemplate t = TileSourceManager.createTileSourceTemplate(dir);
      if (warnWhenSelected && !t.isRuleAcceptable()) {
        Toast.makeText(
                ctx,
                ctx.getString(R.string.warning_tile_layer_not_downloadable, dir.getName()),
                Toast.LENGTH_SHORT)
            .show();
      }
      if (!TileSourceManager.isTileSourceMetaInfoExist(dir)) {
        TileSourceTemplate ret = checkAmongAvailableTileSources(dir, knownTemplates);
        if (ret != null) {
          t = ret;
        } else {
          // try to find among other templates
          ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates());
          if (ret != null) {
            t = ret;
          }
        }
      }

      return t;
    }
    return null;
  }
コード例 #2
0
ファイル: LocalIndexHelper.java プロジェクト: AmZaf/Osmand
 public void updateDescription(LocalIndexInfo info) {
   File f = new File(info.getPathToData());
   if (info.getType() == LocalIndexType.MAP_DATA) {
     Map<String, String> ifns = app.getResourceManager().getIndexFileNames();
     if (ifns.containsKey(info.getFileName())) {
       try {
         Date dt = app.getResourceManager().getDateFormat().parse(ifns.get(info.getFileName()));
         info.setDescription(getInstalledDate(dt.getTime(), null));
       } catch (ParseException e) {
         e.printStackTrace();
       }
     } else {
       info.setDescription(getInstalledDate(f));
     }
   } else if (info.getType() == LocalIndexType.TILES_DATA) {
     ITileSource template;
     if (f.isDirectory() && TileSourceManager.isTileSourceMetaInfoExist(f)) {
       template = TileSourceManager.createTileSourceTemplate(new File(info.getPathToData()));
     } else if (f.isFile() && f.getName().endsWith(SQLiteTileSource.EXT)) {
       template = new SQLiteTileSource(app, f, TileSourceManager.getKnownSourceTemplates());
     } else {
       return;
     }
     String descr = "";
     descr += app.getString(R.string.local_index_tile_data_name, template.getName());
     if (template.getExpirationTimeMinutes() >= 0) {
       descr +=
           "\n"
               + app.getString(
                   R.string.local_index_tile_data_expire, template.getExpirationTimeMinutes());
     }
     info.setDescription(descr);
   } else if (info.getType() == LocalIndexType.SRTM_DATA) {
     info.setDescription(app.getString(R.string.download_srtm_maps));
   } else if (info.getType() == LocalIndexType.WIKI_DATA) {
     info.setDescription(getInstalledDate(f));
   } else if (info.getType() == LocalIndexType.TTS_VOICE_DATA) {
     info.setDescription(getInstalledDate(f));
   } else if (info.getType() == LocalIndexType.DEACTIVATED) {
     info.setDescription(getInstalledDate(f));
   } else if (info.getType() == LocalIndexType.VOICE_DATA) {
     info.setDescription(getInstalledDate(f));
   }
 }