unified warnings/error msgs

This commit is contained in:
iNPUTmice 2014-07-09 21:45:03 +02:00
parent da0b426125
commit 6e3e1d310a
12 changed files with 59 additions and 156 deletions

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF1da9da" />
</shape>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="false"
android:drawable="@drawable/blue" />
<item
android:state_pressed="true"
android:drawable="@drawable/darkblue" />
</selector>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF0099cc" />
</shape>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffcc0000" />
</shape>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFe92727" />
</shape>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="false"
android:drawable="@drawable/red" />
<item
android:state_pressed="true"
android:drawable="@drawable/darkred" />
</selector>

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/primarybackground" > android:background="@color/secondarybackground" >
<RelativeLayout <RelativeLayout
android:id="@+id/textsend" android:id="@+id/textsend"
@ -49,7 +49,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/textsend" android:layout_above="@+id/textsend"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@+id/info_box" android:layout_below="@+id/snackbar"
android:background="@color/secondarybackground" android:background="@color/secondarybackground"
android:divider="@null" android:divider="@null"
android:dividerHeight="0dp" android:dividerHeight="0dp"
@ -59,94 +59,37 @@
tools:listitem="@layout/message_sent" > tools:listitem="@layout/message_sent" >
</ListView> </ListView>
<LinearLayout <RelativeLayout
android:id="@+id/info_box" android:id="@+id/snackbar"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" > android:minHeight="48dp"
android:background="@color/darkbackground"
android:visibility="gone">
<LinearLayout <TextView
android:id="@+id/muc_error" android:id="@+id/snackbar_message"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/redbackground" android:layout_alignParentLeft="true"
android:orientation="vertical" android:layout_centerVertical="true"
android:visibility="gone" > android:textSize="14sp"
android:textColor="@color/ondarktext"
<TextView android:paddingLeft="24dp"/>
android:id="@+id/muc_error_msg" <TextView
android:layout_width="wrap_content" android:id="@+id/snackbar_action"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:padding="6dp"
android:textColor="#eee"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:paddingLeft="6dp"
android:text="@string/edit_conference_details"
android:textColor="#eee"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/new_fingerprint"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/redbackground" android:layout_alignParentRight="true"
android:orientation="vertical" android:layout_centerVertical="true"
android:visibility="gone" > android:textSize="14sp"
android:textColor="@color/ondarktext"
<TextView android:textStyle="bold"
android:layout_width="wrap_content" android:textAllCaps="true"
android:layout_height="wrap_content" android:paddingLeft="24dp"
android:padding="6dp" android:paddingRight="24dp"
android:text="@string/unknown_otr_fingerprint" android:paddingTop="18dp"
android:textColor="#eee" android:paddingBottom="18dp"/>
android:textSize="18sp" </RelativeLayout>
android:textStyle="bold" />
<TextView
android:id="@+id/otr_fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:paddingLeft="6dp"
android:textColor="#eee"
android:textSize="14sp"
android:singleLine="true"
android:typeface="monospace" />
</LinearLayout>
<LinearLayout
android:id="@+id/pgp_keyentry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bluebackground"
android:orientation="vertical"
android:visibility="gone" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/openpgp_messages_found"
android:textColor="#eee"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:paddingLeft="6dp"
android:text="@string/openpgp_click_to_decrypt"
android:textColor="#eee"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -2,8 +2,10 @@
<resources> <resources>
<color name="primarytext" type="color">#de000000</color> <color name="primarytext" type="color">#de000000</color>
<color name="secondarytext" type="color">#8a000000</color> <color name="secondarytext" type="color">#8a000000</color>
<color name="ondarktext" type="color">#fffafafa</color>
<color name="primarybackground" type="color">#fffafafa</color> <color name="primarybackground" type="color">#fffafafa</color>
<color name="secondarybackground" type="color">#ffeeeeee</color> <color name="secondarybackground" type="color">#ffeeeeee</color>
<color name="darkbackground" type="color">#ff323232</color>
<color name="divider">#1f000000</color> <color name="divider">#1f000000</color>
<color name="red">#ffe51c23</color> <color name="red">#ffe51c23</color>
</resources> </resources>

View File

@ -252,4 +252,6 @@
<string name="no_muc_server_found">No suitable Conference Server found</string> <string name="no_muc_server_found">No suitable Conference Server found</string>
<string name="your_fingerprint">Your fingerprint</string> <string name="your_fingerprint">Your fingerprint</string>
<string name="otr_fingerprint">OTR fingerprint</string> <string name="otr_fingerprint">OTR fingerprint</string>
<string name="verify">Verify</string>
<string name="decrypt">Decrypt</string>
</resources> </resources>

View File

@ -768,7 +768,7 @@ public class ConversationActivity extends XmppActivity {
ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
.findFragmentByTag("conversation"); .findFragmentByTag("conversation");
if (selectedFragment != null) { if (selectedFragment != null) {
selectedFragment.hidePgpPassphraseBox(); selectedFragment.hideSnackbar();
} }
} else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) { } else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) {
attachImageToConversation(getSelectedConversation(), attachImageToConversation(getSelectedConversation(),

View File

@ -48,6 +48,7 @@ import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -68,6 +69,9 @@ public class ConversationFragment extends Fragment {
private EditText chatMsg; private EditText chatMsg;
private String pastedText = null; private String pastedText = null;
private RelativeLayout snackbar;
private TextView snackbarMessage;
private TextView snackbarAction;
protected Bitmap selfBitmap; protected Bitmap selfBitmap;
@ -110,9 +114,6 @@ public class ConversationFragment extends Fragment {
} }
}; };
private LinearLayout pgpInfo;
private LinearLayout mucError;
private TextView mucErrorText;
private OnClickListener clickToMuc = new OnClickListener() { private OnClickListener clickToMuc = new OnClickListener() {
@Override @Override
@ -152,10 +153,6 @@ public class ConversationFragment extends Fragment {
private ConversationActivity activity; private ConversationActivity activity;
public void hidePgpPassphraseBox() {
pgpInfo.setVisibility(View.GONE);
}
public void updateChatMsgHint() { public void updateChatMsgHint() {
switch (conversation.getNextEncryption()) { switch (conversation.getNextEncryption()) {
case Message.ENCRYPTION_NONE: case Message.ENCRYPTION_NONE:
@ -191,11 +188,9 @@ public class ConversationFragment extends Fragment {
.findViewById(R.id.textSendButton); .findViewById(R.id.textSendButton);
sendButton.setOnClickListener(this.sendMsgListener); sendButton.setOnClickListener(this.sendMsgListener);
pgpInfo = (LinearLayout) view.findViewById(R.id.pgp_keyentry); snackbar = (RelativeLayout) view.findViewById(R.id.snackbar);
pgpInfo.setOnClickListener(clickToDecryptListener); snackbarMessage = (TextView) view.findViewById(R.id.snackbar_message);
mucError = (LinearLayout) view.findViewById(R.id.muc_error); snackbarAction = (TextView) view.findViewById(R.id.snackbar_action);
mucError.setOnClickListener(clickToMuc);
mucErrorText = (TextView) view.findViewById(R.id.muc_error_msg);
messagesView = (ListView) view.findViewById(R.id.messages_view); messagesView = (ListView) view.findViewById(R.id.messages_view);
messagesView.setOnScrollListener(mOnScrollListener); messagesView.setOnScrollListener(mOnScrollListener);
@ -688,7 +683,7 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void userInputRequried(PendingIntent pi, Message message) { public void userInputRequried(PendingIntent pi, Message message) {
askForPassphraseIntent = pi.getIntentSender(); askForPassphraseIntent = pi.getIntentSender();
pgpInfo.setVisibility(View.VISIBLE); showSnackbar(R.string.openpgp_messages_found,R.string.decrypt,clickToDecryptListener);
} }
@Override @Override
@ -704,8 +699,6 @@ public class ConversationFragment extends Fragment {
// updateMessages(); // updateMessages();
} }
}); });
} else {
pgpInfo.setVisibility(View.GONE);
} }
} }
@ -742,12 +735,10 @@ public class ConversationFragment extends Fragment {
} }
} else { } else {
if (conversation.getMucOptions().getError() != 0) { if (conversation.getMucOptions().getError() != 0) {
mucError.setVisibility(View.VISIBLE); showSnackbar(R.string.nick_in_use, R.string.edit,clickToMuc);
if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) { if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) {
mucErrorText.setText(getString(R.string.nick_in_use)); showSnackbar(R.string.nick_in_use, R.string.edit,clickToMuc);
} }
} else {
mucError.setVisibility(View.GONE);
} }
} }
getActivity().invalidateOptionsMenu(); getActivity().invalidateOptionsMenu();
@ -795,35 +786,38 @@ public class ConversationFragment extends Fragment {
} }
protected void makeFingerprintWarning(int latestEncryption) { protected void makeFingerprintWarning(int latestEncryption) {
final LinearLayout fingerprintWarning = (LinearLayout) getView()
.findViewById(R.id.new_fingerprint);
Set<String> knownFingerprints = conversation.getContact() Set<String> knownFingerprints = conversation.getContact()
.getOtrFingerprints(); .getOtrFingerprints();
if ((latestEncryption == Message.ENCRYPTION_OTR) if ((latestEncryption == Message.ENCRYPTION_OTR)
&& (conversation.hasValidOtrSession() && (conversation.hasValidOtrSession()
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints
.contains(conversation.getOtrFingerprint())))) { .contains(conversation.getOtrFingerprint())))) {
fingerprintWarning.setVisibility(View.VISIBLE); showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, new OnClickListener() {
TextView fingerprint = (TextView) getView().findViewById(
R.id.otr_fingerprint);
fingerprint.setText(conversation.getOtrFingerprint());
fingerprintWarning.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (conversation.getOtrFingerprint() != null) { if (conversation.getOtrFingerprint() != null) {
AlertDialog dialog = UIHelper.getVerifyFingerprintDialog( AlertDialog dialog = UIHelper.getVerifyFingerprintDialog(
(ConversationActivity) getActivity(), conversation, (ConversationActivity) getActivity(), conversation,
fingerprintWarning); snackbar);
dialog.show(); dialog.show();
} }
} }
}); });
} else {
fingerprintWarning.setVisibility(View.GONE);
} }
} }
protected void showSnackbar(int message, int action, OnClickListener clickListener) {
snackbar.setVisibility(View.VISIBLE);
snackbarMessage.setText(message);
snackbarAction.setText(action);
snackbarAction.setOnClickListener(clickListener);
}
protected void hideSnackbar() {
snackbar.setVisibility(View.GONE);
}
protected void sendPlainTextMessage(Message message) { protected void sendPlainTextMessage(Message message) {
ConversationActivity activity = (ConversationActivity) getActivity(); ConversationActivity activity = (ConversationActivity) getActivity();
activity.xmppConnectionService.sendMessage(message); activity.xmppConnectionService.sendMessage(message);

View File

@ -492,7 +492,7 @@ public class UIHelper {
public static AlertDialog getVerifyFingerprintDialog( public static AlertDialog getVerifyFingerprintDialog(
final ConversationActivity activity, final ConversationActivity activity,
final Conversation conversation, final LinearLayout msg) { final Conversation conversation, final View msg) {
final Contact contact = conversation.getContact(); final Contact contact = conversation.getContact();
final Account account = conversation.getAccount(); final Account account = conversation.getAccount();