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
cf7b024b
Commit
cf7b024b
authored
Nov 05, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
respect ShortVariable, ShortMethodName rules for PMD
parent
9bb20414
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
81 additions
and
74 deletions
+81
-74
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+3
-3
AbstractFragmentActivity.java
...hat/rocket/android/activity/AbstractFragmentActivity.java
+9
-6
ServerConfigActivity.java
...va/chat/rocket/android/activity/ServerConfigActivity.java
+9
-9
InputHostnameFragment.java
...android/fragment/server_config/InputHostnameFragment.java
+3
-3
TextUtils.java
app/src/main/java/chat/rocket/android/helper/TextUtils.java
+1
-0
MeteorLoginServiceConfiguration.java
...rocket/android/model/MeteorLoginServiceConfiguration.java
+1
-0
ServerConfig.java
...src/main/java/chat/rocket/android/model/ServerConfig.java
+3
-2
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+11
-11
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+18
-18
AbstractDDPDocEventSubscriber.java
...service/ddp_subscriber/AbstractDDPDocEventSubscriber.java
+3
-3
AbstractCustomFontTextView.java
.../chat/rocket/android/view/AbstractCustomFontTextView.java
+2
-2
TypefaceHelper.java
...rc/main/java/chat/rocket/android/view/TypefaceHelper.java
+5
-5
WaitingView.java
app/src/main/java/chat/rocket/android/view/WaitingView.java
+9
-8
RocketChatWebSocketAPI.java
...n/java/chat/rocket/android/ws/RocketChatWebSocketAPI.java
+2
-2
pmd-ruleset.xml
config/quality/pmd/pmd-ruleset.xml
+2
-2
No files found.
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
cf7b024b
...
...
@@ -10,12 +10,12 @@ import chat.rocket.android.activity.ServerConfigActivity;
*/
public
class
LaunchUtil
{
/**
* launc ServerConfigActivity with proper flags.
* launc
h
ServerConfigActivity with proper flags.
*/
public
static
void
showServerConfigActivity
(
Context
context
,
String
i
d
)
{
public
static
void
showServerConfigActivity
(
Context
context
,
String
serverCondigI
d
)
{
Intent
intent
=
new
Intent
(
context
,
ServerConfigActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
intent
.
putExtra
(
"id"
,
i
d
);
intent
.
putExtra
(
"id"
,
serverCondigI
d
);
context
.
startActivity
(
intent
);
}
}
app/src/main/java/chat/rocket/android/activity/AbstractFragmentActivity.java
View file @
cf7b024b
...
...
@@ -12,21 +12,24 @@ abstract class AbstractFragmentActivity extends AppCompatActivity {
@Override
public
void
onBackPressed
()
{
Fragment
f
=
getSupportFragmentManager
().
findFragmentById
(
getLayoutContainerForFragment
());
if
(
f
instanceof
OnBackPressListener
&&
((
OnBackPressListener
)
f
).
onBackPressed
())
{
Fragment
fragment
=
getSupportFragmentManager
().
findFragmentById
(
getLayoutContainerForFragment
());
if
(
fragment
instanceof
OnBackPressListener
&&
((
OnBackPressListener
)
fragment
).
onBackPressed
())
{
//consumed. do nothing.
}
else
super
.
onBackPressed
();
}
protected
void
showFragment
(
Fragment
f
)
{
protected
void
showFragment
(
Fragment
f
ragment
)
{
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
getLayoutContainerForFragment
(),
f
)
.
replace
(
getLayoutContainerForFragment
(),
f
ragment
)
.
commit
();
}
protected
void
showFragmentWithBackStack
(
Fragment
f
)
{
protected
void
showFragmentWithBackStack
(
Fragment
f
ragment
)
{
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
getLayoutContainerForFragment
(),
f
)
.
replace
(
getLayoutContainerForFragment
(),
f
ragment
)
.
addToBackStack
(
null
)
.
commit
();
}
...
...
app/src/main/java/chat/rocket/android/activity/ServerConfigActivity.java
View file @
cf7b024b
...
...
@@ -161,22 +161,22 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
}
@Override
protected
void
showFragment
(
Fragment
f
)
{
injectIdArgTo
(
f
);
super
.
showFragment
(
f
);
protected
void
showFragment
(
Fragment
f
ragment
)
{
injectIdArgTo
(
f
ragment
);
super
.
showFragment
(
f
ragment
);
}
@Override
protected
void
showFragmentWithBackStack
(
Fragment
f
)
{
injectIdArgTo
(
f
);
super
.
showFragmentWithBackStack
(
f
);
protected
void
showFragmentWithBackStack
(
Fragment
f
ragment
)
{
injectIdArgTo
(
f
ragment
);
super
.
showFragmentWithBackStack
(
f
ragment
);
}
private
void
injectIdArgTo
(
Fragment
f
)
{
Bundle
args
=
f
.
getArguments
();
private
void
injectIdArgTo
(
Fragment
f
ragment
)
{
Bundle
args
=
f
ragment
.
getArguments
();
if
(
args
==
null
)
args
=
new
Bundle
();
args
.
putString
(
"id"
,
mServerConfigId
);
f
.
setArguments
(
args
);
f
ragment
.
setArguments
(
args
);
}
@Override
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/InputHostnameFragment.java
View file @
cf7b024b
...
...
@@ -41,7 +41,7 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
@Override
protected
void
onSetupView
()
{
mRootView
.
findViewById
(
R
.
id
.
btn_connect
).
setOnClickListener
(
v
->
handleConnect
());
mRootView
.
findViewById
(
R
.
id
.
btn_connect
).
setOnClickListener
(
v
iew
->
handleConnect
());
mObserver
.
sub
();
}
...
...
@@ -83,8 +83,8 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
private
void
showError
(
String
errString
)
{
mShowError
.
removeMessages
(
0
);
Message
m
=
Message
.
obtain
(
mShowError
,
0
,
errString
);
mShowError
.
sendMessageDelayed
(
m
,
160
);
Message
m
sg
=
Message
.
obtain
(
mShowError
,
0
,
errString
);
mShowError
.
sendMessageDelayed
(
m
sg
,
160
);
}
private
void
onRenderServerConfig
(
ServerConfig
config
)
{
...
...
app/src/main/java/chat/rocket/android/helper/TextUtils.java
View file @
cf7b024b
...
...
@@ -18,6 +18,7 @@ public class TextUtils {
/**
* Returns str if it is not empty; otherwise defaultValue is returned.
*/
@SuppressWarnings
(
"PMD.ShortMethodName"
)
public
static
CharSequence
or
(
CharSequence
str
,
CharSequence
defaultValue
)
{
if
(
isEmpty
(
str
))
return
defaultValue
;
return
str
;
...
...
app/src/main/java/chat/rocket/android/model/MeteorLoginServiceConfiguration.java
View file @
cf7b024b
...
...
@@ -6,6 +6,7 @@ import io.realm.annotations.PrimaryKey;
/**
* subscription model for "meteor_accounts_loginServiceConfiguration"
*/
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
MeteorLoginServiceConfiguration
extends
RealmObject
{
@PrimaryKey
private
String
id
;
...
...
app/src/main/java/chat/rocket/android/model/ServerConfig.java
View file @
cf7b024b
...
...
@@ -15,6 +15,7 @@ import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
/**
* Server configuration
*/
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
ServerConfig
extends
RealmObject
{
@PrimaryKey
private
String
id
;
...
...
@@ -99,12 +100,12 @@ public class ServerConfig extends RealmObject {
}
@DebugLog
public
static
void
logError
(
String
id
,
Exception
e
)
{
public
static
void
logError
(
String
id
,
Exception
e
xception
)
{
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
()
.
put
(
"id"
,
id
)
.
put
(
"connectionError"
,
e
.
getMessage
())))
.
put
(
"connectionError"
,
e
xception
.
getMessage
())))
.
continueWith
(
new
LogcatIfError
());
}
}
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
cf7b024b
...
...
@@ -66,22 +66,22 @@ public class RocketChatService extends Service {
}
private
void
syncWebSocketThreadsWith
(
List
<
ServerConfig
>
configList
)
{
final
Iterator
<
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>>
it
=
final
Iterator
<
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>>
it
erator
=
mWebSocketThreads
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>
e
=
it
.
next
();
String
id
=
e
.
getKey
();
while
(
it
erator
.
hasNext
())
{
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>
e
ntry
=
iterator
.
next
();
String
serverConfigId
=
entry
.
getKey
();
boolean
found
=
false
;
for
(
ServerConfig
config:
configList
)
{
if
(
i
d
.
equals
(
config
.
getId
()))
{
if
(
serverConfigI
d
.
equals
(
config
.
getId
()))
{
found
=
true
;
break
;
}
}
if
(!
found
)
{
RocketChatWebSocketThread
.
terminate
(
e
.
getValue
());
it
.
remove
();
RocketChatWebSocketThread
.
terminate
(
e
ntry
.
getValue
());
it
erator
.
remove
();
}
}
...
...
@@ -95,13 +95,13 @@ public class RocketChatService extends Service {
}
private
Task
<
RocketChatWebSocketThread
>
findOrCreateWebSocketThread
(
final
ServerConfig
config
)
{
final
String
i
d
=
config
.
getId
();
if
(
mWebSocketThreads
.
containsKey
(
i
d
))
{
return
Task
.
forResult
(
mWebSocketThreads
.
get
(
i
d
));
final
String
serverConfigI
d
=
config
.
getId
();
if
(
mWebSocketThreads
.
containsKey
(
serverConfigI
d
))
{
return
Task
.
forResult
(
mWebSocketThreads
.
get
(
serverConfigI
d
));
}
else
{
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
config
)
.
onSuccessTask
(
task
->
{
mWebSocketThreads
.
put
(
i
d
,
task
.
getResult
());
mWebSocketThreads
.
put
(
serverConfigI
d
,
task
.
getResult
());
return
task
;
});
}
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
cf7b024b
...
...
@@ -29,9 +29,9 @@ public class RocketChatWebSocketThread extends HandlerThread {
private
boolean
mSocketExists
;
private
boolean
mListenersRegistered
;
private
RocketChatWebSocketThread
(
Context
appContext
,
String
i
d
)
{
super
(
"RC_thread_"
+
i
d
);
mServerConfigId
=
i
d
;
private
RocketChatWebSocketThread
(
Context
appContext
,
String
serverConfigI
d
)
{
super
(
"RC_thread_"
+
serverConfigI
d
);
mServerConfigId
=
serverConfigI
d
;
mAppContext
=
appContext
;
}
...
...
@@ -48,8 +48,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
try
{
super
.
onLooperPrepared
();
task
.
setResult
(
this
);
}
catch
(
Exception
e
)
{
task
.
setError
(
e
);
}
catch
(
Exception
e
xception
)
{
task
.
setError
(
e
xception
);
}
}
}.
start
();
...
...
@@ -60,8 +60,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
* terminate the thread
*/
@DebugLog
public
static
void
terminate
(
RocketChatWebSocketThread
t
)
{
t
.
quit
();
public
static
void
terminate
(
RocketChatWebSocketThread
t
hread
)
{
t
hread
.
quit
();
}
private
Task
<
Void
>
ensureConnection
()
{
...
...
@@ -178,12 +178,12 @@ public class RocketChatWebSocketThread extends HandlerThread {
Object
obj
=
ctor
.
newInstance
(
mAppContext
,
mWebSocketAPI
);
if
(
obj
instanceof
Registerable
)
{
Registerable
l
=
(
Registerable
)
obj
;
l
.
register
();
mListeners
.
add
(
l
);
Registerable
registerable
=
(
Registerable
)
obj
;
registerable
.
register
();
mListeners
.
add
(
registerable
);
}
}
catch
(
Exception
e
)
{
Timber
.
w
(
e
,
"Failed to register listeners!!"
);
}
catch
(
Exception
e
xception
)
{
Timber
.
w
(
e
xception
,
"Failed to register listeners!!"
);
}
}
}
...
...
@@ -192,18 +192,18 @@ public class RocketChatWebSocketThread extends HandlerThread {
private
void
keepaliveListeners
()
{
if
(!
mSocketExists
||
!
mListenersRegistered
)
return
;
for
(
Registerable
l
:
mListeners
)
l
.
keepalive
();
for
(
Registerable
registerable
:
mListeners
)
registerable
.
keepalive
();
}
//@DebugLog
private
void
unregisterListeners
()
{
if
(!
mSocketExists
||
!
mListenersRegistered
)
return
;
Iterator
<
Registerable
>
it
=
mListeners
.
iterator
();
while
(
it
.
hasNext
())
{
Registerable
l
=
it
.
next
();
l
.
unregister
();
it
.
remove
();
Iterator
<
Registerable
>
it
erator
=
mListeners
.
iterator
();
while
(
it
erator
.
hasNext
())
{
Registerable
registerable
=
iterator
.
next
();
registerable
.
unregister
();
it
erator
.
remove
();
}
if
(
mWebSocketAPI
!=
null
)
{
mWebSocketAPI
.
close
();
...
...
app/src/main/java/chat/rocket/android/service/ddp_subscriber/AbstractDDPDocEventSubscriber.java
View file @
cf7b024b
...
...
@@ -103,9 +103,9 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
private
void
mergeJSON
(
JSONObject
target
,
JSONObject
src
)
throws
JSONException
{
Iterator
<
String
>
it
=
src
.
keys
();
while
(
it
.
hasNext
())
{
String
key
=
it
.
next
();
Iterator
<
String
>
it
erator
=
src
.
keys
();
while
(
it
erator
.
hasNext
())
{
String
key
=
it
erator
.
next
();
target
.
put
(
key
,
src
.
get
(
key
));
}
}
...
...
app/src/main/java/chat/rocket/android/view/AbstractCustomFontTextView.java
View file @
cf7b024b
...
...
@@ -33,8 +33,8 @@ abstract class AbstractCustomFontTextView extends AppCompatTextView {
private
void
init
()
{
String
font
=
getFont
();
if
(
font
!=
null
)
{
Typeface
t
f
=
TypefaceHelper
.
getTypeface
(
getContext
(),
font
);
if
(
t
f
!=
null
)
setTypeface
(
tf
);
Typeface
t
ypeface
=
TypefaceHelper
.
getTypeface
(
getContext
(),
font
);
if
(
t
ypeface
!=
null
)
setTypeface
(
typeface
);
}
}
}
app/src/main/java/chat/rocket/android/view/TypefaceHelper.java
View file @
cf7b024b
...
...
@@ -18,16 +18,16 @@ public class TypefaceHelper {
/**
* read font in assets directory.
*/
public
static
Typeface
getTypeface
(
Context
c
,
String
assetPath
)
{
public
static
Typeface
getTypeface
(
Context
c
ontext
,
String
assetPath
)
{
synchronized
(
CACHE
)
{
if
(!
CACHE
.
containsKey
(
assetPath
))
{
try
{
Typeface
t
=
Typeface
.
createFromAsset
(
c
.
getAssets
(),
Typeface
t
ypeface
=
Typeface
.
createFromAsset
(
context
.
getAssets
(),
assetPath
);
CACHE
.
put
(
assetPath
,
t
);
}
catch
(
Exception
e
)
{
CACHE
.
put
(
assetPath
,
t
ypeface
);
}
catch
(
Exception
e
xception
)
{
Log
.
e
(
TAG
,
"Could not get typeface '"
+
assetPath
+
"' because "
+
e
.
getMessage
());
+
"' because "
+
e
xception
.
getMessage
());
return
null
;
}
}
...
...
app/src/main/java/chat/rocket/android/view/WaitingView.java
View file @
cf7b024b
...
...
@@ -48,12 +48,12 @@ public class WaitingView extends LinearLayout {
int
count
=
3
;
if
(
attrs
!=
null
)
{
TypedArray
a
=
context
.
getTheme
().
obtainStyledAttributes
(
TypedArray
a
rray
=
context
.
getTheme
().
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
WaitingView
,
0
,
0
);
size
=
a
.
getDimensionPixelSize
(
R
.
styleable
.
WaitingView_dotSize
,
size
);
count
=
a
.
getInteger
(
R
.
styleable
.
WaitingView_dotCount
,
count
);
a
.
recycle
();
size
=
a
rray
.
getDimensionPixelSize
(
R
.
styleable
.
WaitingView_dotSize
,
size
);
count
=
a
rray
.
getInteger
(
R
.
styleable
.
WaitingView_dotCount
,
count
);
a
rray
.
recycle
();
}
mDots
=
new
ArrayList
<>();
...
...
@@ -74,13 +74,14 @@ public class WaitingView extends LinearLayout {
}
private
void
addDot
(
Context
context
,
int
size
)
{
FrameLayout
f
=
new
FrameLayout
(
context
);
f
.
setLayoutParams
(
new
LinearLayoutCompat
.
LayoutParams
(
size
*
3
/
2
,
size
*
3
/
2
));
FrameLayout
frameLayout
=
new
FrameLayout
(
context
);
frameLayout
.
setLayoutParams
(
new
LinearLayoutCompat
.
LayoutParams
(
size
*
3
/
2
,
size
*
3
/
2
));
ImageView
dot
=
new
ImageView
(
context
);
dot
.
setImageResource
(
R
.
drawable
.
white_circle
);
dot
.
setLayoutParams
(
new
FrameLayout
.
LayoutParams
(
size
,
size
,
Gravity
.
CENTER
));
f
.
addView
(
dot
);
addView
(
f
);
f
rameLayout
.
addView
(
dot
);
addView
(
f
rameLayout
);
mDots
.
add
(
dot
);
}
...
...
app/src/main/java/chat/rocket/android/ws/RocketChatWebSocketAPI.java
View file @
cf7b024b
...
...
@@ -62,8 +62,8 @@ public class RocketChatWebSocketAPI {
/**
* Unsubscribe with DDP client.
*/
public
Task
<
DDPSubscription
.
NoSub
>
unsubscribe
(
final
String
i
d
)
{
return
mDDPClient
.
unsub
(
i
d
);
public
Task
<
DDPSubscription
.
NoSub
>
unsubscribe
(
final
String
subscriptionI
d
)
{
return
mDDPClient
.
unsub
(
subscriptionI
d
);
}
/**
...
...
config/quality/pmd/pmd-ruleset.xml
View file @
cf7b024b
...
...
@@ -20,8 +20,8 @@
<rule
ref=
"rulesets/java/naming.xml"
>
<!--<exclude name="AbstractNaming" />-->
<exclude
name=
"LongVariable"
/>
<
exclude
name=
"ShortMethodName"
/
>
<
exclude
name=
"ShortVariable"
/
>
<
!--exclude name="ShortMethodName" /--
>
<
!--exclude name="ShortVariable" /--
>
<!--<exclude name="ShortClassName" />-->
<!--<exclude name="VariableNamingConventions" />-->
</rule>
...
...
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