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
Hide 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;
...
@@ -79,7 +79,8 @@ import com.xabber.android.ui.adapter.AccountConfiguration;
import
com.xabber.android.ui.adapter.AccountToggleAdapter
;
import
com.xabber.android.ui.adapter.AccountToggleAdapter
;
import
com.xabber.android.ui.adapter.ContactListAdapter
;
import
com.xabber.android.ui.adapter.ContactListAdapter
;
import
com.xabber.android.ui.adapter.GroupConfiguration
;
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.ConfirmDialogListener
;
import
com.xabber.android.ui.dialog.ContactDeleteDialogFragment
;
import
com.xabber.android.ui.dialog.ContactDeleteDialogFragment
;
import
com.xabber.android.ui.dialog.ContactIntegrationDialogFragment
;
import
com.xabber.android.ui.dialog.ContactIntegrationDialogFragment
;
...
@@ -101,7 +102,7 @@ import com.xabber.xmpp.uri.XMPPUri;
...
@@ -101,7 +102,7 @@ import com.xabber.xmpp.uri.XMPPUri;
public
class
ContactList
extends
ManagedListActivity
implements
public
class
ContactList
extends
ManagedListActivity
implements
OnContactChangedListener
,
OnAccountChangedListener
,
OnContactChangedListener
,
OnAccountChangedListener
,
OnChatChangedListener
,
View
.
OnClickListener
,
ConfirmDialogListener
,
OnChatChangedListener
,
View
.
OnClickListener
,
ConfirmDialogListener
,
OnItemClickListener
,
OnLongClickListener
{
OnItemClickListener
,
OnLongClickListener
,
OnChoosedListener
{
/**
/**
* Select contact to be invited to the room was requested.
* Select contact to be invited to the room was requested.
...
@@ -115,8 +116,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -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_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_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_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_ADD_CONTACT_ID
=
0x02
;
private
static
final
int
OPTION_MENU_STATUS_EDITOR_ID
=
0x04
;
private
static
final
int
OPTION_MENU_STATUS_EDITOR_ID
=
0x04
;
...
@@ -153,7 +152,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -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_NORMAL_ID
=
0x42
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_NEVER_ID
=
0x43
;
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
;
private
static
final
int
DIALOG_CLOSE_APPLICATION_ID
=
0x57
;
/**
/**
...
@@ -178,8 +176,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -178,8 +176,6 @@ public class ContactList extends ManagedListActivity implements
private
String
actionWithGroup
;
private
String
actionWithGroup
;
private
String
actionWithUser
;
private
String
actionWithUser
;
private
String
sendText
;
private
String
sendText
;
private
String
openDialogUser
;
private
String
openDialogText
;
/**
/**
* Title view.
* Title view.
...
@@ -240,18 +236,12 @@ public class ContactList extends ManagedListActivity implements
...
@@ -240,18 +236,12 @@ public class ContactList extends ManagedListActivity implements
actionWithUser
=
savedInstanceState
actionWithUser
=
savedInstanceState
.
getString
(
SAVED_ACTION_WITH_USER
);
.
getString
(
SAVED_ACTION_WITH_USER
);
sendText
=
savedInstanceState
.
getString
(
SAVED_SEND_TEXT
);
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
);
action
=
savedInstanceState
.
getString
(
SAVED_ACTION
);
}
else
{
}
else
{
actionWithAccount
=
null
;
actionWithAccount
=
null
;
actionWithGroup
=
null
;
actionWithGroup
=
null
;
actionWithUser
=
null
;
actionWithUser
=
null
;
sendText
=
null
;
sendText
=
null
;
openDialogUser
=
null
;
openDialogText
=
null
;
action
=
getIntent
().
getAction
();
action
=
getIntent
().
getAction
();
}
}
getIntent
().
setAction
(
null
);
getIntent
().
setAction
(
null
);
...
@@ -273,8 +263,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -273,8 +263,6 @@ public class ContactList extends ManagedListActivity implements
outState
.
putString
(
SAVED_ACTION_WITH_GROUP
,
actionWithGroup
);
outState
.
putString
(
SAVED_ACTION_WITH_GROUP
,
actionWithGroup
);
outState
.
putString
(
SAVED_ACTION_WITH_USER
,
actionWithUser
);
outState
.
putString
(
SAVED_ACTION_WITH_USER
,
actionWithUser
);
outState
.
putString
(
SAVED_SEND_TEXT
,
sendText
);
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
...
@@ -313,9 +301,8 @@ public class ContactList extends ManagedListActivity implements
text
);
text
);
return
;
return
;
}
}
openDialogUser
=
bareAddress
;
AccountChooseDialogFragment
.
newInstance
(
bareAddress
,
text
).
show
(
openDialogText
=
text
;
getSupportFragmentManager
(),
"OPEN_WITH_ACCOUNT"
);
showDialog
(
DIALOG_OPEN_WITH_ACCOUNT_ID
);
}
}
/**
/**
...
@@ -783,9 +770,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -783,9 +770,6 @@ public class ContactList extends ManagedListActivity implements
protected
Dialog
onCreateDialog
(
int
id
)
{
protected
Dialog
onCreateDialog
(
int
id
)
{
super
.
onCreateDialog
(
id
);
super
.
onCreateDialog
(
id
);
switch
(
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:
case
DIALOG_CLOSE_APPLICATION_ID:
ProgressDialog
progressDialog
=
new
ProgressDialog
(
this
);
ProgressDialog
progressDialog
=
new
ProgressDialog
(
this
);
progressDialog
progressDialog
...
@@ -996,16 +980,13 @@ public class ContactList extends ManagedListActivity implements
...
@@ -996,16 +980,13 @@ public class ContactList extends ManagedListActivity implements
contactListAdapter
.
refreshRequest
();
contactListAdapter
.
refreshRequest
();
}
}
@Override
public
void
onChoosed
(
String
account
,
String
user
,
String
text
)
{
openChat
(
new
BaseEntity
(
account
,
user
),
text
);
}
@Override
@Override
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
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
;
}
}
}
@Override
@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
;
package
com
.
xabber
.
android
.
ui
.
dialog
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.app.AlertDialog.Builder
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface.OnClickListener
;
import
android.content.DialogInterface.OnClickListener
;
import
android.support.v4.app.DialogFragment
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
...
@@ -26,34 +14,39 @@ import com.xabber.android.data.roster.RosterContact;
...
@@ -26,34 +14,39 @@ import com.xabber.android.data.roster.RosterContact;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.adapter.AccountChooseAdapter
;
import
com.xabber.android.ui.adapter.AccountChooseAdapter
;
public
class
AccountChooseDialog
Builder
extends
ListenableDialogBuilder
{
public
class
AccountChooseDialog
Fragment
extends
AbstractDialogFragment
{
private
final
String
user
;
private
static
final
String
USER
=
"USER"
;
private
String
selected
;
private
static
final
String
TEXT
=
"TEXT"
;
public
AccountChooseDialogBuilder
(
Activity
activity
,
int
dialogId
,
/**
final
ConfirmDialogListener
listener
,
String
user
)
{
* @param user
super
(
activity
,
dialogId
);
* @param text
this
.
user
=
user
;
* @return
this
.
selected
=
null
;
*/
setOnCancelListener
(
listener
);
public
static
DialogFragment
newInstance
(
String
user
,
String
text
)
{
setOnDeclineListener
(
listener
);
return
new
AccountChooseDialogFragment
().
putAgrument
(
USER
,
user
)
final
Adapter
adapter
=
new
Adapter
(
activity
);
.
putAgrument
(
TEXT
,
text
);
setSingleChoiceItems
(
adapter
,
-
1
,
new
OnClickListener
()
{
}
private
String
user
;
private
String
text
;
@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
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
selected
=
(
String
)
adapter
.
getItem
(
which
);
String
account
=
(
String
)
adapter
.
getItem
(
which
);
dialog
.
dismiss
();
OnChoosedListener
listener
=
(
OnChoosedListener
)
getActivity
();
listener
.
on
Accept
(
AccountChooseDialogBuilder
.
this
);
listener
.
on
Choosed
(
account
,
user
,
text
);
}
}
});
});
}
return
builder
;
/**
* @return <code>null</code> can be returned.
*/
public
String
getSelected
()
{
return
selected
;
}
}
private
class
Adapter
extends
AccountChooseAdapter
{
private
class
Adapter
extends
AccountChooseAdapter
{
...
@@ -78,4 +71,10 @@ public class AccountChooseDialogBuilder extends ListenableDialogBuilder {
...
@@ -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