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" >
|
android:padding="8dp" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayout1"
|
android:id="@+id/message_box"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
android:padding="8dp" >
|
android:padding="8dp" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/message_box"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
|
|
|
@ -241,4 +241,5 @@
|
||||||
<string name="last_seen_hours">last seen %d hours ago</string>
|
<string name="last_seen_hours">last seen %d hours ago</string>
|
||||||
<string name="last_seen_days">last seen %d days ago</string>
|
<string name="last_seen_days">last seen %d days ago</string>
|
||||||
<string name="never_seen">never seen</string>
|
<string name="never_seen">never seen</string>
|
||||||
|
<string name="install_openkeychain">Encrypted message. Please install OpenKeychain to decrypt.</string>
|
||||||
</resources>
|
</resources>
|
|
@ -434,6 +434,8 @@ public class ConversationActivity extends XmppActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
showInstallPgpDialog();
|
||||||
}
|
}
|
||||||
} else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) {
|
} else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) {
|
||||||
selectPresenceToAttachFile(attachmentChoice);
|
selectPresenceToAttachFile(attachmentChoice);
|
||||||
|
@ -568,6 +570,8 @@ public class ConversationActivity extends XmppActivity {
|
||||||
announcePgp(conversation.getAccount(),
|
announcePgp(conversation.getAccount(),
|
||||||
conversation);
|
conversation);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
showInstallPgpDialog();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -276,6 +276,7 @@ public class ConversationFragment extends Fragment {
|
||||||
viewHolder.messageBody.setText(getString(r));
|
viewHolder.messageBody.setText(getString(r));
|
||||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||||
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
|
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
|
||||||
|
viewHolder.messageBody.setTextIsSelectable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayDecryptionFailed(ViewHolder viewHolder) {
|
private void displayDecryptionFailed(ViewHolder viewHolder) {
|
||||||
|
@ -286,6 +287,7 @@ public class ConversationFragment extends Fragment {
|
||||||
.setText(getString(R.string.decryption_failed));
|
.setText(getString(R.string.decryption_failed));
|
||||||
viewHolder.messageBody.setTextColor(0xFFe92727);
|
viewHolder.messageBody.setTextColor(0xFFe92727);
|
||||||
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||||
|
viewHolder.messageBody.setTextIsSelectable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayTextMessage(ViewHolder viewHolder, String text) {
|
private void displayTextMessage(ViewHolder viewHolder, String text) {
|
||||||
|
@ -301,6 +303,7 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
viewHolder.messageBody.setTextColor(0xff333333);
|
viewHolder.messageBody.setTextColor(0xff333333);
|
||||||
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||||
|
viewHolder.messageBody.setTextIsSelectable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayImageMessage(ViewHolder viewHolder,
|
private void displayImageMessage(ViewHolder viewHolder,
|
||||||
|
@ -367,6 +370,8 @@ public class ConversationFragment extends Fragment {
|
||||||
case SENT:
|
case SENT:
|
||||||
view = (View) inflater.inflate(R.layout.message_sent,
|
view = (View) inflater.inflate(R.layout.message_sent,
|
||||||
null);
|
null);
|
||||||
|
viewHolder.message_box = (LinearLayout) view
|
||||||
|
.findViewById(R.id.message_box);
|
||||||
viewHolder.contact_picture = (ImageView) view
|
viewHolder.contact_picture = (ImageView) view
|
||||||
.findViewById(R.id.message_photo);
|
.findViewById(R.id.message_photo);
|
||||||
viewHolder.contact_picture.setImageBitmap(selfBitmap);
|
viewHolder.contact_picture.setImageBitmap(selfBitmap);
|
||||||
|
@ -383,6 +388,8 @@ public class ConversationFragment extends Fragment {
|
||||||
case RECIEVED:
|
case RECIEVED:
|
||||||
view = (View) inflater.inflate(
|
view = (View) inflater.inflate(
|
||||||
R.layout.message_recieved, null);
|
R.layout.message_recieved, null);
|
||||||
|
viewHolder.message_box = (LinearLayout) view
|
||||||
|
.findViewById(R.id.message_box);
|
||||||
viewHolder.contact_picture = (ImageView) view
|
viewHolder.contact_picture = (ImageView) view
|
||||||
.findViewById(R.id.message_photo);
|
.findViewById(R.id.message_photo);
|
||||||
|
|
||||||
|
@ -492,8 +499,20 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
|
if (activity.hasPgp()) {
|
||||||
displayInfoMessage(viewHolder,
|
displayInfoMessage(viewHolder,
|
||||||
R.string.encrypted_message);
|
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) {
|
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||||
displayDecryptionFailed(viewHolder);
|
displayDecryptionFailed(viewHolder);
|
||||||
} else {
|
} else {
|
||||||
|
@ -646,7 +665,7 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pgpInfo.setVisibility(View.VISIBLE);
|
pgpInfo.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +685,8 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
if (activity.showLastseen()) {
|
if (activity.showLastseen()) {
|
||||||
Contact contact = conversation.getContact();
|
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.clear();
|
||||||
this.messageList.addAll(this.conversation.getMessages());
|
this.messageList.addAll(this.conversation.getMessages());
|
||||||
|
@ -762,7 +782,8 @@ public class ConversationFragment extends Fragment {
|
||||||
new UiCallback<Contact>() {
|
new UiCallback<Contact>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi,Contact contact) {
|
public void userInputRequried(PendingIntent pi,
|
||||||
|
Contact contact) {
|
||||||
activity.runIntent(
|
activity.runIntent(
|
||||||
pi,
|
pi,
|
||||||
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
|
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 {
|
private static class ViewHolder {
|
||||||
|
|
||||||
|
protected LinearLayout message_box;
|
||||||
protected Button download_button;
|
protected Button download_button;
|
||||||
protected ImageView image;
|
protected ImageView image;
|
||||||
protected ImageView indicator;
|
protected ImageView indicator;
|
||||||
|
|
|
@ -279,6 +279,8 @@ public class ManageAccountActivity extends XmppActivity {
|
||||||
if (activity.hasPgp()) {
|
if (activity.hasPgp()) {
|
||||||
mode.finish();
|
mode.finish();
|
||||||
announcePgp(selectedAccountForActionMode,null);
|
announcePgp(selectedAccountForActionMode,null);
|
||||||
|
} else {
|
||||||
|
activity.showInstallPgpDialog();
|
||||||
}
|
}
|
||||||
} else if (item.getItemId() == R.id.mgmt_otr_key) {
|
} else if (item.getItemId() == R.id.mgmt_otr_key) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
|
|
@ -83,22 +83,23 @@ public abstract class XmppActivity extends Activity {
|
||||||
|
|
||||||
if (focus != null) {
|
if (focus != null) {
|
||||||
|
|
||||||
inputManager.hideSoftInputFromWindow(
|
inputManager.hideSoftInputFromWindow(focus.getWindowToken(),
|
||||||
focus.getWindowToken(),
|
|
||||||
InputMethodManager.HIDE_NOT_ALWAYS);
|
InputMethodManager.HIDE_NOT_ALWAYS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPgp() {
|
public boolean hasPgp() {
|
||||||
if (xmppConnectionService.getPgpEngine()!=null) {
|
return xmppConnectionService.getPgpEngine() != null;
|
||||||
return true;
|
}
|
||||||
} else {
|
|
||||||
|
public void showInstallPgpDialog() {
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(getString(R.string.openkeychain_required));
|
builder.setTitle(getString(R.string.openkeychain_required));
|
||||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
builder.setMessage(getText(R.string.openkeychain_required_long));
|
builder.setMessage(getText(R.string.openkeychain_required_long));
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
builder.setNeutralButton(getString(R.string.restart), new OnClickListener() {
|
builder.setNeutralButton(getString(R.string.restart),
|
||||||
|
new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -106,23 +107,24 @@ public abstract class XmppActivity extends Activity {
|
||||||
unbindService(mConnection);
|
unbindService(mConnection);
|
||||||
xmppConnectionServiceBound = false;
|
xmppConnectionServiceBound = false;
|
||||||
}
|
}
|
||||||
stopService(new Intent(XmppActivity.this, XmppConnectionService.class));
|
stopService(new Intent(XmppActivity.this,
|
||||||
|
XmppConnectionService.class));
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(getString(R.string.install), new OnClickListener() {
|
builder.setPositiveButton(getString(R.string.install),
|
||||||
|
new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
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);
|
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void onBackendConnected();
|
abstract void onBackendConnected();
|
||||||
|
@ -145,7 +147,8 @@ public abstract class XmppActivity extends Activity {
|
||||||
ExceptionHelper.init(getApplicationContext());
|
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,
|
Intent viewConversationIntent = new Intent(this,
|
||||||
ConversationActivity.class);
|
ConversationActivity.class);
|
||||||
viewConversationIntent.setAction(Intent.ACTION_VIEW);
|
viewConversationIntent.setAction(Intent.ACTION_VIEW);
|
||||||
|
@ -167,23 +170,29 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void announcePgp(Account account, final Conversation conversation) {
|
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
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi, Account account) {
|
public void userInputRequried(PendingIntent pi,
|
||||||
|
Account account) {
|
||||||
try {
|
try {
|
||||||
startIntentSenderForResult(pi.getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
startIntentSenderForResult(pi.getIntentSender(),
|
||||||
|
REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
||||||
} catch (SendIntentException e) {
|
} catch (SendIntentException e) {
|
||||||
Log.d("xmppService","coulnd start intent for pgp anncouncment");
|
Log.d("xmppService",
|
||||||
|
"coulnd start intent for pgp anncouncment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success(Account account) {
|
public void success(Account account) {
|
||||||
xmppConnectionService.databaseBackend.updateAccount(account);
|
xmppConnectionService.databaseBackend
|
||||||
|
.updateAccount(account);
|
||||||
xmppConnectionService.sendPresence(account);
|
xmppConnectionService.sendPresence(account);
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
conversation.setNextEncryption(Message.ENCRYPTION_PGP);
|
conversation
|
||||||
|
.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +208,8 @@ public abstract class XmppActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
builder.setTitle(getString(R.string.error));
|
builder.setTitle(getString(R.string.error));
|
||||||
builder.setMessage(errorCode);
|
builder.setMessage(errorCode);
|
||||||
|
|
Loading…
Reference in a new issue