diff options
Diffstat (limited to 'src/org/thialfihar/android/apg/Apg.java')
-rw-r--r-- | src/org/thialfihar/android/apg/Apg.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java index e860bddc8..001fa138f 100644 --- a/src/org/thialfihar/android/apg/Apg.java +++ b/src/org/thialfihar/android/apg/Apg.java @@ -108,6 +108,7 @@ public class Apg { public static final String ENCRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.ENCRYPT_AND_RETURN";
public static final String SELECT_PUBLIC_KEYS = "org.thialfihar.android.apg.intent.SELECT_PUBLIC_KEYS";
public static final String SELECT_SECRET_KEY = "org.thialfihar.android.apg.intent.SELECT_SECRET_KEY";
+ public static final String IMPORT = "org.thialfihar.android.apg.intent.IMPORT";
}
public static final String EXTRA_TEXT = "text";
@@ -573,7 +574,8 @@ public class Apg { progress.setProgress(R.string.progress_done, 100, 100);
}
- public static Bundle importKeyRings(Activity context, int type, String filename,
+ public static Bundle importKeyRings(Activity context, int type,
+ InputStream inStream, long dataLength,
ProgressDialogUpdater progress)
throws GeneralException, FileNotFoundException, PGPException, IOException {
Bundle returnData = new Bundle();
@@ -588,9 +590,7 @@ public class Apg { throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));
}
- FileInputStream fileIn = new FileInputStream(filename);
- long fileSize = new File(filename).length();
- PositionAwareInputStream progressIn = new PositionAwareInputStream(fileIn);
+ PositionAwareInputStream progressIn = new PositionAwareInputStream(inStream);
// need to have access to the bufferedInput, so we can reuse it for the possible
// PGPObject chunks after the first one, e.g. files with several consecutive ASCII
// armour blocks
@@ -636,7 +636,7 @@ public class Apg { } else if (retValue == Id.return_value.ok) {
++newKeys;
}
- progress.setProgress((int)(100 * progressIn.position() / fileSize), 100);
+ progress.setProgress((int)(100 * progressIn.position() / dataLength), 100);
obj = objectFactory.nextObject();
}
}
@@ -653,7 +653,7 @@ public class Apg { }
public static Bundle exportKeyRings(Activity context, Vector<Integer> keyRingIds,
- String filename,
+ OutputStream outStream,
ProgressDialogUpdater progress)
throws GeneralException, FileNotFoundException, PGPException, IOException {
Bundle returnData = new Bundle();
@@ -667,8 +667,7 @@ public class Apg { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));
}
- FileOutputStream fileOut = new FileOutputStream(new File(filename), false);
- ArmoredOutputStream out = new ArmoredOutputStream(fileOut);
+ ArmoredOutputStream out = new ArmoredOutputStream(outStream);
int numKeys = 0;
for (int i = 0; i < keyRingIds.size(); ++i) {
@@ -689,7 +688,6 @@ public class Apg { ++numKeys;
}
out.close();
- fileOut.close();
returnData.putInt("exported", numKeys);
progress.setProgress(R.string.progress_done, 100, 100);
|