Minor style enhancement.

This commit is contained in:
Antoine POPINEAU 2020-06-14 00:42:45 +02:00
parent dcc6da655f
commit fc1419c2fb
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
11 changed files with 43 additions and 26 deletions

View File

@ -33,6 +33,7 @@ import com.google.android.exoplayer2.Player
import com.google.gson.Gson
import com.preference.PowerPreference
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.partial_now_playing.*
import kotlinx.coroutines.Dispatchers.IO
@ -329,6 +330,7 @@ class MainActivity : AppCompatActivity() {
.maybeLoad(maybeNormalizeUrl(track.album.cover.original))
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0))
.into(now_playing_details_cover)
}

View File

@ -8,8 +8,10 @@ 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.log
import com.github.apognu.otter.utils.toDurationString
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.row_playlist.view.*
class PlaylistsAdapter(val context: Context?, private val listener: OnPlaylistClickListener) : FunkwhaleAdapter<Playlist, PlaylistsAdapter.ViewHolder>() {
@ -44,8 +46,17 @@ class PlaylistsAdapter(val context: Context?, private val listener: OnPlaylistCl
else -> holder.cover_top_left
}
val corner = when (index) {
0 -> RoundedCornersTransformation.CornerType.TOP_LEFT
1 -> RoundedCornersTransformation.CornerType.TOP_RIGHT
2 -> RoundedCornersTransformation.CornerType.BOTTOM_LEFT
3 -> RoundedCornersTransformation.CornerType.BOTTOM_RIGHT
else -> RoundedCornersTransformation.CornerType.TOP_LEFT
}
Picasso.get()
.load(url)
.transform(RoundedCornersTransformation(32, 0, corner))
.into(imageView)
}
}

View File

@ -23,6 +23,7 @@ import com.github.apognu.otter.repositories.Repository
import com.github.apognu.otter.utils.*
import com.github.apognu.otter.views.LoadingFlotingActionButton
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.fragment_albums.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO
@ -112,33 +113,10 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
.noFade()
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0))
.into(cover)
}
cover_background?.let { background ->
activity?.let { activity ->
GlobalScope.launch(IO) {
val width = DisplayMetrics().apply {
activity.windowManager.defaultDisplay.getMetrics(this)
}.widthPixels
val backgroundCover = Picasso.get()
.maybeLoad(maybeNormalizeUrl(artistArt))
.get()
.run { Bitmap.createScaledBitmap(this, width, width, false) }
.run { Bitmap.createBitmap(this, 0, 0, width, background.height).toDrawable(resources) }
.apply {
alpha = 20
gravity = Gravity.CENTER
}
withContext(Dispatchers.Main) {
background.background = backgroundCover
}
}
}
}
artist.text = artistName
play.setOnClickListener {

View File

@ -10,6 +10,7 @@ import com.github.apognu.otter.repositories.FavoritesRepository
import com.github.apognu.otter.repositories.PlaylistTracksRepository
import com.github.apognu.otter.utils.*
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.fragment_tracks.*
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.GlobalScope
@ -100,10 +101,21 @@ class PlaylistTracksFragment : FunkwhaleFragment<PlaylistTrack, PlaylistTracksAd
else -> cover_top_left
}
val corner = when (index) {
0 -> RoundedCornersTransformation.CornerType.TOP_LEFT
1 -> RoundedCornersTransformation.CornerType.TOP_RIGHT
2 -> RoundedCornersTransformation.CornerType.BOTTOM_LEFT
3 -> RoundedCornersTransformation.CornerType.BOTTOM_RIGHT
else -> RoundedCornersTransformation.CornerType.TOP_LEFT
}
imageView?.let { view ->
GlobalScope.launch(Main) {
Picasso.get()
.maybeLoad(maybeNormalizeUrl(url))
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0, corner))
.into(view)
}
}

View File

@ -10,6 +10,7 @@ import com.github.apognu.otter.repositories.FavoritesRepository
import com.github.apognu.otter.repositories.TracksRepository
import com.github.apognu.otter.utils.*
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.fragment_tracks.*
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.GlobalScope
@ -65,6 +66,7 @@ class TracksFragment : FunkwhaleFragment<Track, TracksAdapter>() {
.noFade()
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0))
.into(cover)
artist.text = albumArtist

View File

@ -32,7 +32,6 @@
android:elevation="1dp">
<LinearLayout
android:id="@+id/cover_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
@ -47,6 +46,7 @@
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="8dp"
android:contentDescription="@string/alt_artist_art"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -41,6 +41,7 @@
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="8dp"
android:contentDescription="@string/alt_album_cover"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -44,6 +44,7 @@
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_margin="8dp"
android:contentDescription="@string/alt_artist_art"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -43,6 +43,7 @@
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_margin="8dp"
android:contentDescription="@string/alt_album_cover"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
@ -57,6 +58,7 @@
android:id="@+id/covers"
android:layout_width="match_parent"
android:layout_height="250dp"
android:padding="8dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -107,7 +107,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
android:layout_weight="1"
android:padding="8dp">
<com.github.apognu.otter.views.SquareImageView
android:id="@+id/now_playing_details_cover"

View File

@ -13,6 +13,9 @@
<item name="preferenceTheme">@style/AppTheme.Preference</item>
<item name="colorError">@color/colorError</item>
<item name="buttonBarNegativeButtonStyle">@style/AppTheme.DialogButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/AppTheme.DialogButtonStyle</item>
</style>
<style name="AppTheme.Fragment"></style>
@ -86,4 +89,8 @@
<item name="android:textSize">16sp</item>
</style>
<style name="AppTheme.DialogButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/controlColor</item>
</style>
</resources>