mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
don't display 'enter password' message if OpenKeychain is not installed. made status messages in chat not selectable
This commit is contained in:
parent
d0a338f814
commit
28b7a6c92a
@ -6,7 +6,7 @@
|
||||
android:padding="8dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout1"
|
||||
android:id="@+id/message_box"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
|
@ -6,6 +6,7 @@
|
||||
android:padding="8dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/message_box"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
|
@ -241,4 +241,5 @@
|
||||
<string name="last_seen_hours">last seen %d hours ago</string>
|
||||
<string name="last_seen_days">last seen %d days ago</string>
|
||||
<string name="never_seen">never seen</string>
|
||||
<string name="install_openkeychain">Encrypted message. Please install OpenKeychain to decrypt.</string>
|
||||
</resources>
|
@ -434,6 +434,8 @@ public class ConversationActivity extends XmppActivity {
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showInstallPgpDialog();
|
||||
}
|
||||
} else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) {
|
||||
selectPresenceToAttachFile(attachmentChoice);
|
||||
@ -568,6 +570,8 @@ public class ConversationActivity extends XmppActivity {
|
||||
announcePgp(conversation.getAccount(),
|
||||
conversation);
|
||||
}
|
||||
} else {
|
||||
showInstallPgpDialog();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -276,6 +276,7 @@ public class ConversationFragment extends Fragment {
|
||||
viewHolder.messageBody.setText(getString(r));
|
||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
|
||||
viewHolder.messageBody.setTextIsSelectable(false);
|
||||
}
|
||||
|
||||
private void displayDecryptionFailed(ViewHolder viewHolder) {
|
||||
@ -286,6 +287,7 @@ public class ConversationFragment extends Fragment {
|
||||
.setText(getString(R.string.decryption_failed));
|
||||
viewHolder.messageBody.setTextColor(0xFFe92727);
|
||||
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||
viewHolder.messageBody.setTextIsSelectable(false);
|
||||
}
|
||||
|
||||
private void displayTextMessage(ViewHolder viewHolder, String text) {
|
||||
@ -301,6 +303,7 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
viewHolder.messageBody.setTextColor(0xff333333);
|
||||
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||
viewHolder.messageBody.setTextIsSelectable(true);
|
||||
}
|
||||
|
||||
private void displayImageMessage(ViewHolder viewHolder,
|
||||
@ -367,6 +370,8 @@ public class ConversationFragment extends Fragment {
|
||||
case SENT:
|
||||
view = (View) inflater.inflate(R.layout.message_sent,
|
||||
null);
|
||||
viewHolder.message_box = (LinearLayout) view
|
||||
.findViewById(R.id.message_box);
|
||||
viewHolder.contact_picture = (ImageView) view
|
||||
.findViewById(R.id.message_photo);
|
||||
viewHolder.contact_picture.setImageBitmap(selfBitmap);
|
||||
@ -383,6 +388,8 @@ public class ConversationFragment extends Fragment {
|
||||
case RECIEVED:
|
||||
view = (View) inflater.inflate(
|
||||
R.layout.message_recieved, null);
|
||||
viewHolder.message_box = (LinearLayout) view
|
||||
.findViewById(R.id.message_box);
|
||||
viewHolder.contact_picture = (ImageView) view
|
||||
.findViewById(R.id.message_photo);
|
||||
|
||||
@ -492,8 +499,20 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
} else {
|
||||
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
if (activity.hasPgp()) {
|
||||
displayInfoMessage(viewHolder,
|
||||
R.string.encrypted_message);
|
||||
} else {
|
||||
displayInfoMessage(viewHolder,
|
||||
R.string.install_openkeychain);
|
||||
viewHolder.message_box.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activity.showInstallPgpDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
displayDecryptionFailed(viewHolder);
|
||||
} else {
|
||||
@ -646,7 +665,7 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
pgpInfo.setVisibility(View.VISIBLE);
|
||||
pgpInfo.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,7 +685,8 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
if (activity.showLastseen()) {
|
||||
Contact contact = conversation.getContact();
|
||||
lastSeenText.setText(UIHelper.lastseen(getActivity(), contact.lastseen.time));
|
||||
lastSeenText.setText(UIHelper.lastseen(getActivity(),
|
||||
contact.lastseen.time));
|
||||
}
|
||||
this.messageList.clear();
|
||||
this.messageList.addAll(this.conversation.getMessages());
|
||||
@ -762,7 +782,8 @@ public class ConversationFragment extends Fragment {
|
||||
new UiCallback<Contact>() {
|
||||
|
||||
@Override
|
||||
public void userInputRequried(PendingIntent pi,Contact contact) {
|
||||
public void userInputRequried(PendingIntent pi,
|
||||
Contact contact) {
|
||||
activity.runIntent(
|
||||
pi,
|
||||
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
|
||||
@ -822,6 +843,8 @@ public class ConversationFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
activity.showInstallPgpDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@ -873,6 +896,7 @@ public class ConversationFragment extends Fragment {
|
||||
|
||||
private static class ViewHolder {
|
||||
|
||||
protected LinearLayout message_box;
|
||||
protected Button download_button;
|
||||
protected ImageView image;
|
||||
protected ImageView indicator;
|
||||
|
@ -279,6 +279,8 @@ public class ManageAccountActivity extends XmppActivity {
|
||||
if (activity.hasPgp()) {
|
||||
mode.finish();
|
||||
announcePgp(selectedAccountForActionMode,null);
|
||||
} else {
|
||||
activity.showInstallPgpDialog();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.mgmt_otr_key) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
|
@ -83,22 +83,23 @@ public abstract class XmppActivity extends Activity {
|
||||
|
||||
if (focus != null) {
|
||||
|
||||
inputManager.hideSoftInputFromWindow(
|
||||
focus.getWindowToken(),
|
||||
inputManager.hideSoftInputFromWindow(focus.getWindowToken(),
|
||||
InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPgp() {
|
||||
if (xmppConnectionService.getPgpEngine()!=null) {
|
||||
return true;
|
||||
} else {
|
||||
return xmppConnectionService.getPgpEngine() != null;
|
||||
}
|
||||
|
||||
public void showInstallPgpDialog() {
|
||||
Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(getString(R.string.openkeychain_required));
|
||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||
builder.setMessage(getText(R.string.openkeychain_required_long));
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
builder.setNeutralButton(getString(R.string.restart), new OnClickListener() {
|
||||
builder.setNeutralButton(getString(R.string.restart),
|
||||
new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@ -106,23 +107,24 @@ public abstract class XmppActivity extends Activity {
|
||||
unbindService(mConnection);
|
||||
xmppConnectionServiceBound = false;
|
||||
}
|
||||
stopService(new Intent(XmppActivity.this, XmppConnectionService.class));
|
||||
stopService(new Intent(XmppActivity.this,
|
||||
XmppConnectionService.class));
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(getString(R.string.install), new OnClickListener() {
|
||||
builder.setPositiveButton(getString(R.string.install),
|
||||
new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Uri uri = Uri.parse("market://details?id=org.sufficientlysecure.keychain");
|
||||
Uri uri = Uri
|
||||
.parse("market://details?id=org.sufficientlysecure.keychain");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
abstract void onBackendConnected();
|
||||
@ -145,13 +147,14 @@ public abstract class XmppActivity extends Activity {
|
||||
ExceptionHelper.init(getApplicationContext());
|
||||
}
|
||||
|
||||
public void switchToConversation(Conversation conversation, String text, boolean newTask) {
|
||||
public void switchToConversation(Conversation conversation, String text,
|
||||
boolean newTask) {
|
||||
Intent viewConversationIntent = new Intent(this,
|
||||
ConversationActivity.class);
|
||||
viewConversationIntent.setAction(Intent.ACTION_VIEW);
|
||||
viewConversationIntent.putExtra(ConversationActivity.CONVERSATION,
|
||||
conversation.getUuid());
|
||||
if (text!=null) {
|
||||
if (text != null) {
|
||||
viewConversationIntent.putExtra(ConversationActivity.TEXT, text);
|
||||
}
|
||||
viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
|
||||
@ -167,23 +170,29 @@ public abstract class XmppActivity extends Activity {
|
||||
}
|
||||
|
||||
protected void announcePgp(Account account, final Conversation conversation) {
|
||||
xmppConnectionService.getPgpEngine().generateSignature(account, "online", new UiCallback<Account>() {
|
||||
xmppConnectionService.getPgpEngine().generateSignature(account,
|
||||
"online", new UiCallback<Account>() {
|
||||
|
||||
@Override
|
||||
public void userInputRequried(PendingIntent pi, Account account) {
|
||||
public void userInputRequried(PendingIntent pi,
|
||||
Account account) {
|
||||
try {
|
||||
startIntentSenderForResult(pi.getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
||||
startIntentSenderForResult(pi.getIntentSender(),
|
||||
REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
||||
} catch (SendIntentException e) {
|
||||
Log.d("xmppService","coulnd start intent for pgp anncouncment");
|
||||
Log.d("xmppService",
|
||||
"coulnd start intent for pgp anncouncment");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void success(Account account) {
|
||||
xmppConnectionService.databaseBackend.updateAccount(account);
|
||||
xmppConnectionService.databaseBackend
|
||||
.updateAccount(account);
|
||||
xmppConnectionService.sendPresence(account);
|
||||
if (conversation!=null) {
|
||||
conversation.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||
if (conversation != null) {
|
||||
conversation
|
||||
.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +208,8 @@ public abstract class XmppActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(XmppActivity.this);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
XmppActivity.this);
|
||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||
builder.setTitle(getString(R.string.error));
|
||||
builder.setMessage(errorCode);
|
||||
|
Loading…
Reference in New Issue
Block a user