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
2f5263cb
Commit
2f5263cb
authored
May 23, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace contact list confirmation dialogs with dialog fragments.
parent
52ffd997
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
201 additions
and
82 deletions
+201
-82
ContactList.java
src/com/xabber/android/ui/ContactList.java
+16
-82
ContactDeleteDialogFragment.java
...xabber/android/ui/dialog/ContactDeleteDialogFragment.java
+64
-0
ContactIntegrationDialogFragment.java
...r/android/ui/dialog/ContactIntegrationDialogFragment.java
+36
-0
GroupDeleteDialogFragment.java
...m/xabber/android/ui/dialog/GroupDeleteDialogFragment.java
+51
-0
StartAtBootDialogFragment.java
...m/xabber/android/ui/dialog/StartAtBootDialogFragment.java
+34
-0
No files found.
src/com/xabber/android/ui/ContactList.java
View file @
2f5263cb
...
...
@@ -80,10 +80,13 @@ 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.ConfirmDialogBuilder
;
import
com.xabber.android.ui.dialog.ConfirmDialogListener
;
import
com.xabber.android.ui.dialog.ContactDeleteDialogFragment
;
import
com.xabber.android.ui.dialog.ContactIntegrationDialogFragment
;
import
com.xabber.android.ui.dialog.DialogBuilder
;
import
com.xabber.android.ui.dialog.GroupDeleteDialogFragment
;
import
com.xabber.android.ui.dialog.GroupRenameDialogFragment
;
import
com.xabber.android.ui.dialog.StartAtBootDialogFragment
;
import
com.xabber.android.ui.helper.ManagedListActivity
;
import
com.xabber.androiddev.R
;
import
com.xabber.xmpp.address.Jid
;
...
...
@@ -150,10 +153,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_DELETE_CONTACT_ID
=
0x50
;
private
static
final
int
DIALOG_DELETE_GROUP_ID
=
0x51
;
private
static
final
int
DIALOG_START_AT_BOOT_ID
=
0x53
;
private
static
final
int
DIALOG_CONTACT_INTEGRATION_ID
=
0x54
;
private
static
final
int
DIALOG_OPEN_WITH_ACCOUNT_ID
=
0x55
;
private
static
final
int
DIALOG_CLOSE_APPLICATION_ID
=
0x57
;
...
...
@@ -388,13 +387,15 @@ public class ContactList extends ManagedListActivity implements
if
(
SettingsManager
.
bootCount
()
>
2
&&
!
SettingsManager
.
connectionStartAtBoot
()
&&
!
SettingsManager
.
startAtBootSuggested
())
showDialog
(
DIALOG_START_AT_BOOT_ID
);
StartAtBootDialogFragment
.
newInstance
().
show
(
getSupportFragmentManager
(),
"START_AT_BOOT"
);
if
(!
SettingsManager
.
contactIntegrationSuggested
()
&&
Application
.
getInstance
().
isContactsSupported
())
{
if
(
AccountManager
.
getInstance
().
getAllAccounts
().
isEmpty
())
SettingsManager
.
setContactIntegrationSuggested
();
else
showDialog
(
DIALOG_CONTACT_INTEGRATION_ID
);
ContactIntegrationDialogFragment
.
newInstance
().
show
(
getSupportFragmentManager
(),
"CONTACT_INTEGRATION"
);
}
}
}
...
...
@@ -653,7 +654,10 @@ public class ContactList extends ManagedListActivity implements
actionWithUser
));
return
true
;
case
CONTEXT_MENU_DELETE_CONTACT_ID:
showDialog
(
DIALOG_DELETE_CONTACT_ID
);
ContactDeleteDialogFragment
.
newInstance
(
actionWithAccount
==
GroupManager
.
NO_ACCOUNT
?
null
:
actionWithAccount
,
actionWithUser
).
show
(
getSupportFragmentManager
(),
"CONTACT_DELETE"
);
return
true
;
case
CONTEXT_MENU_EDIT_ROOM_ID:
startActivity
(
MUCEditor
.
createIntent
(
this
,
actionWithAccount
,
...
...
@@ -716,7 +720,10 @@ public class ContactList extends ManagedListActivity implements
getSupportFragmentManager
(),
"GROUP_RENAME"
);
return
true
;
case
CONTEXT_MENU_GROUP_DELETE_ID:
showDialog
(
DIALOG_DELETE_GROUP_ID
);
GroupDeleteDialogFragment
.
newInstance
(
actionWithAccount
==
GroupManager
.
NO_ACCOUNT
?
null
:
actionWithAccount
,
actionWithGroup
).
show
(
getSupportFragmentManager
(),
"GROUP_DELETE"
);
return
true
;
// Account
...
...
@@ -776,34 +783,6 @@ public class ContactList extends ManagedListActivity implements
protected
Dialog
onCreateDialog
(
int
id
)
{
super
.
onCreateDialog
(
id
);
switch
(
id
)
{
case
DIALOG_DELETE_CONTACT_ID:
int
resource
;
if
(
MUCManager
.
getInstance
().
hasRoom
(
actionWithAccount
,
actionWithUser
))
resource
=
R
.
string
.
muc_delete_confirm
;
else
resource
=
R
.
string
.
contact_delete_confirm
;
return
new
ConfirmDialogBuilder
(
this
,
DIALOG_DELETE_CONTACT_ID
,
this
).
setMessage
(
getString
(
resource
,
RosterManager
.
getInstance
().
getName
(
actionWithAccount
,
actionWithUser
),
AccountManager
.
getInstance
().
getVerboseName
(
actionWithAccount
))).
create
();
case
DIALOG_DELETE_GROUP_ID:
return
new
ConfirmDialogBuilder
(
this
,
DIALOG_DELETE_GROUP_ID
,
this
)
.
setMessage
(
getString
(
R
.
string
.
group_remove_confirm
,
actionWithGroup
)).
create
();
case
DIALOG_START_AT_BOOT_ID:
return
new
ConfirmDialogBuilder
(
this
,
DIALOG_START_AT_BOOT_ID
,
this
)
.
setMessage
(
getString
(
R
.
string
.
start_at_boot_suggest
))
.
create
();
case
DIALOG_CONTACT_INTEGRATION_ID:
return
new
ConfirmDialogBuilder
(
this
,
DIALOG_CONTACT_INTEGRATION_ID
,
this
).
setMessage
(
getString
(
R
.
string
.
contact_integration_suggest
)).
create
();
case
DIALOG_OPEN_WITH_ACCOUNT_ID:
return
new
AccountChooseDialogBuilder
(
this
,
DIALOG_OPEN_WITH_ACCOUNT_ID
,
this
,
openDialogUser
).
create
();
...
...
@@ -1020,43 +999,6 @@ public class ContactList extends ManagedListActivity implements
@Override
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
DIALOG_DELETE_CONTACT_ID:
if
(
MUCManager
.
getInstance
().
hasRoom
(
actionWithAccount
,
actionWithUser
))
{
MUCManager
.
getInstance
().
removeRoom
(
actionWithAccount
,
actionWithUser
);
MessageManager
.
getInstance
().
closeChat
(
actionWithAccount
,
actionWithUser
);
NotificationManager
.
getInstance
().
removeMessageNotification
(
actionWithAccount
,
actionWithUser
);
}
else
try
{
RosterManager
.
getInstance
().
removeContact
(
actionWithAccount
,
actionWithUser
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
break
;
case
DIALOG_DELETE_GROUP_ID:
try
{
if
(
actionWithAccount
==
GroupManager
.
NO_ACCOUNT
)
RosterManager
.
getInstance
().
removeGroup
(
actionWithGroup
);
else
RosterManager
.
getInstance
().
removeGroup
(
actionWithAccount
,
actionWithGroup
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
break
;
case
DIALOG_START_AT_BOOT_ID:
SettingsManager
.
setStartAtBootSuggested
();
SettingsManager
.
setConnectionStartAtBoot
(
true
);
break
;
case
DIALOG_CONTACT_INTEGRATION_ID:
SettingsManager
.
setContactIntegrationSuggested
();
for
(
String
account
:
AccountManager
.
getInstance
().
getAllAccounts
())
AccountManager
.
getInstance
().
setSyncable
(
account
,
true
);
break
;
case
DIALOG_OPEN_WITH_ACCOUNT_ID:
BaseEntity
baseEntity
=
new
BaseEntity
(
((
AccountChooseDialogBuilder
)
dialogBuilder
).
getSelected
(),
...
...
@@ -1068,14 +1010,6 @@ public class ContactList extends ManagedListActivity implements
@Override
public
void
onDecline
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
DIALOG_START_AT_BOOT_ID:
SettingsManager
.
setStartAtBootSuggested
();
break
;
case
DIALOG_CONTACT_INTEGRATION_ID:
SettingsManager
.
setContactIntegrationSuggested
();
break
;
}
}
@Override
...
...
src/com/xabber/android/ui/dialog/ContactDeleteDialogFragment.java
0 → 100644
View file @
2f5263cb
package
com
.
xabber
.
android
.
ui
.
dialog
;
import
android.app.AlertDialog.Builder
;
import
android.support.v4.app.DialogFragment
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.extension.muc.MUCManager
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.notification.NotificationManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.androiddev.R
;
public
class
ContactDeleteDialogFragment
extends
ConfirmDialogFragment
{
private
static
final
String
ACCOUNT
=
"ACCOUNT"
;
private
static
final
String
USER
=
"USER"
;
/**
* @param account
* can be <code>null</code> to be used for all accounts.
* @param user
* @return
*/
public
static
DialogFragment
newInstance
(
String
account
,
String
user
)
{
return
new
ContactDeleteDialogFragment
().
putAgrument
(
ACCOUNT
,
account
)
.
putAgrument
(
USER
,
user
);
}
private
String
user
;
private
String
account
;
private
boolean
isRoom
;
@Override
protected
Builder
getBuilder
()
{
user
=
getArguments
().
getString
(
USER
);
account
=
getArguments
().
getString
(
ACCOUNT
);
isRoom
=
MUCManager
.
getInstance
().
hasRoom
(
account
,
user
);
return
new
Builder
(
getActivity
()).
setMessage
(
getString
(
isRoom
?
R
.
string
.
muc_delete_confirm
:
R
.
string
.
contact_delete_confirm
,
RosterManager
.
getInstance
().
getName
(
account
,
user
),
AccountManager
.
getInstance
().
getVerboseName
(
account
)));
}
@Override
protected
boolean
onPositiveClick
()
{
if
(
isRoom
)
{
MUCManager
.
getInstance
().
removeRoom
(
account
,
user
);
MessageManager
.
getInstance
().
closeChat
(
account
,
user
);
NotificationManager
.
getInstance
().
removeMessageNotification
(
account
,
user
);
}
else
{
try
{
RosterManager
.
getInstance
().
removeContact
(
account
,
user
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
return
true
;
}
}
src/com/xabber/android/ui/dialog/ContactIntegrationDialogFragment.java
0 → 100644
View file @
2f5263cb
package
com
.
xabber
.
android
.
ui
.
dialog
;
import
android.app.AlertDialog.Builder
;
import
android.support.v4.app.DialogFragment
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.androiddev.R
;
public
class
ContactIntegrationDialogFragment
extends
ConfirmDialogFragment
{
public
static
DialogFragment
newInstance
()
{
return
new
ContactIntegrationDialogFragment
();
}
@Override
protected
Builder
getBuilder
()
{
return
new
Builder
(
getActivity
())
.
setMessage
(
R
.
string
.
contact_integration_suggest
);
}
@Override
protected
boolean
onPositiveClick
()
{
SettingsManager
.
setContactIntegrationSuggested
();
for
(
String
account
:
AccountManager
.
getInstance
().
getAllAccounts
())
AccountManager
.
getInstance
().
setSyncable
(
account
,
true
);
return
true
;
}
@Override
protected
boolean
onNegativeClicked
()
{
SettingsManager
.
setContactIntegrationSuggested
();
return
true
;
}
}
src/com/xabber/android/ui/dialog/GroupDeleteDialogFragment.java
0 → 100644
View file @
2f5263cb
package
com
.
xabber
.
android
.
ui
.
dialog
;
import
android.app.AlertDialog.Builder
;
import
android.support.v4.app.DialogFragment
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.androiddev.R
;
public
class
GroupDeleteDialogFragment
extends
ConfirmDialogFragment
{
private
static
final
String
ACCOUNT
=
"ACCOUNT"
;
private
static
final
String
GROUP
=
"GROUP"
;
/**
* @param account
* can be <code>null</code> to be used for all accounts.
* @param group
* @return
*/
public
static
DialogFragment
newInstance
(
String
account
,
String
group
)
{
return
new
GroupDeleteDialogFragment
().
putAgrument
(
ACCOUNT
,
account
)
.
putAgrument
(
GROUP
,
group
);
}
private
String
group
;
private
String
account
;
@Override
protected
Builder
getBuilder
()
{
group
=
getArguments
().
getString
(
GROUP
);
account
=
getArguments
().
getString
(
ACCOUNT
);
return
new
Builder
(
getActivity
()).
setMessage
(
getString
(
R
.
string
.
group_remove_confirm
,
group
));
}
@Override
protected
boolean
onPositiveClick
()
{
try
{
if
(
account
==
null
)
RosterManager
.
getInstance
().
removeGroup
(
group
);
else
RosterManager
.
getInstance
().
removeGroup
(
account
,
group
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
return
true
;
}
}
src/com/xabber/android/ui/dialog/StartAtBootDialogFragment.java
0 → 100644
View file @
2f5263cb
package
com
.
xabber
.
android
.
ui
.
dialog
;
import
android.app.AlertDialog.Builder
;
import
android.support.v4.app.DialogFragment
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.androiddev.R
;
public
class
StartAtBootDialogFragment
extends
ConfirmDialogFragment
{
public
static
DialogFragment
newInstance
()
{
return
new
StartAtBootDialogFragment
();
}
@Override
protected
Builder
getBuilder
()
{
return
new
Builder
(
getActivity
())
.
setMessage
(
R
.
string
.
start_at_boot_suggest
);
}
@Override
protected
boolean
onPositiveClick
()
{
SettingsManager
.
setStartAtBootSuggested
();
SettingsManager
.
setConnectionStartAtBoot
(
true
);
return
true
;
}
@Override
protected
boolean
onNegativeClicked
()
{
SettingsManager
.
setStartAtBootSuggested
();
return
true
;
}
}
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