made pgp decrypt stuff a little bit more bearable
This commit is contained in:
parent
37d1a53806
commit
9581dfcde4
|
@ -44,24 +44,24 @@ public final class R {
|
|||
}
|
||||
public static final class id {
|
||||
public static final int account_confirm_password_desc=0x7f0a001c;
|
||||
public static final int account_delete=0x7f0a0035;
|
||||
public static final int account_disable=0x7f0a0036;
|
||||
public static final int account_enable=0x7f0a0037;
|
||||
public static final int account_delete=0x7f0a0037;
|
||||
public static final int account_disable=0x7f0a0038;
|
||||
public static final int account_enable=0x7f0a0039;
|
||||
public static final int account_jid=0x7f0a0000;
|
||||
public static final int account_list=0x7f0a0027;
|
||||
public static final int account_list=0x7f0a0029;
|
||||
public static final int account_password=0x7f0a0019;
|
||||
public static final int account_password_confirm2=0x7f0a001d;
|
||||
public static final int account_status=0x7f0a0002;
|
||||
public static final int account_usetls=0x7f0a001a;
|
||||
public static final int action_accounts=0x7f0a002f;
|
||||
public static final int action_add=0x7f0a002b;
|
||||
public static final int action_add_account=0x7f0a0034;
|
||||
public static final int action_archive=0x7f0a002e;
|
||||
public static final int action_details=0x7f0a002d;
|
||||
public static final int action_refresh_contacts=0x7f0a0039;
|
||||
public static final int action_security=0x7f0a002c;
|
||||
public static final int action_settings=0x7f0a0030;
|
||||
public static final int announce_pgp=0x7f0a0038;
|
||||
public static final int action_accounts=0x7f0a0031;
|
||||
public static final int action_add=0x7f0a002d;
|
||||
public static final int action_add_account=0x7f0a0036;
|
||||
public static final int action_archive=0x7f0a0030;
|
||||
public static final int action_details=0x7f0a002f;
|
||||
public static final int action_refresh_contacts=0x7f0a003b;
|
||||
public static final int action_security=0x7f0a002e;
|
||||
public static final int action_settings=0x7f0a0032;
|
||||
public static final int announce_pgp=0x7f0a003a;
|
||||
public static final int contactList=0x7f0a0006;
|
||||
public static final int contact_display_name=0x7f0a0008;
|
||||
public static final int contact_jid=0x7f0a0009;
|
||||
|
@ -79,20 +79,22 @@ public final class R {
|
|||
public static final int details_receive_presence=0x7f0a0014;
|
||||
public static final int details_send_presence=0x7f0a0013;
|
||||
public static final int edit_account_register_new=0x7f0a001b;
|
||||
public static final int encryption_choice_none=0x7f0a0031;
|
||||
public static final int encryption_choice_otr=0x7f0a0032;
|
||||
public static final int encryption_choice_pgp=0x7f0a0033;
|
||||
public static final int list=0x7f0a0025;
|
||||
public static final int message_body=0x7f0a0029;
|
||||
public static final int message_photo=0x7f0a0028;
|
||||
public static final int message_time=0x7f0a002a;
|
||||
public static final int encryption_choice_none=0x7f0a0033;
|
||||
public static final int encryption_choice_otr=0x7f0a0034;
|
||||
public static final int encryption_choice_pgp=0x7f0a0035;
|
||||
public static final int info_box=0x7f0a0022;
|
||||
public static final int list=0x7f0a0027;
|
||||
public static final int message_body=0x7f0a002b;
|
||||
public static final int message_photo=0x7f0a002a;
|
||||
public static final int message_time=0x7f0a002c;
|
||||
public static final int messages_view=0x7f0a0021;
|
||||
public static final int new_conversation_search=0x7f0a0004;
|
||||
public static final int new_fingerprint=0x7f0a0022;
|
||||
public static final int otr_fingerprint=0x7f0a0023;
|
||||
public static final int new_fingerprint=0x7f0a0023;
|
||||
public static final int otr_fingerprint=0x7f0a0024;
|
||||
public static final int pgp_keyentry=0x7f0a0025;
|
||||
public static final int progressBar1=0x7f0a0003;
|
||||
public static final int selected_conversation=0x7f0a0026;
|
||||
public static final int slidingpanelayout=0x7f0a0024;
|
||||
public static final int selected_conversation=0x7f0a0028;
|
||||
public static final int slidingpanelayout=0x7f0a0026;
|
||||
public static final int textSendButton=0x7f0a0020;
|
||||
public static final int textView1=0x7f0a0018;
|
||||
public static final int textView2=0x7f0a0001;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
package org.sufficientlysecure.keychain.api;
|
||||
|
||||
public final class R {
|
||||
public static final class drawable {
|
||||
public static final int ic_action_cancel_launchersize = 0x7f020003;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int openpgp_install_openkeychain_via = 0x7f050001;
|
||||
public static final int openpgp_list_preference_none = 0x7f050000;
|
||||
}
|
||||
}
|
|
@ -45,6 +45,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/textsend"
|
||||
android:layout_below="@+id/info_box"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="#e5e5e5"
|
||||
tools:listitem="@layout/message_sent"
|
||||
|
@ -53,13 +54,17 @@
|
|||
android:transcriptMode="alwaysScroll"
|
||||
android:listSelector="@android:color/transparent">
|
||||
</ListView>
|
||||
<LinearLayout
|
||||
android:id="@+id/info_box"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<LinearLayout
|
||||
android:id="@+id/new_fingerprint"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignTop="@+id/messages_view"
|
||||
android:background="#cc0000"
|
||||
android:background="#e92727"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
@ -77,11 +82,38 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/otr_fingerprint"
|
||||
android:textColor="#eee"
|
||||
android:text="2674D6A0 0B1421B1 BFC42AEC C56F3719 672437D8"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="14sp"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/pgp_keyentry"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#ffa713"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OpenPGP encrypted messages found"
|
||||
android:textColor="#000"
|
||||
android:textStyle="bold"
|
||||
android:padding="8dp"
|
||||
android:textSize="20sp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#000"
|
||||
android:text="Click here to enter passphrase and decrypt messages"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -13,5 +13,5 @@
|
|||
<string name="just_now">just now</string>
|
||||
<string name="sending">sending…</string>
|
||||
<string name="announce_pgp">Renew PGP announcement</string>
|
||||
<string name="encrypted_message">This message is encrypted. Click to decrypt.</string>
|
||||
<string name="encrypted_message">Decrypting message. please wait…</string>
|
||||
</resources>
|
||||
|
|
|
@ -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(");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue