Commit d715229a authored by Grigory Fedorov's avatar Grigory Fedorov

ChatViewer: security icon moved from title bar to input bar.

parent 1f05781a
...@@ -27,7 +27,6 @@ import android.view.Menu; ...@@ -27,7 +27,6 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.xabber.android.data.ActivityManager; import com.xabber.android.data.ActivityManager;
...@@ -655,21 +654,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -655,21 +654,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
final AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user); final AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user);
contactTitleActionBarInflater.update(abstractContact); contactTitleActionBarInflater.update(abstractContact);
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
SettingsManager.SecurityOtrMode securityOtrMode = SettingsManager.securityOtrMode();
ImageView securityView = contactTitleActionBarInflater.getSecurityView();
if (securityLevel == SecurityLevel.plain
&& (securityOtrMode == SettingsManager.SecurityOtrMode.disabled
|| securityOtrMode == SettingsManager.SecurityOtrMode.manual)) {
securityView.setVisibility(View.GONE);
} else {
securityView.setVisibility(View.VISIBLE);
securityView.setImageLevel(securityLevel.getImageLevel());
}
} }
private void updateRegisteredChats() { private void updateRegisteredChats() {
......
...@@ -23,6 +23,8 @@ import com.xabber.android.data.LogManager; ...@@ -23,6 +23,8 @@ import com.xabber.android.data.LogManager;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.cs.ChatStateManager; import com.xabber.android.data.extension.cs.ChatStateManager;
import com.xabber.android.data.extension.otr.OTRManager;
import com.xabber.android.data.extension.otr.SecurityLevel;
import com.xabber.android.data.message.MessageItem; import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.MessageManager; import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.message.chat.ChatManager; import com.xabber.android.data.message.chat.ChatManager;
...@@ -45,6 +47,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -45,6 +47,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
boolean isInputEmpty = true; boolean isInputEmpty = true;
private ImageButton sendButton; private ImageButton sendButton;
private ImageButton securityButton;
public static ChatViewerFragment newInstance(String account, String user) { public static ChatViewerFragment newInstance(String account, String user) {
ChatViewerFragment fragment = new ChatViewerFragment(); ChatViewerFragment fragment = new ChatViewerFragment();
...@@ -74,6 +77,8 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -74,6 +77,8 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
sendButton = (ImageButton) view.findViewById(R.id.button_send_message); sendButton = (ImageButton) view.findViewById(R.id.button_send_message);
sendButton.setImageResource(R.drawable.ic_button_send_inactive_24dp); sendButton.setImageResource(R.drawable.ic_button_send_inactive_24dp);
securityButton = (ImageButton) view.findViewById(R.id.button_security);
chatMessageAdapter = new ChatMessageAdapter(getActivity(), account, user); chatMessageAdapter = new ChatMessageAdapter(getActivity(), account, user);
listView = (ListView) view.findViewById(android.R.id.list); listView = (ListView) view.findViewById(android.R.id.list);
...@@ -274,6 +279,22 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -274,6 +279,22 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
public void updateChat() { public void updateChat() {
chatMessageAdapter.onChange(); chatMessageAdapter.onChange();
updateSecurityButton();
}
private void updateSecurityButton() {
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
SettingsManager.SecurityOtrMode securityOtrMode = SettingsManager.securityOtrMode();
if (securityLevel == SecurityLevel.plain
&& (securityOtrMode == SettingsManager.SecurityOtrMode.disabled
|| securityOtrMode == SettingsManager.SecurityOtrMode.manual)) {
securityButton.setVisibility(View.GONE);
} else {
securityButton.setVisibility(View.VISIBLE);
securityButton.setImageLevel(securityLevel.getImageLevel());
}
} }
public boolean isEqual(String account, String user) { public boolean isEqual(String account, String user) {
......
...@@ -11,7 +11,6 @@ import android.view.Window; ...@@ -11,7 +11,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
...@@ -91,10 +90,6 @@ public class ContactTitleActionBarInflater { ...@@ -91,10 +90,6 @@ public class ContactTitleActionBarInflater {
activity.setTitle(title); activity.setTitle(title);
} }
public ImageView getSecurityView() {
return (ImageView)actionBarView.findViewById(R.id.security);
}
public void playIncomingAnimation() { public void playIncomingAnimation() {
if (shakeAnimation == null) { if (shakeAnimation == null) {
shakeAnimation = AnimationUtils.loadAnimation(activity, R.anim.shake); shakeAnimation = AnimationUtils.loadAnimation(activity, R.anim.shake);
......
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_security_plain_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_security_encrypted_24dp" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_security_verified_24dp" android:minLevel="2" android:maxLevel="2" />
<item android:drawable="@drawable/ic_security_finished_24dp" android:minLevel="3" android:maxLevel="3" />
</level-list>
\ No newline at end of file
...@@ -44,6 +44,18 @@ ...@@ -44,6 +44,18 @@
android:elevation="8dp" android:elevation="8dp"
> >
<ImageButton
android:id="@+id/button_security"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:src="@drawable/ic_security_grey_24dp"
android:background="@null"
android:contentDescription="@string/otr_encryption"
android:layout_gravity="bottom"
android:visibility="gone"
/>
<EditText <EditText
android:id="@+id/chat_input" android:id="@+id/chat_input"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine" android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical"
> >
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
...@@ -34,32 +34,18 @@ ...@@ -34,32 +34,18 @@
android:layout_marginLeft="6dp" android:layout_marginLeft="6dp"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" /> android:textStyle="bold"
<LinearLayout />
<TextView
android:id="@+id/status_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:singleLine="true"
> android:textColor="@color/grey_200"
android:text="Lorem ipsum dolor sit amet"
<ImageView android:layout_marginLeft="6dp"
android:id="@+id/security" />
android:src="@drawable/ic_security"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:padding="3dp"
/>
<TextView
android:id="@+id/status_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:textColor="@color/grey_200"
android:text="Lorem ipsum dolor sit amet"
android:layout_marginLeft="6dp"
/>
</LinearLayout>
</LinearLayout> </LinearLayout>
<ImageView <ImageView
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment