mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Refactor variable names to adhere to naming conventions (#6111)
* Rename Constants to Follow Kotlin Naming Conventions >This PR refactors constant names in the project to adhere to Kotlin's UPPERCASE_SNAKE_CASE naming convention, improving code readability and maintaining consistency across the codebase. >Renamed the following constants in LoginActivity: >saveProgressDialog → SAVE_PROGRESS_DIALOG >saveErrorMessage → SAVE_ERROR_MESSAGE >saveUsername → SAVE_USERNAME >savePassword → SAVE_PASSWORD >Updated all references to these constants throughout the project. * Update Project_Default.xml * Refactor variable names to adhere to naming conventions Renamed variables to use camel case: -UPLOAD_COUNT_THRESHOLD → uploadCountThreshold -REVERT_PERCENTAGE_FOR_MESSAGE → revertPercentageForMessage -REVERT_SHARED_PREFERENCE → revertSharedPreference -UPLOAD_SHARED_PREFERENCE → uploadSharedPreference Renamed variables with uppercase initials to lowercase for alignment with Kotlin conventions: -Latitude → latitude -Longitude → longitude -Accuracy → accuracy Refactored the following variable names: -NUMBER_OF_QUESTIONS → numberOfQuestions -MULTIPLIER_TO_GET_PERCENTAGE → multiplierToGetPercentage
This commit is contained in:
parent
87a453cb72
commit
3e7565c7e3
3 changed files with 32 additions and 32 deletions
|
|
@ -61,16 +61,16 @@ class CoordinateEditHelper @Inject constructor(
|
|||
/**
|
||||
* Replaces new coordinates
|
||||
* @param media to be added
|
||||
* @param Latitude to be added
|
||||
* @param Longitude to be added
|
||||
* @param Accuracy to be added
|
||||
* @param latitude to be added
|
||||
* @param longitude to be added
|
||||
* @param accuracy to be added
|
||||
* @return Observable<Boolean>
|
||||
*/
|
||||
private fun addCoordinates(
|
||||
media: Media,
|
||||
Latitude: String,
|
||||
Longitude: String,
|
||||
Accuracy: String
|
||||
latitude: String,
|
||||
longitude: String,
|
||||
accuracy: String
|
||||
): Observable<Boolean>? {
|
||||
Timber.d("thread is coordinates adding %s", Thread.currentThread().getName())
|
||||
val summary = "Adding Coordinates"
|
||||
|
|
@ -83,9 +83,9 @@ class CoordinateEditHelper @Inject constructor(
|
|||
.blockingGet()
|
||||
}
|
||||
|
||||
if (Latitude != null) {
|
||||
buffer.append("\n{{Location|").append(Latitude).append("|").append(Longitude)
|
||||
.append("|").append(Accuracy).append("}}")
|
||||
if (latitude != null) {
|
||||
buffer.append("\n{{Location|").append(latitude).append("|").append(longitude)
|
||||
.append("|").append(accuracy).append("}}")
|
||||
}
|
||||
|
||||
val editedLocation = buffer.toString()
|
||||
|
|
@ -141,7 +141,7 @@ class CoordinateEditHelper @Inject constructor(
|
|||
* @param media to be added
|
||||
* @param latitude to be added
|
||||
* @param longitude to be added
|
||||
* @param Accuracy to be added
|
||||
* @param accuracy to be added
|
||||
* @param result to be added
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -150,7 +150,7 @@ class CoordinateEditHelper @Inject constructor(
|
|||
media: Media,
|
||||
latitude: String,
|
||||
longitude: String,
|
||||
Accuracy: String,
|
||||
accuracy: String,
|
||||
result: Boolean
|
||||
): Boolean {
|
||||
val message: String
|
||||
|
|
@ -160,7 +160,7 @@ class CoordinateEditHelper @Inject constructor(
|
|||
media.coordinates = fr.free.nrw.commons.location.LatLng(
|
||||
latitude.toDouble(),
|
||||
longitude.toDouble(),
|
||||
Accuracy.toFloat()
|
||||
accuracy.toFloat()
|
||||
)
|
||||
title += ": " + context.getString(R.string.coordinates_edit_helper_show_edit_title_success)
|
||||
val coordinatesInMessage = StringBuilder()
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ class QuizChecker @Inject constructor(
|
|||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
private val UPLOAD_COUNT_THRESHOLD = 5
|
||||
private val REVERT_PERCENTAGE_FOR_MESSAGE = "50%"
|
||||
private val REVERT_SHARED_PREFERENCE = "revertCount"
|
||||
private val UPLOAD_SHARED_PREFERENCE = "uploadCount"
|
||||
private val uploadCountThreshold = 5
|
||||
private val revertPercentageForMessage = "50%"
|
||||
private val revertSharedPreference = "revertCount"
|
||||
private val uploadSharedPreference = "uploadCount"
|
||||
|
||||
/**
|
||||
* Initializes quiz check by calculating revert parameters and showing quiz if necessary
|
||||
|
|
@ -80,12 +80,12 @@ class QuizChecker @Inject constructor(
|
|||
*/
|
||||
private fun setTotalUploadCount(uploadCount: Int) {
|
||||
totalUploadCount = uploadCount - revertKvStore.getInt(
|
||||
UPLOAD_SHARED_PREFERENCE,
|
||||
uploadSharedPreference,
|
||||
0
|
||||
)
|
||||
if (totalUploadCount < 0) {
|
||||
totalUploadCount = 0
|
||||
revertKvStore.putInt(UPLOAD_SHARED_PREFERENCE, 0)
|
||||
revertKvStore.putInt(uploadSharedPreference, 0)
|
||||
}
|
||||
isUploadCountFetched = true
|
||||
}
|
||||
|
|
@ -112,10 +112,10 @@ class QuizChecker @Inject constructor(
|
|||
* @param revertCountFetched Count of deleted uploads
|
||||
*/
|
||||
private fun setRevertParameter(revertCountFetched: Int) {
|
||||
revertCount = revertCountFetched - revertKvStore.getInt(REVERT_SHARED_PREFERENCE, 0)
|
||||
revertCount = revertCountFetched - revertKvStore.getInt(revertSharedPreference, 0)
|
||||
if (revertCount < 0) {
|
||||
revertCount = 0
|
||||
revertKvStore.putInt(REVERT_SHARED_PREFERENCE, 0)
|
||||
revertKvStore.putInt(revertSharedPreference, 0)
|
||||
}
|
||||
isRevertCountFetched = true
|
||||
}
|
||||
|
|
@ -128,13 +128,13 @@ class QuizChecker @Inject constructor(
|
|||
setRevertCount()
|
||||
|
||||
if (revertCount < 0 || totalUploadCount < 0) {
|
||||
revertKvStore.putInt(REVERT_SHARED_PREFERENCE, 0)
|
||||
revertKvStore.putInt(UPLOAD_SHARED_PREFERENCE, 0)
|
||||
revertKvStore.putInt(revertSharedPreference, 0)
|
||||
revertKvStore.putInt(uploadSharedPreference, 0)
|
||||
return
|
||||
}
|
||||
|
||||
if (isRevertCountFetched && isUploadCountFetched &&
|
||||
totalUploadCount >= UPLOAD_COUNT_THRESHOLD &&
|
||||
totalUploadCount >= uploadCountThreshold &&
|
||||
(revertCount * 100) / totalUploadCount >= 50
|
||||
) {
|
||||
callQuiz(activity)
|
||||
|
|
@ -149,7 +149,7 @@ class QuizChecker @Inject constructor(
|
|||
DialogUtil.showAlertDialog(
|
||||
activity,
|
||||
activity.getString(R.string.quiz),
|
||||
activity.getString(R.string.quiz_alert_message, REVERT_PERCENTAGE_FOR_MESSAGE),
|
||||
activity.getString(R.string.quiz_alert_message, revertPercentageForMessage),
|
||||
activity.getString(R.string.about_translate_proceed),
|
||||
activity.getString(android.R.string.cancel),
|
||||
{ startQuizActivity(activity) },
|
||||
|
|
@ -161,11 +161,11 @@ class QuizChecker @Inject constructor(
|
|||
* Starts the quiz activity and updates preferences for revert and upload counts
|
||||
*/
|
||||
private fun startQuizActivity(activity: Activity) {
|
||||
val newRevertSharedPrefs = revertCount + revertKvStore.getInt(REVERT_SHARED_PREFERENCE, 0)
|
||||
revertKvStore.putInt(REVERT_SHARED_PREFERENCE, newRevertSharedPrefs)
|
||||
val newRevertSharedPrefs = revertCount + revertKvStore.getInt(revertSharedPreference, 0)
|
||||
revertKvStore.putInt(revertSharedPreference, newRevertSharedPrefs)
|
||||
|
||||
val newUploadCount = totalUploadCount + revertKvStore.getInt(UPLOAD_SHARED_PREFERENCE, 0)
|
||||
revertKvStore.putInt(UPLOAD_SHARED_PREFERENCE, newUploadCount)
|
||||
val newUploadCount = totalUploadCount + revertKvStore.getInt(uploadSharedPreference, 0)
|
||||
revertKvStore.putInt(uploadSharedPreference, newUploadCount)
|
||||
|
||||
val intent = Intent(activity, WelcomeActivity::class.java).apply {
|
||||
putExtra("isQuiz", true)
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ import fr.free.nrw.commons.contributions.MainActivity
|
|||
class QuizResultActivity : AppCompatActivity() {
|
||||
|
||||
private var binding: ActivityQuizResultBinding? = null
|
||||
private val NUMBER_OF_QUESTIONS = 5
|
||||
private val MULTIPLIER_TO_GET_PERCENTAGE = 20
|
||||
private val numberOfQuestions = 5
|
||||
private val multiplierToGetPercentage = 20
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
@ -67,9 +67,9 @@ class QuizResultActivity : AppCompatActivity() {
|
|||
*/
|
||||
@SuppressLint("StringFormatInvalid", "SetTextI18n")
|
||||
fun setScore(score: Int) {
|
||||
val scorePercent = score * MULTIPLIER_TO_GET_PERCENTAGE
|
||||
val scorePercent = score * multiplierToGetPercentage
|
||||
binding?.resultProgressBar?.progress = scorePercent
|
||||
binding?.tvResultProgress?.text = "$score / $NUMBER_OF_QUESTIONS"
|
||||
binding?.tvResultProgress?.text = "$score / $numberOfQuestions"
|
||||
val message = resources.getString(R.string.congratulatory_message_quiz, "$scorePercent%")
|
||||
binding?.congratulatoryMessage?.text = message
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue