X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FFileNameHelper.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FFileNameHelper.java;h=0000000000000000000000000000000000000000;hp=980a838d90bf0d4b2055fed9cc39cf107e849e0a;hb=d4f39c36beb5e6c3568a1e075274ad66defd8e8e;hpb=f825cc15f0383acce10bb16443e027edb869a11e diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/FileNameHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/FileNameHelper.java deleted file mode 100644 index 980a838d..00000000 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/FileNameHelper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright © 2019-2020 Soren Stoutner . - * - * This file is part of Privacy Browser . - * - * Privacy Browser is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Privacy Browser is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser. If not, see . - */ - -package com.stoutner.privacybrowser.helpers; - -import android.net.Uri; -import android.os.Environment; - -public class FileNameHelper { - public String convertUriToFileNamePath(Uri Uri) { - // Initialize a file name path string. - String fileNamePath = ""; - - // Convert the URI to a raw file name path. - String rawFileNamePath = Uri.getPath(); - - // Only process the raw file name path if it is not null. - if (rawFileNamePath != null) { - // Check to see if the file name Path includes a valid storage location. - if (rawFileNamePath.contains(":")) { // The path contains a `:`. - // Split the path into the initial content uri and the final path information. - String fileNameContentPath = rawFileNamePath.substring(0, rawFileNamePath.indexOf(":")); - String fileNameFinalPath = rawFileNamePath.substring(rawFileNamePath.indexOf(":") + 1); - - // Check to see if the current file name final patch is a complete, valid path. - if (fileNameFinalPath.startsWith("/storage/emulated/")) { // The existing file name final path is a complete, valid path. - // Use the provided file name path as is. - fileNamePath = fileNameFinalPath; - } else { // The existing file name final path is not a complete, valid path. - // Construct the file name path. - switch (fileNameContentPath) { - // The documents home has a special content path. - case "/document/home": - fileNamePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/" + fileNameFinalPath; - break; - - // Everything else for the primary user should be in `/document/primary`. - case "/document/primary": - fileNamePath = Environment.getExternalStorageDirectory() + "/" + fileNameFinalPath; - break; - - // Just in case, catch everything else and place it in the external storage directory. - default: - fileNamePath = Environment.getExternalStorageDirectory() + "/" + fileNameFinalPath; - break; - } - } - } else { // The path does not contain a `:`. - // Use the raw file name path. - fileNamePath = rawFileNamePath; - } - } - - // Return the file name path string. - return fileNamePath; - } -} \ No newline at end of file