aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-28 02:58:15 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-28 02:58:15 +0100
commit9581dfcde4720ede5c9fa5ca97210504b6609b3f (patch)
tree58429691f2cf772c5b7c351a045936c0603627f5 /src/de/gultsch/chat
parent37d1a5380634471b11c828cf265d4a39e818a1c1 (diff)
made pgp decrypt stuff a little bit more bearable
Diffstat (limited to 'src/de/gultsch/chat')
-rw-r--r--src/de/gultsch/chat/services/XmppConnectionService.java26
-rw-r--r--src/de/gultsch/chat/ui/ConversationActivity.java12
-rw-r--r--src/de/gultsch/chat/ui/ConversationFragment.java32
3 files changed, 45 insertions, 25 deletions
diff --git a/src/de/gultsch/chat/services/XmppConnectionService.java b/src/de/gultsch/chat/services/XmppConnectionService.java
index a2b85f62..4e75f7aa 100644
--- a/src/de/gultsch/chat/services/XmppConnectionService.java
+++ b/src/de/gultsch/chat/services/XmppConnectionService.java
@@ -1,39 +1,21 @@
package de.gultsch.chat.services;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
-import java.util.Set;
import org.json.JSONException;
-import org.openintents.openpgp.IOpenPgpService;
-import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection;
-import org.openintents.openpgp.OpenPgpError;
import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
-import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus;
import de.gultsch.chat.crypto.PgpEngine;
import de.gultsch.chat.crypto.PgpEngine.OpenPgpException;
-import de.gultsch.chat.crypto.PgpEngine.UserInputRequiredException;
import de.gultsch.chat.entities.Account;
import de.gultsch.chat.entities.Contact;
import de.gultsch.chat.entities.Conversation;
@@ -67,9 +49,7 @@ import android.database.DatabaseUtils;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
-import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
-import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
import android.util.Log;
@@ -307,6 +287,11 @@ public class XmppConnectionService extends Service {
}
private void processRosterItems(Account account, Element elements) {
+ String version = elements.getAttribute("ver");
+ if (version != null) {
+ account.setRosterVersion(version);
+ databaseBackend.updateAccount(account);
+ }
for (Element item : elements.getChildren()) {
if (item.getName().equals("item")) {
String jid = item.getAttribute("jid");
@@ -549,7 +534,6 @@ public class XmppConnectionService extends Service {
IqPacket packet) {
Element roster = packet.findChild("query");
if (roster != null) {
- String version = roster.getAttribute("ver");
processRosterItems(account, roster);
StringBuilder mWhere = new StringBuilder();
mWhere.append("jid NOT IN(");
diff --git a/src/de/gultsch/chat/ui/ConversationActivity.java b/src/de/gultsch/chat/ui/ConversationActivity.java
index 7fbc432e..88d30bc5 100644
--- a/src/de/gultsch/chat/ui/ConversationActivity.java
+++ b/src/de/gultsch/chat/ui/ConversationActivity.java
@@ -469,4 +469,16 @@ public class ConversationActivity extends XmppActivity {
}
}
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (resultCode == RESULT_OK) {
+ if (requestCode == REQUEST_DECRYPT_PGP) {
+ ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager().findFragmentByTag("conversation");
+ if (selectedFragment!=null) {
+ selectedFragment.hidePgpPassphraseBox();
+ }
+ }
+ }
+ }
}
diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java
index 099f2253..af07fdbb 100644
--- a/src/de/gultsch/chat/ui/ConversationFragment.java
+++ b/src/de/gultsch/chat/ui/ConversationFragment.java
@@ -43,7 +43,6 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ImageButton;
import android.widget.ImageView;
-import android.widget.ProgressBar;
import android.widget.TextView;
public class ConversationFragment extends Fragment {
@@ -95,6 +94,11 @@ public class ConversationFragment extends Fragment {
}
}
};
+ private LinearLayout pgpInfo;
+
+ public void hidePgpPassphraseBox() {
+ pgpInfo.setVisibility(View.GONE);
+ }
public void updateChatMsgHint() {
if (conversation.getMode() == Conversation.MODE_MULTI) {
@@ -132,6 +136,9 @@ public class ConversationFragment extends Fragment {
.findViewById(R.id.textSendButton);
sendButton.setOnClickListener(this.sendMsgListener);
+ pgpInfo = (LinearLayout) view.findViewById(R.id.pgp_keyentry);
+ pgpInfo.setOnClickListener(clickToDecryptListener);
+
messagesView = (ListView) view.findViewById(R.id.messages_view);
messageListAdapter = new ArrayAdapter<Message>(this.getActivity()
@@ -231,11 +238,11 @@ public class ConversationFragment extends Fragment {
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
viewHolder.messageBody.setText(getString(R.string.encrypted_message));
viewHolder.messageBody.setTextColor(0xff33B5E5);
- viewHolder.messageBody.setOnClickListener(clickToDecryptListener);
+ viewHolder.messageBody.setTypeface(null,Typeface.ITALIC);
} else {
viewHolder.messageBody.setText(body.trim());
viewHolder.messageBody.setTextColor(0xff000000);
- viewHolder.messageBody.setOnClickListener(null);
+ viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
}
}
if (item.getStatus() == Message.STATUS_UNSEND) {
@@ -536,7 +543,7 @@ public class ConversationFragment extends Fragment {
@Override
protected Boolean doInBackground(Message... params) {
- XmppActivity activity = (XmppActivity) getActivity();
+ final ConversationActivity activity = (ConversationActivity) getActivity();
askForPassphraseIntent = null;
for(int i = 0; i < params.length; ++i) {
if (params[i].getEncryption() == Message.ENCRYPTION_PGP) {
@@ -550,6 +557,14 @@ public class ConversationFragment extends Fragment {
decrypted = activity.xmppConnectionService.getPgpEngine().decrypt(body);
} catch (UserInputRequiredException e) {
askForPassphraseIntent = e.getPendingIntent().getIntentSender();
+ activity.runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ pgpInfo.setVisibility(View.VISIBLE);
+ }
+ });
+
return false;
} catch (OpenPgpException e) {
@@ -570,6 +585,15 @@ public class ConversationFragment extends Fragment {
});
}
}
+ if (activity!=null) {
+ activity.runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ activity.updateConversationList();
+ }
+ });
+ }
}
return true;
}