Skip to content

Commit

Permalink
Migrated settings modules from Java to Kotlin (commons-app#5944)
Browse files Browse the repository at this point in the history
* Rename .java to .kt

* Migrated settings module to Kotlin
  • Loading branch information
Saifuddin53 authored Nov 21, 2024
1 parent 5f1d284 commit cf88f9b
Show file tree
Hide file tree
Showing 6 changed files with 640 additions and 665 deletions.
21 changes: 0 additions & 21 deletions app/src/main/java/fr/free/nrw/commons/settings/Prefs.java

This file was deleted.

21 changes: 21 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/settings/Prefs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package fr.free.nrw.commons.settings

object Prefs {
const val GLOBAL_PREFS = "fr.free.nrw.commons.preferences"

const val TRACKING_ENABLED = "eventLogging"
const val DEFAULT_LICENSE = "defaultLicense"
const val UPLOADS_SHOWING = "uploadsShowing"
const val MANAGED_EXIF_TAGS = "managed_exif_tags"
const val DESCRIPTION_LANGUAGE = "languageDescription"
const val APP_UI_LANGUAGE = "appUiLanguage"
const val KEY_THEME_VALUE = "appThemePref"

object Licenses {
const val CC_BY_SA_3 = "CC BY-SA 3.0"
const val CC_BY_3 = "CC BY 3.0"
const val CC_BY_SA_4 = "CC BY-SA 4.0"
const val CC_BY_4 = "CC BY 4.0"
const val CC0 = "CC0"
}
}

This file was deleted.

63 changes: 63 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/settings/SettingsActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package fr.free.nrw.commons.settings

import android.os.Bundle
import android.view.MenuItem
import fr.free.nrw.commons.databinding.ActivitySettingsBinding
import fr.free.nrw.commons.theme.BaseActivity


/**
* allows the user to change the settings
*/
class SettingsActivity : BaseActivity() {

private lateinit var binding: ActivitySettingsBinding
// private var settingsDelegate: AppCompatDelegate? = null

/**
* to be called when the activity starts
* @param savedInstanceState the previously saved state
*/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)

setSupportActionBar(binding.toolbarBinding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

// Get an action bar
/**
* takes care of actions taken after the creation has happened
* @param savedInstanceState the saved state
*/
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
// if (settingsDelegate == null) {
// settingsDelegate = AppCompatDelegate.create(this, null)
// }
// settingsDelegate?.onPostCreate(savedInstanceState)
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}

/**
* Handle action-bar clicks
* @param item the selected item
* @return true on success, false on failure
*/
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
finish()
true
}
else -> super.onOptionsItemSelected(item)
}
}
}
Loading

0 comments on commit cf88f9b

Please sign in to comment.