mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
feat(notification): improve RecyclerView edge-to-edge insets handling
Also, refactor LocationPicker and DescriptionEdit activities to use extension functions and reduce duplication
This commit is contained in:
parent
a37002876e
commit
c64faeefd8
4 changed files with 8 additions and 23 deletions
|
|
@ -7,10 +7,7 @@ import android.speech.RecognizerIntent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.result.ActivityResult
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.updatePadding
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import fr.free.nrw.commons.CommonsApplication
|
import fr.free.nrw.commons.CommonsApplication
|
||||||
|
|
@ -28,6 +25,7 @@ import fr.free.nrw.commons.utils.applyEdgeToEdgeBottomInsets
|
||||||
import fr.free.nrw.commons.upload.UploadMediaDetail
|
import fr.free.nrw.commons.upload.UploadMediaDetail
|
||||||
import fr.free.nrw.commons.upload.UploadMediaDetailAdapter
|
import fr.free.nrw.commons.upload.UploadMediaDetailAdapter
|
||||||
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
|
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
|
||||||
|
import fr.free.nrw.commons.utils.applyEdgeToEdgeTopPaddingInsets
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.functions.Consumer
|
import io.reactivex.functions.Consumer
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
|
@ -95,14 +93,7 @@ class DescriptionEditActivity :
|
||||||
applyEdgeToEdgeBottomInsets(binding.btnEditSubmit)
|
applyEdgeToEdgeBottomInsets(binding.btnEditSubmit)
|
||||||
WindowCompat.getInsetsController(window, window.decorView)
|
WindowCompat.getInsetsController(window, window.decorView)
|
||||||
.isAppearanceLightStatusBars = false
|
.isAppearanceLightStatusBars = false
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(binding.toolbar) { v, windowInsets ->
|
binding.toolbar.applyEdgeToEdgeTopPaddingInsets()
|
||||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
||||||
|
|
||||||
v.updatePadding(
|
|
||||||
top = insets.top
|
|
||||||
)
|
|
||||||
WindowInsetsCompat.CONSUMED
|
|
||||||
}
|
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
val bundle = intent.extras
|
val bundle = intent.extras
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,7 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.IntentCompat
|
import androidx.core.content.IntentCompat
|
||||||
import androidx.core.os.BundleCompat
|
import androidx.core.os.BundleCompat
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.updatePadding
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import fr.free.nrw.commons.CameraPosition
|
import fr.free.nrw.commons.CameraPosition
|
||||||
import fr.free.nrw.commons.CommonsApplication
|
import fr.free.nrw.commons.CommonsApplication
|
||||||
|
|
@ -49,6 +46,7 @@ import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.Compani
|
||||||
import fr.free.nrw.commons.utils.DialogUtil
|
import fr.free.nrw.commons.utils.DialogUtil
|
||||||
import fr.free.nrw.commons.utils.MapUtils.ZOOM_LEVEL
|
import fr.free.nrw.commons.utils.MapUtils.ZOOM_LEVEL
|
||||||
import fr.free.nrw.commons.utils.applyEdgeToEdgeBottomInsets
|
import fr.free.nrw.commons.utils.applyEdgeToEdgeBottomInsets
|
||||||
|
import fr.free.nrw.commons.utils.applyEdgeToEdgeTopPaddingInsets
|
||||||
import fr.free.nrw.commons.utils.handleGeoCoordinates
|
import fr.free.nrw.commons.utils.handleGeoCoordinates
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
|
@ -337,14 +335,7 @@ class LocationPickerActivity : BaseActivity(), LocationPermissionCallback {
|
||||||
val toolbar: ConstraintLayout = findViewById(R.id.location_picker_toolbar)
|
val toolbar: ConstraintLayout = findViewById(R.id.location_picker_toolbar)
|
||||||
WindowCompat.getInsetsController(window, window.decorView)
|
WindowCompat.getInsetsController(window, window.decorView)
|
||||||
.isAppearanceLightStatusBars = false
|
.isAppearanceLightStatusBars = false
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(toolbar) { v, windowInsets ->
|
toolbar.applyEdgeToEdgeTopPaddingInsets()
|
||||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
||||||
|
|
||||||
v.updatePadding(
|
|
||||||
top = insets.top
|
|
||||||
)
|
|
||||||
WindowInsetsCompat.CONSUMED
|
|
||||||
}
|
|
||||||
largeToolbarText = findViewById(R.id.location_picker_toolbar_primary_text_view)
|
largeToolbarText = findViewById(R.id.location_picker_toolbar_primary_text_view)
|
||||||
smallToolbarText = findViewById(R.id.location_picker_toolbar_secondary_text_view)
|
smallToolbarText = findViewById(R.id.location_picker_toolbar_secondary_text_view)
|
||||||
toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.primaryColor))
|
toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.primaryColor))
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import fr.free.nrw.commons.theme.BaseActivity
|
||||||
import fr.free.nrw.commons.utils.applyEdgeToEdgeTopInsets
|
import fr.free.nrw.commons.utils.applyEdgeToEdgeTopInsets
|
||||||
import fr.free.nrw.commons.utils.NetworkUtils
|
import fr.free.nrw.commons.utils.NetworkUtils
|
||||||
import fr.free.nrw.commons.utils.ViewUtil
|
import fr.free.nrw.commons.utils.ViewUtil
|
||||||
|
import fr.free.nrw.commons.utils.applyEdgeToEdgeBottomPaddingInsets
|
||||||
import fr.free.nrw.commons.utils.handleWebUrl
|
import fr.free.nrw.commons.utils.handleWebUrl
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
|
@ -57,7 +58,8 @@ class NotificationActivity : BaseActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
isRead = intent.getStringExtra("title") == "read"
|
isRead = intent.getStringExtra("title") == "read"
|
||||||
binding = ActivityNotificationBinding.inflate(layoutInflater)
|
binding = ActivityNotificationBinding.inflate(layoutInflater)
|
||||||
applyEdgeToEdgeTopInsets(binding.root)
|
applyEdgeToEdgeTopInsets(binding.toolbar.toolbar)
|
||||||
|
binding.listView.applyEdgeToEdgeBottomPaddingInsets()
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
mNotificationWorkerFragment = supportFragmentManager.findFragmentByTag(
|
mNotificationWorkerFragment = supportFragmentManager.findFragmentByTag(
|
||||||
tagNotificationWorkerFragment
|
tagNotificationWorkerFragment
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:fadeScrollbars="false"
|
android:fadeScrollbars="false"
|
||||||
android:scrollbarThumbVertical="@color/primaryColor"
|
android:scrollbarThumbVertical="@color/primaryColor"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:scrollbarSize="@dimen/dimen_6"/>
|
android:scrollbarSize="@dimen/dimen_6"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue