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
f24bde0c
Commit
f24bde0c
authored
Jan 30, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
View pager and FragmentStatePagerAdapter used to scroll active chats.
parent
68946a30
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
313 additions
and
174 deletions
+313
-174
build.gradle
app/build.gradle
+1
-0
ChatViewer.java
app/src/main/java/com/xabber/android/ui/ChatViewer.java
+109
-54
ChatViewerFragment.java
...c/main/java/com/xabber/android/ui/ChatViewerFragment.java
+80
-53
ChatMessageAdapter.java
...ava/com/xabber/android/ui/adapter/ChatMessageAdapter.java
+1
-2
ChatViewerAdapter.java
...java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+83
-0
ContactTitleInflater.java
...va/com/xabber/android/ui/helper/ContactTitleInflater.java
+31
-24
activity_chat_viewer.xml
app/src/main/res/layout/activity_chat_viewer.xml
+8
-0
chat_viewer.xml
app/src/main/res/layout/chat_viewer.xml
+0
-20
chat_viewer_container.xml
app/src/main/res/layout/chat_viewer_container.xml
+0
-21
No files found.
app/build.gradle
View file @
f24bde0c
...
...
@@ -27,4 +27,5 @@ android {
dependencies
{
compile
files
(
'libs/otr4j.jar'
)
compile
'com.android.support:appcompat-v7:21.0.3'
compile
'com.android.support:support-v13:21.0.3'
}
app/src/main/java/com/xabber/android/ui/ChatViewer.java
View file @
f24bde0c
This diff is collapsed.
Click to expand it.
app/src/main/java/com/xabber/android/ui/ChatViewerFragment.java
View file @
f24bde0c
This diff is collapsed.
Click to expand it.
app/src/main/java/com/xabber/android/ui/adapter/ChatMessageAdapter.java
View file @
f24bde0c
...
...
@@ -309,8 +309,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
@Override
public
void
onChange
()
{
messages
=
new
ArrayList
<>(
MessageManager
.
getInstance
()
.
getMessages
(
account
,
user
));
messages
=
new
ArrayList
<>(
MessageManager
.
getInstance
().
getMessages
(
account
,
user
));
hint
=
getHint
();
notifyDataSetChanged
();
}
...
...
app/src/main/java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
0 → 100644
View file @
f24bde0c
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
android.app.Fragment
;
import
android.app.FragmentManager
;
import
android.support.v13.app.FragmentStatePagerAdapter
;
import
android.view.ViewGroup
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.ui.ChatViewerFragment
;
import
com.xabber.xmpp.address.Jid
;
import
java.util.ArrayList
;
public
class
ChatViewerAdapter
extends
FragmentStatePagerAdapter
implements
UpdatableAdapter
{
private
ArrayList
<
AbstractChat
>
activeChats
;
public
ChatViewerAdapter
(
FragmentManager
fragmentManager
)
{
super
(
fragmentManager
);
LogManager
.
i
(
this
,
"ChatViewerAdapter"
);
onChange
();
}
@Override
public
int
getCount
()
{
return
activeChats
.
size
();
}
@Override
public
Fragment
getItem
(
int
i
)
{
LogManager
.
i
(
this
,
"getItem: "
+
i
);
AbstractChat
abstractChat
=
getChat
(
i
);
return
ChatViewerFragment
.
newInstance
(
abstractChat
.
getAccount
(),
abstractChat
.
getUser
());
}
public
AbstractChat
getChat
(
int
i
)
{
return
activeChats
.
get
(
i
);
}
@Override
public
void
onChange
()
{
LogManager
.
i
(
this
,
"onChange: "
);
activeChats
=
new
ArrayList
<>(
MessageManager
.
getInstance
().
getActiveChats
());
notifyDataSetChanged
();
}
public
int
getPosition
(
String
account
,
String
user
)
{
LogManager
.
i
(
this
,
"getPosition: "
+
account
+
" : "
+
user
);
activeChats
=
new
ArrayList
<>(
MessageManager
.
getInstance
().
getActiveChats
());
for
(
int
position
=
0
;
position
<
activeChats
.
size
();
position
++)
{
if
(
activeChats
.
get
(
position
).
equals
(
account
,
user
))
{
return
position
;
}
}
LogManager
.
i
(
this
,
"creating new chat: "
+
account
+
" : "
+
user
);
AbstractChat
chat
=
MessageManager
.
getInstance
().
getOrCreateChat
(
account
,
Jid
.
getBareAddress
(
user
));
activeChats
.
add
(
chat
);
notifyDataSetChanged
();
return
activeChats
.
indexOf
(
chat
);
}
@Override
public
void
setPrimaryItem
(
ViewGroup
container
,
int
position
,
Object
object
)
{
super
.
setPrimaryItem
(
container
,
position
,
object
);
LogManager
.
i
(
this
,
"setPrimaryItem position: "
+
position
);
}
}
\ No newline at end of file
app/src/main/java/com/xabber/android/ui/helper/ContactTitleInflater.java
View file @
f24bde0c
...
...
@@ -50,46 +50,53 @@ public class ContactTitleInflater {
*/
public
static
void
updateTitle
(
View
titleView
,
final
Activity
activity
,
AbstractContact
abstractContact
)
{
final
TypedArray
typedArray
=
activity
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
final
TypedArray
typedArray
=
activity
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
final
Drawable
titleAccountBackground
=
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_titleAccountBackground
);
typedArray
.
recycle
();
final
TextView
nameView
=
(
TextView
)
titleView
.
findViewById
(
R
.
id
.
name
);
final
ImageView
avatarView
=
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
avatar
);
final
ImageView
statusModeView
=
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
status_mode
);
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
);
titleView
.
setBackgroundDrawable
(
titleAccountBackground
);
nameView
.
setText
(
abstractContact
.
getName
());
statusModeView
.
setImageLevel
(
abstractContact
.
getStatusMode
()
.
getStatusLevel
());
titleView
.
getBackground
().
setLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
statusModeView
.
setImageLevel
(
abstractContact
.
getStatusMode
().
getStatusLevel
());
titleView
.
getBackground
().
setLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
abstractContact
.
getAccount
()));
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
,
TextView
statusTextView
)
{
ChatState
chatState
=
ChatStateManager
.
getInstance
().
getChatState
(
abstractContact
.
getAccount
(),
abstractContact
.
getUser
());
final
CharSequence
statusText
;
if
(
chatState
==
ChatState
.
composing
)
if
(
chatState
==
ChatState
.
composing
)
{
statusText
=
activity
.
getString
(
R
.
string
.
chat_state_composing
);
else
if
(
chatState
==
ChatState
.
paused
)
}
else
if
(
chatState
==
ChatState
.
paused
)
{
statusText
=
activity
.
getString
(
R
.
string
.
chat_state_paused
);
else
statusText
=
Emoticons
.
getSmiledText
(
activity
,
abstractContact
.
getStatusText
());
}
else
{
statusText
=
Emoticons
.
getSmiledText
(
activity
,
abstractContact
.
getStatusText
());
}
statusTextView
.
setText
(
statusText
);
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
);
}
}
app/src/main/res/layout/activity_chat_viewer.xml
0 → 100644
View file @
f24bde0c
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/pager"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</android.support.v4.view.ViewPager>
\ No newline at end of file
app/src/main/res/layout/chat_viewer.xml
deleted
100644 → 0
View file @
68946a30
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<com.xabber.android.ui.widget.PageSwitcher
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:id=
"@+id/switcher"
/>
\ No newline at end of file
app/src/main/res/layout/chat_viewer_container.xml
deleted
100644 → 0
View file @
68946a30
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/container"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
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