-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
} | ||
|
||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method setupControls
has 56 lines of code (exceeds 25 allowed). Consider refactoring.
|
||
binding.cameraSurfaceView.getHolder().addCallback(object : SurfaceHolder.Callback { | ||
@SuppressLint("MissingPermission") | ||
override fun surfaceCreated(holder: SurfaceHolder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
format: Int, | ||
width: Int, | ||
height: Int | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the body of surfaceChanged and surfaceCreated are identical, refactor may also boost the coverage
@@ -38,6 +44,14 @@ class SearchUserActivity : AppCompatActivity() { | |||
searchEditText = findViewById(R.id.searchUserET) | |||
searchForUsers("") | |||
|
|||
val buttonScan: FloatingActionButton = findViewById(R.id.searchUser_scanning) | |||
|
|||
buttonScan.setOnClickListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
val usersRepo: DataGetter = DataGetter() | ||
var isTest: Boolean = false | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method onCreate
has 29 lines of code (exceeds 25 allowed). Consider refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be a good practice to break onCreate down into smaller functions.
} | ||
|
||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method setupControls
has 45 lines of code (exceeds 25 allowed). Consider refactoring.
* This section is related to the handler when code is detected | ||
*/ | ||
|
||
private fun solveDetection(detections: Detector.Detections<Barcode>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method solveDetection
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
* This section is related to the handler when code is detected | ||
*/ | ||
|
||
private fun solveDetection(detections: Detector.Detections<Barcode>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method solveDetection
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
var uidList: ArrayList<String> = ArrayList() | ||
val usersRepo: DataGetter = DataGetter() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method onCreate
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
} | ||
|
||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method setupControls
has 42 lines of code (exceeds 25 allowed). Consider refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I left some comments concerning breaking down large functions into multiple smaller functions and duplications.
if (extras != null) { | ||
uidList = extras.get("uidList") as ArrayList<String> | ||
isTest = extras.getBoolean("isTest", false) | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}else{ | |
} else { |
AnimationUtils.loadAnimation(this@QrScanningActivity, R.anim.qr_anim) | ||
binding.barcodeLine.startAnimation(aniSlide) | ||
|
||
if(isTest){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(isTest){ | |
if (isTest) { |
val usersRepo: DataGetter = DataGetter() | ||
var isTest: Boolean = false | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be a good practice to break onCreate down into smaller functions.
format: Int, | ||
width: Int, | ||
height: Int | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the body of surfaceChanged and surfaceCreated are identical, refactor may also boost the coverage
finish() | ||
} else { | ||
// Camera permission not granted, come back to previous activity | ||
Toast.makeText(applicationContext, "Camera Permission should be granted for that feature", Toast.LENGTH_LONG).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use string.xml
|
||
barcodeDetector.setProcessor(object : Detector.Processor<Barcode> { | ||
override fun release() { | ||
Toast.makeText(applicationContext, "Scanner has been closed", Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use string.xml
/* | ||
* This section is related to the handler when code is detected | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
Toast.makeText(this@QrScanningActivity, "Congratulations, you have a new friends", Toast.LENGTH_SHORT).show() | ||
endInt.putExtra("isSuccess", true) | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}else{ | |
} else { |
if (!isTest) { | ||
usersRepo.setSubFieldValue(FireBaseAuthenticator.getCurrentUID(),"friends", scannedValue, true) | ||
} | ||
Toast.makeText(this@QrScanningActivity, "Congratulations, you have a new friends", Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toast.makeText(this@QrScanningActivity, "Congratulations, you have a new friends", Toast.LENGTH_SHORT).show() | |
Toast.makeText(this@QrScanningActivity, "Congratulations, you have a new friend", Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string.xml
@@ -136,7 +136,9 @@ class DataGetter @Inject constructor() { | |||
* @param searchInput search text inputed by user | |||
* @param callback function to call with found users by username | |||
*/ | |||
fun searchByField(field: String, searchInput: String, callback:(ArrayList<User>) -> Unit) { | |||
fun searchByField(field: String, searchInput: String, callback:(ArrayList<User>) -> Unit, callback2 :(ArrayList<String>) -> Unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to update the function documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe give callback and callback2 more meaningful names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have did a partial review. I wanna give it a second look later! thank you for the changes! The feature is cool and the moving bar in an old way is the best.
app/src/main/java/ch/sdp/vibester/activity/QrScanningActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/ch/sdp/vibester/activity/QrScanningActivity.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/ch/sdp/vibester/activity/QrScanningActivityTest.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method setupControls
has 35 lines of code (exceeds 25 allowed). Consider refactoring.
if (!isTest) { | ||
usersRepo.setSubFieldValue(FireBaseAuthenticator.getCurrentUID(),"friends", scannedValue, true) | ||
} | ||
Toast.makeText(this@QrScanningActivity, getString(R.string.qrScanning_newFriend), Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
Toast.makeText(this@QrScanningActivity, getString(R.string.qrScanning_newFriend), Toast.LENGTH_SHORT).show() | ||
startActivityWExtra(Intent(this@QrScanningActivity, SearchUserActivity::class.java), "isSuccess", true) | ||
} else { | ||
Toast.makeText(this@QrScanningActivity, getString(R.string.qrScanning_noExistUid), Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
|
||
barcodeDetector.setProcessor(object : Detector.Processor<Barcode> { | ||
override fun release() { | ||
Toast.makeText(applicationContext, getString(R.string.qrScanning_scannerClosed), Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
startActivityWExtra(Intent(this@QrScanningActivity, QrScanningActivity::class.java), "uidList", uidList) | ||
} else { | ||
// Camera permission not granted, come back to previous activity | ||
Toast.makeText(applicationContext, getString(R.string.qrScanning_cameraError), Toast.LENGTH_LONG).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will having a function for toast solve the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! thanks for a nice feature!
startActivityWExtra(Intent(this@QrScanningActivity, QrScanningActivity::class.java), "uidList", uidList) | ||
} else { | ||
// Camera permission not granted, come back to previous activity | ||
Toast.makeText(applicationContext, getString(R.string.qrScanning_cameraError), Toast.LENGTH_LONG).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will having a function for toast solve the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but don't forget to change the string.xml
app/src/main/res/values/strings.xml
Outdated
<string name="qrScanning_scannerClosed">Scanner has been closed</string> | ||
<string name="qrScanning_cameraError">Camera Permission should be granted for that feature</string> | ||
<string name="qrScanning_noExistUid">Error not an existing uid</string> | ||
<string name="qrScanning_newFriend">Congratulations, you have a new friends</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<string name="qrScanning_newFriend">Congratulations, you have a new friends</string> | |
<string name="qrScanning_newFriend">Congratulations, you have a new friend</string> |
Co-authored-by: jiabaow <[email protected]>
Code Climate has analyzed commit a766e60 and detected 7 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 71.7% (80% is the threshold). This pull request will bring the total coverage in the repository to 84.0% (0.0% change). View more on Code Climate. |
Qr Reader
This is related to issue #221
This Pull Requests contains:
In addition the code is tested with a coverage of: [64.8]%
Notes for reviewers