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
f05895d9
Commit
f05895d9
authored
May 24, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use separate activity for subscription request.
parent
52d0e56d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
104 deletions
+106
-104
AndroidManifest.xml
AndroidManifest.xml
+3
-0
SubscriptionRequest.java
src/com/xabber/android/data/roster/SubscriptionRequest.java
+2
-2
ContactAdd.java
src/com/xabber/android/ui/ContactAdd.java
+5
-102
ContactSubscription.java
src/com/xabber/android/ui/ContactSubscription.java
+96
-0
No files found.
AndroidManifest.xml
View file @
f05895d9
...
...
@@ -170,6 +170,9 @@
android:name=
"com.xabber.android.ui.OpenSourceViewer"
android:theme=
"@style/Theme.NoTitleBar"
/>
<activity
android:name=
"com.xabber.android.ui.ContactSubscription"
/>
<activity
android:name=
"com.xabber.android.ui.CertificateConfirmation"
/>
...
...
src/com/xabber/android/data/roster/SubscriptionRequest.java
View file @
f05895d9
...
...
@@ -20,7 +20,7 @@ import com.xabber.android.data.Application;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.notification.EntityNotificationItem
;
import
com.xabber.android.ui.Contact
Add
;
import
com.xabber.android.ui.Contact
Subscription
;
import
com.xabber.androiddev.R
;
public
class
SubscriptionRequest
extends
BaseEntity
implements
...
...
@@ -32,7 +32,7 @@ public class SubscriptionRequest extends BaseEntity implements
@Override
public
Intent
getIntent
()
{
return
Contact
Add
.
createSubscription
Intent
(
Application
.
getInstance
(),
return
Contact
Subscription
.
create
Intent
(
Application
.
getInstance
(),
account
,
user
);
}
...
...
src/com/xabber/android/ui/ContactAdd.java
View file @
f05895d9
...
...
@@ -18,7 +18,6 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.HashSet
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
...
...
@@ -39,34 +38,19 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.roster.PresenceManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.data.roster.SubscriptionRequest
;
import
com.xabber.android.ui.adapter.AccountChooseAdapter
;
import
com.xabber.android.ui.dialog.ConfirmDialogBuilder
;
import
com.xabber.android.ui.dialog.ConfirmDialogListener
;
import
com.xabber.android.ui.dialog.DialogBuilder
;
import
com.xabber.androiddev.R
;
public
class
ContactAdd
extends
GroupListActivity
implements
View
.
OnClickListener
,
ConfirmDialogListener
,
OnItemSelectedListener
{
/**
* Action for subscription request to be show.
*
* Clear action on dialog dismiss.
*/
private
static
final
String
ACTION_SUBSCRIPTION_REQUEST
=
"com.xabber.android.data.SUBSCRIPTION_REQUEST"
;
View
.
OnClickListener
,
OnItemSelectedListener
{
private
static
final
String
SAVED_ACCOUNT
=
"com.xabber.android.ui.ContactAdd.SAVED_ACCOUNT"
;
private
static
final
String
SAVED_USER
=
"com.xabber.android.ui.ContactAdd.SAVED_USER"
;
private
static
final
String
SAVED_NAME
=
"com.xabber.android.ui.ContactAdd.SAVED_NAME"
;
private
static
final
int
DIALOG_SUBSCRIPTION_REQUEST_ID
=
0x20
;
private
String
account
;
private
String
user
;
private
SubscriptionRequest
subscriptionRequest
;
/**
* Views
*/
...
...
@@ -125,17 +109,6 @@ public class ContactAdd extends GroupListActivity implements
userView
.
setText
(
user
);
if
(
name
!=
null
)
nameView
.
setText
(
name
);
if
(
ACTION_SUBSCRIPTION_REQUEST
.
equals
(
intent
.
getAction
()))
{
subscriptionRequest
=
PresenceManager
.
getInstance
()
.
getSubscriptionRequest
(
account
,
user
);
if
(
subscriptionRequest
==
null
)
{
Application
.
getInstance
().
onError
(
R
.
string
.
ENTRY_IS_NOT_FOUND
);
finish
();
return
;
}
}
else
{
subscriptionRequest
=
null
;
}
}
@Override
...
...
@@ -147,13 +120,6 @@ public class ContactAdd extends GroupListActivity implements
outState
.
putString
(
SAVED_NAME
,
nameView
.
getText
().
toString
());
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(
subscriptionRequest
!=
null
)
showDialog
(
DIALOG_SUBSCRIPTION_REQUEST_ID
);
}
@Override
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
...
...
@@ -188,62 +154,6 @@ public class ContactAdd extends GroupListActivity implements
}
}
@Override
protected
Dialog
onCreateDialog
(
int
id
)
{
Dialog
dialog
=
super
.
onCreateDialog
(
id
);
if
(
dialog
!=
null
)
return
dialog
;
switch
(
id
)
{
case
DIALOG_SUBSCRIPTION_REQUEST_ID:
return
new
ConfirmDialogBuilder
(
this
,
DIALOG_SUBSCRIPTION_REQUEST_ID
,
this
).
setMessage
(
subscriptionRequest
.
getConfirmation
()).
create
();
default
:
return
null
;
}
}
@Override
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
DIALOG_SUBSCRIPTION_REQUEST_ID:
try
{
PresenceManager
.
getInstance
().
acceptSubscription
(
subscriptionRequest
.
getAccount
(),
subscriptionRequest
.
getUser
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
getIntent
().
setAction
(
null
);
break
;
}
}
@Override
public
void
onDecline
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
DIALOG_SUBSCRIPTION_REQUEST_ID:
try
{
PresenceManager
.
getInstance
().
discardSubscription
(
subscriptionRequest
.
getAccount
(),
subscriptionRequest
.
getUser
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
finish
();
break
;
}
}
@Override
public
void
onCancel
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
DIALOG_SUBSCRIPTION_REQUEST_ID:
finish
();
break
;
}
}
@Override
Collection
<
String
>
getInitialGroups
()
{
String
account
=
(
String
)
accountView
.
getSelectedItem
();
...
...
@@ -280,21 +190,14 @@ public class ContactAdd extends GroupListActivity implements
return
createIntent
(
context
,
null
);
}
private
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
return
new
EntityIntentBuilder
(
context
,
ContactAdd
.
class
)
.
setAccount
(
account
).
setUser
(
user
).
build
();
}
public
static
Intent
createIntent
(
Context
context
,
String
account
)
{
return
createIntent
(
context
,
account
,
null
);
}
public
static
Intent
createSubscriptionIntent
(
Context
context
,
String
account
,
String
user
)
{
Intent
intent
=
createIntent
(
context
,
account
,
user
);
intent
.
setAction
(
ACTION_SUBSCRIPTION_REQUEST
);
return
intent
;
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
return
new
EntityIntentBuilder
(
context
,
ContactAdd
.
class
)
.
setAccount
(
account
).
setUser
(
user
).
build
();
}
private
static
String
getAccount
(
Intent
intent
)
{
...
...
src/com/xabber/android/ui/ContactSubscription.java
0 → 100644
View file @
f05895d9
/**
* 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
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.data.roster.PresenceManager
;
import
com.xabber.android.data.roster.SubscriptionRequest
;
import
com.xabber.android.ui.helper.ManagedDialog
;
import
com.xabber.androiddev.R
;
public
class
ContactSubscription
extends
ManagedDialog
{
private
String
account
;
private
String
user
;
private
SubscriptionRequest
subscriptionRequest
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Intent
intent
=
getIntent
();
account
=
getAccount
(
intent
);
user
=
getUser
(
intent
);
subscriptionRequest
=
PresenceManager
.
getInstance
()
.
getSubscriptionRequest
(
account
,
user
);
if
(
subscriptionRequest
==
null
)
{
Application
.
getInstance
().
onError
(
R
.
string
.
ENTRY_IS_NOT_FOUND
);
finish
();
return
;
}
setDialogMessage
(
subscriptionRequest
.
getConfirmation
());
setDialogTitle
(
R
.
string
.
subscription_request_message
);
findViewById
(
android
.
R
.
id
.
button3
).
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onAccept
()
{
super
.
onAccept
();
try
{
PresenceManager
.
getInstance
().
acceptSubscription
(
subscriptionRequest
.
getAccount
(),
subscriptionRequest
.
getUser
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
startActivity
(
ContactAdd
.
createIntent
(
this
,
account
,
user
));
finish
();
}
@Override
public
void
onDecline
()
{
super
.
onDecline
();
try
{
PresenceManager
.
getInstance
().
discardSubscription
(
subscriptionRequest
.
getAccount
(),
subscriptionRequest
.
getUser
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
finish
();
}
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
return
new
EntityIntentBuilder
(
context
,
ContactSubscription
.
class
)
.
setAccount
(
account
).
setUser
(
user
).
build
();
}
private
static
String
getAccount
(
Intent
intent
)
{
return
EntityIntentBuilder
.
getAccount
(
intent
);
}
private
static
String
getUser
(
Intent
intent
)
{
return
EntityIntentBuilder
.
getUser
(
intent
);
}
}
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