mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-03 08:13:55 +01:00
Convert top level "Utils" class to kotlin (#6364)
* Unused class removed * Convert BasePresenter to kotlin * Removed redundent class * Move the Utils class into the utils package * Inline the creation of a page title object * Move license utilities into their own file * Inline app rating since its only ever used in 1 place * Moved GeoCoordinates utilities into their own class * Moved Monuments related utils into their own class * Moved screen capture into its own util class * Moved handleWebUrl to its own utility class * Moved fixExtension to its own class * Moved clipboard copy into its own utility class * Renames class to match remaining utility method * Convert UnderlineUtils to kotlin * Converted the copy-to-clipboard utility to kotlin * Converted license name and url lookup to kotlin * Converted fixExtension to kotlin * Convert handleGeoCoordinates to kotlin * Monument utils converted to kotlin * Convert then inline screeen capture in kotlin * Convert handleWebUrl to kotlin
This commit is contained in:
parent
4befff8f42
commit
3bd0ec4466
44 changed files with 387 additions and 519 deletions
|
|
@ -9,7 +9,6 @@ import fr.free.nrw.commons.BasePresenter
|
|||
interface ContributionsContract {
|
||||
|
||||
interface View {
|
||||
fun showMessage(localizedMessage: String)
|
||||
fun getContext(): Context?
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import androidx.work.WorkManager
|
|||
import fr.free.nrw.commons.MapController.NearbyPlacesInfo
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.Utils
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.campaigns.CampaignView
|
||||
import fr.free.nrw.commons.campaigns.CampaignsPresenter
|
||||
|
|
@ -64,6 +63,9 @@ import fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween
|
|||
import fr.free.nrw.commons.utils.NetworkUtils.isInternetConnectionEstablished
|
||||
import fr.free.nrw.commons.utils.PermissionUtils.hasPermission
|
||||
import fr.free.nrw.commons.utils.ViewUtil.showLongToast
|
||||
import fr.free.nrw.commons.utils.isMonumentsEnabled
|
||||
import fr.free.nrw.commons.utils.wLMEndDate
|
||||
import fr.free.nrw.commons.utils.wLMStartDate
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
|
@ -242,8 +244,8 @@ class ContributionsFragment : CommonsDaggerSupportFragment(), FragmentManager.On
|
|||
private fun initWLMCampaign() {
|
||||
wlmCampaign = Campaign(
|
||||
getString(R.string.wlm_campaign_title),
|
||||
getString(R.string.wlm_campaign_description), Utils.getWLMStartDate().toString(),
|
||||
Utils.getWLMEndDate().toString(), NearbyParentFragment.WLM_URL, true
|
||||
getString(R.string.wlm_campaign_description), wLMStartDate,
|
||||
wLMEndDate, NearbyParentFragment.WLM_URL, true
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -729,7 +731,7 @@ class ContributionsFragment : CommonsDaggerSupportFragment(), FragmentManager.On
|
|||
* of campaigns on the campaigns card
|
||||
*/
|
||||
private fun fetchCampaigns() {
|
||||
if (Utils.isMonumentsEnabled(Date())) {
|
||||
if (isMonumentsEnabled) {
|
||||
if (binding != null) {
|
||||
binding!!.campaignsView.setCampaign(wlmCampaign)
|
||||
binding!!.campaignsView.visibility = View.VISIBLE
|
||||
|
|
@ -743,10 +745,6 @@ class ContributionsFragment : CommonsDaggerSupportFragment(), FragmentManager.On
|
|||
}
|
||||
}
|
||||
|
||||
override fun showMessage(message: String) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
override fun showCampaigns(campaign: Campaign?) {
|
||||
if (campaign != null && !isUserProfile) {
|
||||
if (binding != null) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class ContributionsListContract {
|
|||
fun showNoContributionsUI(shouldShow: Boolean)
|
||||
}
|
||||
|
||||
interface UserActionListener : BasePresenter<View?> {
|
||||
interface UserActionListener : BasePresenter<View> {
|
||||
fun refreshList(swipeRefreshLayout: SwipeRefreshLayout?)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import androidx.recyclerview.widget.SimpleItemAnimator
|
|||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.MediaDataExtractor
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.Utils
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.contributions.WikipediaInstructionsDialogFragment.Companion.newInstance
|
||||
import fr.free.nrw.commons.databinding.FragmentContributionsListBinding
|
||||
|
|
@ -41,6 +40,8 @@ import fr.free.nrw.commons.profile.ProfileActivity
|
|||
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
|
||||
import fr.free.nrw.commons.utils.SystemThemeUtils
|
||||
import fr.free.nrw.commons.utils.ViewUtil.showShortToast
|
||||
import fr.free.nrw.commons.utils.copyToClipboard
|
||||
import fr.free.nrw.commons.utils.handleWebUrl
|
||||
import fr.free.nrw.commons.wikidata.model.WikiSite
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import javax.inject.Inject
|
||||
|
|
@ -527,14 +528,13 @@ class ContributionsListFragment : CommonsDaggerSupportFragment(), ContributionsL
|
|||
*/
|
||||
override fun onConfirmClicked(contribution: Contribution?, copyWikicode: Boolean) {
|
||||
if (copyWikicode) {
|
||||
val wikicode = contribution!!.media.wikiCode
|
||||
Utils.copy("wikicode", wikicode, context)
|
||||
requireContext().copyToClipboard("wikicode", contribution!!.media.wikiCode)
|
||||
}
|
||||
|
||||
val url =
|
||||
languageWikipediaSite!!.mobileUrl() + "/wiki/" + (contribution!!.wikidataPlace
|
||||
?.getWikipediaPageTitle())
|
||||
Utils.handleWebUrl(context, Uri.parse(url))
|
||||
handleWebUrl(requireContext(), Uri.parse(url))
|
||||
}
|
||||
|
||||
fun getContributionStateAt(position: Int): Int {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue