Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ public static DataStorageProvider getInstance() {
private DataStorageProvider() {}

public StoragePoint[] getAvailableStoragePoints() {
if (mCachedStoragePoints.size() != 0) {
if (!mCachedStoragePoints.isEmpty()) {
return mCachedStoragePoints.toArray(new StoragePoint[0]);
}

List<String> paths = new ArrayList<>();
StoragePoint storagePoint;
for (File f : MainApp.getAppContext().getExternalMediaDirs()) {
if (f != null && !paths.contains(f.getAbsolutePath())) {
if (f != null) {
storagePoint = new StoragePoint();
storagePoint.setPath(f.getAbsolutePath());
storagePoint.setDescription(f.getAbsolutePath());
Expand All @@ -64,9 +63,7 @@ public StoragePoint[] getAvailableStoragePoints() {
storagePoint.setPath(MainApp.getAppContext().getFilesDir().getAbsolutePath());
storagePoint.setPrivacyType(StoragePoint.PrivacyType.PRIVATE);
storagePoint.setStorageType(StoragePoint.StorageType.INTERNAL);
if (!paths.contains(MainApp.getAppContext().getFilesDir().getAbsolutePath())) {
mCachedStoragePoints.add(storagePoint);
}
mCachedStoragePoints.add(storagePoint);

// Add external storage directory if available.
if (isExternalStorageWritable()) {
Expand All @@ -80,25 +77,13 @@ public StoragePoint[] getAvailableStoragePoints() {
storagePoint.setDescription(externalFilesDirPath);
storagePoint.setPrivacyType(StoragePoint.PrivacyType.PRIVATE);
storagePoint.setStorageType(StoragePoint.StorageType.EXTERNAL);
if (!paths.contains(externalFilesDirPath)) {
mCachedStoragePoints.add(storagePoint);
}
mCachedStoragePoints.add(storagePoint);
}
}

return mCachedStoragePoints.toArray(new StoragePoint[0]);
}

public String getStorageDescriptionByPath(String path) {
for (StoragePoint s : getAvailableStoragePoints()) {
if (s.getPath().equals(path)) {
return s.getDescription();
}
}
// Fallback to just display complete path
return path;
}

/* Checks if external storage is available for read and write */
public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
Expand Down
Loading