Export is cancellable now

This commit is contained in:
grait
2014-03-11 01:37:16 +05:30
parent 217f4a1cef
commit 3f649d4458
3 changed files with 52 additions and 16 deletions

View File

@@ -73,7 +73,7 @@ import android.os.RemoteException;
* data from the activities or other apps, queues these intents, executes them, and stops itself
* after doing them.
*/
public class KeychainIntentService extends IntentService implements ProgressDialogUpdater {
public class KeychainIntentService extends IntentService implements ProgressDialogUpdater, PgpImportExport.KeychainServiceListener {
/* extras that can be given by intent */
public static final String EXTRA_MESSENGER = "messenger";
@@ -712,10 +712,15 @@ public class KeychainIntentService extends IntentService implements ProgressDial
Bundle resultData;
PgpImportExport pgpImportExport = new PgpImportExport(this, this);
PgpImportExport pgpImportExport = new PgpImportExport(this, this, this);
resultData = pgpImportExport
.exportKeyRings(keyRingRowIds, keyType, outStream);
if(mIsCanceled){
boolean isDeleted = new File(outputFile).delete();
}
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
} catch (Exception e) {
sendErrorToHandler(e);
@@ -903,4 +908,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial
public void setProgress(int progress, int max) {
setProgress(null, progress, max);
}
@Override
public boolean hasServiceStopped() {
return mIsCanceled;
}
}