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
e7ed2237
Commit
e7ed2237
authored
May 23, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use dialog fragment in account chooser for send-to feature.
parent
2f5263cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
29 deletions
+90
-29
ContactList.java
src/com/xabber/android/ui/ContactList.java
+10
-29
AccountChooseDialogFragment.java
...xabber/android/ui/dialog/AccountChooseDialogFragment.java
+80
-0
No files found.
src/com/xabber/android/ui/ContactList.java
View file @
e7ed2237
...
...
@@ -79,7 +79,8 @@ import com.xabber.android.ui.adapter.AccountConfiguration;
import
com.xabber.android.ui.adapter.AccountToggleAdapter
;
import
com.xabber.android.ui.adapter.ContactListAdapter
;
import
com.xabber.android.ui.adapter.GroupConfiguration
;
import
com.xabber.android.ui.dialog.AccountChooseDialogBuilder
;
import
com.xabber.android.ui.dialog.AccountChooseDialogFragment
;
import
com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener
;
import
com.xabber.android.ui.dialog.ConfirmDialogListener
;
import
com.xabber.android.ui.dialog.ContactDeleteDialogFragment
;
import
com.xabber.android.ui.dialog.ContactIntegrationDialogFragment
;
...
...
@@ -101,7 +102,7 @@ import com.xabber.xmpp.uri.XMPPUri;
public
class
ContactList
extends
ManagedListActivity
implements
OnContactChangedListener
,
OnAccountChangedListener
,
OnChatChangedListener
,
View
.
OnClickListener
,
ConfirmDialogListener
,
OnItemClickListener
,
OnLongClickListener
{
OnItemClickListener
,
OnLongClickListener
,
OnChoosedListener
{
/**
* Select contact to be invited to the room was requested.
...
...
@@ -115,8 +116,6 @@ public class ContactList extends ManagedListActivity implements
private
static
final
String
SAVED_ACTION_WITH_GROUP
=
"com.xabber.android.ui.ContactList.SAVED_ACTION_WITH_GROUP"
;
private
static
final
String
SAVED_ACTION_WITH_USER
=
"com.xabber.android.ui.ContactList.SAVED_ACTION_WITH_USER"
;
private
static
final
String
SAVED_SEND_TEXT
=
"com.xabber.android.ui.ContactList.SAVED_SEND_TEXT"
;
private
static
final
String
SAVED_OPEN_DIALOG_USER
=
"com.xabber.android.ui.ContactList.SAVED_OPEN_DIALOG_USER"
;
private
static
final
String
SAVED_OPEN_DIALOG_TEXT
=
"com.xabber.android.ui.ContactList.SAVED_OPEN_DIALOG_TEXT"
;
private
static
final
int
OPTION_MENU_ADD_CONTACT_ID
=
0x02
;
private
static
final
int
OPTION_MENU_STATUS_EDITOR_ID
=
0x04
;
...
...
@@ -153,7 +152,6 @@ public class ContactList extends ManagedListActivity implements
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_NORMAL_ID
=
0x42
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_NEVER_ID
=
0x43
;
private
static
final
int
DIALOG_OPEN_WITH_ACCOUNT_ID
=
0x55
;
private
static
final
int
DIALOG_CLOSE_APPLICATION_ID
=
0x57
;
/**
...
...
@@ -178,8 +176,6 @@ public class ContactList extends ManagedListActivity implements
private
String
actionWithGroup
;
private
String
actionWithUser
;
private
String
sendText
;
private
String
openDialogUser
;
private
String
openDialogText
;
/**
* Title view.
...
...
@@ -240,18 +236,12 @@ public class ContactList extends ManagedListActivity implements
actionWithUser
=
savedInstanceState
.
getString
(
SAVED_ACTION_WITH_USER
);
sendText
=
savedInstanceState
.
getString
(
SAVED_SEND_TEXT
);
openDialogUser
=
savedInstanceState
.
getString
(
SAVED_OPEN_DIALOG_USER
);
openDialogText
=
savedInstanceState
.
getString
(
SAVED_OPEN_DIALOG_TEXT
);
action
=
savedInstanceState
.
getString
(
SAVED_ACTION
);
}
else
{
actionWithAccount
=
null
;
actionWithGroup
=
null
;
actionWithUser
=
null
;
sendText
=
null
;
openDialogUser
=
null
;
openDialogText
=
null
;
action
=
getIntent
().
getAction
();
}
getIntent
().
setAction
(
null
);
...
...
@@ -273,8 +263,6 @@ public class ContactList extends ManagedListActivity implements
outState
.
putString
(
SAVED_ACTION_WITH_GROUP
,
actionWithGroup
);
outState
.
putString
(
SAVED_ACTION_WITH_USER
,
actionWithUser
);
outState
.
putString
(
SAVED_SEND_TEXT
,
sendText
);
outState
.
putString
(
SAVED_OPEN_DIALOG_USER
,
openDialogUser
);
outState
.
putString
(
SAVED_OPEN_DIALOG_TEXT
,
openDialogText
);
}
/**
...
...
@@ -313,9 +301,8 @@ public class ContactList extends ManagedListActivity implements
text
);
return
;
}
openDialogUser
=
bareAddress
;
openDialogText
=
text
;
showDialog
(
DIALOG_OPEN_WITH_ACCOUNT_ID
);
AccountChooseDialogFragment
.
newInstance
(
bareAddress
,
text
).
show
(
getSupportFragmentManager
(),
"OPEN_WITH_ACCOUNT"
);
}
/**
...
...
@@ -783,9 +770,6 @@ public class ContactList extends ManagedListActivity implements
protected
Dialog
onCreateDialog
(
int
id
)
{
super
.
onCreateDialog
(
id
);
switch
(
id
)
{
case
DIALOG_OPEN_WITH_ACCOUNT_ID:
return
new
AccountChooseDialogBuilder
(
this
,
DIALOG_OPEN_WITH_ACCOUNT_ID
,
this
,
openDialogUser
).
create
();
case
DIALOG_CLOSE_APPLICATION_ID:
ProgressDialog
progressDialog
=
new
ProgressDialog
(
this
);
progressDialog
...
...
@@ -997,15 +981,12 @@ public class ContactList extends ManagedListActivity implements
}
@Override
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
DIALOG_OPEN_WITH_ACCOUNT_ID:
BaseEntity
baseEntity
=
new
BaseEntity
(
((
AccountChooseDialogBuilder
)
dialogBuilder
).
getSelected
(),
openDialogUser
);
openChat
(
baseEntity
,
openDialogText
);
break
;
public
void
onChoosed
(
String
account
,
String
user
,
String
text
)
{
openChat
(
new
BaseEntity
(
account
,
user
),
text
);
}
@Override
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
}
@Override
...
...
src/com/xabber/android/ui/dialog/AccountChooseDialog
Builder
.java
→
src/com/xabber/android/ui/dialog/AccountChooseDialog
Fragment
.java
View file @
e7ed2237
/**
* 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
.
dialog
;
import
java.util.ArrayList
;
import
android.app.Activity
;
import
android.app.AlertDialog.Builder
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface.OnClickListener
;
import
android.support.v4.app.DialogFragment
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -26,34 +14,39 @@ import com.xabber.android.data.roster.RosterContact;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.adapter.AccountChooseAdapter
;
public
class
AccountChooseDialogBuilder
extends
ListenableDialogBuilder
{
public
class
AccountChooseDialogFragment
extends
AbstractDialogFragment
{
private
static
final
String
USER
=
"USER"
;
private
static
final
String
TEXT
=
"TEXT"
;
/**
* @param user
* @param text
* @return
*/
public
static
DialogFragment
newInstance
(
String
user
,
String
text
)
{
return
new
AccountChooseDialogFragment
().
putAgrument
(
USER
,
user
)
.
putAgrument
(
TEXT
,
text
);
}
private
final
String
user
;
private
String
selected
;
private
String
user
;
private
String
text
;
public
AccountChooseDialogBuilder
(
Activity
activity
,
int
dialogId
,
final
ConfirmDialogListener
listener
,
String
user
)
{
super
(
activity
,
dialogId
);
this
.
user
=
user
;
this
.
selected
=
null
;
setOnCancelListener
(
listener
);
setOnDeclineListener
(
listener
);
final
Adapter
adapter
=
new
Adapter
(
activity
);
setSingleChoiceItems
(
adapter
,
-
1
,
new
OnClickListener
()
{
@Override
protected
Builder
getBuilder
()
{
user
=
getArguments
().
getString
(
USER
);
text
=
getArguments
().
getString
(
TEXT
);
final
Adapter
adapter
=
new
Adapter
(
getActivity
());
Builder
builder
=
new
Builder
(
getActivity
());
builder
.
setSingleChoiceItems
(
adapter
,
-
1
,
new
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
selected
=
(
String
)
adapter
.
getItem
(
which
);
dialog
.
dismiss
();
listener
.
on
Accept
(
AccountChooseDialogBuilder
.
this
);
String
account
=
(
String
)
adapter
.
getItem
(
which
);
OnChoosedListener
listener
=
(
OnChoosedListener
)
getActivity
();
listener
.
on
Choosed
(
account
,
user
,
text
);
}
});
}
/**
* @return <code>null</code> can be returned.
*/
public
String
getSelected
()
{
return
selected
;
return
builder
;
}
private
class
Adapter
extends
AccountChooseAdapter
{
...
...
@@ -78,4 +71,10 @@ public class AccountChooseDialogBuilder extends ListenableDialogBuilder {
}
public
interface
OnChoosedListener
{
void
onChoosed
(
String
account
,
String
user
,
String
text
);
}
}
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