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
a881509f
Commit
a881509f
authored
Feb 16, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ChatViewer: action bar main functions completed (incoming animation, security icon).
parent
42dca0e7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
137 deletions
+97
-137
ChatViewer.java
app/src/main/java/com/xabber/android/ui/ChatViewer.java
+38
-6
ChatViewerFragment.java
...c/main/java/com/xabber/android/ui/ChatViewerFragment.java
+16
-56
ContactTitleInflater.java
...va/com/xabber/android/ui/helper/ContactTitleInflater.java
+0
-16
chat_viewer_action_bar.xml
app/src/main/res/layout/chat_viewer_action_bar.xml
+34
-53
chat_viewer_item.xml
app/src/main/res/layout/chat_viewer_item.xml
+0
-1
contact_title_avatar.xml
app/src/main/res/layout/contact_title_avatar.xml
+4
-0
chat.xml
app/src/main/res/menu/chat.xml
+5
-5
No files found.
app/src/main/java/com/xabber/android/ui/ChatViewer.java
View file @
a881509f
...
...
@@ -17,6 +17,7 @@ package com.xabber.android.ui;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.v4.view.ViewPager
;
import
android.support.v7.app.ActionBar
;
...
...
@@ -24,14 +25,20 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.ImageView
;
import
com.xabber.android.data.ActivityManager
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.extension.archive.MessageArchiveManager
;
import
com.xabber.android.data.extension.attention.AttentionManager
;
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.message.AbstractChat
;
import
com.xabber.android.data.message.MessageManager
;
...
...
@@ -87,6 +94,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
private
Window
window
;
private
int
defaultStatusBarColor
;
private
Animation
shakeAnimation
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -111,12 +120,15 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
exitOnSend
=
savedInstanceState
.
getBoolean
(
SAVED_EXIT_ON_SEND
);
}
shakeAnimation
=
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
shake
);
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
);
defaultStatusBarColor
=
window
.
getStatusBarColor
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
defaultStatusBarColor
=
window
.
getStatusBarColor
();
}
accountActionBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
accountStatusBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
...
...
@@ -302,7 +314,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
if
(
chat
.
isEqual
(
account
,
user
))
{
chat
.
updateChat
(
true
);
chat
.
updateChat
();
}
}
}
...
...
@@ -310,6 +322,9 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
if
(
actionWithAccount
!=
null
&&
actionWithAccount
.
equals
(
account
)
&&
actionWithUser
!=
null
&&
actionWithUser
.
equals
(
user
))
{
updateActionBar
(
account
,
user
);
if
(
incoming
)
{
actionBarView
.
findViewById
(
R
.
id
.
name_holder
).
startAnimation
(
shakeAnimation
);
}
}
...
...
@@ -361,7 +376,9 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
AbstractChat
selectedChat
=
chatViewerAdapter
.
getChatByPageNumber
(
position
);
if
(
selectedChat
==
null
)
{
window
.
setStatusBarColor
(
defaultStatusBarColor
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
defaultStatusBarColor
);
}
getSupportActionBar
().
setBackgroundDrawable
(
null
);
getSupportActionBar
().
setDisplayShowTitleEnabled
(
true
);
actionBarView
.
setVisibility
(
View
.
GONE
);
...
...
@@ -394,14 +411,29 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
ContactTitleInflater
.
updateTitle
(
actionBarView
,
this
,
abstractContact
);
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
abstractContact
.
getAccount
());
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
}
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
accountActionBarColors
[
colorLevel
]));
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
().
getSecurityLevel
(
account
,
user
);
SettingsManager
.
SecurityOtrMode
securityOtrMode
=
SettingsManager
.
securityOtrMode
();
ImageView
securityView
=
(
ImageView
)
actionBarView
.
findViewById
(
R
.
id
.
security
);
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
()
{
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
chat
.
updateChat
(
false
);
chat
.
updateChat
();
}
}
...
...
app/src/main/java/com/xabber/android/ui/ChatViewerFragment.java
View file @
a881509f
...
...
@@ -22,7 +22,6 @@ import android.view.inputmethod.EditorInfo;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
...
...
@@ -43,12 +42,8 @@ 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.notification.NotificationManager
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.adapter.ChatMessageAdapter
;
import
com.xabber.android.ui.dialog.ChatExportDialogFragment
;
import
com.xabber.android.ui.helper.AbstractAvatarInflaterHelper
;
import
com.xabber.android.ui.helper.ContactTitleInflater
;
import
com.xabber.android.ui.preferences.ChatEditor
;
import
com.xabber.androiddev.R
;
...
...
@@ -60,20 +55,12 @@ public class ChatViewerFragment extends Fragment {
private
static
final
int
MINIMUM_MESSAGES_TO_LOAD
=
10
;
private
TextView
pageView
;
private
View
titleView
;
private
EditText
inputView
;
private
ListView
listView
;
private
ChatMessageAdapter
chatMessageAdapter
;
private
boolean
skipOnTextChanges
;
/**
* Animation used for incoming message notification.
*/
private
Animation
shakeAnimation
;
private
AbstractAvatarInflaterHelper
avatarInflaterHelper
;
private
String
account
;
private
String
user
;
...
...
@@ -96,16 +83,12 @@ public class ChatViewerFragment extends Fragment {
Bundle
args
=
getArguments
();
account
=
args
.
getString
(
ARGUMENT_ACCOUNT
,
null
);
user
=
args
.
getString
(
ARGUMENT_USER
,
null
);
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
.
createAbstractContactInflaterHelper
();
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
shakeAnimation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
shake
);
/*
Animation used to hide pages.
*/
...
...
@@ -136,7 +119,7 @@ public class ChatViewerFragment extends Fragment {
listView
.
setAdapter
(
chatMessageAdapter
);
pageView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_page
);
titleView
=
view
.
findViewById
(
R
.
id
.
title
);
//
titleView = view.findViewById(R.id.title);
inputView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
chat_input
);
view
.
findViewById
(
R
.
id
.
chat_send
).
setOnClickListener
(
...
...
@@ -148,16 +131,16 @@ public class ChatViewerFragment extends Fragment {
}
});
titleView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
int
size
=
listView
.
getCount
();
if
(
size
>
0
)
listView
.
setSelection
(
size
-
1
);
}
});
//
titleView.setOnClickListener(new View.OnClickListener() {
//
//
@Override
//
public void onClick(View v) {
//
int size = listView.getCount();
//
if (size > 0)
//
listView.setSelection(size - 1);
//
}
//
//
});
inputView
.
setOnKeyListener
(
new
View
.
OnKeyListener
()
{
@Override
...
...
@@ -305,30 +288,11 @@ public class ChatViewerFragment extends Fragment {
private
void
sendMessage
(
String
text
)
{
MessageManager
.
getInstance
().
sendMessage
(
account
,
user
,
text
);
updateChat
(
false
);
updateChat
();
}
private
void
updateView
()
{
chatMessageAdapter
.
onChange
();
final
AbstractContact
abstractContact
=
RosterManager
.
getInstance
().
getBestContact
(
account
,
user
);
ContactTitleInflater
.
updateTitle
(
titleView
,
getActivity
(),
abstractContact
);
avatarInflaterHelper
.
updateAvatar
((
ImageView
)
titleView
.
findViewById
(
R
.
id
.
avatar
),
abstractContact
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
().
getSecurityLevel
(
account
,
user
);
SettingsManager
.
SecurityOtrMode
securityOtrMode
=
SettingsManager
.
securityOtrMode
();
ImageView
securityView
=
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
security
);
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
());
}
}
@Override
...
...
@@ -379,7 +343,7 @@ public class ChatViewerFragment extends Fragment {
MessageManager
.
getInstance
().
requestToLoadLocalHistory
(
account
,
user
);
MessageArchiveManager
.
getInstance
()
.
requestHistory
(
account
,
user
,
MINIMUM_MESSAGES_TO_LOAD
,
0
);
updateChat
(
false
);
updateChat
();
return
true
;
}
});
...
...
@@ -433,7 +397,7 @@ public class ChatViewerFragment extends Fragment {
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
MessageManager
.
getInstance
()
.
clearHistory
(
account
,
user
);
updateChat
(
false
);
updateChat
();
return
false
;
}
});
...
...
@@ -573,7 +537,7 @@ public class ChatViewerFragment extends Fragment {
case
R
.
id
.
action_message_remove
:
MessageManager
.
getInstance
().
removeMessage
(
message
);
updateChat
(
false
);
updateChat
();
return
true
;
default
:
...
...
@@ -601,11 +565,7 @@ public class ChatViewerFragment extends Fragment {
inputView
.
setSelection
(
selection
+
additional
.
length
());
}
public
void
updateChat
(
boolean
incomingMessage
)
{
if
(
incomingMessage
)
{
titleView
.
findViewById
(
R
.
id
.
name_holder
).
startAnimation
(
shakeAnimation
);
}
public
void
updateChat
()
{
updateView
();
}
...
...
app/src/main/java/com/xabber/android/ui/helper/ContactTitleInflater.java
View file @
a881509f
...
...
@@ -15,10 +15,6 @@
package
com
.
xabber
.
android
.
ui
.
helper
;
import
android.app.Activity
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Shader.TileMode
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.ColorDrawable
;
import
android.view.View
;
import
android.widget.ImageView
;
...
...
@@ -53,7 +49,6 @@ public class ContactTitleInflater {
final
ImageView
avatarView
=
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
avatar
);
final
ImageView
statusModeView
=
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
status_mode
);
final
TextView
statusTextView
=
(
TextView
)
titleView
.
findViewById
(
R
.
id
.
status_text
);
final
View
shadowView
=
titleView
.
findViewById
(
R
.
id
.
shadow
);
int
[]
accountActionBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
...
...
@@ -64,17 +59,6 @@ public class ContactTitleInflater {
avatarView
.
setImageDrawable
(
abstractContact
.
getAvatar
());
setStatusText
(
activity
,
abstractContact
,
statusTextView
);
final
Bitmap
bitmap
=
BitmapFactory
.
decodeResource
(
activity
.
getResources
(),
R
.
drawable
.
shadow
);
final
BitmapDrawable
shadowDrawable
=
new
BitmapDrawable
(
bitmap
);
shadowDrawable
.
setTileModeXY
(
TileMode
.
REPEAT
,
TileMode
.
REPEAT
);
shadowView
.
setBackgroundDrawable
(
shadowDrawable
);
if
(
abstractContact
.
isConnected
())
{
shadowView
.
setVisibility
(
View
.
GONE
);
}
else
{
shadowView
.
setVisibility
(
View
.
VISIBLE
);
}
}
private
static
void
setStatusText
(
Activity
activity
,
AbstractContact
abstractContact
,
...
...
app/src/main/res/layout/chat_viewer_action_bar.xml
View file @
a881509f
<?xml version="1.0" encoding="utf-8"?>
<
Relative
Layout
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/title"
android:layout_width=
"match_parent"
android:layout_height=
"?android:attr/actionBarSize"
android:orientation=
"horizontal"
>
<include
layout=
"@layout/contact_title_avatar"
/>
<LinearLayout
android:id=
"@+id/
title_colo
r"
android:id=
"@+id/
name_holde
r"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:layout_gravity=
"center_vertical"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:gravity=
"center_vertical"
>
<include
layout=
"@layout/contact_title_avatar"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/security"
android:src=
"@drawable/ic_security"
android:paddingLeft=
"6dip"
<TextView
android:id=
"@+id/name"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:visibility=
"gone"
android:layout_height=
"0dp"
android:gravity=
"center_vertical"
android:singleLine=
"true"
android:layout_weight=
"1"
android:text=
"name"
/>
<LinearLayout
android:id=
"@+id/name_holder"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:layout_width=
"wrap_content"
android:layout_height=
"0dp"
android:orientation=
"horizontal"
android:layout_weight=
"1"
android:layout_gravity=
"center_vertical"
android:paddingLeft=
"6dip"
>
<TextView
android:id=
"@+id/name"
android:layout_width=
"match_parent"
<ImageView
android:id=
"@+id/security"
android:src=
"@drawable/ic_security"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:visibility=
"gone"
/>
<ImageView
android:id=
"@+id/status_mode"
android:src=
"@drawable/ic_status"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"bottom"
android:singleLine=
"true"
android:ellipsize=
"marquee"
android:textStyle=
"bold"
android:textColor=
"@color/secondary_text_default_material_light"
android:text=
"name"
/>
<TextView
android:id=
"@+id/status_text"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"top"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:singleLine=
"true"
android:ellipsize=
"marquee"
android:textColor=
"@color/secondary_text_default_material_light"
android:text=
"status"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/status_mode"
android:src=
"@drawable/ic_status"
android:paddingLeft=
"@dimen/active_chat_padding_right"
android:paddingRight=
"@dimen/active_chat_padding_right"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:visibility=
"gone"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/shadow"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/shadow"
android:visibility=
"gone"
/>
</RelativeLayout>
</LinearLayout>
app/src/main/res/layout/chat_viewer_item.xml
View file @
a881509f
...
...
@@ -18,7 +18,6 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/contact_title"
/>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/layout/contact_title_avatar.xml
View file @
a881509f
...
...
@@ -18,4 +18,8 @@
android:layout_width=
"48dip"
android:layout_height=
"48dip"
android:src=
"@drawable/avatar_1_1"
android:layout_gravity=
"center_vertical"
android:layout_marginRight=
"4dp"
android:layout_marginEnd=
"4dp"
/>
app/src/main/res/menu/chat.xml
View file @
a881509f
...
...
@@ -4,7 +4,7 @@
<item
android:id=
"@+id/action_join_conference"
android:title=
"@string/muc_join"
app:showAsAction=
"
ifRoom
"
app:showAsAction=
"
never
"
android:orderInCategory=
"80"
android:visible=
"false"
android:icon=
"@drawable/ic_group_white_24dp"
...
...
@@ -19,7 +19,7 @@
<item
android:id=
"@+id/action_edit_contact"
android:title=
"@string/contact_editor"
app:showAsAction=
"
ifRoom
"
app:showAsAction=
"
never
"
android:orderInCategory=
"100"
android:visible=
"false"
android:icon=
"@drawable/ic_create_white_24dp"
...
...
@@ -40,7 +40,7 @@
<item
android:id=
"@+id/action_show_history"
android:title=
"@string/show_history"
app:showAsAction=
"
ifRoom
"
app:showAsAction=
"
never
"
android:orderInCategory=
"130"
android:icon=
"@drawable/ic_forum_white_24dp"
/>
...
...
@@ -67,14 +67,14 @@
<item
android:id=
"@+id/action_clear_history"
android:title=
"@string/clear_history"
app:showAsAction=
"
ifRoom
"
app:showAsAction=
"
never
"
android:orderInCategory=
"160"
android:icon=
"@drawable/ic_clear_all_white_24dp"
/>
<item
android:id=
"@+id/action_close_chat"
android:title=
"@string/close_chat"
app:showAsAction=
"
ifRoom
"
app:showAsAction=
"
never
"
android:orderInCategory=
"165"
android:visible=
"false"
android:icon=
"@drawable/ic_clear_white_24dp"
...
...
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