mirror of
https://github.com/apognu/otter
synced 2025-02-17 11:20:34 +01:00
Linting.
This commit is contained in:
parent
69d789c4f8
commit
0b14415e1e
@ -241,8 +241,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
track.favorite = favorites.contains(track.id)
|
||||
when (track.favorite) {
|
||||
true -> now_playing_details_favorite.setColorFilter(resources.getColor(R.color.colorFavorite))
|
||||
false -> now_playing_details_favorite.setColorFilter(resources.getColor(R.color.controlForeground))
|
||||
true -> now_playing_details_favorite.setColorFilter(getColor(R.color.colorFavorite))
|
||||
false -> now_playing_details_favorite.setColorFilter(getColor(R.color.controlForeground))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,12 +251,12 @@ class MainActivity : AppCompatActivity() {
|
||||
when (track.favorite) {
|
||||
true -> {
|
||||
favoriteRepository.deleteFavorite(track.id)
|
||||
now_playing_details_favorite.setColorFilter(resources.getColor(R.color.controlForeground))
|
||||
now_playing_details_favorite.setColorFilter(getColor(R.color.controlForeground))
|
||||
}
|
||||
|
||||
false -> {
|
||||
favoriteRepository.addFavorite(track.id)
|
||||
now_playing_details_favorite.setColorFilter(resources.getColor(R.color.colorFavorite))
|
||||
now_playing_details_favorite.setColorFilter(getColor(R.color.colorFavorite))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import com.github.apognu.otter.repositories.Repository
|
||||
import com.github.apognu.otter.repositories.SearchRepository
|
||||
import com.github.apognu.otter.utils.untilNetwork
|
||||
import kotlinx.android.synthetic.main.activity_search.*
|
||||
import java.util.*
|
||||
|
||||
class SearchActivity : AppCompatActivity() {
|
||||
private lateinit var adapter: TracksAdapter
|
||||
@ -35,7 +36,7 @@ class SearchActivity : AppCompatActivity() {
|
||||
search.setOnQueryTextListener(object : androidx.appcompat.widget.SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
query?.let {
|
||||
repository = SearchRepository(this@SearchActivity, it.toLowerCase())
|
||||
repository = SearchRepository(this@SearchActivity, it.toLowerCase(Locale.ROOT))
|
||||
|
||||
search_spinner.visibility = View.VISIBLE
|
||||
search_no_results.visibility = View.GONE
|
||||
|
@ -71,8 +71,8 @@ class FavoritesAdapter(private val context: Context?, private val favoriteListen
|
||||
|
||||
context?.let {
|
||||
when (favorite.track.favorite) {
|
||||
true -> holder.favorite.setColorFilter(context.resources.getColor(R.color.colorFavorite))
|
||||
false -> holder.favorite.setColorFilter(context.resources.getColor(R.color.colorSelected))
|
||||
true -> holder.favorite.setColorFilter(context.getColor(R.color.colorFavorite))
|
||||
false -> holder.favorite.setColorFilter(context.getColor(R.color.colorSelected))
|
||||
}
|
||||
|
||||
holder.favorite.setOnClickListener {
|
||||
|
@ -8,6 +8,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.apognu.otter.R
|
||||
import com.github.apognu.otter.fragments.FunkwhaleAdapter
|
||||
import com.github.apognu.otter.utils.Playlist
|
||||
import com.github.apognu.otter.utils.toDurationString
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.android.synthetic.main.row_playlist.view.*
|
||||
|
||||
@ -32,7 +33,7 @@ class PlaylistsAdapter(val context: Context?, private val listener: OnPlaylistCl
|
||||
val playlist = data[position]
|
||||
|
||||
holder.name.text = playlist.name
|
||||
holder.summary.text = "${playlist.tracks_count} tracks • ${playlist.duration} seconds"
|
||||
holder.summary.text = context?.getString(R.string.playlist_description, playlist.tracks_count, toDurationString(playlist.duration.toLong())) ?: ""
|
||||
|
||||
playlist.album_covers.shuffled().take(4).forEachIndexed { index, url ->
|
||||
val imageView = when (index) {
|
||||
|
@ -184,13 +184,10 @@ class TracksAdapter(private val context: Context?, private val favoriteListener:
|
||||
|
||||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
||||
context?.let {
|
||||
Build.VERSION_CODES.M.onApi(
|
||||
{ viewHolder?.itemView?.background = ColorDrawable(context.resources.getColor(R.color.colorSelected, null)) },
|
||||
{ viewHolder?.itemView?.background = ColorDrawable(context.resources.getColor(R.color.colorSelected)) })
|
||||
viewHolder?.itemView?.background = ColorDrawable(context.getColor(R.color.colorSelected))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.github.apognu.otter.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.github.apognu.otter.fragments.BrowseFragment
|
||||
import com.github.apognu.otter.repositories.Repository
|
||||
@ -10,6 +12,10 @@ import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
fun Context.getColor(colorRes: Int): Int {
|
||||
return ContextCompat.getColor(this, colorRes)
|
||||
}
|
||||
|
||||
inline fun <D> Channel<Repository.Response<D>>.await(context: CoroutineContext = Main, crossinline callback: (data: List<D>) -> Unit) {
|
||||
GlobalScope.launch(context) {
|
||||
this@await.receive().also {
|
||||
|
@ -24,3 +24,17 @@ fun normalizeUrl(url: String): String {
|
||||
URI("https", host, path, query, null)
|
||||
}.toString()
|
||||
}
|
||||
|
||||
fun toDurationString(seconds: Long): String {
|
||||
val days = (seconds / 86400)
|
||||
val hours = (seconds % 86400) / 3600
|
||||
val minutes = (seconds % 86400 % 3600) / 60
|
||||
|
||||
val ret = StringBuilder()
|
||||
|
||||
if (days > 0) ret.append("${days}d")
|
||||
if (hours > 0) ret.append(" ${hours}h")
|
||||
if (minutes > 0) ret.append(" ${minutes}m")
|
||||
|
||||
return ret.toString()
|
||||
}
|
@ -15,8 +15,10 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/title_oss_licences" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -25,8 +25,8 @@
|
||||
android:textColor="@android:color/white" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:id="@+id/hostname_field"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
@ -46,8 +46,8 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:id="@+id/username_field"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
@ -67,8 +67,8 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:id="@+id/password_field"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
@ -93,6 +93,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/colorAccent"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/login_submit" />
|
||||
android:text="@string/login_submit"
|
||||
android:textColor="@android:color/white" />
|
||||
</LinearLayout>
|
||||
|
@ -35,8 +35,9 @@
|
||||
android:id="@+id/search_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:drawableTop="@drawable/ottericon"
|
||||
android:drawablePadding="16dp"
|
||||
android:drawableTint="#525252"
|
||||
@ -48,8 +49,9 @@
|
||||
android:id="@+id/search_no_results"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:drawableTop="@drawable/ottericon"
|
||||
android:drawablePadding="16dp"
|
||||
android:drawableTint="#525252"
|
||||
|
@ -9,8 +9,10 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/title_settings" />
|
||||
|
||||
<FrameLayout
|
||||
|
@ -44,7 +44,7 @@
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:contentDescription="@string/alt_album_cover"
|
||||
android:contentDescription="@string/alt_artist_art"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -58,34 +58,29 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/albums"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/albums"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/artist"
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
tools:text="Muse" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/artist"
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
tools:text="Muse" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -25,8 +25,10 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/albums" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/swiper"
|
||||
style="@style/AppTheme.Fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
style="@style/AppTheme.Fragment">
|
||||
android:clipToPadding="false">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scroller"
|
||||
@ -28,8 +27,10 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/artists" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -27,8 +27,9 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/favorites" />
|
||||
|
||||
|
@ -27,8 +27,10 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/playlists" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -4,7 +4,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
@ -29,7 +30,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginVertical="64dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:drawableTop="@drawable/ottericon"
|
||||
android:drawablePadding="16dp"
|
||||
android:drawableTint="#525252"
|
||||
|
@ -159,8 +159,9 @@
|
||||
android:id="@+id/artist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="14sp"
|
||||
tools:text="Muse" />
|
||||
@ -170,7 +171,8 @@
|
||||
style="@style/AppTheme.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
tools:text="Absolution" />
|
||||
|
||||
@ -182,7 +184,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/playback_queue"
|
||||
app:icon="@drawable/add" />
|
||||
|
||||
|
@ -126,7 +126,8 @@
|
||||
android:id="@+id/now_playing_details_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="32dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="32dp">
|
||||
|
||||
|
@ -3,11 +3,13 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="12dp"
|
||||
android:transitionGroup="true"
|
||||
tools:showIn="@layout/fragment_albums">
|
||||
|
||||
|
@ -3,11 +3,13 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="12dp"
|
||||
android:transitionGroup="true"
|
||||
tools:showIn="@layout/fragment_artists">
|
||||
|
||||
|
@ -4,10 +4,12 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="12dp"
|
||||
android:transitionGroup="true"
|
||||
tools:showIn="@layout/fragment_playlists">
|
||||
|
||||
|
@ -6,8 +6,10 @@
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="12dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:transitionGroup="true"
|
||||
tools:showIn="@layout/fragment_tracks">
|
||||
|
||||
@ -67,6 +69,7 @@
|
||||
style="@style/IconButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/alt_more_options"
|
||||
android:src="@drawable/more" />
|
||||
|
||||
</LinearLayout>
|
@ -71,7 +71,10 @@
|
||||
<string name="alt_app_logo">Logo de l\'application</string>
|
||||
<string name="alt_artist_art">Image de l\'artiste</string>
|
||||
<string name="alt_album_cover">Couverture de l\'album</string>
|
||||
<string name="alt_more_options">Plus d\'options</string>
|
||||
|
||||
<string name="logout_title">Déconnexion</string>
|
||||
<string name="logout_content">Etes-vous certains de vouloir vous déconnecter de votre instance Funkwhale ?</string>
|
||||
|
||||
<string name="playlist_description">%d tracks • %s"</string>
|
||||
</resources>
|
||||
|
@ -71,7 +71,10 @@
|
||||
<string name="alt_app_logo">Application logo</string>
|
||||
<string name="alt_artist_art">Artist art</string>
|
||||
<string name="alt_album_cover">Album cover</string>
|
||||
<string name="alt_more_options">More options</string>
|
||||
|
||||
<string name="logout_title">Sign out</string>
|
||||
<string name="logout_content">Are you sure you want to sign out of your Funkwhale instance?</string>
|
||||
|
||||
<string name="playlist_description">%d tracks • %s"</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user