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
43132231
Commit
43132231
authored
Jul 27, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conference filter activity added - list of conferences can be filtered by typing. #503
parent
bfa625b4
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
632 additions
and
77 deletions
+632
-77
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+7
-3
ConferenceAddFragment.java
...ain/java/com/xabber/android/ui/ConferenceAddFragment.java
+12
-14
ConferenceFilterActivity.java
.../java/com/xabber/android/ui/ConferenceFilterActivity.java
+156
-0
ConferenceSelectActivity.java
.../java/com/xabber/android/ui/ConferenceSelectActivity.java
+4
-4
ConferenceSelectFragment.java
.../java/com/xabber/android/ui/ConferenceSelectFragment.java
+122
-14
ContactList.java
app/src/main/java/com/xabber/android/ui/ContactList.java
+1
-1
HostedConferencesAdapter.java
...m/xabber/android/ui/adapter/HostedConferencesAdapter.java
+147
-0
HostedRoomsAdapter.java
...ava/com/xabber/android/ui/adapter/HostedRoomsAdapter.java
+0
-40
ic_close_circle_grey600_24dp.png
...c/main/res/drawable-hdpi/ic_close_circle_grey600_24dp.png
+0
-0
ic_close_circle_grey600_24dp.png
...c/main/res/drawable-mdpi/ic_close_circle_grey600_24dp.png
+0
-0
ic_close_circle_grey600_24dp.png
.../main/res/drawable-xhdpi/ic_close_circle_grey600_24dp.png
+0
-0
ic_close_circle_grey600_24dp.png
...main/res/drawable-xxhdpi/ic_close_circle_grey600_24dp.png
+0
-0
conference_select_fragment.xml
app/src/main/res/layout/conference_select_fragment.xml
+128
-0
conferences_filter.xml
app/src/main/res/layout/conferences_filter.xml
+52
-0
muc_editor.xml
app/src/main/res/values/muc_editor.xml
+3
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
43132231
...
...
@@ -177,12 +177,12 @@
<activity
android:name=
".ui.ConferenceAdd"
android:label=
"@string/muc_add"
android:parentActivityName=
".ui.
Room
SelectActivity"
>
android:parentActivityName=
".ui.
Conference
SelectActivity"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name=
"android.support.PARENT_ACTIVITY"
android:value=
"
com.xabber.android.ui.Room
SelectActivity"
/>
android:value=
"
.ui.Conference
SelectActivity"
/>
</activity>
<activity
android:name=
".ui.StatusEditor"
...
...
@@ -369,7 +369,7 @@
</activity>
<activity
android:name=
".ui.
Room
SelectActivity"
android:name=
".ui.
Conference
SelectActivity"
android:parentActivityName=
".ui.ContactList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
...
...
@@ -378,6 +378,10 @@
android:value=
"com.xabber.android.ui.ContactList"
/>
</activity>
<activity
android:name=
".ui.ConferenceFilterActivity"
>
</activity>
<service
android:name=
".service.XabberService"
/>
<service
android:name=
".service.SyncAdapterService"
...
...
app/src/main/java/com/xabber/android/ui/ConferenceAddFragment.java
View file @
43132231
...
...
@@ -3,7 +3,6 @@ package com.xabber.android.ui;
import
android.app.Fragment
;
import
android.graphics.drawable.Drawable
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
...
...
@@ -25,19 +24,19 @@ import org.jivesoftware.smack.util.StringUtils;
public
class
ConferenceAddFragment
extends
Fragment
{
protected
static
final
String
ARG_ACCOUNT
=
"com.xabber.android.ui.ConferenceAddFragment.ARG_ACCOUNT"
;
protected
static
final
String
ARG_
ROOM
=
"com.xabber.android.ui.ConferenceAddFragment.ARG_ROOM
"
;
protected
static
final
String
ARG_
CONFERENCE_JID
=
"com.xabber.android.ui.ConferenceAddFragment.ARG_CONFERENCE_NAME
"
;
private
EditText
nickView
;
private
EditText
passwordView
;
private
String
account
=
null
;
private
String
room
=
null
;
private
String
conferenceJid
=
null
;
public
static
ConferenceAddFragment
newInstance
(
String
account
,
String
room
)
{
public
static
ConferenceAddFragment
newInstance
(
String
account
,
String
conference
)
{
ConferenceAddFragment
fragment
=
new
ConferenceAddFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_ACCOUNT
,
account
);
args
.
putString
(
ARG_
ROOM
,
room
);
args
.
putString
(
ARG_
CONFERENCE_JID
,
conference
);
fragment
.
setArguments
(
args
);
return
fragment
;
}
...
...
@@ -48,16 +47,15 @@ public class ConferenceAddFragment extends Fragment {
if
(
getArguments
()
!=
null
)
{
account
=
getArguments
().
getString
(
ARG_ACCOUNT
);
room
=
getArguments
().
getString
(
ARG_ROOM
);
conferenceJid
=
getArguments
().
getString
(
ARG_CONFERENCE_JID
);
}
}
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
conference_add_fragment
,
container
,
false
);
((
TextView
)
view
.
findViewById
(
R
.
id
.
muc_conference_jid
)).
setText
(
room
);
((
TextView
)
view
.
findViewById
(
R
.
id
.
muc_conference_jid
)).
setText
(
conferenceJid
);
((
TextView
)
view
.
findViewById
(
R
.
id
.
muc_account_jid
)).
setText
(
StringUtils
.
parseBareAddress
(
account
));
Drawable
accountAvatar
=
AvatarManager
.
getInstance
().
getAccountAvatar
(
account
);
...
...
@@ -67,22 +65,22 @@ public class ConferenceAddFragment extends Fragment {
((
TextView
)
view
.
findViewById
(
R
.
id
.
muc_account_jid
)).
setCompoundDrawables
(
accountAvatar
,
null
,
null
,
null
);
nickView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
muc_nick
);
nickView
.
setText
(
MUCManager
.
getInstance
().
getNickname
(
account
,
room
));
nickView
.
setText
(
MUCManager
.
getInstance
().
getNickname
(
account
,
conferenceJid
));
if
(
""
.
equals
(
nickView
.
getText
().
toString
()))
{
nickView
.
setText
(
getNickname
(
account
));
}
passwordView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
muc_password
);
String
password
;
RoomInvite
roomInvite
=
MUCManager
.
getInstance
().
getInvite
(
account
,
room
);
RoomInvite
roomInvite
=
MUCManager
.
getInstance
().
getInvite
(
account
,
conferenceJid
);
if
(
roomInvite
!=
null
)
{
password
=
roomInvite
.
getPassword
();
}
else
{
password
=
MUCManager
.
getInstance
().
getPassword
(
account
,
room
);
password
=
MUCManager
.
getInstance
().
getPassword
(
account
,
conferenceJid
);
}
passwordView
.
setText
(
password
);
MUCManager
.
getInstance
().
removeAuthorizationError
(
account
,
room
);
MUCManager
.
getInstance
().
removeAuthorizationError
(
account
,
conferenceJid
);
setHasOptionsMenu
(
true
);
...
...
@@ -91,7 +89,7 @@ public class ConferenceAddFragment extends Fragment {
/**
* @return Suggested nickname in the
room
.
* @return Suggested nickname in the
conferenceJid
.
*/
private
String
getNickname
(
String
account
)
{
if
(
account
==
null
)
{
...
...
@@ -114,7 +112,7 @@ public class ConferenceAddFragment extends Fragment {
}
String
password
=
passwordView
.
getText
().
toString
();
final
boolean
join
=
true
;
MUCManager
.
getInstance
().
createRoom
(
account
,
room
,
nick
,
password
,
join
);
MUCManager
.
getInstance
().
createRoom
(
account
,
conferenceJid
,
nick
,
password
,
join
);
getActivity
().
finish
();
}
...
...
app/src/main/java/com/xabber/android/ui/ConferenceFilterActivity.java
0 → 100644
View file @
43132231
package
com
.
xabber
.
android
.
ui
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.ListView
;
import
com.xabber.android.R
;
import
com.xabber.android.data.intent.AccountIntentBuilder
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.ui.adapter.HostedConferencesAdapter
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
org.jivesoftware.smackx.muc.HostedRoom
;
import
org.jivesoftware.smackx.packet.DiscoverItems
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ConferenceFilterActivity
extends
ManagedActivity
implements
TextWatcher
,
View
.
OnClickListener
,
AdapterView
.
OnItemClickListener
{
public
static
final
String
ARG_CONFERENCE_NAME
=
"com.xabber.android.ui.ConferenceFilterActivity.ARG_CONFERENCE_NAME"
;
public
static
final
String
ARG_CONFERENCE_LIST_NAMES
=
"com.xabber.android.ui.ConferenceFilterActivity.ARG_CONFERENCE_LIST_NAMES"
;
public
static
final
String
ARG_CONFERENCE_LIST_JIDS
=
"com.xabber.android.ui.ConferenceFilterActivity.ARG_CONFERENCE_LIST_JIDS"
;
public
static
final
String
ARG_CONFERENCE_LIST
=
"com.xabber.android.ui.ConferenceFilterActivity.ARG_CONFERENCE_LIST"
;
public
static
final
int
REQUEST_CODE_FILTER_ROOMS
=
1
;
private
EditText
conferenceNameEditText
;
private
ImageButton
roomClearButton
;
private
String
account
;
private
HostedConferencesAdapter
hostedConferencesAdapter
;
public
static
Intent
createIntent
(
Context
context
,
String
account
)
{
return
new
EntityIntentBuilder
(
context
,
ConferenceFilterActivity
.
class
).
setAccount
(
account
).
build
();
}
private
static
String
getAccount
(
Intent
intent
)
{
return
AccountIntentBuilder
.
getAccount
(
intent
);
}
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
event
)
{
if
(
event
.
getKeyCode
()
==
KeyEvent
.
KEYCODE_BACK
)
{
Intent
data
=
new
Intent
();
data
.
putExtra
(
ARG_CONFERENCE_NAME
,
conferenceNameEditText
.
getText
().
toString
());
setResult
(
RESULT_OK
,
data
);
finish
();
return
true
;
}
return
super
.
dispatchKeyEvent
(
event
);
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
conferences_filter
);
roomClearButton
=
(
ImageButton
)
findViewById
(
R
.
id
.
room_clear_button
);
roomClearButton
.
setOnClickListener
(
this
);
conferenceNameEditText
=
(
EditText
)
findViewById
(
R
.
id
.
room_name_edit_text
);
conferenceNameEditText
.
addTextChangedListener
(
this
);
setRoomClearButtonVisibility
();
Intent
intent
=
getIntent
();
account
=
getAccount
(
intent
);
hostedConferencesAdapter
=
new
HostedConferencesAdapter
(
this
);
ListView
listView
=
(
ListView
)
findViewById
(
R
.
id
.
hosted_rooms_list_view
);
listView
.
setAdapter
(
hostedConferencesAdapter
);
listView
.
setOnItemClickListener
(
this
);
Bundle
bundleExtra
=
intent
.
getBundleExtra
(
ARG_CONFERENCE_LIST
);
hostedConferencesAdapter
.
addAll
(
restoreConferenceList
(
bundleExtra
));
String
room
=
intent
.
getStringExtra
(
ARG_CONFERENCE_NAME
);
if
(
room
!=
null
)
{
conferenceNameEditText
.
setText
(
room
);
conferenceNameEditText
.
setSelection
(
room
.
length
());
}
}
public
static
List
<
HostedRoom
>
restoreConferenceList
(
Bundle
bundleExtra
)
{
List
<
String
>
conferencesNames
=
bundleExtra
.
getStringArrayList
(
ARG_CONFERENCE_LIST_NAMES
);
List
<
String
>
conferencesJids
=
bundleExtra
.
getStringArrayList
(
ARG_CONFERENCE_LIST_JIDS
);
List
<
HostedRoom
>
conferences
=
new
ArrayList
<>();
if
(
conferencesNames
!=
null
&&
conferencesJids
!=
null
&&
conferencesNames
.
size
()
==
conferencesJids
.
size
())
{
for
(
int
i
=
0
;
i
<
conferencesNames
.
size
();
i
++)
{
DiscoverItems
.
Item
item
=
new
DiscoverItems
.
Item
(
conferencesJids
.
get
(
i
));
item
.
setName
(
conferencesNames
.
get
(
i
));
conferences
.
add
(
new
HostedRoom
(
item
));
}
}
return
conferences
;
}
private
void
setRoomClearButtonVisibility
()
{
if
(
conferenceNameEditText
.
getText
().
toString
().
trim
().
isEmpty
())
{
roomClearButton
.
setVisibility
(
View
.
GONE
);
}
else
{
roomClearButton
.
setVisibility
(
View
.
VISIBLE
);
}
}
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
setRoomClearButtonVisibility
();
hostedConferencesAdapter
.
getFilter
().
filter
(
s
);
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
}
@Override
public
void
onClick
(
View
v
)
{
if
(
v
.
getId
()
==
R
.
id
.
room_clear_button
)
{
conferenceNameEditText
.
getText
().
clear
();
}
}
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
startActivity
(
ConferenceAdd
.
createIntent
(
this
,
account
,
hostedConferencesAdapter
.
getItem
(
position
).
getJid
()));
}
}
app/src/main/java/com/xabber/android/ui/
Room
SelectActivity.java
→
app/src/main/java/com/xabber/android/ui/
Conference
SelectActivity.java
View file @
43132231
...
...
@@ -12,12 +12,12 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import
com.xabber.android.ui.helper.BarPainter
;
import
com.xabber.android.ui.helper.ManagedActivity
;
public
class
RoomSelectActivity
extends
ManagedActivity
implements
Room
SelectFragment
.
Listener
{
public
class
ConferenceSelectActivity
extends
ManagedActivity
implements
Conference
SelectFragment
.
Listener
{
private
BarPainter
barPainter
;
public
static
Intent
createIntent
(
Context
context
)
{
return
new
EntityIntentBuilder
(
context
,
Room
SelectActivity
.
class
).
build
();
return
new
EntityIntentBuilder
(
context
,
Conference
SelectActivity
.
class
).
build
();
}
@Override
...
...
@@ -31,7 +31,7 @@ public class RoomSelectActivity extends ManagedActivity implements RoomSelectFra
toolbar
.
setNavigationOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
NavUtils
.
navigateUpFromSameTask
(
Room
SelectActivity
.
this
);
NavUtils
.
navigateUpFromSameTask
(
Conference
SelectActivity
.
this
);
}
});
toolbar
.
setTitle
(
getString
(
R
.
string
.
muc_choose_conference
));
...
...
@@ -40,7 +40,7 @@ public class RoomSelectActivity extends ManagedActivity implements RoomSelectFra
barPainter
.
setDefaultColor
();
if
(
savedInstanceState
==
null
)
{
getFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
new
Room
SelectFragment
()).
commit
();
getFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
new
Conference
SelectFragment
()).
commit
();
}
}
...
...
app/src/main/java/com/xabber/android/ui/
Room
SelectFragment.java
→
app/src/main/java/com/xabber/android/ui/
Conference
SelectFragment.java
View file @
43132231
...
...
@@ -2,7 +2,10 @@ package com.xabber.android.ui;
import
android.app.Activity
;
import
android.app.ListFragment
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -17,20 +20,22 @@ import com.xabber.android.R;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.extension.muc.MUCManager
;
import
com.xabber.android.ui.adapter.AccountChooseAdapter
;
import
com.xabber.android.ui.adapter.Hosted
Room
sAdapter
;
import
com.xabber.android.ui.adapter.Hosted
Conference
sAdapter
;
import
com.xabber.android.ui.helper.AccountPainter
;
import
org.jivesoftware.smackx.muc.HostedRoom
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
public
class
Room
SelectFragment
extends
ListFragment
implements
AdapterView
.
OnItemSelectedListener
,
public
class
Conference
SelectFragment
extends
ListFragment
implements
AdapterView
.
OnItemSelectedListener
,
View
.
OnClickListener
,
MUCManager
.
HostedRoomsListener
,
AdapterView
.
OnItemClickListener
{
private
Spinner
accountView
;
private
EditText
serverView
;
private
EditText
roomView
;
private
Hosted
RoomsAdapter
hostedRoom
sAdapter
;
private
Hosted
ConferencesAdapter
hostedConference
sAdapter
;
private
View
roomsProgressBar
;
private
String
account
;
...
...
@@ -38,7 +43,7 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
private
AccountPainter
accountPainter
;
private
Button
nextButton
;
public
Room
SelectFragment
()
{
public
Conference
SelectFragment
()
{
}
@Override
...
...
@@ -57,11 +62,39 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
room
_select_fragment
,
container
,
false
);
View
view
=
inflater
.
inflate
(
R
.
layout
.
conference
_select_fragment
,
container
,
false
);
accountView
=
(
Spinner
)
view
.
findViewById
(
R
.
id
.
contact_account
);
serverView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
muc_server
);
roomView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
muc_room
);
roomView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
muc_conference_name
);
roomView
.
setOnClickListener
(
this
);
roomView
.
setOnFocusChangeListener
(
new
View
.
OnFocusChangeListener
()
{
@Override
public
void
onFocusChange
(
View
v
,
boolean
hasFocus
)
{
if
(
hasFocus
)
{
onRoomNameEditTextClick
();
}
}
});
roomView
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
hostedConferencesAdapter
.
getFilter
().
filter
(
s
);
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
}
});
roomsProgressBar
=
view
.
findViewById
(
R
.
id
.
muc_rooms_progress_bar
);
...
...
@@ -87,17 +120,31 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
public
void
onActivityCreated
(
Bundle
savedInstanceState
)
{
super
.
onActivityCreated
(
savedInstanceState
);
hosted
RoomsAdapter
=
new
HostedRoomsAdapter
(
getActivity
(),
android
.
R
.
layout
.
simple_list_item_2
);
hosted
ConferencesAdapter
=
new
HostedConferencesAdapter
(
getActivity
()
);
ListView
listView
=
getListView
();
listView
.
setAdapter
(
hosted
Room
sAdapter
);
listView
.
setAdapter
(
hosted
Conference
sAdapter
);
listView
.
setOnItemClickListener
(
this
);
if
(
savedInstanceState
!=
null
)
{
hostedConferencesAdapter
.
clear
();
hostedConferencesAdapter
.
addAll
(
ConferenceFilterActivity
.
restoreConferenceList
(
savedInstanceState
));
}
}
@Override
public
void
onSaveInstanceState
(
Bundle
outState
)
{
super
.
onSaveInstanceState
(
outState
);
storeConferenceList
(
outState
);
}
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
startActivity
(
ConferenceAdd
.
createIntent
(
getActivity
(),
account
,
hosted
Room
sAdapter
.
getItem
(
position
).
getJid
()));
hosted
Conference
sAdapter
.
getItem
(
position
).
getJid
()));
}
@Override
...
...
@@ -108,12 +155,16 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
return
;
}
if
(
account
!=
null
)
{
hostedConferencesAdapter
.
clear
();
}
account
=
newAccount
;
listener
.
onAccountSelected
(
account
);
nextButton
.
setTextColor
(
accountPainter
.
getAccountDarkColor
(
account
));
hostedRoomsAdapter
.
clear
();
}
@Override
...
...
@@ -129,6 +180,58 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
break
;
case
R
.
id
.
muc_next
:
onNextClick
();
break
;
case
R
.
id
.
muc_conference_name
:
onRoomNameEditTextClick
();
break
;
}
}
private
void
onRoomNameEditTextClick
()
{
if
(
hostedConferencesAdapter
.
isEmpty
())
{
return
;
}
Intent
intent
=
ConferenceFilterActivity
.
createIntent
(
getActivity
(),
account
);
intent
.
putExtra
(
ConferenceFilterActivity
.
ARG_CONFERENCE_NAME
,
roomView
.
getText
().
toString
());
Bundle
bundle
=
new
Bundle
();
storeConferenceList
(
bundle
);
intent
.
putExtra
(
ConferenceFilterActivity
.
ARG_CONFERENCE_LIST
,
bundle
);
startActivityForResult
(
intent
,
ConferenceFilterActivity
.
REQUEST_CODE_FILTER_ROOMS
);
}
private
void
storeConferenceList
(
Bundle
intent
)
{
List
<
HostedRoom
>
conferencesList
=
new
ArrayList
<>();
conferencesList
.
addAll
(
hostedConferencesAdapter
.
getConferencesList
());
ArrayList
<
String
>
names
=
new
ArrayList
<>();
ArrayList
<
String
>
jids
=
new
ArrayList
<>();
for
(
HostedRoom
hostedRoom
:
conferencesList
)
{
names
.
add
(
hostedRoom
.
getName
());
jids
.
add
(
hostedRoom
.
getJid
());
}
intent
.
putStringArrayList
(
ConferenceFilterActivity
.
ARG_CONFERENCE_LIST_NAMES
,
names
);
intent
.
putStringArrayList
(
ConferenceFilterActivity
.
ARG_CONFERENCE_LIST_JIDS
,
jids
);
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
ConferenceFilterActivity
.
REQUEST_CODE_FILTER_ROOMS
)
{
String
stringExtra
=
data
.
getStringExtra
(
ConferenceFilterActivity
.
ARG_CONFERENCE_NAME
);
if
(
stringExtra
!=
null
)
{
onConferenceNameChanged
(
stringExtra
);
}
}
}
...
...
@@ -167,7 +270,7 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
ChatViewer
.
hideKeyboard
(
getActivity
());
MUCManager
.
requestHostedRooms
(
account
,
server
,
this
);
hosted
Room
sAdapter
.
clear
();
hosted
Conference
sAdapter
.
clear
();
roomsProgressBar
.
setVisibility
(
View
.
VISIBLE
);
}
...
...
@@ -176,12 +279,17 @@ public class RoomSelectFragment extends ListFragment implements AdapterView.OnIt
roomsProgressBar
.
setVisibility
(
View
.
GONE
);
if
(
hostedRooms
==
null
)
{
Toast
.
makeText
(
getActivity
(),
"Error getting rooms"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getActivity
(),
R
.
string
.
muc_error_getting_conferences
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
hostedRoomsAdapter
.
clear
();
hostedRoomsAdapter
.
addAll
(
hostedRooms
);
hostedConferencesAdapter
.
clear
();
hostedConferencesAdapter
.
addAll
(
hostedRooms
);
}
public
void
onConferenceNameChanged
(
String
stringExtra
)
{
roomView
.
setText
(
stringExtra
);
roomView
.
setSelection
(
stringExtra
.
length
());
}
interface
Listener
{
...
...
app/src/main/java/com/xabber/android/ui/ContactList.java
View file @
43132231
...
...
@@ -429,7 +429,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
closeAllChats
();
return
true
;
case
R
.
id
.
action_join_conference
:
startActivity
(
Room
SelectActivity
.
createIntent
(
this
));
startActivity
(
Conference
SelectActivity
.
createIntent
(
this
));
return
true
;
case
R
.
id
.
action_chat_list
:
startActivity
(
ChatViewer
.
createRecentChatsIntent
(
this
));
...
...
app/src/main/java/com/xabber/android/ui/adapter/HostedConferencesAdapter.java
0 → 100644
View file @
43132231
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
android.content.Context
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseAdapter
;
import
android.widget.Filter
;
import
android.widget.Filterable
;
import
android.widget.TextView
;
import
org.jivesoftware.smack.util.StringUtils
;
import
org.jivesoftware.smackx.muc.HostedRoom
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
public
class
HostedConferencesAdapter
extends
BaseAdapter
implements
Filterable
{
private
List
<
HostedRoom
>
originalData
=
null
;
private
List
<
HostedRoom
>
filteredData
=
null
;
private
LayoutInflater
inflater
;
private
HostedRoomsFilter
filter
=
new
HostedRoomsFilter
();
public
HostedConferencesAdapter
(
Context
context
)
{
this
.
filteredData
=
new
ArrayList
<>();
this
.
originalData
=
new
ArrayList
<>();
inflater
=
LayoutInflater
.
from
(
context
);
}
@Override
public
int
getCount
()
{
return
filteredData
.
size
();
}
@Override
public
HostedRoom
getItem
(
int
position
)
{
return
filteredData
.
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
return
position
;
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
// A ViewHolder keeps references to children views to avoid unnecessary calls
// to findViewById() on each row.
ViewHolder
holder
;
// When convertView is not null, we can reuse it directly, there is no need
// to reinflate it. We only inflate a new View when the convertView supplied
// by ListView is null.
if
(
convertView
==
null
)
{
convertView
=
inflater
.
inflate
(
android
.
R
.
layout
.
simple_list_item_2
,
null
);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder
=
new
ViewHolder
();
holder
.
name
=
(
TextView
)
convertView
.
findViewById
(
android
.
R
.
id
.
text1
);
holder
.
jid
=
(
TextView
)
convertView
.
findViewById
(
android
.
R
.
id
.
text2
);
// Bind the data efficiently with the holder.
convertView
.
setTag
(
holder
);
}
else
{
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder
=
(
ViewHolder
)
convertView
.
getTag
();
}
// If weren't re-ordering this you could rely on what you set last time
HostedRoom
hostedRoom
=
filteredData
.
get
(
position
);
holder
.
name
.
setText
(
hostedRoom
.
getName
());
holder
.
jid
.
setText
(
hostedRoom
.
getJid
());
return
convertView
;
}
static
class
ViewHolder
{
TextView
name
;
TextView
jid
;
}
public
void
clear
()
{
filteredData
.
clear
();
originalData
.
clear
();
notifyDataSetChanged
();
}
public
void
addAll
(
Collection
<
HostedRoom
>
hostedRooms
)
{
filteredData
.
addAll
(
hostedRooms
);
originalData
.
addAll
(
hostedRooms
);
notifyDataSetChanged
();
}
@Override
public
Filter
getFilter
()
{
return
filter
;
}
private
class
HostedRoomsFilter
extends
Filter
{
@Override
protected
FilterResults
performFiltering
(
CharSequence
constraint
)
{
String
filterString
=
constraint
.
toString
().
toLowerCase
();
FilterResults
results
=
new
FilterResults
();
final
List
<
HostedRoom
>
list
=
originalData
;
int
count
=
list
.
size
();
final
ArrayList
<
HostedRoom
>
newList
=
new
ArrayList
<>(
count
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
HostedRoom
room
=
list
.
get
(
i
);
String
filterableJidName
=
StringUtils
.
parseName
(
room
.
getJid
()).
toLowerCase
();
String
filterableRoomName
=
room
.
getName
().
toLowerCase
();
if
(
filterableJidName
.
contains
(
filterString
)
||
filterableRoomName
.
contains
(
filterString
))
{
newList
.
add
(
room
);
}
}
results
.
values
=
newList
;
results
.
count
=
newList
.
size
();
return
results
;
}
@SuppressWarnings
(
"unchecked"
)
@Override
protected
void
publishResults
(
CharSequence
constraint
,
FilterResults
results
)
{
filteredData
=
(
List
<
HostedRoom
>)
results
.
values
;
notifyDataSetChanged
();
}
}
public
List
<
HostedRoom
>
getConferencesList
()
{
return
originalData
;
}
}
app/src/main/java/com/xabber/android/ui/adapter/HostedRoomsAdapter.java
deleted
100644 → 0
View file @
bfa625b4
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
android.content.Context
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ArrayAdapter
;
import
android.widget.TextView
;
import
org.jivesoftware.smackx.muc.HostedRoom
;
public
class
HostedRoomsAdapter
extends
ArrayAdapter
<
HostedRoom
>
{
public
HostedRoomsAdapter
(
Context
context
,
int
resource
)
{
super
(
context
,
resource
);
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
View
view
;
if
(
convertView
==
null
)
{
LayoutInflater
layoutInflater
=
(
LayoutInflater
)
getContext
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
view
=
layoutInflater
.
inflate
(
android
.
R
.
layout
.
simple_list_item_2
,
parent
,
false
);
}
else
{
view
=
convertView
;
}
TextView
mainText
=
(
TextView
)
view
.
findViewById
(
android
.
R
.
id
.
text1
);
TextView
secondText
=
(
TextView
)
view
.
findViewById
(
android
.
R
.
id
.
text2
);
HostedRoom
room
=
getItem
(
position
);
mainText
.
setText
(
room
.
getName
());
secondText
.
setText
(
room
.
getJid
());
return
view
;
}
}
app/src/main/res/drawable-hdpi/ic_close_circle_grey600_24dp.png
0 → 100644
View file @
43132231
924 Bytes
app/src/main/res/drawable-mdpi/ic_close_circle_grey600_24dp.png
0 → 100644
View file @
43132231
553 Bytes
app/src/main/res/drawable-xhdpi/ic_close_circle_grey600_24dp.png
0 → 100644
View file @
43132231
1.07 KB
app/src/main/res/drawable-xxhdpi/ic_close_circle_grey600_24dp.png
0 → 100644
View file @
43132231
1.45 KB
app/src/main/res/layout/
room
_select_fragment.xml
→
app/src/main/res/layout/
conference
_select_fragment.xml
View file @
43132231
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"com.xabber.android.ui.
Room
SelectFragment"
tools:context=
"com.xabber.android.ui.
Conference
SelectFragment"
android:orientation=
"vertical"
>
...
...
@@ -9,18 +9,18 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:layout_above=
"@+id/bottom_bar"
android:layout_alignParentTop=
"true"
android:paddingTop=
"16dp"
android:paddingLeft=
"16dp"
android:paddingRight=
"16dp"
android:id=
"@+id/top_panel"
>
<com.xabber.android.ui.widget.NoDefaultSpinner
android:id=
"@+id/contact_account"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"@dimen/avatar_normal_size
"
android:minHeight=
"56dp
"
android:prompt=
"@string/choose_account"
/>
<LinearLayout
...
...
@@ -56,11 +56,14 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_search_grey600_24dp"
android:padding=
"16dp"
android:paddingLeft=
"16dp"
android:paddingRight=
"8dp"
android:paddingTop=
"16dp"
android:paddingBottom=
"8dp"
android:background=
"@drawable/drawer_touch"
android:id=
"@+id/muc_get_hosted_rooms"
android:contentDescription=
"@string/muc_get_hosted_room
s"
android:layout_gravity=
"center_vertical
"
android:contentDescription=
"@string/muc_get_hosted_conference
s"
android:layout_gravity=
"bottom|right
"
/>
</LinearLayout>
...
...
@@ -71,9 +74,10 @@
android:text=
"@string/muc_room"
/>
<EditText
android:id=
"@+id/muc_room
"
android:id=
"@+id/muc_conference_name
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"@string/muc_type_conference_name"
android:singleLine=
"true"
/>
<ProgressBar
...
...
@@ -84,15 +88,6 @@
android:visibility=
"gone"
/>
<ListView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@android:id/list"
>
</ListView>
</LinearLayout>
<RelativeLayout
...
...
@@ -122,4 +117,12 @@
/>
</RelativeLayout>
<ListView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@android:id/list"
android:layout_above=
"@id/bottom_bar"
android:layout_below=
"@id/top_panel"
/>
</RelativeLayout>
app/src/main/res/layout/conferences_filter.xml
0 → 100644
View file @
43132231
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"com.xabber.android.ui.ConferenceFilterActivity"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:orientation=
"horizontal"
android:layout_alignParentTop=
"true"
android:elevation=
"8dp"
android:background=
"@color/white"
android:id=
"@+id/linearLayout"
>
<EditText
android:layout_height=
"match_parent"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:background=
"@null"
android:hint=
"@string/muc_type_conference_name"
android:paddingLeft=
"16dp"
android:id=
"@+id/room_name_edit_text"
android:imeOptions=
"flagNoExtractUi"
/>
<ImageButton
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:src=
"@drawable/ic_close_circle_grey600_24dp"
android:background=
"@drawable/drawer_touch"
android:layout_gravity=
"center_vertical"
android:paddingRight=
"16dp"
android:paddingLeft=
"16dp"
android:id=
"@+id/room_clear_button"
/>
</LinearLayout>
<ListView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/hosted_rooms_list_view"
android:layout_below=
"@+id/linearLayout"
android:layout_alignLeft=
"@+id/linearLayout"
android:layout_alignStart=
"@+id/linearLayout"
android:layout_alignParentBottom=
"true"
/>
</RelativeLayout>
app/src/main/res/values/muc_editor.xml
View file @
43132231
...
...
@@ -23,5 +23,7 @@
<string
name=
"muc_choose_conference"
>
Choose conference
</string>
<string
name=
"muc_next"
>
Next
</string>
<string
name=
"muc_get_hosted_rooms"
>
Get hosted rooms
</string>
<string
name=
"muc_get_hosted_conferences"
>
Get hosted conferences
</string>
<string
name=
"muc_error_getting_conferences"
>
Error getting conferences
</string>
<string
name=
"muc_type_conference_name"
>
Type conference name
</string>
</resources>
\ 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