Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-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
AloqaIM-Android
Commits
eb93a930
Commit
eb93a930
authored
Nov 06, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Twitter/Github button and fix some logic of AbstractDDPDocEventSubscriber
parent
9214fc3e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
7 deletions
+102
-7
LoginFragment.java
.../rocket/android/fragment/server_config/LoginFragment.java
+38
-0
MeteorLoginServiceConfiguration.java
...rocket/android/model/MeteorLoginServiceConfiguration.java
+48
-0
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+2
-2
AbstractDDPDocEventSubscriber.java
...service/ddp_subscriber/AbstractDDPDocEventSubscriber.java
+7
-2
LoginServiceConfigurationSubscriber.java
...e/ddp_subscriber/LoginServiceConfigurationSubscriber.java
+3
-2
AbstractModelObserver.java
...ocket/android/service/observer/AbstractModelObserver.java
+4
-1
No files found.
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.java
View file @
eb93a930
package
chat
.
rocket
.
android
.
fragment
.
server_config
;
package
chat
.
rocket
.
android
.
fragment
.
server_config
;
import
android.view.View
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.model.MeteorLoginServiceConfiguration
;
import
io.realm.Realm
;
import
io.realm.RealmResults
;
import
java.util.List
;
import
jp.co.crowdworks.realm_java_helpers.RealmListObserver
;
/**
/**
* Login screen.
* Login screen.
...
@@ -10,7 +16,39 @@ public class LoginFragment extends AbstractServerConfigFragment {
...
@@ -10,7 +16,39 @@ public class LoginFragment extends AbstractServerConfigFragment {
return
R
.
layout
.
fragment_login
;
return
R
.
layout
.
fragment_login
;
}
}
private
RealmListObserver
<
MeteorLoginServiceConfiguration
>
authProvidersObserver
=
new
RealmListObserver
<
MeteorLoginServiceConfiguration
>()
{
@Override
protected
RealmResults
<
MeteorLoginServiceConfiguration
>
queryItems
(
Realm
realm
)
{
return
realm
.
where
(
MeteorLoginServiceConfiguration
.
class
)
.
equalTo
(
"serverConfig.id"
,
serverConfigId
)
.
findAll
();
}
@Override
protected
void
onCollectionChanged
(
List
<
MeteorLoginServiceConfiguration
>
list
)
{
onRenderAuthProviders
(
list
);
}
};
@Override
protected
void
onSetupView
()
{
@Override
protected
void
onSetupView
()
{
}
}
private
void
onRenderAuthProviders
(
List
<
MeteorLoginServiceConfiguration
>
authProviders
)
{
final
View
btnTwitter
=
rootView
.
findViewById
(
R
.
id
.
btn_login_with_twitter
);
final
View
btnGitHub
=
rootView
.
findViewById
(
R
.
id
.
btn_login_with_github
);
boolean
hasTwitter
=
false
;
boolean
hasGitHub
=
false
;
for
(
MeteorLoginServiceConfiguration
authProvider
:
authProviders
)
{
if
(!
hasTwitter
&&
"twitter"
.
equals
(
authProvider
.
getService
()))
{
hasTwitter
=
true
;
}
if
(!
hasGitHub
&&
"github"
.
equals
(
authProvider
.
getService
()))
{
hasGitHub
=
true
;
}
}
btnTwitter
.
setVisibility
(
hasTwitter
?
View
.
VISIBLE
:
View
.
GONE
);
btnGitHub
.
setVisibility
(
hasGitHub
?
View
.
VISIBLE
:
View
.
GONE
);
}
}
}
app/src/main/java/chat/rocket/android/model/MeteorLoginServiceConfiguration.java
View file @
eb93a930
...
@@ -15,4 +15,52 @@ public class MeteorLoginServiceConfiguration
...
@@ -15,4 +15,52 @@ public class MeteorLoginServiceConfiguration
private
String
consumerKey
;
//for Twitter
private
String
consumerKey
;
//for Twitter
private
String
appId
;
//for Facebook
private
String
appId
;
//for Facebook
private
String
clientId
;
//for other auth providers
private
String
clientId
;
//for other auth providers
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
ServerConfig
getServerConfig
()
{
return
serverConfig
;
}
public
void
setServerConfig
(
ServerConfig
serverConfig
)
{
this
.
serverConfig
=
serverConfig
;
}
public
String
getService
()
{
return
service
;
}
public
void
setService
(
String
service
)
{
this
.
service
=
service
;
}
public
String
getConsumerKey
()
{
return
consumerKey
;
}
public
void
setConsumerKey
(
String
consumerKey
)
{
this
.
consumerKey
=
consumerKey
;
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
String
getClientId
()
{
return
clientId
;
}
public
void
setClientId
(
String
clientId
)
{
this
.
clientId
=
clientId
;
}
}
}
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
eb93a930
...
@@ -170,8 +170,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -170,8 +170,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
for
(
Class
clazz
:
REGISTERABLE_CLASSES
)
{
for
(
Class
clazz
:
REGISTERABLE_CLASSES
)
{
try
{
try
{
Constructor
ctor
=
clazz
.
getConstructor
(
Context
.
class
,
RocketChatWebSocketAPI
.
class
);
Constructor
ctor
=
clazz
.
getConstructor
(
Context
.
class
,
String
.
class
,
RocketChatWebSocketAPI
.
class
);
Object
obj
=
ctor
.
newInstance
(
appContext
,
webSocketAPI
);
Object
obj
=
ctor
.
newInstance
(
appContext
,
serverConfigId
,
webSocketAPI
);
if
(
obj
instanceof
Registerable
)
{
if
(
obj
instanceof
Registerable
)
{
Registerable
registerable
=
(
Registerable
)
obj
;
Registerable
registerable
=
(
Registerable
)
obj
;
...
...
app/src/main/java/chat/rocket/android/service/ddp_subscriber/AbstractDDPDocEventSubscriber.java
View file @
eb93a930
...
@@ -17,12 +17,15 @@ import timber.log.Timber;
...
@@ -17,12 +17,15 @@ import timber.log.Timber;
abstract
class
AbstractDDPDocEventSubscriber
implements
Registerable
{
abstract
class
AbstractDDPDocEventSubscriber
implements
Registerable
{
protected
final
Context
context
;
protected
final
Context
context
;
protected
final
String
serverConfigId
;
protected
final
RocketChatWebSocketAPI
webSocketAPI
;
protected
final
RocketChatWebSocketAPI
webSocketAPI
;
private
String
subscriptionId
;
private
String
subscriptionId
;
private
Subscription
rxSubscription
;
private
Subscription
rxSubscription
;
protected
AbstractDDPDocEventSubscriber
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
protected
AbstractDDPDocEventSubscriber
(
Context
context
,
String
serverConfigId
,
RocketChatWebSocketAPI
api
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
serverConfigId
=
serverConfigId
;
this
.
webSocketAPI
=
api
;
this
.
webSocketAPI
=
api
;
}
}
...
@@ -90,6 +93,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -90,6 +93,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
private
void
onDocumentAdded
(
Realm
realm
,
DDPSubscription
.
Added
docEvent
)
throws
JSONException
{
private
void
onDocumentAdded
(
Realm
realm
,
DDPSubscription
.
Added
docEvent
)
throws
JSONException
{
//executed in RealmTransaction
//executed in RealmTransaction
JSONObject
json
=
new
JSONObject
().
put
(
"id"
,
docEvent
.
docID
);
JSONObject
json
=
new
JSONObject
().
put
(
"id"
,
docEvent
.
docID
);
json
.
put
(
"serverConfig"
,
new
JSONObject
().
put
(
"id"
,
serverConfigId
));
mergeJson
(
json
,
docEvent
.
fields
);
mergeJson
(
json
,
docEvent
.
fields
);
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJson
(
json
));
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJson
(
json
));
}
}
...
@@ -105,9 +109,10 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -105,9 +109,10 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
throws
JSONException
{
throws
JSONException
{
//executed in RealmTransaction
//executed in RealmTransaction
JSONObject
json
=
new
JSONObject
().
put
(
"id"
,
docEvent
.
docID
);
JSONObject
json
=
new
JSONObject
().
put
(
"id"
,
docEvent
.
docID
);
json
.
put
(
"serverConfig"
,
new
JSONObject
().
put
(
"id"
,
serverConfigId
));
for
(
int
i
=
0
;
i
<
docEvent
.
cleared
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
docEvent
.
cleared
.
length
();
i
++)
{
String
fieldToDelete
=
docEvent
.
cleared
.
getString
(
i
);
String
fieldToDelete
=
docEvent
.
cleared
.
getString
(
i
);
json
.
remove
(
fieldToDelete
);
json
.
put
(
fieldToDelete
,
JSONObject
.
NULL
);
}
}
mergeJson
(
json
,
docEvent
.
fields
);
mergeJson
(
json
,
docEvent
.
fields
);
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJson
(
json
));
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJson
(
json
));
...
...
app/src/main/java/chat/rocket/android/service/ddp_subscriber/LoginServiceConfigurationSubscriber.java
View file @
eb93a930
...
@@ -9,8 +9,9 @@ import io.realm.RealmObject;
...
@@ -9,8 +9,9 @@ import io.realm.RealmObject;
* meteor.loginServiceConfiguration subscriber
* meteor.loginServiceConfiguration subscriber
*/
*/
public
class
LoginServiceConfigurationSubscriber
extends
AbstractDDPDocEventSubscriber
{
public
class
LoginServiceConfigurationSubscriber
extends
AbstractDDPDocEventSubscriber
{
public
LoginServiceConfigurationSubscriber
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
public
LoginServiceConfigurationSubscriber
(
Context
context
,
String
serverConfigId
,
super
(
context
,
api
);
RocketChatWebSocketAPI
api
)
{
super
(
context
,
serverConfigId
,
api
);
}
}
@Override
protected
String
getSubscriptionName
()
{
@Override
protected
String
getSubscriptionName
()
{
...
...
app/src/main/java/chat/rocket/android/service/observer/AbstractModelObserver.java
View file @
eb93a930
...
@@ -10,10 +10,13 @@ abstract class AbstractModelObserver<T extends RealmObject> extends RealmListObs
...
@@ -10,10 +10,13 @@ abstract class AbstractModelObserver<T extends RealmObject> extends RealmListObs
implements
Registerable
{
implements
Registerable
{
protected
final
Context
context
;
protected
final
Context
context
;
protected
final
String
serverConfigId
;
protected
final
RocketChatWebSocketAPI
webSocketAPI
;
protected
final
RocketChatWebSocketAPI
webSocketAPI
;
protected
AbstractModelObserver
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
protected
AbstractModelObserver
(
Context
context
,
String
serverConfigId
,
RocketChatWebSocketAPI
api
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
serverConfigId
=
serverConfigId
;
webSocketAPI
=
api
;
webSocketAPI
=
api
;
}
}
...
...
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