Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Rename Constants to Follow CamelCase Naming Convention #6126

Merged
merged 21 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5c1b031
Rename Constants to Follow Kotlin Naming Conventions
Akshaykomar890 Jan 5, 2025
2f899ec
Update Project_Default.xml
Akshaykomar890 Jan 6, 2025
a7c1842
Refactor variable names to adhere to naming conventions
Akshaykomar890 Jan 8, 2025
570ed58
Refactor Dialog View Initialization with Null-Safe Calls
Akshaykomar890 Jan 10, 2025
83bef3a
Merge branch 'main' into main
Akshaykomar890 Jan 10, 2025
abef27a
Refactor Unit Test: Replace Unsafe Casting with Type-Safe Mocking for…
Akshaykomar890 Jan 11, 2025
5e24bde
Merge branch 'commons-app:main' into main
Akshaykomar890 Jan 11, 2025
f2ef4bb
Update NearbyParentFragmentUnitTest.kt
Akshaykomar890 Jan 11, 2025
7edf393
Refactor: Rename Constants to Follow CamelCase Naming Convention
Akshaykomar890 Jan 13, 2025
6d31048
Merge branch 'main' into main
Akshaykomar890 Jan 13, 2025
8a76209
Replace private val with const val for URL constants in QuizController
Akshaykomar890 Jan 15, 2025
ecf5437
Merge remote-tracking branch 'origin/main'
Akshaykomar890 Jan 15, 2025
d4de3cd
Renaming the constant to use UPPER_SNAKE_CASE
Akshaykomar890 Jan 16, 2025
50c900e
Merge branch 'main' into main
Akshaykomar890 Jan 16, 2025
6d17621
Merge remote-tracking branch 'origin/main'
Akshaykomar890 Jan 16, 2025
0c8763b
Renaming the constant to use UPPER_SNAKE_CASE
Akshaykomar890 Jan 16, 2025
7d6a460
Update Done
Akshaykomar890 Jan 16, 2025
d4950b1
Merge branch 'main' into main
nicolas-raoul Jan 17, 2025
cb41668
**Refactor: Convert `minimumThresholdForSwipe` to a compile-time cons…
Akshaykomar890 Jan 17, 2025
dd46bc7
Merge remote-tracking branch 'origin/main'
Akshaykomar890 Jan 17, 2025
35fa618
Merge branch 'main' into main
Akshaykomar890 Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/src/main/java/fr/free/nrw/commons/quiz/QuizController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ class QuizController {

private val quiz: ArrayList<QuizQuestion> = ArrayList()

private val URL_FOR_SELFIE = "https://i.imgur.com/0fMYcpM.jpg"
private val URL_FOR_TAJ_MAHAL = "https://upload.wikimedia.org/wikipedia/commons/1/15/Taj_Mahal-03.jpg"
private val URL_FOR_BLURRY_IMAGE = "https://i.imgur.com/Kepb5jR.jpg"
private val URL_FOR_SCREENSHOT = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Social_media_app_mockup_screenshot.svg/500px-Social_media_app_mockup_screenshot.svg.png"
private val URL_FOR_EVENT = "https://upload.wikimedia.org/wikipedia/commons/5/51/HouseBuildingInNorthernVietnam.jpg"
companion object{

const val URL_FOR_SELFIE = "https://i.imgur.com/0fMYcpM.jpg"
const val URL_FOR_TAJ_MAHAL = "https://upload.wikimedia.org/wikipedia/commons/1/15/Taj_Mahal-03.jpg"
const val URL_FOR_BLURRY_IMAGE = "https://i.imgur.com/Kepb5jR.jpg"
const val URL_FOR_SCREENSHOT = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Social_media_app_mockup_screenshot.svg/500px-Social_media_app_mockup_screenshot.svg.png"
const val URL_FOR_EVENT = "https://upload.wikimedia.org/wikipedia/commons/5/51/HouseBuildingInNorthernVietnam.jpg"
}


fun initialize(context: Context) {
val q1 = QuizQuestion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class ReviewActivity : BaseActivity() {
private var hasNonHiddenCategories = false
var media: Media? = null

private val SAVED_MEDIA = "saved_media"
private val savedMedia = "saved_media"

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
media?.let {
outState.putParcelable(SAVED_MEDIA, it)
outState.putParcelable(savedMedia, it)
}
}

Expand Down Expand Up @@ -90,8 +90,8 @@ class ReviewActivity : BaseActivity() {
PorterDuff.Mode.SRC_IN
)

if (savedInstanceState?.getParcelable<Media>(SAVED_MEDIA) != null) {
updateImage(savedInstanceState.getParcelable(SAVED_MEDIA)!!)
if (savedInstanceState?.getParcelable<Media>(savedMedia) != null) {
updateImage(savedInstanceState.getParcelable(savedMedia)!!)
setUpMediaDetailOnOrientation()
} else {
runRandomizer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ReviewImageFragment : CommonsDaggerSupportFragment() {
lateinit var sessionManager: SessionManager

// Constant variable used to store user's key name for onSaveInstanceState method
private val SAVED_USER = "saved_user"
private val savedUser = "saved_user"

// Variable that stores the value of user
private var user: String? = null
Expand Down Expand Up @@ -129,7 +129,7 @@ class ReviewImageFragment : CommonsDaggerSupportFragment() {
question = getString(R.string.review_thanks)

user = reviewActivity.reviewController.firstRevision?.user()
?: savedInstanceState?.getString(SAVED_USER)
?: savedInstanceState?.getString(savedUser)

//if the user is null because of whatsoever reason, review will not be sent anyways
if (!user.isNullOrEmpty()) {
Expand Down Expand Up @@ -172,7 +172,7 @@ class ReviewImageFragment : CommonsDaggerSupportFragment() {
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
//Save user name when configuration changes happen
outState.putString(SAVED_USER, user)
outState.putString(savedUser, user)
}

private val reviewCallback: ReviewController.ReviewCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
private var languageHistoryListView: ListView? = null

private lateinit var inAppCameraLocationPermissionLauncher: ActivityResultLauncher<Array<String>>
private val GET_CONTENT_PICKER_HELP_URL = "https://commons-app.github.io/docs.html#get-content"
private val getContentPickerHelpUrl = "https://commons-app.github.io/docs.html#get-content"
Akshaykomar890 marked this conversation as resolved.
Show resolved Hide resolved

private val cameraPickLauncherForResult: ActivityResultLauncher<Intent> =
registerForActivityResult(StartActivityForResult()) { result ->
Expand Down Expand Up @@ -297,7 +297,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
getString(R.string.ok),
getString(R.string.read_help_link),
{ },
{ Utils.handleWebUrl(requireContext(), Uri.parse(GET_CONTENT_PICKER_HELP_URL)) },
{ Utils.handleWebUrl(requireContext(), Uri.parse(getContentPickerHelpUrl)) },
null
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import fr.free.nrw.commons.utils.ImageUtils.IMAGE_KEEP
import fr.free.nrw.commons.utils.ImageUtils.IMAGE_OK
import fr.free.nrw.commons.utils.ImageUtilsWrapper
import io.reactivex.Single
import io.reactivex.functions.Function
import io.reactivex.schedulers.Schedulers
import org.apache.commons.lang3.StringUtils
import timber.log.Timber
Expand All @@ -26,7 +25,7 @@ class ImageProcessingService @Inject constructor(
private val fileUtilsWrapper: FileUtilsWrapper,
private val imageUtilsWrapper: ImageUtilsWrapper,
private val readFBMD: ReadFBMD,
private val EXIFReader: EXIFReader,
private val exifReader: EXIFReader,
private val mediaClient: MediaClient
) {
/**
Expand Down Expand Up @@ -94,7 +93,7 @@ class ImageProcessingService @Inject constructor(
* the presence of some basic Exif metadata.
*/
private fun checkEXIF(filepath: String): Single<Int> =
EXIFReader.processMetadata(filepath)
exifReader.processMetadata(filepath)


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class SwipableCardView @JvmOverloads constructor(

private var x1 = 0f
private var x2 = 0f
private val MINIMUM_THRESHOLD_FOR_SWIPE = 100f
private val minimumThresholdForSwipe = 100f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also should be const val, as it will not change at runtime.


init {
interceptOnTouchListener()
Expand All @@ -45,7 +45,7 @@ abstract class SwipableCardView @JvmOverloads constructor(
isSwipe = deltaX != 0f
}
}
if (isSwipe && pixelToDp(abs(deltaX)) > MINIMUM_THRESHOLD_FOR_SWIPE) {
if (isSwipe && pixelToDp(abs(deltaX)) > minimumThresholdForSwipe) {
onSwipe(v)
return@setOnTouchListener true
}
Expand Down
Loading