Use user-friendly display path for local backup folder.

Co-authored-by: Greyson Parrelli <greyson@signal.org>
This commit is contained in:
Alex Hart
2026-02-27 13:35:56 -04:00
committed by Greyson Parrelli
parent f439e1f8e3
commit db4c11cd53
3 changed files with 17 additions and 5 deletions

View File

@@ -11,7 +11,6 @@ import android.provider.MediaStore;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import org.signal.core.ui.CoreUiDependencies;
@@ -91,12 +90,15 @@ public class StorageUtil {
return backups;
}
@RequiresApi(24)
public static @NonNull String getDisplayPath(@NonNull Context context, @NonNull Uri uri) {
String lastPathSegment = Objects.requireNonNull(uri.getLastPathSegment());
String backupVolume = lastPathSegment.replaceFirst(":.*", "");
String backupName = lastPathSegment.replaceFirst(".*:", "");
if (Build.VERSION.SDK_INT < 24) {
return backupName;
}
StorageManager storageManager = ContextCompat.getSystemService(context, StorageManager.class);
List<StorageVolume> storageVolumes = storageManager.getStorageVolumes();
StorageVolume storageVolume = null;