android-go/examples/pgp/PgpConnect.java

62 lines
1.8 KiB
Java

package st.wow.git.pgp;
import java.lang.Runnable;
import java.lang.String;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import android.os.Handler;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.PendingIntent;
import android.content.IntentSender;
import android.content.IntentSender.OnFinished;
import android.content.IntentSender.SendIntentException;
import android.os.Bundle;
public class PgpConnect {
//OpenPgpServiceConnection mServiceConnection;
Activity act;
Context ctx;
Handler handler;
PgpFragment frag;
PgpConnect(Activity act) {
act = act;
ctx = act.getApplicationContext();
this.handler = new Handler(ctx.getMainLooper());
//this.mServiceConnection = new OpenPgpServiceConnection(ctx, "org.sufficientlysecure.keychain");
//this.mServiceConnection.bindToService();
final FragmentManager fm = act.getFragmentManager();
frag = new PgpFragment();
handler.post(new Runnable() {
public void run() {
FragmentTransaction ft = fm.beginTransaction();
ft.add(frag, "PgpFragment");
ft.commitNow();
}
});
}
public String Decrypt(byte[] dat, int chint) {
return frag.Decrypt(dat, chint);
}
public String Encrypt(byte[] id, byte[] dat, int chint) {
return frag.Encrypt(id, dat, chint);
}
}