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
23408a81
Commit
23408a81
authored
Feb 09, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactList menu options "Chat list" now leads to recent chats page of ChatViewer.
parent
27abcc57
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
208 deletions
+64
-208
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-10
ChatList.java
app/src/main/java/com/xabber/android/ui/ChatList.java
+0
-117
ChatViewer.java
app/src/main/java/com/xabber/android/ui/ChatViewer.java
+44
-70
ContactList.java
app/src/main/java/com/xabber/android/ui/ContactList.java
+1
-1
RecentChatFragment.java
...c/main/java/com/xabber/android/ui/RecentChatFragment.java
+7
-0
ChatViewerAdapter.java
...java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+12
-10
No files found.
app/src/main/AndroidManifest.xml
View file @
23408a81
...
...
@@ -110,16 +110,6 @@
android:name=
"android.support.PARENT_ACTIVITY"
android:value=
"com.xabber.android.ui.preferences.AccountList"
/>
</activity>
<activity
android:label=
"@string/chat_list"
android:name=
"com.xabber.android.ui.ChatList"
android:parentActivityName=
"com.xabber.android.ui.ContactList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name=
"android.support.PARENT_ACTIVITY"
android:value=
"com.xabber.android.ui.ContactList"
/>
</activity>
<activity
android:label=
"@string/occupant_list"
android:name=
"com.xabber.android.ui.OccupantList"
...
...
app/src/main/java/com/xabber/android/ui/ChatList.java
deleted
100644 → 0
View file @
27abcc57
/**
* 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/.
*/
package
com
.
xabber
.
android
.
ui
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView.OnItemClickListener
;
import
android.widget.Toast
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.message.OnChatChangedListener
;
import
com.xabber.android.data.roster.OnContactChangedListener
;
import
com.xabber.android.ui.adapter.ChatComparator
;
import
com.xabber.android.ui.adapter.ChatListAdapter
;
import
com.xabber.android.ui.helper.ManagedListActivity
;
import
com.xabber.androiddev.R
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
public
class
ChatList
extends
ManagedListActivity
implements
OnAccountChangedListener
,
OnContactChangedListener
,
OnChatChangedListener
,
OnItemClickListener
{
private
ChatListAdapter
listAdapter
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
isFinishing
())
return
;
setContentView
(
R
.
layout
.
list
);
listAdapter
=
new
ChatListAdapter
(
this
);
setListAdapter
(
listAdapter
);
getListView
().
setOnItemClickListener
(
this
);
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnChatChangedListener
.
class
,
this
);
updateAdapter
();
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
Application
.
getInstance
().
removeUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnChatChangedListener
.
class
,
this
);
}
@Override
public
void
onChatChanged
(
String
account
,
String
user
,
boolean
incoming
)
{
updateAdapter
();
}
@Override
public
void
onContactsChanged
(
Collection
<
BaseEntity
>
addresses
)
{
updateAdapter
();
}
@Override
public
void
onAccountsChanged
(
Collection
<
String
>
accounts
)
{
updateAdapter
();
}
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
AbstractChat
chat
=
(
AbstractChat
)
parent
.
getAdapter
().
getItem
(
position
);
startActivity
(
ChatViewer
.
createIntent
(
this
,
chat
.
getAccount
(),
chat
.
getUser
()));
finish
();
}
public
static
Intent
createIntent
(
Context
context
)
{
return
new
Intent
(
context
,
ChatList
.
class
);
}
private
void
updateAdapter
()
{
List
<
AbstractChat
>
chats
=
new
ArrayList
<>();
chats
.
addAll
(
MessageManager
.
getInstance
().
getActiveChats
());
if
(
chats
.
size
()
==
0
)
{
Toast
.
makeText
(
this
,
R
.
string
.
chat_list_is_empty
,
Toast
.
LENGTH_LONG
).
show
();
finish
();
}
Collections
.
sort
(
chats
,
ChatComparator
.
CHAT_COMPARATOR
);
listAdapter
.
updateChats
(
chats
);
}
}
app/src/main/java/com/xabber/android/ui/ChatViewer.java
View file @
23408a81
...
...
@@ -14,6 +14,7 @@
*/
package
com
.
xabber
.
android
.
ui
;
import
android.app.Fragment
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
...
...
@@ -86,46 +87,35 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
Intent
intent
=
getIntent
();
String
account
=
getAccount
(
intent
);
String
user
=
getUser
(
intent
);
LogManager
.
i
(
this
,
"onCreate account: "
+
account
+
", user: "
+
user
);
if
(
account
==
null
||
user
==
null
)
{
Application
.
getInstance
().
onError
(
R
.
string
.
ENTRY_IS_NOT_FOUND
);
finish
();
return
;
}
if
(
hasAttention
(
intent
))
{
AttentionManager
.
getInstance
().
removeAccountNotifications
(
account
,
user
);
}
actionWithAccount
=
null
;
actionWithUser
=
null
;
if
(
savedInstanceState
!=
null
)
{
actionWithAccount
=
savedInstanceState
.
getString
(
SAVED_ACCOUNT
);
actionWithUser
=
savedInstanceState
.
getString
(
SAVED_USER
);
if
(
account
==
null
||
user
==
null
)
{
account
=
savedInstanceState
.
getString
(
SAVED_ACCOUNT
);
user
=
savedInstanceState
.
getString
(
SAVED_USER
);
}
exitOnSend
=
savedInstanceState
.
getBoolean
(
SAVED_EXIT_ON_SEND
);
}
if
(
actionWithAccount
==
null
)
{
actionWithAccount
=
account
;
}
if
(
actionWithUser
==
null
)
{
actionWithUser
=
user
;
}
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
setContentView
(
R
.
layout
.
activity_chat_viewer
);
chatViewerAdapter
=
new
ChatViewerAdapter
(
getFragmentManager
(),
actionWithAccount
,
actionWithUser
,
this
);
if
(
account
!=
null
&&
user
!=
null
)
{
chatViewerAdapter
=
new
ChatViewerAdapter
(
getFragmentManager
(),
account
,
user
,
this
);
}
else
{
chatViewerAdapter
=
new
ChatViewerAdapter
(
getFragmentManager
(),
this
);
}
viewPager
=
(
ViewPager
)
findViewById
(
R
.
id
.
pager
);
viewPager
.
setAdapter
(
chatViewerAdapter
);
viewPager
.
setOnPageChangeListener
(
this
);
LogManager
.
i
(
this
,
"onCreate user: "
+
actionWithUser
);
selectPage
(
false
);
onChatSelected
();
selectPage
(
account
,
user
,
false
);
}
@Override
...
...
@@ -179,25 +169,13 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
LogManager
.
i
(
this
,
"onNewIntent account: "
+
account
+
", user: "
+
user
);
actionWithUser
=
user
;
actionWithAccount
=
account
;
selectPage
(
false
);
onChatSelected
();
selectPage
(
account
,
user
,
false
);
}
private
void
selectPage
(
boolean
smoothScroll
)
{
int
position
=
chatViewerAdapter
.
getPageNumber
(
actionWithAccount
,
actionWithUser
);
LogManager
.
i
(
this
,
"selectPage user: "
+
actionWithUser
+
" position: "
+
position
);
private
void
selectPage
(
String
account
,
String
user
,
boolean
smoothScroll
)
{
int
position
=
chatViewerAdapter
.
getPageNumber
(
account
,
user
);
viewPager
.
setCurrentItem
(
position
,
smoothScroll
);
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
chat
.
updateChat
(
false
);
}
onPageSelected
(
position
);
}
private
static
String
getAccount
(
Intent
intent
)
{
...
...
@@ -225,6 +203,10 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return
new
EntityIntentBuilder
(
context
,
ChatViewer
.
class
).
setAccount
(
account
).
setUser
(
user
).
build
();
}
public
static
Intent
createIntent
(
Context
context
)
{
return
new
EntityIntentBuilder
(
context
,
ChatViewer
.
class
).
build
();
}
public
static
Intent
createClearTopIntent
(
Context
context
,
String
account
,
String
user
)
{
Intent
intent
=
createIntent
(
context
,
account
,
user
);
...
...
@@ -277,9 +259,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
LogManager
.
i
(
this
,
"onContactsChanged"
);
chatViewerAdapter
.
onChange
();
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
chat
.
updateChat
(
false
);
}
updateRegisteredChats
();
}
@Override
...
...
@@ -287,9 +267,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
LogManager
.
i
(
this
,
"onAccountsChanged"
);
chatViewerAdapter
.
onChange
();
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
chat
.
updateChat
(
false
);
}
updateRegisteredChats
();
}
void
onSent
()
{
...
...
@@ -315,8 +293,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override
public
void
onPageSelected
(
int
position
)
{
AbstractChat
selectedChat
=
chatViewerAdapter
.
getChatByPageNumber
(
position
);
if
(
selectedChat
==
null
)
{
...
...
@@ -324,29 +300,29 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return
;
}
actionWithAccount
=
selectedChat
.
getAccount
();
actionWithUser
=
selectedChat
.
getUser
();
LogManager
.
i
(
this
,
"onPageSelected position: "
+
position
+
" user: "
+
actionWithUser
+
" position: "
+
position
);
String
account
=
selectedChat
.
getAccount
();
String
user
=
selectedChat
.
getUser
();
onChatSelected
();
}
private
void
onChatSelected
()
{
LogManager
.
i
(
this
,
"onChatSelected user: "
+
actionWithUser
);
final
AbstractContact
abstractContact
=
RosterManager
.
getInstance
().
getBestContact
(
actionWithAccount
,
actionWithUser
);
final
AbstractContact
abstractContact
=
RosterManager
.
getInstance
().
getBestContact
(
account
,
user
);
setTitle
(
abstractContact
.
getName
());
MessageManager
.
getInstance
().
setVisibleChat
(
ac
tionWithAccount
,
actionWithU
ser
);
MessageManager
.
getInstance
().
setVisibleChat
(
ac
count
,
u
ser
);
MessageArchiveManager
.
getInstance
().
requestHistory
(
ac
tionWithAccount
,
actionWithU
ser
,
0
,
MessageManager
.
getInstance
().
getChat
(
ac
tionWithAccount
,
actionWithU
ser
).
getRequiredMessageCount
());
ac
count
,
u
ser
,
0
,
MessageManager
.
getInstance
().
getChat
(
ac
count
,
u
ser
).
getRequiredMessageCount
());
NotificationManager
.
getInstance
().
removeMessageNotification
(
actionWithAccount
,
actionWithUser
);
NotificationManager
.
getInstance
().
removeMessageNotification
(
account
,
user
);
actionWithAccount
=
account
;
actionWithUser
=
user
;
}
private
void
updateRegisteredChats
()
{
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
chat
.
updateChat
(
false
);
}
}
@Override
...
...
@@ -366,6 +342,11 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
public
void
onChatViewAdapterFinishUpdate
()
{
LogManager
.
i
(
this
,
"onChatViewAdapterFinishUpdate position: user: "
+
actionWithUser
);
insertExtraText
();
Fragment
currentFragment
=
chatViewerAdapter
.
getCurrentFragment
();
if
(
currentFragment
instanceof
ChatViewerFragment
)
{
((
ChatViewerFragment
)
currentFragment
).
setInputFocus
();
}
}
private
void
insertExtraText
()
{
...
...
@@ -390,14 +371,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override
public
void
onRecentChatSelected
(
AbstractChat
chat
)
{
actionWithAccount
=
chat
.
getAccount
();
actionWithUser
=
chat
.
getUser
();
LogManager
.
i
(
this
,
"onRecentChatSelected position: user: "
+
actionWithUser
);
selectPage
(
true
);
selectPage
(
chat
.
getAccount
(),
chat
.
getUser
(),
true
);
}
@Override
...
...
app/src/main/java/com/xabber/android/ui/ContactList.java
View file @
23408a81
...
...
@@ -283,7 +283,7 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
startActivity
(
MUCEditor
.
createIntent
(
this
));
return
true
;
case
R
.
id
.
action_chat_list
:
startActivity
(
Chat
List
.
createIntent
(
this
));
startActivity
(
Chat
Viewer
.
createIntent
(
this
));
return
true
;
case
R
.
id
.
action_settings
:
startActivity
(
PreferenceEditor
.
createIntent
(
this
));
...
...
app/src/main/java/com/xabber/android/ui/RecentChatFragment.java
View file @
23408a81
...
...
@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ListView
;
import
android.widget.Toast
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.ui.adapter.ChatListAdapter
;
...
...
@@ -63,6 +64,12 @@ public class RecentChatFragment extends ListFragment {
initialChats
=
null
;
}
if
(
getListAdapter
().
isEmpty
())
{
Activity
activity
=
getActivity
();
Toast
.
makeText
(
activity
,
R
.
string
.
chat_list_is_empty
,
Toast
.
LENGTH_LONG
).
show
();
activity
.
finish
();
}
return
inflater
.
inflate
(
R
.
layout
.
list
,
container
,
false
);
}
...
...
app/src/main/java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
View file @
23408a81
...
...
@@ -43,6 +43,15 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
onChange
();
}
public
ChatViewerAdapter
(
FragmentManager
fragmentManager
,
FinishUpdateListener
finishUpdateListener
)
{
super
(
fragmentManager
);
this
.
finishUpdateListener
=
finishUpdateListener
;
activeChats
=
new
ArrayList
<>(
MessageManager
.
getInstance
().
getActiveChats
());
intent
=
null
;
onChange
();
}
@Override
public
int
getCount
()
{
// warning: scrolling to very high values (1,000,000+) results in
...
...
@@ -51,9 +60,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
}
public
int
getRealCount
()
{
int
realCount
=
activeChats
.
size
();
return
realCount
+
1
;
return
activeChats
.
size
()
+
1
;
}
@Override
...
...
@@ -78,7 +85,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
public
void
onChange
()
{
activeChats
=
new
ArrayList
<>(
MessageManager
.
getInstance
().
getActiveChats
());
if
(!
activeChats
.
contains
(
intent
))
{
if
(
intent
!=
null
&&
!
activeChats
.
contains
(
intent
))
{
activeChats
.
add
(
intent
);
}
...
...
@@ -99,7 +106,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
}
}
return
-
1
;
return
0
;
}
public
AbstractChat
getChatByPageNumber
(
int
virtualPosition
)
{
...
...
@@ -127,11 +134,6 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
super
.
finishUpdate
(
container
);
finishUpdateListener
.
onChatViewAdapterFinishUpdate
();
if
(
currentFragment
instanceof
ChatViewerFragment
)
{
((
ChatViewerFragment
)
currentFragment
).
updateChat
(
false
);
((
ChatViewerFragment
)
currentFragment
).
setInputFocus
();
}
}
public
interface
FinishUpdateListener
{
...
...
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