aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/ui
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/ui
parent37d1a5380634471b11c828cf265d4a39e818a1c1 (diff)
made pgp decrypt stuff a little bit more bearable
Diffstat (limited to 'src/de/gultsch/chat/ui')
-rw-r--r--src/de/gultsch/chat/ui/ConversationActivity.java12
-rw-r--r--src/de/gultsch/chat/ui/ConversationFragment.java32
2 files changed, 40 insertions, 4 deletions
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;
}