all: view cleanup

Do even more cleanup regarding views.
This commit is contained in:
OxygenCobalt 2022-03-13 18:56:24 -06:00
parent 33da09a08a
commit 2ff7d93263
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
48 changed files with 122 additions and 98 deletions

View file

@ -2,6 +2,9 @@
## dev [v2.2.3, v2.3.0, or v3.0.0]
#### What's Fixed
- Fixed incorrect ellipsizing on song items
#### Dev/Meta
- Switched to spotless and ktfmt instead of ktlint

View file

@ -38,7 +38,9 @@ import org.oxycblt.auxio.util.replaceSystemBarInsetsCompat
import org.oxycblt.auxio.util.systemBarInsetsCompat
/**
* The single [AppCompatActivity] for Auxio. TODO: Add a new view for crashes with a stack trace
* The single [AppCompatActivity] for Auxio.
*
* TODO: Add a new view for crashes with a stack trace
* TODO: Custom language support TODO: Rework menus [perhaps add multi-select]
*/
class MainActivity : AppCompatActivity() {

View file

@ -40,8 +40,9 @@ import org.oxycblt.auxio.util.logW
/**
* A wrapper around the home fragment that shows the playback fragment and controls the more
* high-level navigation features.
* @author OxygenCobalt TODO: Add a new view with a stack trace whenever the music loading process
* fails.
* @author OxygenCobalt
*
* TODO: Add a new view with a stack trace whenever the music loading process fails.
*/
class MainFragment : Fragment() {
private val playbackModel: PlaybackViewModel by activityViewModels()

View file

@ -53,8 +53,10 @@ import org.oxycblt.auxio.util.logTraceOrThrow
/**
* The main "Launching Point" fragment of Auxio, allowing navigation to the detail views for each
* respective item.
* @author OxygenCobalt TODO: Make tabs invisible when there is only one TODO: Add duration and song
* count sorts
* @author OxygenCobalt
*
* TODO: Make tabs invisible when there is only one
* TODO: Add duration and song count sorts
*/
class HomeFragment : Fragment() {
private val playbackModel: PlaybackViewModel by activityViewModels()

View file

@ -35,13 +35,13 @@ import androidx.annotation.AttrRes
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.math.MathUtils
import androidx.core.view.isInvisible
import androidx.core.view.updatePadding
import androidx.core.widget.TextViewCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlin.math.abs
import org.oxycblt.auxio.R
import org.oxycblt.auxio.ui.EdgeRecyclerView
import org.oxycblt.auxio.util.canScroll
import org.oxycblt.auxio.util.getAttrColorSafe
import org.oxycblt.auxio.util.getDimenOffsetSafe
@ -76,7 +76,7 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat
class FastScrollRecyclerView
@JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
RecyclerView(context, attrs, defStyleAttr) {
EdgeRecyclerView(context, attrs, defStyleAttr) {
/** Callback to provide a string to be shown on the popup when an item is passed */
var popupProvider: ((Int) -> String)? = null
@ -118,7 +118,6 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
}
private val initialPadding = Rect(paddingLeft, paddingTop, paddingRight, paddingBottom)
private val scrollerPadding = Rect(0, 0, 0, 0)
init {
@ -316,16 +315,9 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
override fun onApplyWindowInsets(insets: WindowInsets): WindowInsets {
super.onApplyWindowInsets(insets)
val bars = insets.systemBarInsetsCompat
updatePadding(
initialPadding.left,
initialPadding.top,
initialPadding.right,
initialPadding.bottom + bars.bottom)
scrollerPadding.bottom = bars.bottom
return insets
}

View file

@ -56,7 +56,6 @@ abstract class HomeListFragment : Fragment() {
onDragListener = { dragging -> homeModel.updateFastScrolling(dragging) }
}
// Make sure that this RecyclerView has data before startup
homeData.observe(viewLifecycleOwner) { data -> homeAdapter.updateData(data) }
}

View file

@ -23,8 +23,10 @@ import androidx.recyclerview.widget.RecyclerView
/**
* A simple [ItemTouchHelper.Callback] that handles dragging items in the tab customization menu.
* Unlike QueueAdapter's ItemTouchHelper, this one is bare and simple. TODO: Consider unifying the
* shared behavior between this and QueueDragCallback into a single class.
* Unlike QueueAdapter's ItemTouchHelper, this one is bare and simple.
*
* TODO: Consider unifying the
* shared behavior between this and QueueDragCallback into a single class.
*/
class TabDragCallback(private val getTabs: () -> Array<Tab>) : ItemTouchHelper.Callback() {
private val tabs: Array<Tab>

View file

@ -33,8 +33,10 @@ sealed class Item {
}
/**
* [Item] variant that represents a music item. TODO: Make name the actual display name and move raw
* names (including file names) to a new field called rawName.
* [Item] variant that represents a music item.
*
* TODO: Make name the actual display name and move raw names (including file names) to a
* new field called rawName.
*/
sealed class Music : Item() {
/** The raw name of this item. */

View file

@ -32,8 +32,9 @@ import org.oxycblt.auxio.util.logE
/**
* The main storage for music items. Getting an instance of this object is more complicated as it
* loads asynchronously. See the companion object for more. TODO: Add automatic rescanning [major
* change]
* loads asynchronously. See the companion object for more.
*
* TODO: Add automatic rescanning [major change]
* @author OxygenCobalt
*/
class MusicStore private constructor() {
@ -111,7 +112,9 @@ class MusicStore private constructor() {
/**
* A response that [MusicStore] returns when loading music. And before you ask, yes, I do like
* rust. TODO: Add the exception to the "FAILED" ErrorKind
* rust.
*
* TODO: Add the exception to the "FAILED" ErrorKind
*/
sealed class Response {
class Ok(val musicStore: MusicStore) : Response()

View file

@ -30,8 +30,10 @@ import org.oxycblt.auxio.util.logD
/**
* ViewModel that acts as a wrapper around [ExcludedDatabase], allowing for the addition/removal of
* paths. Use [Factory] to instantiate this. TODO: Unify with MusicViewModel
* paths. Use [Factory] to instantiate this.
* @author OxygenCobalt
*
* TODO: Unify with MusicViewModel
*/
class ExcludedViewModel(private val excludedDatabase: ExcludedDatabase) : ViewModel() {
private val mPaths = MutableLiveData(mutableListOf<String>())

View file

@ -37,7 +37,9 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat
/**
* A [Fragment] that displays more information about the song, along with more media controls.
* Instantiation is done by the navigation component, **do not instantiate this fragment manually.**
* @author OxygenCobalt TODO: Handle RTL correctly in the playback buttons
* @author OxygenCobalt
*
* TODO: Handle RTL correctly in the playback buttons
*/
class PlaybackFragment : Fragment() {
private val playbackModel: PlaybackViewModel by activityViewModels()

View file

@ -64,8 +64,9 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat
* state and view magic. I tried my best to document it, but it's probably not the most friendly or
* extendable. You have been warned.
*
* @author OxygenCobalt (With help from Umano and Hai Zhang) TODO: Find a better way to handle
* PlaybackFragment in general (navigation, creation)
* @author OxygenCobalt (With help from Umano and Hai Zhang)
*
* TODO: Find a better way to handle PlaybackFragment in general (navigation, creation)
*/
class PlaybackLayout
@JvmOverloads

View file

@ -34,8 +34,9 @@ import org.oxycblt.auxio.util.stateList
/**
* A custom view that bundles together a seekbar with a current duration and a total duration. The
* sub-views are specifically laid out so that the seekbar has an adequate touch height while still
* not having gobs of whitespace everywhere. TODO: Add smooth seeking [i.e seeking in sub-second
* values]
* not having gobs of whitespace everywhere.
*
* TODO: Add smooth seeking [i.e seeking in sub-second values]
* @author OxygenCobalt
*/
@SuppressLint("RestrictedApi")

View file

@ -61,7 +61,8 @@ class AudioReactor(context: Context, private val callback: (Float) -> Unit) :
private var pauseWasTransient = false
// It's good to keep the volume and the ducking multiplier separate so that we can
// It's good to keep the volume and the ducking multiplier separate so that we don't
// lose information
private var multiplier = 1f
set(value) {
field = value
@ -87,8 +88,11 @@ class AudioReactor(context: Context, private val callback: (Float) -> Unit) :
/**
* Updates the rough volume adjustment for [Metadata] with ReplayGain tags. This is based off
* Vanilla Music's implementation. TODO: Add ReplayGain pre-amp TODO: Add positive ReplayGain
* values
* Vanilla Music's implementation.
*
* TODO: Add ReplayGain pre-amp
*
* TODO: Add positive ReplayGain
*/
fun applyReplayGain(metadata: Metadata?) {
if (metadata == null) {

View file

@ -498,9 +498,10 @@ class PlaybackService :
}
/**
* Pause from a headset plug. TODO: Find a way to centralize this stuff into a single
* BroadcastReciever instead of the weird disjointed arrangement between MediaSession and
* this.
* Pause from a headset plug.
*
* TODO: Find a way to centralize this stuff into a single BroadcastReceiver instead of
* the weird disjointed arrangement between MediaSession and this.
*/
private fun pauseFromPlug() {
if (playbackManager.song != null) {

View file

@ -54,8 +54,10 @@ fun Fragment.newMenu(anchor: View, data: Item, flag: Int = ActionMenu.FLAG_NONE)
* @param flag Any extra flags to accompany the data. See [FLAG_NONE], [FLAG_IN_ALBUM],
* [FLAG_IN_ARTIST], [FLAG_IN_GENRE] for more details.
* @throws IllegalStateException When there is no menu for this specific datatype/flag
* @author OxygenCobalt TODO: Stop scrolling when a menu is open TODO: Prevent duplicate menus from
* showing up TODO: Maybe replace this with a bottom sheet?
* @author OxygenCobalt
*
* TODO: Stop scrolling when a menu is open TODO: Prevent duplicate menus from showing up
* TODO: Maybe replace this with a bottom sheet?
*/
class ActionMenu(
activity: AppCompatActivity,

View file

@ -18,6 +18,7 @@
package org.oxycblt.auxio.ui
import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.view.WindowInsets
import androidx.annotation.AttrRes
@ -26,12 +27,25 @@ import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.util.systemBarInsetsCompat
/** A [RecyclerView] that automatically applies insets to itself. */
class EdgeRecyclerView
open class EdgeRecyclerView
@JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
RecyclerView(context, attrs, defStyleAttr) {
private val initialPadding = Rect(paddingLeft, paddingTop, paddingRight, paddingBottom)
init {
// Prevent children from being clipped by window insets
clipToPadding = false
}
override fun onApplyWindowInsets(insets: WindowInsets): WindowInsets {
updatePadding(bottom = insets.systemBarInsetsCompat.bottom)
updatePadding(
initialPadding.left,
initialPadding.top,
initialPadding.right,
initialPadding.bottom + insets.systemBarInsetsCompat.bottom)
return insets
}
}

View file

@ -32,9 +32,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
abstract class LifecycleDialog : AppCompatDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = MaterialAlertDialogBuilder(requireActivity(), theme)
onConfigDialog(builder)
return builder.create()
}

View file

@ -68,7 +68,6 @@ abstract class BaseViewHolder<T : Item>(
doOnLongClick?.let { onLongClick ->
binding.root.setOnLongClickListener { view ->
onLongClick(view, data)
true
}
}

View file

@ -5,7 +5,7 @@
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorPrimary">
<path
android:fillColor="@android:color/white"
android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z" />
</vector>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:height="4dp"
<size
android:height="4dp"
android:width="4dp" />
<solid android:color="?attr/colorPrimary" />
</shape>

View file

@ -23,8 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playback_toolbar"

View file

@ -23,8 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playback_toolbar"

View file

@ -23,8 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playback_toolbar"

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<org.oxycblt.auxio.home.fastscroll.FastScrollRecyclerView
android:id="@+id/home_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="@dimen/recycler_fab_space_large"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_artist" />
</layout>

View file

@ -23,8 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playback_toolbar"

View file

@ -29,7 +29,6 @@
android:id="@+id/detail_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_detail" />

View file

@ -5,10 +5,9 @@
<org.oxycblt.auxio.home.fastscroll.FastScrollRecyclerView
android:id="@+id/home_recycler"
style="@style/Widget.Auxio.RecyclerView.WithAdaptiveFab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="@dimen/recycler_fab_space_normal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_artist" />

View file

@ -22,8 +22,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playback_toolbar"

View file

@ -30,7 +30,6 @@
android:id="@+id/queue_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="ifContentScrolls"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

View file

@ -50,7 +50,6 @@
android:id="@+id/search_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_song" />

View file

@ -30,7 +30,6 @@
android:name="org.oxycblt.auxio.settings.SettingsListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
</org.oxycblt.auxio.ui.EdgeCoordinatorLayout>

View file

@ -21,7 +21,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"
tools:src="@drawable/ic_album" />
<TextView
@ -31,6 +30,7 @@
android:layout_height="wrap_content"
android:text="@{song.name}"
app:layout_constraintBottom_toTopOf="@+id/song_info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
@ -43,8 +43,10 @@
android:layout_height="wrap_content"
app:songInfo="@{song}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
app:layout_constraintTop_toBottomOf="@+id/song_name"
tools:text="Artist / Album" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -15,7 +15,8 @@
android:title="@string/lbl_sort_year" />
</group>
<group android:checkableBehavior="all">
<item android:id="@+id/option_sort_asc"
<item
android:id="@+id/option_sort_asc"
android:title="@string/lbl_sort_asc" />
</group>
</menu>

View file

@ -29,7 +29,8 @@
android:title="@string/lbl_sort_year" />
</group>
<group android:checkableBehavior="all">
<item android:id="@+id/option_sort_asc"
<item
android:id="@+id/option_sort_asc"
android:title="@string/lbl_sort_asc" />
</group>
</menu>

View file

@ -30,7 +30,7 @@
<string name="lbl_play_genre">"Přehrát z žánru"</string>
<string name="lbl_playback">"Nyní hraje"</string>
<string name="lbl_queue">"Fronta"</string>
<string name="lbl_play_next">Další skladba</string>
<string name="lbl_play_next">Další skladba</string>
<string name="lbl_queue_add">"Přidat do fronty"</string>
<string name="lbl_queue_added">"Přidáno do fronty"</string>
<string name="lbl_go_artist">"Jít na umělce"</string>

View file

@ -83,7 +83,7 @@
<string name="set_audio">Звук</string>
<string name="set_focus">Аудио-фокус</string>
<string name="set_focus_desc">Ставить на паузу при звонках</string>
<string name="set_replay_gain">ReplayGain (экспериментально)</string>
<string name="set_replay_gain">ReplayGain (экспериментально)</string>
<string name="set_off">Выкл.</string>
<string name="set_replay_gain_track">По треку</string>
<string name="set_replay_gain_album">По альбому</string>

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Auxio.RecyclerView.WithAdaptiveFab" parent="">
<item name="android:paddingBottom">@dimen/recycler_fab_space_large</item>
</style>
<style name="Widget.Auxio.FloatingActionButton.Adaptive" parent="Widget.Material3.FloatingActionButton.Large.Primary">
<item name="fabSize">normal</item>
</style>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Auxio.Button.AppWidget.V31" parent="Widget.AppCompat.Button.Borderless">
<style name="Widget.Auxio.Button.AppWidget.V31" parent="Widget.AppCompat.Button.Borderless">
<item name="android:background">@drawable/ui_large_unbounded_ripple</item>
</style>
</resources>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Widget" parent="@android:style/Theme.DeviceDefault.DayNight">
<style name="Theme.Widget" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="colorSurface">@color/widget_surface</item>
<item name="colorPrimary">?android:attr/colorAccent</item>
<item name="colorSecondary">?android:attr/colorAccent</item>

View file

@ -9,8 +9,10 @@
<style name="Theme.Auxio.Dialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:checkedTextViewStyle">@style/Widget.Auxio.Dialog.CheckedTextView</item>
<item name="materialAlertDialogTitleTextStyle">@style/Widget.Auxio.Dialog.TextView</item>
<item name="buttonBarPositiveButtonStyle">@style/Widget.Material3.Button.TextButton.Dialog</item>
<item name="buttonBarNegativeButtonStyle">@style/Widget.Material3.Button.TextButton.Dialog</item>
<item name="buttonBarPositiveButtonStyle">@style/Widget.Material3.Button.TextButton.Dialog
</item>
<item name="buttonBarNegativeButtonStyle">@style/Widget.Material3.Button.TextButton.Dialog
</item>
<item name="buttonBarNeutralButtonStyle">@style/Widget.Auxio.Dialog.Button.Flush</item>
</style>

View file

@ -44,7 +44,7 @@
<style name="Widget.Auxio.Image.MidHuge" parent="">
<item name="android:layout_width">@dimen/size_cover_mid_huge</item>
<item name="android:layout_height">@dimen/size_cover_mid_huge</item>
<item name="cornerRadius">@dimen/size_corners_large</item>
<item name="cornerRadius">@dimen/size_corners_large</item>
</style>
<style name="Widget.Auxio.Image.Huge" parent="">
@ -69,6 +69,10 @@
<item name="android:focusable">true</item>
</style>
<style name="Widget.Auxio.RecyclerView.WithAdaptiveFab" parent="">
<item name="android:paddingBottom">@dimen/recycler_fab_space_normal</item>
</style>
<style name="ThemeOverlay.Accent" parent="">
<item name="colorOnPrimary">?attr/colorSurface</item>
</style>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Auxio.Black" parent="Theme.Auxio.App">
<style name="Theme.Auxio.Black" parent="Theme.Auxio.App">
<item name="colorSurface">@android:color/black</item>
</style>