Fix plurals

main
h4h13 2020-04-26 16:29:35 +05:30
parent 3ae88a4e5d
commit 0c9525834e
8 changed files with 80 additions and 133 deletions

View File

@ -24,7 +24,7 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 417 versionCode 418
versionName '3.5.100' versionName '3.5.100'
multiDexEnabled true multiDexEnabled true

View File

@ -176,6 +176,14 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
this.album = album this.album = album
albumTitle.text = album.title albumTitle.text = album.title
val songText =
resources.getQuantityString(
R.plurals.albumSongs,
album.songCount,
album.songCount
)
songTitle.text = songText
if (MusicUtil.getYearString(album.year) == "-") { if (MusicUtil.getYearString(album.year) == "-") {
albumText.text = String.format( albumText.text = String.format(
"%s • %s", "%s • %s",
@ -193,7 +201,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
loadAlbumCover() loadAlbumCover()
simpleSongAdapter.swapDataSet(album.songs) simpleSongAdapter.swapDataSet(album.songs)
albumDetailsPresenter.loadMore(album.artistId) albumDetailsPresenter.loadMore(album.artistId)
albumDetailsPresenter.aboutAlbum(album.artistName!!, album.title!!) albumDetailsPresenter.aboutAlbum(album.artistName ?: "-", album.title ?: "-")
} }
override fun moreAlbums(albums: List<Album>) { override fun moreAlbums(albums: List<Album>) {
@ -216,7 +224,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
if (lastFmAlbum.album.wiki != null) { if (lastFmAlbum.album.wiki != null) {
aboutAlbumText.show() aboutAlbumText.show()
aboutAlbumTitle.show() aboutAlbumTitle.show()
aboutAlbumTitle.text = String.format(getString(R.string.about_album_label), lastFmAlbum.album.name) aboutAlbumTitle.text =
String.format(getString(R.string.about_album_label), lastFmAlbum.album.name)
aboutAlbumText.text = lastFmAlbum.album.wiki.content aboutAlbumText.text = lastFmAlbum.album.wiki.content
} }
if (lastFmAlbum.album.listeners.isNotEmpty()) { if (lastFmAlbum.album.listeners.isNotEmpty()) {

View File

@ -2,9 +2,7 @@ package code.name.monkey.retromusic.activities
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Html
import android.text.Spanned import android.text.Spanned
import android.transition.Slide import android.transition.Slide
import android.view.Menu import android.view.Menu
@ -188,7 +186,20 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
MusicUtil.getArtistInfoString(this, artist), MusicUtil.getArtistInfoString(this, artist),
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(artist.songs)) MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(artist.songs))
) )
val songText =
resources.getQuantityString(
R.plurals.albumSongs,
artist.songCount,
artist.songCount
)
val albumText =
resources.getQuantityString(
R.plurals.albums,
artist.songCount,
artist.songCount
)
songTitle.text = songText
albumTitle.text =albumText
songAdapter.swapDataSet(artist.songs) songAdapter.swapDataSet(artist.songs)
albumAdapter.swapDataSet(artist.albums!!) albumAdapter.swapDataSet(artist.albums!!)
} }

View File

@ -51,21 +51,20 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity; import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity;
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog; import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.fragments.albums.AlbumsFragment; import code.name.monkey.retromusic.fragments.albums.AlbumsFragment;
import code.name.monkey.retromusic.fragments.artists.ArtistsFragment; import code.name.monkey.retromusic.fragments.artists.ArtistsFragment;
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.fragments.genres.GenresFragment;
import code.name.monkey.retromusic.fragments.home.BannerHomeFragment; import code.name.monkey.retromusic.fragments.home.BannerHomeFragment;
import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment; import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment;
import code.name.monkey.retromusic.fragments.genres.GenresFragment;
import code.name.monkey.retromusic.fragments.queue.PlayingQueueFragment;
import code.name.monkey.retromusic.fragments.playlists.PlaylistsFragment; import code.name.monkey.retromusic.fragments.playlists.PlaylistsFragment;
import code.name.monkey.retromusic.fragments.queue.PlayingQueueFragment;
import code.name.monkey.retromusic.fragments.songs.SongsFragment; import code.name.monkey.retromusic.fragments.songs.SongsFragment;
import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.helper.SearchQueryHelper; import code.name.monkey.retromusic.helper.SearchQueryHelper;
@ -765,16 +764,9 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
@Override @Override
public void run() { public void run() {
TransitionManager.beginDelayedTransition(mToolbar); TransitionManager.beginDelayedTransition(mToolbar);
Log.i(TAG, "run: " + Thread.currentThread().getName());
mAppTitle.setVisibility(View.GONE); mAppTitle.setVisibility(View.GONE);
setTitle(R.string.action_search); setTitle(R.string.action_search);
} }
}, 3000); }, 3000);
Locale[] locales = Locale.getAvailableLocales();
for (Locale l : locales) {
Log.d(TAG, "setupToolbar: " + l.toLanguageTag());
}
} }
} }

View File

@ -2,13 +2,11 @@ package code.name.monkey.retromusic.adapter.song
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.PopupMenu
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil import com.google.android.material.button.MaterialButton
import com.google.android.material.textview.MaterialTextView
class ShuffleButtonSongAdapter( class ShuffleButtonSongAdapter(
activity: AppCompatActivity, activity: AppCompatActivity,
@ -17,75 +15,38 @@ class ShuffleButtonSongAdapter(
cabHolder: CabHolder? cabHolder: CabHolder?
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, cabHolder) { ) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, cabHolder) {
override fun createViewHolder(view: View): ViewHolder { override fun createViewHolder(view: View): SongAdapter.ViewHolder {
return ViewHolder(view) return ViewHolder(view)
} }
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) { override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
if (holder.itemViewType == OFFSET_ITEM) { if (holder.itemViewType == OFFSET_ITEM) {
val viewHolder = holder as ViewHolder val viewHolder = holder as ViewHolder
val info = viewHolder.playAction?.let {
activity.resources.getQuantityString( it.setOnClickListener {
R.plurals.numSongs, MusicPlayerRemote.openQueue(dataSet, 0, true)
dataSet.size, }
dataSet.size }
) viewHolder.shuffleAction?.let {
viewHolder.info?.text = info it.setOnClickListener {
viewHolder.shuffleAction?.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue(dataSet, true) MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
} }
showChangeLayout(viewHolder) }
showSortMenu(viewHolder)
} else { } else {
super.onBindViewHolder(holder, position - 1) super.onBindViewHolder(holder, position - 1)
} }
} }
private fun showChangeLayout(viewHolder: ViewHolder) {
viewHolder.changeLayoutType?.setOnClickListener {
val popupMenu = PopupMenu(activity, viewHolder.changeLayoutType)
popupMenu.inflate(R.menu.menu_layout_types)
popupMenu.setOnMenuItemClickListener {
when (it.itemId) {
R.layout.item_card ->
popupMenu.menu.findItem(R.id.action_layout_card).isChecked = true
R.layout.item_grid ->
popupMenu.menu.findItem(R.id.action_layout_normal).isChecked = true
R.layout.item_card_color ->
popupMenu.menu.findItem(R.id.action_layout_colored_card).isChecked = true
R.layout.item_grid_circle ->
popupMenu.menu.findItem(R.id.action_layout_circular).isChecked = true
R.layout.image ->
popupMenu.menu.findItem(R.id.action_layout_image).isChecked = true
R.layout.item_image_gradient ->
popupMenu.menu.findItem(R.id.action_layout_gradient_image).isChecked = true
}
PreferenceUtil.getInstance(activity).songGridStyle = it.itemId
true
}
popupMenu.show()
popupMenu.menu
.findItem(PreferenceUtil.getInstance(activity).songGridStyle).isChecked = true
}
}
private fun showSortMenu(viewHolder: ViewHolder) {
viewHolder.sortOrder?.setOnClickListener {
val popupMenu = PopupMenu(activity, viewHolder.sortOrder)
popupMenu.inflate(R.menu.menu_song_sort_order)
popupMenu.show()
}
}
inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) { inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) {
val sortOrder: View? = itemView.findViewById(R.id.sortOrder) val playAction: MaterialButton? = itemView.findViewById(R.id.playAction)
val changeLayoutType: View? = itemView.findViewById(R.id.changeLayoutType) val shuffleAction: MaterialButton? = itemView.findViewById(R.id.shuffleAction)
val shuffleAction: View? = itemView.findViewById(R.id.shuffleAction)
val info: MaterialTextView? = itemView.findViewById(R.id.info) override fun onClick(v: View?) {
if (itemViewType == OFFSET_ITEM) {
MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
return
}
super.onClick(v)
}
} }
} }

View File

@ -125,6 +125,7 @@ public class ArtistGlideRequest {
.asBitmap() .asBitmap()
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.animate(DEFAULT_ANIMATION) .animate(DEFAULT_ANIMATION)
.error(DEFAULT_ERROR_IMAGE)
.priority(Priority.LOW) .priority(Priority.LOW)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.dontTransform() .dontTransform()
@ -150,6 +151,7 @@ public class ArtistGlideRequest {
.asBitmap() .asBitmap()
.transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.error(DEFAULT_ERROR_IMAGE)
.animate(DEFAULT_ANIMATION) .animate(DEFAULT_ANIMATION)
.priority(Priority.LOW) .priority(Priority.LOW)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)

View File

@ -12,71 +12,35 @@
~ See the GNU General Public License for more details. ~ See the GNU General Public License for more details.
--> -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.button.MaterialButton
android:id="@+id/info" android:id="@+id/playAction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/gridSize"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/full_names" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/gridSize"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:text="@string/action_play_all" android:text="@string/action_play_all"
app:layout_constraintBottom_toBottomOf="parent" app:backgroundTint="?attr/colorSurface"
app:layout_constraintEnd_toStartOf="@id/sortOrder" app:icon="@drawable/ic_play_arrow_white_24dp" />
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_grid_size_white_24dp"
app:tint="?android:attr/colorControlNormal" />
<androidx.appcompat.widget.AppCompatImageView <com.google.android.material.button.MaterialButton
android:id="@+id/sortOrder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/action_play_all"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/changeLayoutType"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_sort_white_24dp"
app:tint="?android:attr/colorControlNormal" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/changeLayoutType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/action_play_all"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/shuffleAction"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_dashboard_white_24dp"
app:tint="?android:attr/colorControlNormal" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/shuffleAction" android:id="@+id/shuffleAction"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:text="@string/shuffle" android:text="@string/shuffle"
app:layout_constraintBottom_toBottomOf="parent" app:backgroundTint="?attr/colorSurface"
app:layout_constraintEnd_toEndOf="parent" app:icon="@drawable/ic_shuffle_white_24dp" />
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_shuffle_white_24dp"
app:tint="?android:attr/colorControlNormal" />
</androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>

View File

@ -851,6 +851,14 @@
<string name="translators">Translators</string> <string name="translators">Translators</string>
<string name="translators_summary">The people who helped translate this app</string> <string name="translators_summary">The people who helped translate this app</string>
<plurals name="albumSongs">
<item quantity="one">Song</item>
<item quantity="other">Songs</item>
</plurals>
<plurals name="albums">
<item quantity="one">Album</item>
<item quantity="other">Albums</item>
</plurals>
<plurals name="numSongs"> <plurals name="numSongs">
<item quantity="one">%d Song</item> <item quantity="one">%d Song</item>
<item quantity="other">%d Songs</item> <item quantity="other">%d Songs</item>