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(),
|
brandGlowEffect(getApplicationContext(),
|
||||||
FormattingUtils.getColorFromAttr(getApplicationContext(), R.attr.colorPrimary));
|
FormattingUtils.getColorFromAttr(getApplicationContext(), R.attr.colorPrimary));
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,15 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
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.ArgbEvaluator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
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.FileHelper;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
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>
|
public class BackupCodeFragment extends CryptoOperationFragment<BackupKeyringParcel, ExportResult>
|
||||||
implements OnBackStackChangedListener {
|
implements OnBackStackChangedListener {
|
||||||
|
|
||||||
@@ -559,6 +560,11 @@ public class BackupCodeFragment extends CryptoOperationFragment<BackupKeyringPar
|
|||||||
return;
|
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);
|
File file = new File(Constants.Path.APP_DIR, filename);
|
||||||
|
|
||||||
if (!overwrite && file.exists()) {
|
if (!overwrite && file.exists()) {
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public class BackupRestoreFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void restore() {
|
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() {
|
mDecryptFile.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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() {
|
private void addInputUri() {
|
||||||
FileHelper.openDocument(EncryptFilesFragment.this, mFilesAdapter.getModelCount() == 0 ?
|
FileHelper.openDocument(EncryptFilesFragment.this, "*/*", true, REQUEST_CODE_INPUT);
|
||||||
null : mFilesAdapter.getModelItem(mFilesAdapter.getModelCount() - 1).inputUri,
|
|
||||||
"*/*", true, REQUEST_CODE_INPUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInputUri(Intent data) {
|
public void addInputUri(Intent data) {
|
||||||
|
|||||||
@@ -102,8 +102,7 @@ public class ImportKeysFileFragment extends Fragment {
|
|||||||
// open .asc or .gpg files
|
// open .asc or .gpg files
|
||||||
// setting it to text/plain prevents Cyanogenmod's file manager from selecting asc
|
// setting it to text/plain prevents Cyanogenmod's file manager from selecting asc
|
||||||
// or gpg types!
|
// or gpg types!
|
||||||
FileHelper.openDocument(ImportKeysFileFragment.this,
|
FileHelper.openDocument(ImportKeysFileFragment.this, "*/*", false, REQUEST_CODE_FILE);
|
||||||
Uri.fromFile(Constants.Path.APP_DIR), "*/*", false, REQUEST_CODE_FILE);
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_import_keys_file_paste:
|
case R.id.menu_import_keys_file_paste:
|
||||||
importFromClipboard();
|
importFromClipboard();
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class AddEditSmartPGPAuthorityDialogFragment extends DialogFragment imple
|
|||||||
mAuthorityAdd.setOnClickListener(new View.OnClickListener() {
|
mAuthorityAdd.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
FileHelper.openDocument(AddEditSmartPGPAuthorityDialogFragment.this, null, "*/*", false,
|
FileHelper.openDocument(AddEditSmartPGPAuthorityDialogFragment.this, "*/*", false,
|
||||||
EncryptFilesFragment.REQUEST_CODE_INPUT);
|
EncryptFilesFragment.REQUEST_CODE_INPUT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ public class ManageSecurityTokenFragment extends Fragment implements ManageSecur
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showFileSelectDialog() {
|
public void showFileSelectDialog() {
|
||||||
FileHelper.openDocument(this, null, "*/*", false, REQUEST_CODE_OPEN_FILE);
|
FileHelper.openDocument(this, "*/*", false, REQUEST_CODE_OPEN_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -100,26 +100,23 @@ public class FileHelper {
|
|||||||
fragment.startActivityForResult(intent, requestCode);
|
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
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
|
||||||
&& hasOpenDocumentIntent(fragment.getContext())) {
|
&& hasOpenDocumentIntent(fragment.getContext())) {
|
||||||
openDocumentKitKat(fragment, mimeType, multiple, requestCode);
|
openDocumentKitKat(fragment, mimeType, multiple, requestCode);
|
||||||
} else {
|
} else {
|
||||||
openDocumentPreKitKat(fragment, last, mimeType, multiple, requestCode);
|
openDocumentPreKitKat(fragment, mimeType, multiple, requestCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Opens the preferred installed file manager on Android and shows a toast
|
/** Opens the preferred installed file manager on Android and shows a toast
|
||||||
* if no manager is installed. */
|
* if no manager is installed. */
|
||||||
private static void openDocumentPreKitKat(
|
private static void openDocumentPreKitKat(Fragment fragment, String mimeType, boolean multiple, int requestCode) {
|
||||||
Fragment fragment, Uri last, String mimeType, boolean multiple, int requestCode) {
|
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
|
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
|
||||||
}
|
}
|
||||||
intent.setData(last);
|
|
||||||
intent.setType(mimeType);
|
intent.setType(mimeType);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user