aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/message_recieved.xml2
-rw-r--r--res/layout/message_sent.xml1
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java4
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java34
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java174
7 files changed, 130 insertions, 88 deletions
diff --git a/res/layout/message_recieved.xml b/res/layout/message_recieved.xml
index 9f0c41e5..6e4577fb 100644
--- a/res/layout/message_recieved.xml
+++ b/res/layout/message_recieved.xml
@@ -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"
diff --git a/res/layout/message_sent.xml b/res/layout/message_sent.xml
index 990df59b..ebba6ac5 100644
--- a/res/layout/message_sent.xml
+++ b/res/layout/message_sent.xml
@@ -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"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e960bee3..52e14199 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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> \ No newline at end of file
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 0c9c154f..36339bf4 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -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:
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 9cf834a8..3c63a0e5 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -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) {
- displayInfoMessage(viewHolder,
- R.string.encrypted_message);
+ 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;
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index 8a26d907..5f96526a 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -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);
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index ca9ee490..a6cf0588 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -27,15 +27,15 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
public abstract class XmppActivity extends Activity {
-
+
public static final int REQUEST_ANNOUNCE_PGP = 0x73731;
-
+
protected final static String LOGTAG = "xmppService";
-
+
public XmppConnectionService xmppConnectionService;
public boolean xmppConnectionServiceBound = false;
protected boolean handledViewIntent = false;
-
+
protected ServiceConnection mConnection = new ServiceConnection() {
@Override
@@ -51,7 +51,7 @@ public abstract class XmppActivity extends Activity {
xmppConnectionServiceBound = false;
}
};
-
+
@Override
protected void onStart() {
super.onStart();
@@ -59,14 +59,14 @@ public abstract class XmppActivity extends Activity {
connectToBackend();
}
}
-
+
public void connectToBackend() {
Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction("ui");
startService(intent);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
-
+
@Override
protected void onStop() {
super.onStop();
@@ -75,7 +75,7 @@ public abstract class XmppActivity extends Activity {
xmppConnectionServiceBound = false;
}
}
-
+
protected void hideKeyboard() {
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -83,50 +83,52 @@ 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 {
- 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() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (xmppConnectionServiceBound) {
- unbindService(mConnection);
- xmppConnectionServiceBound = false;
+ 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() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (xmppConnectionServiceBound) {
+ unbindService(mConnection);
+ xmppConnectionServiceBound = false;
+ }
+ stopService(new Intent(XmppActivity.this,
+ XmppConnectionService.class));
+ finish();
}
- stopService(new Intent(XmppActivity.this, XmppConnectionService.class));
- finish();
- }
- });
- 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");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
- finish();
- }
- });
- builder.create().show();
- return false;
- }
+ });
+ 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");
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(intent);
+ finish();
+ }
+ });
+ builder.create().show();
}
-
+
abstract void onBackendConnected();
-
+
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
@@ -138,68 +140,76 @@ public abstract class XmppActivity extends Activity {
}
return super.onOptionsItemSelected(item);
}
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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);
if (newTask) {
viewConversationIntent.setFlags(viewConversationIntent.getFlags()
- | Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ | Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
} else {
viewConversationIntent.setFlags(viewConversationIntent.getFlags()
- | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(viewConversationIntent);
}
-
+
protected void announcePgp(Account account, final Conversation conversation) {
- xmppConnectionService.getPgpEngine().generateSignature(account, "online", new UiCallback<Account>() {
-
- @Override
- public void userInputRequried(PendingIntent pi, Account account) {
- try {
- startIntentSenderForResult(pi.getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
- } catch (SendIntentException e) {
- Log.d("xmppService","coulnd start intent for pgp anncouncment");
- }
- }
-
- @Override
- public void success(Account account) {
- xmppConnectionService.databaseBackend.updateAccount(account);
- xmppConnectionService.sendPresence(account);
- if (conversation!=null) {
- conversation.setNextEncryption(Message.ENCRYPTION_PGP);
- }
- }
-
- @Override
- public void error(int error, Account account) {
- displayErrorDialog(error);
- }
- });
+ xmppConnectionService.getPgpEngine().generateSignature(account,
+ "online", new UiCallback<Account>() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi,
+ Account account) {
+ try {
+ startIntentSenderForResult(pi.getIntentSender(),
+ REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
+ } catch (SendIntentException e) {
+ Log.d("xmppService",
+ "coulnd start intent for pgp anncouncment");
+ }
+ }
+
+ @Override
+ public void success(Account account) {
+ xmppConnectionService.databaseBackend
+ .updateAccount(account);
+ xmppConnectionService.sendPresence(account);
+ if (conversation != null) {
+ conversation
+ .setNextEncryption(Message.ENCRYPTION_PGP);
+ }
+ }
+
+ @Override
+ public void error(int error, Account account) {
+ displayErrorDialog(error);
+ }
+ });
}
-
+
protected void displayErrorDialog(final int errorCode) {
runOnUiThread(new Runnable() {
-
+
@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);
@@ -207,6 +217,6 @@ public abstract class XmppActivity extends Activity {
builder.create().show();
}
});
-
+
}
}