Cleanup FileHelper
This commit is contained in:
@@ -265,8 +265,8 @@ public class DecryptListFragment
|
||||
filename = "decrypted" + (ext != null ? "."+ext : "");
|
||||
}
|
||||
|
||||
FileHelper.saveDocument(this, filename, null, metadata.getMimeType(),
|
||||
R.string.title_decrypt_to_file, R.string.specify_file_to_decrypt_to, REQUEST_CODE_OUTPUT);
|
||||
FileHelper.saveDocument(this, filename, metadata.getMimeType(),
|
||||
REQUEST_CODE_OUTPUT);
|
||||
}
|
||||
|
||||
private void saveFile(Uri saveUri) {
|
||||
|
||||
@@ -224,9 +224,8 @@ public class EncryptFilesFragment
|
||||
String targetName =
|
||||
(mEncryptFilenames ? "1" : FileHelper.getFilename(getActivity(), model.inputUri))
|
||||
+ (mUseArmor ? Constants.FILE_EXTENSION_ASC : Constants.FILE_EXTENSION_PGP_MAIN);
|
||||
Uri inputUri = model.inputUri;
|
||||
FileHelper.saveDocument(this, targetName, inputUri,
|
||||
R.string.title_encrypt_to_file, R.string.specify_file_to_encrypt_to, REQUEST_CODE_OUTPUT);
|
||||
FileHelper.saveDocument(this, targetName,
|
||||
REQUEST_CODE_OUTPUT);
|
||||
}
|
||||
|
||||
public void addFile(Intent data) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.linked.resources.GenericHttpsResource;
|
||||
@@ -35,7 +34,6 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URI;
|
||||
@@ -136,8 +134,8 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
|
||||
|
||||
// TODO: not supported on Android < 4.4
|
||||
FileHelper.saveDocument(this,
|
||||
targetName, Uri.fromFile(new File(Constants.Path.APP_DIR, targetName)),
|
||||
"text/plain", R.string.title_decrypt_to_file, R.string.specify_file_to_decrypt_to,
|
||||
targetName,
|
||||
"text/plain",
|
||||
REQUEST_CODE_OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,24 +74,23 @@ import java.text.DecimalFormat;
|
||||
public class FileHelper {
|
||||
|
||||
public static void openDocument(Fragment fragment, Uri last, String mimeType, boolean multiple, int requestCode) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
openDocumentPreKitKat(fragment, last, mimeType, multiple, requestCode);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
openDocumentKitKat(fragment, mimeType, multiple, requestCode);
|
||||
} else {
|
||||
openDocumentPreKitKat(fragment, last, mimeType, multiple, requestCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveDocument(Fragment fragment, String targetName, Uri inputUri,
|
||||
@StringRes int title, @StringRes int message, int requestCode) {
|
||||
saveDocument(fragment, targetName, inputUri, "*/*", title, message, requestCode);
|
||||
public static void saveDocument(Fragment fragment, String targetName, int requestCode) {
|
||||
saveDocument(fragment, targetName, "*/*", requestCode);
|
||||
}
|
||||
|
||||
public static void saveDocument(Fragment fragment, String targetName, Uri inputUri, String mimeType,
|
||||
@StringRes int title, @StringRes int message, int requestCode) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
throw new RuntimeException("saveDocument does not support Android < 4.4!");
|
||||
} else {
|
||||
public static void saveDocument(Fragment fragment, String targetName, String mimeType,
|
||||
int requestCode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
saveDocumentKitKat(fragment, mimeType, targetName, requestCode);
|
||||
} else {
|
||||
throw new RuntimeException("saveDocument does not support Android < 4.4!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user