ui: make toolbar fix dedicated class

Make the toolbar spacing fixes a dedicated class.

This resolves an issue on lollipop devices where the ripple would be
clipped.
This commit is contained in:
OxygenCobalt
2022-07-03 16:23:53 -06:00
parent 9647b53f78
commit b1a8544b73
17 changed files with 78 additions and 78 deletions
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2022 Auxio Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.auxio.ui
import android.content.Context
import android.util.AttributeSet
import androidx.annotation.AttrRes
import androidx.core.view.updatePaddingRelative
import com.google.android.material.appbar.MaterialToolbar
import org.oxycblt.auxio.R
import org.oxycblt.auxio.util.getDimenSizeSafe
/** [MaterialToolbar] that automatically fixes padding in order to align with the M3 specs. */
class M3Toolbar : MaterialToolbar {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(
context: Context,
attrs: AttributeSet?,
@AttrRes defStyleAttr: Int
) : super(context, attrs, defStyleAttr)
init {
val tinySpacing = context.getDimenSizeSafe(R.dimen.spacing_tiny)
if (navigationIcon != null) {
updatePaddingRelative(start = tinySpacing)
}
if (menu != null) {
updatePaddingRelative(end = tinySpacing)
}
}
}