mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Merge branch 'main' into added-button
This commit is contained in:
commit
5c05e7d0f6
137 changed files with 1920 additions and 1420 deletions
|
|
@ -1,11 +1,11 @@
|
|||
package fr.free.nrw.commons.upload
|
||||
|
||||
import android.content.Context
|
||||
import fr.free.nrw.commons.Utils
|
||||
import fr.free.nrw.commons.contributions.Contribution
|
||||
import fr.free.nrw.commons.filepicker.UploadableFile.DateTimeWithSource
|
||||
import fr.free.nrw.commons.settings.Prefs.Licenses
|
||||
import fr.free.nrw.commons.utils.ConfigUtils.getVersionNameWithSha
|
||||
import fr.free.nrw.commons.utils.getWikiLovesMonumentsYear
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
|
|
@ -49,7 +49,7 @@ class PageContentsCreator @Inject constructor(private val context: Context) {
|
|||
String.format(
|
||||
Locale.ENGLISH,
|
||||
"{{Wiki Loves Monuments %d|1= %s}}\n",
|
||||
Utils.getWikiLovesMonumentsYear(Calendar.getInstance()),
|
||||
getWikiLovesMonumentsYear(Calendar.getInstance()),
|
||||
contribution.countryCode
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package fr.free.nrw.commons.upload
|
||||
|
||||
import android.net.Uri
|
||||
import fr.free.nrw.commons.Utils
|
||||
import fr.free.nrw.commons.filepicker.MimeTypeMapWrapper.Companion.getExtensionFromMimeType
|
||||
import fr.free.nrw.commons.nearby.Place
|
||||
import fr.free.nrw.commons.utils.ImageUtils
|
||||
import fr.free.nrw.commons.utils.fixExtension
|
||||
|
||||
class UploadItem(
|
||||
var mediaUri: Uri?,
|
||||
|
|
@ -32,7 +32,7 @@ class UploadItem(
|
|||
* languages have been entered, the first language is used.
|
||||
*/
|
||||
val filename: String
|
||||
get() = Utils.fixExtension(
|
||||
get() = fixExtension(
|
||||
uploadMediaDetails[0].captionText,
|
||||
getExtensionFromMimeType(mimeType)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ class UploadProgressActivity : BaseActivity() {
|
|||
@Inject
|
||||
lateinit var contributionDao: ContributionDao
|
||||
|
||||
val fragmentList: MutableList<Fragment> = ArrayList()
|
||||
val titleList: MutableList<String> = ArrayList()
|
||||
var isPaused = true
|
||||
var isPendingIconsVisible = true
|
||||
var isErrorIconsVisisble = false
|
||||
|
|
@ -38,7 +36,7 @@ class UploadProgressActivity : BaseActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityUploadProgressBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
viewPagerAdapter = ViewPagerAdapter(supportFragmentManager)
|
||||
viewPagerAdapter = ViewPagerAdapter(this, supportFragmentManager)
|
||||
binding.uploadProgressViewPager.setAdapter(viewPagerAdapter)
|
||||
binding.uploadProgressViewPager.setId(R.id.upload_progress_view_pager)
|
||||
binding.uploadProgressTabLayout.setupWithViewPager(binding.uploadProgressViewPager)
|
||||
|
|
@ -81,11 +79,10 @@ class UploadProgressActivity : BaseActivity() {
|
|||
pendingUploadsFragment = PendingUploadsFragment()
|
||||
failedUploadsFragment = FailedUploadsFragment()
|
||||
|
||||
fragmentList.add(pendingUploadsFragment!!)
|
||||
titleList.add(getString(R.string.pending))
|
||||
fragmentList.add(failedUploadsFragment!!)
|
||||
titleList.add(getString(R.string.failed))
|
||||
viewPagerAdapter!!.setTabData(fragmentList, titleList)
|
||||
viewPagerAdapter!!.setTabs(
|
||||
R.string.pending to pendingUploadsFragment!!,
|
||||
R.string.failed to failedUploadsFragment!!
|
||||
)
|
||||
viewPagerAdapter!!.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ import android.widget.AdapterView
|
|||
import android.widget.ArrayAdapter
|
||||
import android.widget.TextView
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.Utils
|
||||
import fr.free.nrw.commons.databinding.FragmentMediaLicenseBinding
|
||||
import fr.free.nrw.commons.upload.UploadActivity
|
||||
import fr.free.nrw.commons.upload.UploadBaseFragment
|
||||
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
|
||||
import fr.free.nrw.commons.utils.handleWebUrl
|
||||
import fr.free.nrw.commons.utils.toLicenseName
|
||||
import fr.free.nrw.commons.utils.toLicenseUrl
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -126,20 +128,20 @@ class MediaLicenseFragment : UploadBaseFragment(), MediaLicenseContract.View {
|
|||
}
|
||||
|
||||
override fun setSelectedLicense(license: String?) {
|
||||
var position = licenses!!.indexOf(getString(Utils.licenseNameFor(license)))
|
||||
var position = license?.let { licenses!!.indexOf(getString(it.toLicenseName())) } ?: -1
|
||||
// Check if position is valid
|
||||
if (position < 0) {
|
||||
Timber.d("Invalid position: %d. Using default licenses", position)
|
||||
position = licenses!!.size - 1
|
||||
} else {
|
||||
Timber.d("Position: %d %s", position, getString(Utils.licenseNameFor(license)))
|
||||
}
|
||||
binding.spinnerLicenseList.setSelection(position)
|
||||
}
|
||||
|
||||
override fun updateLicenseSummary(selectedLicense: String?, numberOfItems: Int) {
|
||||
val licenseHyperLink = "<a href='" + Utils.licenseUrlFor(selectedLicense) + "'>" +
|
||||
getString(Utils.licenseNameFor(selectedLicense)) + "</a><br>"
|
||||
if (selectedLicense == null) return
|
||||
|
||||
val licenseHyperLink = "<a href='" + selectedLicense.toLicenseUrl() + "'>" +
|
||||
getString(selectedLicense.toLicenseName()) + "</a><br>"
|
||||
|
||||
setTextViewHTML(
|
||||
binding.tvShareLicenseSummary, resources
|
||||
|
|
@ -184,7 +186,7 @@ class MediaLicenseFragment : UploadBaseFragment(), MediaLicenseContract.View {
|
|||
}
|
||||
|
||||
private fun launchBrowser(hyperLink: String) =
|
||||
Utils.handleWebUrl(context, Uri.parse(hyperLink))
|
||||
handleWebUrl(requireContext(), Uri.parse(hyperLink))
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package fr.free.nrw.commons.upload.license
|
||||
|
||||
import fr.free.nrw.commons.Utils
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore
|
||||
import fr.free.nrw.commons.repository.UploadRepository
|
||||
import fr.free.nrw.commons.settings.Prefs
|
||||
import fr.free.nrw.commons.utils.toLicenseName
|
||||
import timber.log.Timber
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Proxy
|
||||
|
|
@ -34,12 +34,14 @@ class MediaLicensePresenter @Inject constructor(
|
|||
val licenses = repository.getLicenses()
|
||||
view.setLicenses(licenses)
|
||||
|
||||
var selectedLicense = defaultKVStore.getString(
|
||||
//CC_BY_SA_4 is the default one used by the commons web app
|
||||
var selectedLicense: String = defaultKVStore.getString(
|
||||
Prefs.DEFAULT_LICENSE,
|
||||
Prefs.Licenses.CC_BY_SA_4
|
||||
) //CC_BY_SA_4 is the default one used by the commons web app
|
||||
) ?: Prefs.Licenses.CC_BY_SA_4
|
||||
|
||||
try { //I have to make sure that the stored default license was not one of the deprecated one's
|
||||
Utils.licenseNameFor(selectedLicense)
|
||||
selectedLicense.toLicenseName()
|
||||
} catch (exception: IllegalStateException) {
|
||||
Timber.e(exception)
|
||||
selectedLicense = Prefs.Licenses.CC_BY_SA_4
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ interface UploadMediaDetailsContract {
|
|||
fun showBadImagePopup(errorCode: Int, index: Int, uploadItem: UploadItem)
|
||||
}
|
||||
|
||||
interface UserActionListener : BasePresenter<View?> {
|
||||
interface UserActionListener : BasePresenter<View> {
|
||||
fun setupBasicKvStoreFactory(factory: (String) -> BasicKvStore)
|
||||
|
||||
fun receiveImage(
|
||||
|
|
|
|||
|
|
@ -107,7 +107,10 @@ class UploadMediaPresenter @Inject constructor(
|
|||
view.showProgress(false)
|
||||
val gpsCoords = uploadItem.gpsCoords
|
||||
val hasImageCoordinates = gpsCoords != null && gpsCoords.imageCoordsExists
|
||||
if (hasImageCoordinates && place == null) {
|
||||
|
||||
// Only check for nearby places if image has coordinates AND no place was pre-selected
|
||||
// This prevents the popup from appearing when uploading from Nearby feature
|
||||
if (hasImageCoordinates && place == null && uploadItem.place == null) {
|
||||
checkNearbyPlaces(uploadItem)
|
||||
}
|
||||
}, { throwable: Throwable? ->
|
||||
|
|
|
|||
|
|
@ -472,7 +472,10 @@ class UploadWorker(
|
|||
if (wikiDataPlace != null) {
|
||||
if (!contribution.hasInvalidLocation()) {
|
||||
var revisionID: Long? = null
|
||||
val p18WasSkipped = !wikiDataPlace.imageValue.isNullOrBlank()
|
||||
try {
|
||||
if (!p18WasSkipped) {
|
||||
// Only set P18 if the place does not already have a picture
|
||||
revisionID =
|
||||
wikidataEditService.createClaim(
|
||||
wikiDataPlace,
|
||||
|
|
@ -489,9 +492,11 @@ class UploadWorker(
|
|||
.subscribeOn(Schedulers.io())
|
||||
.blockingAwait()
|
||||
Timber.d("Updated WikiItem place ${place.name} with image ${place.pic}")
|
||||
}
|
||||
}
|
||||
showSuccessNotification(contribution)
|
||||
}
|
||||
// Always show success notification, whether P18 was set or skipped
|
||||
showSuccessNotification(contribution)
|
||||
} catch (exception: Exception) {
|
||||
Timber.e(exception)
|
||||
}
|
||||
|
|
@ -500,6 +505,7 @@ class UploadWorker(
|
|||
wikidataEditService.handleImageClaimResult(
|
||||
contribution.wikidataPlace!!,
|
||||
revisionID,
|
||||
p18WasSkipped = p18WasSkipped
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue