mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* chore: upgrade target SDK and refactor function signatures to resolve build issues * chore: bump android gradle plugin version * chore(ui): add extension functions for applying edge to edge insets * fix: apply system bar top and bottom insets for edge to edge * fix: force edge to edge for backward compatibility and consistent UI * fix: apply top bar insets as padding and make the status bar color white Since the toolbars have primary color as bg, we should make the status bar white * chore: bump robolectric version for API 35 compatibility * fix: preserve existing margins when adding new insets * feat(customselector): improve RecyclerView edge-to-edge inset handling It allows the last item to sits above the navigation bar while preserving edge-to-edge appearance. * feat(notification): improve RecyclerView edge-to-edge insets handling Also, refactor LocationPicker and DescriptionEdit activities to use extension functions and reduce duplication * fix(quiz): enable and handle edge-to-edge insets and status icon colors * fix: bottom insets not dispatched on all API versions consistently Upgraded core-ktx version installCompatInsetsDispatch wasn't available on current version * fix: return fallback value when versionName is null Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: resolve compilation errors * docs: add KDoc for edge-to-edge insets utility functions * fix(SearchActivity): apply insets for system bars * fix(util): add utility function to handle keyboard insets with animation * fix(upload): handle keyboard insets for upload media detail card view * fix(login): hadle IME insets and make edge-to-edge backward compatible --------- Co-authored-by: Ritika Pahwa <83745993+RitikaPahwa4444@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
80 lines
2.6 KiB
Kotlin
80 lines
2.6 KiB
Kotlin
package fr.free.nrw.commons
|
|
|
|
import android.app.AlertDialog
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.os.Bundle
|
|
import android.view.View
|
|
import fr.free.nrw.commons.databinding.ActivityWelcomeBinding
|
|
import fr.free.nrw.commons.databinding.PopupForCopyrightBinding
|
|
import fr.free.nrw.commons.quiz.QuizActivity
|
|
import fr.free.nrw.commons.theme.BaseActivity
|
|
import fr.free.nrw.commons.utils.applyEdgeToEdgeAllInsets
|
|
import fr.free.nrw.commons.utils.ConfigUtils.isBetaFlavour
|
|
|
|
class WelcomeActivity : BaseActivity() {
|
|
private var binding: ActivityWelcomeBinding? = null
|
|
private var isQuiz = false
|
|
|
|
/**
|
|
* Initialises exiting fields and dependencies
|
|
*
|
|
* @param savedInstanceState WelcomeActivity bundled data
|
|
*/
|
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
binding = ActivityWelcomeBinding.inflate(layoutInflater)
|
|
applyEdgeToEdgeAllInsets(binding!!.welcomePager.rootView)
|
|
setContentView(binding!!.root)
|
|
|
|
isQuiz = intent?.extras?.getBoolean("isQuiz", false) ?: false
|
|
|
|
// Enable skip button if beta flavor
|
|
if (isBetaFlavour) {
|
|
binding!!.finishTutorialButton.visibility = View.VISIBLE
|
|
|
|
val copyrightBinding = PopupForCopyrightBinding.inflate(layoutInflater)
|
|
|
|
val dialog = AlertDialog.Builder(this)
|
|
.setView(copyrightBinding.root)
|
|
.setCancelable(false)
|
|
.create()
|
|
dialog.show()
|
|
|
|
copyrightBinding.buttonOk.setOnClickListener { v: View? -> dialog.dismiss() }
|
|
}
|
|
|
|
val adapter = WelcomePagerAdapter()
|
|
binding!!.welcomePager.adapter = adapter
|
|
binding!!.welcomePagerIndicator.setViewPager(binding!!.welcomePager)
|
|
binding!!.finishTutorialButton.setOnClickListener { v: View? -> finishTutorial() }
|
|
}
|
|
|
|
public override fun onDestroy() {
|
|
if (isQuiz) {
|
|
startActivity(Intent(this, QuizActivity::class.java))
|
|
}
|
|
super.onDestroy()
|
|
}
|
|
|
|
override fun onBackPressed() {
|
|
if (binding!!.welcomePager.currentItem != 0) {
|
|
binding!!.welcomePager.setCurrentItem(binding!!.welcomePager.currentItem - 1, true)
|
|
} else {
|
|
if (defaultKvStore.getBoolean("firstrun", true)) {
|
|
finishAffinity()
|
|
} else {
|
|
super.onBackPressed()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun finishTutorial() {
|
|
defaultKvStore.putBoolean("firstrun", false)
|
|
finish()
|
|
}
|
|
}
|
|
|
|
fun Context.startWelcome() {
|
|
startActivity(Intent(this, WelcomeActivity::class.java))
|
|
}
|