@Test public void getRelativeMapLayerPathTest() { assertThat(storagePathProvider.getRelativeMapLayerPath(null), is(nullValue())); assertThat(storagePathProvider.getRelativeMapLayerPath(""), is("")); assertThat(storagePathProvider.getRelativeMapLayerPath("countries/countries-raster.mbtiles"), is("countries/countries-raster.mbtiles")); assertThat(storagePathProvider.getRelativeMapLayerPath("/sdcard/odk/layers/countries/countries-raster.mbtiles"), is("countries/countries-raster.mbtiles")); assertThat(storagePathProvider.getRelativeMapLayerPath("/storage/emulated/0/Android/data/org.odk.collect.android/files/layers/countries/countries-raster.mbtiles"), is("countries/countries-raster.mbtiles")); }
@SuppressWarnings("PMD.DoNotHardCodeSDCard") public String getRelativeMapLayerPath(String path) { if (path == null) { return null; } if (path.startsWith("/sdcard/odk/layers")) { return path.substring("/sdcard/odk/layers".length() + 1); } else if (path.startsWith(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } else if (path.startsWith(getScopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getScopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } return path; }
StoragePathProvider { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public String getRelativeMapLayerPath(String path) { if (path == null) { return null; } if (path.startsWith("/sdcard/odk/layers")) { return path.substring("/sdcard/odk/layers".length() + 1); } else if (path.startsWith(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } else if (path.startsWith(getScopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getScopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } return path; } }
StoragePathProvider { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public String getRelativeMapLayerPath(String path) { if (path == null) { return null; } if (path.startsWith("/sdcard/odk/layers")) { return path.substring("/sdcard/odk/layers".length() + 1); } else if (path.startsWith(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } else if (path.startsWith(getScopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getScopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } return path; } StoragePathProvider();  StoragePathProvider(StorageStateProvider storageStateProvider); }
StoragePathProvider { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public String getRelativeMapLayerPath(String path) { if (path == null) { return null; } if (path.startsWith("/sdcard/odk/layers")) { return path.substring("/sdcard/odk/layers".length() + 1); } else if (path.startsWith(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } else if (path.startsWith(getScopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getScopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } return path; } StoragePathProvider();  StoragePathProvider(StorageStateProvider storageStateProvider); String[] getOdkDirPaths(); String getScopedStorageRootDirPath(); String getUnscopedStorageRootDirPath(); String getUnscopedStorageDirPath(StorageSubdirectory subdirectory); String getDirPath(StorageSubdirectory subdirectory); String getStorageRootDirPath(); String getTmpFilePath(); String getTmpDrawFilePath(); String getInstanceDbPath(String filePath); String getAbsoluteInstanceFilePath(String filePath); String getFormDbPath(String filePath); String getAbsoluteFormFilePath(String filePath); String getCacheDbPath(String filePath); String getAbsoluteCacheFilePath(String filePath); String getRelativeFilePath(String dirPath, String filePath); @SuppressWarnings("PMD.DoNotHardCodeSDCard") String getRelativeMapLayerPath(String path); String getAbsoluteOfflineMapLayerPath(String path); }
StoragePathProvider { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public String getRelativeMapLayerPath(String path) { if (path == null) { return null; } if (path.startsWith("/sdcard/odk/layers")) { return path.substring("/sdcard/odk/layers".length() + 1); } else if (path.startsWith(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getUnscopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } else if (path.startsWith(getScopedStorageDirPath(StorageSubdirectory.LAYERS))) { return path.substring(getScopedStorageDirPath(StorageSubdirectory.LAYERS).length() + 1); } return path; } StoragePathProvider();  StoragePathProvider(StorageStateProvider storageStateProvider); String[] getOdkDirPaths(); String getScopedStorageRootDirPath(); String getUnscopedStorageRootDirPath(); String getUnscopedStorageDirPath(StorageSubdirectory subdirectory); String getDirPath(StorageSubdirectory subdirectory); String getStorageRootDirPath(); String getTmpFilePath(); String getTmpDrawFilePath(); String getInstanceDbPath(String filePath); String getAbsoluteInstanceFilePath(String filePath); String getFormDbPath(String filePath); String getAbsoluteFormFilePath(String filePath); String getCacheDbPath(String filePath); String getAbsoluteCacheFilePath(String filePath); String getRelativeFilePath(String dirPath, String filePath); @SuppressWarnings("PMD.DoNotHardCodeSDCard") String getRelativeMapLayerPath(String path); String getAbsoluteOfflineMapLayerPath(String path);  }