Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
e3c90c3d
Commit
e3c90c3d
authored
Mar 27, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chat: security menu moved from options submenu to Security button popup menu.
parent
946308f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
128 deletions
+136
-128
ChatViewer.java
app/src/main/java/com/xabber/android/ui/ChatViewer.java
+0
-69
ChatViewerFragment.java
...c/main/java/com/xabber/android/ui/ChatViewerFragment.java
+102
-11
chat_viewer_item.xml
app/src/main/res/layout/chat_viewer_item.xml
+0
-1
chat.xml
app/src/main/res/menu/chat.xml
+0
-47
security.xml
app/src/main/res/menu/security.xml
+34
-0
No files found.
app/src/main/java/com/xabber/android/ui/ChatViewer.java
View file @
e3c90c3d
...
@@ -32,7 +32,6 @@ import android.widget.LinearLayout;
...
@@ -32,7 +32,6 @@ import android.widget.LinearLayout;
import
com.xabber.android.data.ActivityManager
;
import
com.xabber.android.data.ActivityManager
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.extension.archive.MessageArchiveManager
;
import
com.xabber.android.data.extension.archive.MessageArchiveManager
;
...
@@ -40,8 +39,6 @@ import com.xabber.android.data.extension.attention.AttentionManager;
...
@@ -40,8 +39,6 @@ import com.xabber.android.data.extension.attention.AttentionManager;
import
com.xabber.android.data.extension.muc.MUCManager
;
import
com.xabber.android.data.extension.muc.MUCManager
;
import
com.xabber.android.data.extension.muc.RoomChat
;
import
com.xabber.android.data.extension.muc.RoomChat
;
import
com.xabber.android.data.extension.muc.RoomState
;
import
com.xabber.android.data.extension.muc.RoomState
;
import
com.xabber.android.data.extension.otr.OTRManager
;
import
com.xabber.android.data.extension.otr.SecurityLevel
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.message.MessageManager
;
...
@@ -222,22 +219,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -222,22 +219,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
if
(
abstractChat
instanceof
RegularChat
)
{
if
(
abstractChat
instanceof
RegularChat
)
{
menu
.
findItem
(
R
.
id
.
action_view_contact
).
setVisible
(
true
);
menu
.
findItem
(
R
.
id
.
action_view_contact
).
setVisible
(
true
);
menu
.
findItem
(
R
.
id
.
action_close_chat
).
setVisible
(
true
);
menu
.
findItem
(
R
.
id
.
action_close_chat
).
setVisible
(
true
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
().
getSecurityLevel
(
account
,
user
);
if
(
securityLevel
==
SecurityLevel
.
plain
)
{
menu
.
findItem
(
R
.
id
.
action_start_encryption
).
setVisible
(
true
)
.
setEnabled
(
SettingsManager
.
securityOtrMode
()
!=
SettingsManager
.
SecurityOtrMode
.
disabled
);
}
else
{
menu
.
findItem
(
R
.
id
.
action_restart_encryption
).
setVisible
(
true
);
}
boolean
isEncrypted
=
securityLevel
!=
SecurityLevel
.
plain
;
menu
.
findItem
(
R
.
id
.
action_stop_encryption
).
setEnabled
(
isEncrypted
);
menu
.
findItem
(
R
.
id
.
action_verify_with_fingerprint
).
setEnabled
(
isEncrypted
);
menu
.
findItem
(
R
.
id
.
action_verify_with_question
).
setEnabled
(
isEncrypted
);
menu
.
findItem
(
R
.
id
.
action_verify_with_shared_secret
).
setEnabled
(
isEncrypted
);
}
}
}
}
...
@@ -370,32 +351,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -370,32 +351,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
startActivity
(
OccupantList
.
createIntent
(
this
,
account
,
user
));
startActivity
(
OccupantList
.
createIntent
(
this
,
account
,
user
));
return
true
;
return
true
;
/* encryption */
case
R
.
id
.
action_start_encryption
:
startEncryption
(
account
,
user
);
return
true
;
case
R
.
id
.
action_restart_encryption
:
restartEncryption
(
account
,
user
);
return
true
;
case
R
.
id
.
action_stop_encryption
:
stopEncryption
(
account
,
user
);
return
true
;
case
R
.
id
.
action_verify_with_fingerprint
:
startActivity
(
FingerprintViewer
.
createIntent
(
this
,
account
,
user
));
return
true
;
case
R
.
id
.
action_verify_with_question
:
startActivity
(
QuestionViewer
.
createIntent
(
this
,
account
,
user
,
true
,
false
,
null
));
return
true
;
case
R
.
id
.
action_verify_with_shared_secret
:
startActivity
(
QuestionViewer
.
createIntent
(
this
,
account
,
user
,
false
,
false
,
null
));
return
true
;
default
:
default
:
return
super
.
onOptionsItemSelected
(
item
);
return
super
.
onOptionsItemSelected
(
item
);
}
}
...
@@ -409,30 +364,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -409,30 +364,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
}
}
}
private
void
stopEncryption
(
String
account
,
String
user
)
{
try
{
OTRManager
.
getInstance
().
endSession
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
private
void
restartEncryption
(
String
account
,
String
user
)
{
try
{
OTRManager
.
getInstance
().
refreshSession
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
private
void
startEncryption
(
String
account
,
String
user
)
{
try
{
OTRManager
.
getInstance
().
startSession
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
private
void
callAttention
(
String
account
,
String
user
)
{
private
void
callAttention
(
String
account
,
String
user
)
{
try
{
try
{
AttentionManager
.
getInstance
().
sendAttention
(
account
,
user
);
AttentionManager
.
getInstance
().
sendAttention
(
account
,
user
);
...
...
app/src/main/java/com/xabber/android/ui/ChatViewerFragment.java
View file @
e3c90c3d
...
@@ -10,6 +10,7 @@ import android.text.TextWatcher;
...
@@ -10,6 +10,7 @@ import android.text.TextWatcher;
import
android.view.ContextMenu
;
import
android.view.ContextMenu
;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
...
@@ -18,20 +19,25 @@ import android.widget.AdapterView;
...
@@ -18,20 +19,25 @@ import android.widget.AdapterView;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.ImageButton
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.PopupMenu
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.NetworkException
;
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.OTRManager
;
import
com.xabber.android.data.extension.otr.SecurityLevel
;
import
com.xabber.android.data.extension.otr.SecurityLevel
;
import
com.xabber.android.data.message.AbstractChat
;
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.RegularChat
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.ui.adapter.ChatMessageAdapter
;
import
com.xabber.android.ui.adapter.ChatMessageAdapter
;
import
com.xabber.androiddev.R
;
import
com.xabber.androiddev.R
;
public
class
ChatViewerFragment
extends
Fragment
implements
AdapterView
.
OnItemClickListener
{
public
class
ChatViewerFragment
extends
Fragment
implements
AdapterView
.
OnItemClickListener
,
PopupMenu
.
OnMenuItemClickListener
{
public
static
final
String
ARGUMENT_ACCOUNT
=
"ARGUMENT_ACCOUNT"
;
public
static
final
String
ARGUMENT_ACCOUNT
=
"ARGUMENT_ACCOUNT"
;
public
static
final
String
ARGUMENT_USER
=
"ARGUMENT_USER"
;
public
static
final
String
ARGUMENT_USER
=
"ARGUMENT_USER"
;
...
@@ -77,7 +83,19 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
...
@@ -77,7 +83,19 @@ 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
);
AbstractChat
abstractChat
=
MessageManager
.
getInstance
().
getChat
(
account
,
user
);
securityButton
=
(
ImageButton
)
view
.
findViewById
(
R
.
id
.
button_security
);
securityButton
=
(
ImageButton
)
view
.
findViewById
(
R
.
id
.
button_security
);
if
(
abstractChat
instanceof
RegularChat
)
{
securityButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
showSecurityMenu
();
}
});
}
else
{
securityButton
.
setVisibility
(
View
.
GONE
);
}
chatMessageAdapter
=
new
ChatMessageAdapter
(
getActivity
(),
account
,
user
);
chatMessageAdapter
=
new
ChatMessageAdapter
(
getActivity
(),
account
,
user
);
...
@@ -148,6 +166,32 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
...
@@ -148,6 +166,32 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
}
}
private
void
showSecurityMenu
()
{
PopupMenu
popup
=
new
PopupMenu
(
getActivity
(),
securityButton
);
popup
.
inflate
(
R
.
menu
.
security
);
popup
.
setOnMenuItemClickListener
(
this
);
Menu
menu
=
popup
.
getMenu
();
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
().
getSecurityLevel
(
account
,
user
);
if
(
securityLevel
==
SecurityLevel
.
plain
)
{
menu
.
findItem
(
R
.
id
.
action_start_encryption
).
setVisible
(
true
)
.
setEnabled
(
SettingsManager
.
securityOtrMode
()
!=
SettingsManager
.
SecurityOtrMode
.
disabled
);
}
else
{
menu
.
findItem
(
R
.
id
.
action_restart_encryption
).
setVisible
(
true
);
}
boolean
isEncrypted
=
securityLevel
!=
SecurityLevel
.
plain
;
menu
.
findItem
(
R
.
id
.
action_stop_encryption
).
setEnabled
(
isEncrypted
);
menu
.
findItem
(
R
.
id
.
action_verify_with_fingerprint
).
setEnabled
(
isEncrypted
);
menu
.
findItem
(
R
.
id
.
action_verify_with_question
).
setEnabled
(
isEncrypted
);
menu
.
findItem
(
R
.
id
.
action_verify_with_shared_secret
).
setEnabled
(
isEncrypted
);
popup
.
show
();
}
private
void
setSendButtonColor
()
{
private
void
setSendButtonColor
()
{
boolean
empty
=
inputView
.
getText
().
toString
().
isEmpty
();
boolean
empty
=
inputView
.
getText
().
toString
().
isEmpty
();
...
@@ -285,16 +329,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
...
@@ -285,16 +329,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
private
void
updateSecurityButton
()
{
private
void
updateSecurityButton
()
{
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
().
getSecurityLevel
(
account
,
user
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
().
getSecurityLevel
(
account
,
user
);
SettingsManager
.
SecurityOtrMode
securityOtrMode
=
SettingsManager
.
securityOtrMode
();
securityButton
.
setImageLevel
(
securityLevel
.
getImageLevel
());
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
)
{
...
@@ -335,4 +370,60 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
...
@@ -335,4 +370,60 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
listView
.
showContextMenuForChild
(
view
);
listView
.
showContextMenuForChild
(
view
);
unregisterForContextMenu
(
listView
);
unregisterForContextMenu
(
listView
);
}
}
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
action_start_encryption
:
startEncryption
(
account
,
user
);
return
true
;
case
R
.
id
.
action_restart_encryption
:
restartEncryption
(
account
,
user
);
return
true
;
case
R
.
id
.
action_stop_encryption
:
stopEncryption
(
account
,
user
);
return
true
;
case
R
.
id
.
action_verify_with_fingerprint
:
startActivity
(
FingerprintViewer
.
createIntent
(
getActivity
(),
account
,
user
));
return
true
;
case
R
.
id
.
action_verify_with_question
:
startActivity
(
QuestionViewer
.
createIntent
(
getActivity
(),
account
,
user
,
true
,
false
,
null
));
return
true
;
case
R
.
id
.
action_verify_with_shared_secret
:
startActivity
(
QuestionViewer
.
createIntent
(
getActivity
(),
account
,
user
,
false
,
false
,
null
));
return
true
;
default
:
return
false
;
}
}
private
void
stopEncryption
(
String
account
,
String
user
)
{
try
{
OTRManager
.
getInstance
().
endSession
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
private
void
restartEncryption
(
String
account
,
String
user
)
{
try
{
OTRManager
.
getInstance
().
refreshSession
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
private
void
startEncryption
(
String
account
,
String
user
)
{
try
{
OTRManager
.
getInstance
().
startSession
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
}
}
app/src/main/res/layout/chat_viewer_item.xml
View file @
e3c90c3d
...
@@ -53,7 +53,6 @@
...
@@ -53,7 +53,6 @@
android:background=
"@null"
android:background=
"@null"
android:contentDescription=
"@string/otr_encryption"
android:contentDescription=
"@string/otr_encryption"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:visibility=
"gone"
/>
/>
<EditText
<EditText
...
...
app/src/main/res/menu/chat.xml
View file @
e3c90c3d
...
@@ -91,53 +91,6 @@
...
@@ -91,53 +91,6 @@
android:orderInCategory=
"180"
android:orderInCategory=
"180"
/>
/>
<item
android:id=
"@+id/action_otr_encryption"
android:title=
"@string/otr_encryption"
app:showAsAction=
"never"
android:orderInCategory=
"190"
>
<menu>
<item
android:id=
"@+id/action_start_encryption"
android:title=
"@string/otr_start"
app:showAsAction=
"never"
android:orderInCategory=
"100"
android:visible=
"false"
/>
<item
android:id=
"@+id/action_restart_encryption"
android:title=
"@string/otr_refresh"
app:showAsAction=
"never"
android:orderInCategory=
"105"
android:visible=
"false"
/>
<item
android:id=
"@+id/action_stop_encryption"
android:title=
"@string/otr_end"
app:showAsAction=
"never"
android:orderInCategory=
"110"
/>
<item
android:id=
"@+id/action_verify_with_fingerprint"
android:title=
"@string/otr_verify_fingerprint"
app:showAsAction=
"never"
android:orderInCategory=
"120"
/>
<item
android:id=
"@+id/action_verify_with_question"
android:title=
"@string/otr_verify_question"
app:showAsAction=
"never"
android:orderInCategory=
"130"
/>
<item
android:id=
"@+id/action_verify_with_shared_secret"
android:title=
"@string/otr_verify_secret"
app:showAsAction=
"never"
android:orderInCategory=
"140"
/>
</menu>
</item>
<item
android:id=
"@+id/action_list_of_occupants"
<item
android:id=
"@+id/action_list_of_occupants"
android:title=
"@string/occupant_list"
android:title=
"@string/occupant_list"
app:showAsAction=
"never"
app:showAsAction=
"never"
...
...
app/src/main/res/menu/security.xml
0 → 100644
View file @
e3c90c3d
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:id=
"@+id/action_start_encryption"
android:title=
"@string/otr_start"
android:orderInCategory=
"100"
android:visible=
"false"
/>
<item
android:id=
"@+id/action_restart_encryption"
android:title=
"@string/otr_refresh"
android:orderInCategory=
"105"
android:visible=
"false"
/>
<item
android:id=
"@+id/action_stop_encryption"
android:title=
"@string/otr_end"
android:orderInCategory=
"110"
/>
<item
android:id=
"@+id/action_verify_with_fingerprint"
android:title=
"@string/otr_verify_fingerprint"
android:orderInCategory=
"120"
/>
<item
android:id=
"@+id/action_verify_with_question"
android:title=
"@string/otr_verify_question"
android:orderInCategory=
"130"
/>
<item
android:id=
"@+id/action_verify_with_shared_secret"
android:title=
"@string/otr_verify_secret"
android:orderInCategory=
"140"
/>
</menu>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment