don't create OpenKeychain dir on startup
This commit is contained in:
@@ -84,14 +84,6 @@ public class KeychainApplication extends Application {
|
||||
}
|
||||
*/
|
||||
|
||||
// Create OpenKeychain directory on sdcard if not existing
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
if (!Constants.Path.APP_DIR.exists() && !Constants.Path.APP_DIR.mkdirs()) {
|
||||
// ignore this for now, it's not crucial
|
||||
// that the directory doesn't exist at this point
|
||||
}
|
||||
}
|
||||
|
||||
brandGlowEffect(getApplicationContext(),
|
||||
FormattingUtils.getColorFromAttr(getApplicationContext(), R.attr.colorPrimary));
|
||||
|
||||
|
||||
@@ -18,6 +18,15 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
@@ -61,14 +70,6 @@ import org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator;
|
||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class BackupCodeFragment extends CryptoOperationFragment<BackupKeyringParcel, ExportResult>
|
||||
implements OnBackStackChangedListener {
|
||||
|
||||
@@ -559,6 +560,11 @@ public class BackupCodeFragment extends CryptoOperationFragment<BackupKeyringPar
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Constants.Path.APP_DIR.mkdirs()) {
|
||||
Notify.create(activity, R.string.snack_backup_error_saving, Style.ERROR).show();
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(Constants.Path.APP_DIR, filename);
|
||||
|
||||
if (!overwrite && file.exists()) {
|
||||
|
||||
@@ -254,7 +254,7 @@ public class BackupRestoreFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void restore() {
|
||||
FileHelper.openDocument(this, null, "*/*", false, REQUEST_CODE_INPUT);
|
||||
FileHelper.openDocument(this, "*/*", false, REQUEST_CODE_INPUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class EncryptDecryptFragment extends Fragment {
|
||||
mDecryptFile.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FileHelper.openDocument(EncryptDecryptFragment.this, null, "*/*", false, REQUEST_CODE_INPUT);
|
||||
FileHelper.openDocument(EncryptDecryptFragment.this, "*/*", false, REQUEST_CODE_INPUT);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -211,9 +211,7 @@ public class EncryptFilesFragment
|
||||
}
|
||||
|
||||
private void addInputUri() {
|
||||
FileHelper.openDocument(EncryptFilesFragment.this, mFilesAdapter.getModelCount() == 0 ?
|
||||
null : mFilesAdapter.getModelItem(mFilesAdapter.getModelCount() - 1).inputUri,
|
||||
"*/*", true, REQUEST_CODE_INPUT);
|
||||
FileHelper.openDocument(EncryptFilesFragment.this, "*/*", true, REQUEST_CODE_INPUT);
|
||||
}
|
||||
|
||||
public void addInputUri(Intent data) {
|
||||
|
||||
@@ -102,8 +102,7 @@ public class ImportKeysFileFragment extends Fragment {
|
||||
// open .asc or .gpg files
|
||||
// setting it to text/plain prevents Cyanogenmod's file manager from selecting asc
|
||||
// or gpg types!
|
||||
FileHelper.openDocument(ImportKeysFileFragment.this,
|
||||
Uri.fromFile(Constants.Path.APP_DIR), "*/*", false, REQUEST_CODE_FILE);
|
||||
FileHelper.openDocument(ImportKeysFileFragment.this, "*/*", false, REQUEST_CODE_FILE);
|
||||
return true;
|
||||
case R.id.menu_import_keys_file_paste:
|
||||
importFromClipboard();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class AddEditSmartPGPAuthorityDialogFragment extends DialogFragment imple
|
||||
mAuthorityAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FileHelper.openDocument(AddEditSmartPGPAuthorityDialogFragment.this, null, "*/*", false,
|
||||
FileHelper.openDocument(AddEditSmartPGPAuthorityDialogFragment.this, "*/*", false,
|
||||
EncryptFilesFragment.REQUEST_CODE_INPUT);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -317,7 +317,7 @@ public class ManageSecurityTokenFragment extends Fragment implements ManageSecur
|
||||
|
||||
@Override
|
||||
public void showFileSelectDialog() {
|
||||
FileHelper.openDocument(this, null, "*/*", false, REQUEST_CODE_OPEN_FILE);
|
||||
FileHelper.openDocument(this, "*/*", false, REQUEST_CODE_OPEN_FILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,26 +100,23 @@ public class FileHelper {
|
||||
fragment.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
public static void openDocument(Fragment fragment, Uri last, String mimeType, boolean multiple, int requestCode) {
|
||||
public static void openDocument(Fragment fragment, String mimeType, boolean multiple, int requestCode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
|
||||
&& hasOpenDocumentIntent(fragment.getContext())) {
|
||||
openDocumentKitKat(fragment, mimeType, multiple, requestCode);
|
||||
} else {
|
||||
openDocumentPreKitKat(fragment, last, mimeType, multiple, requestCode);
|
||||
openDocumentPreKitKat(fragment, mimeType, multiple, requestCode);
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens the preferred installed file manager on Android and shows a toast
|
||||
* if no manager is installed. */
|
||||
private static void openDocumentPreKitKat(
|
||||
Fragment fragment, Uri last, String mimeType, boolean multiple, int requestCode) {
|
||||
|
||||
private static void openDocumentPreKitKat(Fragment fragment, String mimeType, boolean multiple, int requestCode) {
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
|
||||
}
|
||||
intent.setData(last);
|
||||
intent.setType(mimeType);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user