Browse Source

Minor style enhancement.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
fc1419c2fb
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 2
      app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt
  2. 11
      app/src/main/java/com/github/apognu/otter/adapters/PlaylistsAdapter.kt
  3. 26
      app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt
  4. 12
      app/src/main/java/com/github/apognu/otter/fragments/PlaylistTracksFragment.kt
  5. 2
      app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt
  6. 2
      app/src/main/res/layout-land/fragment_albums.xml
  7. 1
      app/src/main/res/layout-land/fragment_tracks.xml
  8. 1
      app/src/main/res/layout/fragment_albums.xml
  9. 2
      app/src/main/res/layout/fragment_tracks.xml
  10. 3
      app/src/main/res/layout/partial_now_playing.xml
  11. 7
      app/src/main/res/values/styles.xml

2
app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt

@ -33,6 +33,7 @@ import com.google.android.exoplayer2.Player @@ -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() { @@ -329,6 +330,7 @@ class MainActivity : AppCompatActivity() {
.maybeLoad(maybeNormalizeUrl(track.album.cover.original))
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0))
.into(now_playing_details_cover)
}

11
app/src/main/java/com/github/apognu/otter/adapters/PlaylistsAdapter.kt

@ -8,8 +8,10 @@ import androidx.recyclerview.widget.RecyclerView @@ -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 @@ -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)
}
}

26
app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt

@ -23,6 +23,7 @@ import com.github.apognu.otter.repositories.Repository @@ -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>() { @@ -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 {

12
app/src/main/java/com/github/apognu/otter/fragments/PlaylistTracksFragment.kt

@ -10,6 +10,7 @@ import com.github.apognu.otter.repositories.FavoritesRepository @@ -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 @@ -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)
}
}

2
app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt

@ -10,6 +10,7 @@ import com.github.apognu.otter.repositories.FavoritesRepository @@ -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>() { @@ -65,6 +66,7 @@ class TracksFragment : FunkwhaleFragment<Track, TracksAdapter>() {
.noFade()
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0))
.into(cover)
artist.text = albumArtist

2
app/src/main/res/layout-land/fragment_albums.xml

@ -32,7 +32,6 @@ @@ -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 @@ @@ -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"

1
app/src/main/res/layout-land/fragment_tracks.xml

@ -41,6 +41,7 @@ @@ -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"

1
app/src/main/res/layout/fragment_albums.xml

@ -44,6 +44,7 @@ @@ -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"

2
app/src/main/res/layout/fragment_tracks.xml

@ -43,6 +43,7 @@ @@ -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 @@ @@ -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"

3
app/src/main/res/layout/partial_now_playing.xml

@ -107,7 +107,8 @@ @@ -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"

7
app/src/main/res/values/styles.xml

@ -13,6 +13,9 @@ @@ -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 @@ @@ -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>

Loading…
Cancel
Save