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
baa6b13a
Commit
baa6b13a
authored
Nov 07, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix coding style bugs
parent
48c08f41
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
42 deletions
+65
-42
AbstractWebViewFragment.java
...chat/rocket/android/fragment/AbstractWebViewFragment.java
+12
-8
GitHubOAuthWebViewFragment.java
...et/android/fragment/oauth/GitHubOAuthWebViewFragment.java
+14
-9
AuthenticatingFragment.java
...ndroid/fragment/server_config/AuthenticatingFragment.java
+2
-1
LoginFragment.java
.../rocket/android/fragment/server_config/LoginFragment.java
+13
-9
ServerConfigCredential.java
...ava/chat/rocket/android/model/ServerConfigCredential.java
+1
-0
AbstractRenderer.java
...n/java/chat/rocket/android/renderer/AbstractRenderer.java
+3
-1
ServerConfigCredentialRenderer.java
...cket/android/renderer/ServerConfigCredentialRenderer.java
+6
-0
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+4
-3
RocketChatWebSocketAPI.java
...n/java/chat/rocket/android/ws/RocketChatWebSocketAPI.java
+10
-5
checkstyle-config.xml
config/quality/checkstyle/checkstyle-config.xml
+0
-6
No files found.
app/src/main/java/chat/rocket/android/fragment/AbstractWebViewFragment.java
View file @
baa6b13a
...
...
@@ -13,23 +13,26 @@ import chat.rocket.android.R;
import
chat.rocket.android.helper.OnBackPressListener
;
import
hugo.weaving.DebugLog
;
public
abstract
class
AbstractWebViewFragment
extends
AbstractFragment
implements
OnBackPressListener
{
public
abstract
class
AbstractWebViewFragment
extends
AbstractFragment
implements
OnBackPressListener
{
private
WebView
webview
;
private
WebViewClient
mWebV
iewClient
=
new
WebViewClient
()
{
private
boolean
mE
rror
;
private
WebViewClient
webv
iewClient
=
new
WebViewClient
()
{
private
boolean
e
rror
;
@Override
public
void
onPageStarted
(
WebView
webview
,
String
url
,
Bitmap
favicon
)
{
mE
rror
=
false
;
e
rror
=
false
;
}
@Override
public
void
onPageFinished
(
WebView
webview
,
String
url
)
{
if
(!
mError
)
onPageLoaded
(
webview
,
url
);
if
(!
error
)
{
onPageLoaded
(
webview
,
url
);
}
}
@Override
public
void
onReceivedError
(
WebView
view
,
WebResourceRequest
request
,
WebResourceError
error
)
{
super
.
onReceivedError
(
view
,
request
,
error
);
mE
rror
=
true
;
this
.
e
rror
=
true
;
}
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
webview
,
String
url
)
{
...
...
@@ -37,7 +40,8 @@ public abstract class AbstractWebViewFragment extends AbstractFragment implement
||
super
.
shouldOverrideUrlLoading
(
webview
,
url
);
}
@DebugLog
@Override
@DebugLog
@Override
public
void
onFormResubmission
(
WebView
view
,
Message
dontResend
,
Message
resend
)
{
//resend POST request without confirmation.
resend
.
sendToTarget
();
...
...
@@ -61,7 +65,7 @@ public abstract class AbstractWebViewFragment extends AbstractFragment implement
settings
.
setJavaScriptEnabled
(
true
);
}
webview
.
setHorizontalScrollBarEnabled
(
false
);
webview
.
setWebViewClient
(
mWebV
iewClient
);
webview
.
setWebViewClient
(
webv
iewClient
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
WebView
.
setWebContentsDebuggingEnabled
(
true
);
...
...
app/src/main/java/chat/rocket/android/fragment/oauth/GitHubOAuthWebViewFragment.java
View file @
baa6b13a
...
...
@@ -11,6 +11,7 @@ import chat.rocket.android.fragment.AbstractWebViewFragment;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.model.MeteorLoginServiceConfiguration
;
import
chat.rocket.android.model.ServerConfig
;
import
java.nio.charset.Charset
;
import
jp.co.crowdworks.realm_java_helpers.RealmHelper
;
import
jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts
;
import
okhttp3.HttpUrl
;
...
...
@@ -26,6 +27,9 @@ public class GitHubOAuthWebViewFragment extends AbstractWebViewFragment {
private
String
url
;
private
boolean
resultOK
;
/**
* create new Fragment with ServerConfig-ID.
*/
public
static
Fragment
create
(
final
String
serverConfigId
)
{
Bundle
args
=
new
Bundle
();
args
.
putString
(
"server_config_id"
,
serverConfigId
);
...
...
@@ -70,7 +74,7 @@ public class GitHubOAuthWebViewFragment extends AbstractWebViewFragment {
.
put
(
"credentialToken"
,
"github"
+
System
.
currentTimeMillis
())
.
put
(
"isCordova"
,
true
)
.
toString
()
.
getBytes
(),
Base64
.
NO_WRAP
);
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)
),
Base64
.
NO_WRAP
);
return
new
HttpUrl
.
Builder
().
scheme
(
"https"
)
.
host
(
"github.com"
)
...
...
@@ -123,8 +127,9 @@ public class GitHubOAuthWebViewFragment extends AbstractWebViewFragment {
if
(
url
.
contains
(
hostname
)
&&
url
.
contains
(
"_oauth/github?close"
))
{
webview
.
loadUrl
(
"javascript:window._rocketchet_hook.handleConfig(document.getElementById('config').innerText);"
);
final
String
jsHookUrl
=
"javascript:"
+
"window._rocketchet_hook.handleConfig(document.getElementById('config').innerText);"
;
webview
.
loadUrl
(
jsHookUrl
);
}
}
...
...
@@ -133,17 +138,17 @@ public class GitHubOAuthWebViewFragment extends AbstractWebViewFragment {
}
private
static
final
class
JSInterface
{
private
final
JSInterfaceCallback
m
Callback
;
private
final
JSInterfaceCallback
jsInterface
Callback
;
public
JSInterface
(
JSInterfaceCallback
callback
)
{
m
Callback
=
callback
;
JSInterface
(
JSInterfaceCallback
callback
)
{
jsInterface
Callback
=
callback
;
}
@JavascriptInterface
public
void
handleConfig
(
String
config
)
{
try
{
m
Callback
.
hanldeResult
(
new
JSONObject
(
config
));
}
catch
(
Exception
e
)
{
m
Callback
.
hanldeResult
(
null
);
jsInterface
Callback
.
hanldeResult
(
new
JSONObject
(
config
));
}
catch
(
Exception
e
xception
)
{
jsInterface
Callback
.
hanldeResult
(
null
);
}
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/AuthenticatingFragment.java
View file @
baa6b13a
...
...
@@ -5,6 +5,7 @@ import android.widget.TextView;
import
chat.rocket.android.R
;
/**
* Just show "Authenticating..."
*/
public
class
AuthenticatingFragment
extends
AbstractServerConfigFragment
{
@Override
protected
int
getLayout
()
{
...
...
@@ -14,6 +15,6 @@ public class AuthenticatingFragment extends AbstractServerConfigFragment {
@Override
protected
void
onSetupView
()
{
TextView
caption
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
txt_caption
);
caption
.
setVisibility
(
View
.
VISIBLE
);
caption
.
setText
(
"Authenticati
o
ng..."
);
caption
.
setText
(
"Authenticating..."
);
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.java
View file @
baa6b13a
...
...
@@ -14,6 +14,7 @@ import chat.rocket.android.model.ServerConfigCredential;
import
chat.rocket.android.renderer.ServerConfigCredentialRenderer
;
import
io.realm.Realm
;
import
io.realm.RealmResults
;
import
java.nio.charset.Charset
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.List
;
...
...
@@ -56,7 +57,9 @@ public class LoginFragment extends AbstractServerConfigFragment {
btnEmail
.
setOnClickListener
(
view
->
{
final
CharSequence
username
=
txtUsername
.
getText
();
final
CharSequence
passwd
=
txtPasswd
.
getText
();
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
passwd
))
return
;
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
passwd
))
{
return
;
}
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
()
...
...
@@ -75,7 +78,8 @@ public class LoginFragment extends AbstractServerConfigFragment {
}
private
void
showErrorIfNeeded
()
{
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
)
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
)
.
equalTo
(
"id"
,
serverConfigId
)
.
isNotNull
(
"credential.errorMessage"
)
.
findFirst
());
...
...
@@ -105,14 +109,14 @@ public class LoginFragment extends AbstractServerConfigFragment {
}
catch
(
NoSuchAlgorithmException
exception
)
{
return
null
;
}
messageDigest
.
update
(
orig
.
getBytes
());
messageDigest
.
update
(
orig
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)
));
StringBuilder
s
b
=
new
StringBuilder
();
StringBuilder
s
tringBuilder
=
new
StringBuilder
();
for
(
byte
b
:
messageDigest
.
digest
())
{
s
b
.
append
(
String
.
format
(
"%02x"
,
b
&
0xff
));
s
tringBuilder
.
append
(
String
.
format
(
"%02x"
,
b
&
0xff
));
}
return
s
b
.
toString
();
return
s
tringBuilder
.
toString
();
}
private
void
onRenderAuthProviders
(
List
<
MeteorLoginServiceConfiguration
>
authProviders
)
{
...
...
app/src/main/java/chat/rocket/android/model/ServerConfigCredential.java
View file @
baa6b13a
...
...
@@ -9,6 +9,7 @@ import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
import
org.json.JSONException
;
import
org.json.JSONObject
;
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
ServerConfigCredential
extends
RealmObject
{
public
static
final
String
TYPE_EMAIL
=
"email"
;
public
static
final
String
TYPE_TWITTER
=
"twitter"
;
...
...
app/src/main/java/chat/rocket/android/renderer/AbstractRenderer.java
View file @
baa6b13a
...
...
@@ -21,7 +21,9 @@ abstract class AbstractRenderer<T> {
protected
boolean
shouldHandle
(
View
target
,
Condition
additionalCondition
,
Optional
optional
,
String
key
)
{
if
(
target
==
null
||
object
==
null
)
{
if
(
optional
!=
null
)
optional
.
onNoData
(
key
);
if
(
optional
!=
null
)
{
optional
.
onNoData
(
key
);
}
return
false
;
}
...
...
app/src/main/java/chat/rocket/android/renderer/ServerConfigCredentialRenderer.java
View file @
baa6b13a
...
...
@@ -5,11 +5,17 @@ import android.widget.TextView;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.ServerConfigCredential
;
/**
* renderer class for ServerConfigCredential.
*/
public
class
ServerConfigCredentialRenderer
extends
AbstractRenderer
<
ServerConfigCredential
>
{
public
ServerConfigCredentialRenderer
(
Context
context
,
ServerConfigCredential
credential
)
{
super
(
context
,
credential
);
}
/**
* Inject username into TextView.
*/
public
ServerConfigCredentialRenderer
usernameInto
(
TextView
textView
)
{
if
(!
shouldHandle
(
textView
))
{
return
this
;
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
baa6b13a
...
...
@@ -129,8 +129,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
}
socketExists
=
true
;
final
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
serverConfigId
).
findFirst
());
final
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
serverConfigId
).
findFirst
());
prepareWebSocket
(
config
);
return
webSocketAPI
.
connect
(
config
.
getSession
()).
onSuccessTask
(
task
->
{
...
...
@@ -180,7 +180,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
for
(
Class
clazz
:
REGISTERABLE_CLASSES
)
{
try
{
Constructor
ctor
=
clazz
.
getConstructor
(
Context
.
class
,
String
.
class
,
RocketChatWebSocketAPI
.
class
);
Constructor
ctor
=
clazz
.
getConstructor
(
Context
.
class
,
String
.
class
,
RocketChatWebSocketAPI
.
class
);
Object
obj
=
ctor
.
newInstance
(
appContext
,
serverConfigId
,
webSocketAPI
);
if
(
obj
instanceof
Registerable
)
{
...
...
app/src/main/java/chat/rocket/android/ws/RocketChatWebSocketAPI.java
View file @
baa6b13a
...
...
@@ -102,25 +102,30 @@ public class RocketChatWebSocketAPI {
.
put
(
"credentialToken"
,
credential
.
getCredentialToken
())
.
put
(
"credentialSecret"
,
credential
.
getCredentialSecret
()));
}
}
catch
(
JSONException
e
)
{
return
Task
.
forError
(
e
);
}
catch
(
JSONException
exception
)
{
return
Task
.
forError
(
exception
);
}
return
ddpClient
.
rpc
(
"login"
,
new
JSONArray
().
put
(
param
),
generateId
(
"login"
));
}
/**
* Login with token.
*/
public
Task
<
DDPClientCallback
.
RPC
>
loginWithToken
(
final
String
token
)
{
JSONObject
param
=
new
JSONObject
();
try
{
param
.
put
(
"resume"
,
token
);
}
catch
(
JSONException
e
)
{
return
Task
.
forError
(
e
);
}
catch
(
JSONException
e
xception
)
{
return
Task
.
forError
(
e
xception
);
}
return
ddpClient
.
rpc
(
"login"
,
new
JSONArray
().
put
(
param
),
generateId
(
"login-token"
));
}
/**
* Logout.
*/
public
Task
<
DDPClientCallback
.
RPC
>
logout
()
{
return
ddpClient
.
rpc
(
"logout"
,
null
,
generateId
(
"logout"
));
}
...
...
config/quality/checkstyle/checkstyle-config.xml
View file @
baa6b13a
...
...
@@ -27,12 +27,6 @@
<property
name=
"eachLine"
value=
"true"
/>
</module>
<module
name=
"SuppressionCommentFilter"
>
<property
name=
"offCommentFormat"
value=
"CHECKSTYLE:OFF (\w+)"
/>
<property
name=
"onCommentFormat"
value=
"CHECKSTYLE:ON (\w+)"
/>
<property
name=
"checkFormat"
value=
"$1"
/>
</module>
<module
name=
"SuppressionFilter"
>
<property
name=
"file"
value=
"config/quality/checkstyle/checkstyle-suppressions.xml"
/>
</module>
...
...
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