Fix about page
Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
This commit is contained in:
parent
c1b341ad51
commit
2f782debeb
18 changed files with 95 additions and 705 deletions
|
@ -23,13 +23,13 @@ object Constants {
|
|||
const val TRANSLATE = "https://crowdin.com/project/retromusicplayer"
|
||||
const val WEBSITE = "https://retromusic.app"
|
||||
const val GITHUB_PROJECT = "https://github.com/MuntashirAkon/Metro"
|
||||
const val TELEGRAM_CHANGE_LOG = "https://t.me/retromusiclog"
|
||||
const val TELEGRAM_CHANGE_LOG = "https://t.me/AppManagerChannel"
|
||||
const val USER_PROFILE = "profile.jpg"
|
||||
const val USER_BANNER = "banner.jpg"
|
||||
const val APP_INSTAGRAM_LINK = "https://www.instagram.com/retromusicapp/"
|
||||
const val APP_TELEGRAM_LINK = "https://t.me/retromusicapp/"
|
||||
const val APP_TWITTER_LINK = "https://twitter.com/retromusicapp"
|
||||
const val FAQ_LINK = "https://github.com/RetroMusicPlayer/RetroMusicPlayer/blob/master/FAQ.md"
|
||||
const val FAQ_LINK = "https://github.com/MuntashirAkon/Metro/blob/master/FAQ.md"
|
||||
const val PINTEREST = "https://in.pinterest.com/retromusicapp/"
|
||||
const val AUDIO_SCROBBLER_URL = "https://ws.audioscrobbler.com/2.0/"
|
||||
|
||||
|
|
|
@ -118,7 +118,6 @@ private val dataModule = module {
|
|||
get(),
|
||||
get(),
|
||||
get(),
|
||||
get(),
|
||||
)
|
||||
} bind Repository::class
|
||||
|
||||
|
@ -163,9 +162,6 @@ private val dataModule = module {
|
|||
get()
|
||||
)
|
||||
}
|
||||
single {
|
||||
RealLocalDataRepository(get())
|
||||
} bind LocalDataRepository::class
|
||||
}
|
||||
|
||||
private val viewModules = module {
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
package io.github.muntashirakon.music.adapter
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.openUrl
|
||||
import io.github.muntashirakon.music.model.Contributor
|
||||
import io.github.muntashirakon.music.views.RetroShapeableImageView
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
class ContributorAdapter(
|
||||
private var contributors: List<Contributor>
|
||||
) : RecyclerView.Adapter<ContributorAdapter.ViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return if (viewType == HEADER) {
|
||||
ViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(
|
||||
R.layout.item_contributor_header,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
} else ViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(
|
||||
R.layout.item_contributor,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val HEADER: Int = 0
|
||||
const val ITEM: Int = 1
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (position == 0) {
|
||||
HEADER
|
||||
} else {
|
||||
ITEM
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val contributor = contributors[position]
|
||||
holder.bindData(contributor)
|
||||
holder.itemView.setOnClickListener {
|
||||
it?.context?.openUrl(contributors[position].link)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return contributors.size
|
||||
}
|
||||
|
||||
fun swapData(it: List<Contributor>) {
|
||||
contributors = it
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val title: TextView = itemView.findViewById(R.id.title)
|
||||
val text: TextView = itemView.findViewById(R.id.text)
|
||||
val image: RetroShapeableImageView = itemView.findViewById(R.id.icon)
|
||||
|
||||
internal fun bindData(contributor: Contributor) {
|
||||
title.text = contributor.name
|
||||
text.text = contributor.summary
|
||||
Glide.with(image.context)
|
||||
.load(contributor.image)
|
||||
.error(R.drawable.ic_account)
|
||||
.placeholder(R.drawable.ic_account)
|
||||
.dontAnimate()
|
||||
.into(image)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -278,10 +278,6 @@ class LibraryViewModel(
|
|||
emit(repository.artistById(artistId))
|
||||
}
|
||||
|
||||
fun fetchContributors(): LiveData<List<Contributor>> = liveData(IO) {
|
||||
emit(repository.contributor())
|
||||
}
|
||||
|
||||
fun observableHistorySongs(): LiveData<List<Song>> {
|
||||
viewModelScope.launch(IO) {
|
||||
repository.historySong().forEach { song ->
|
||||
|
|
|
@ -23,7 +23,6 @@ import androidx.recyclerview.widget.DefaultItemAnimator
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import io.github.muntashirakon.music.Constants
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.adapter.ContributorAdapter
|
||||
import io.github.muntashirakon.music.databinding.FragmentAboutBinding
|
||||
import io.github.muntashirakon.music.extensions.openUrl
|
||||
import io.github.muntashirakon.music.fragments.LibraryViewModel
|
||||
|
@ -39,9 +38,8 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentAboutBinding.bind(view)
|
||||
binding.aboutContent.cardOther.version.setSummary(getAppVersion())
|
||||
binding.aboutContent.cardRetroInfo.version.setSummary(getAppVersion())
|
||||
setUpView()
|
||||
loadContributors()
|
||||
|
||||
binding.aboutContent.root.applyInsetter {
|
||||
type(navigationBars = true) {
|
||||
|
@ -53,71 +51,32 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
|||
private fun setUpView() {
|
||||
binding.aboutContent.cardRetroInfo.appGithub.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.faqLink.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.appRate.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.appTranslation.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.appShare.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.donateLink.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.bugReportLink.setOnClickListener(this)
|
||||
|
||||
binding.aboutContent.cardSocial.telegramLink.setOnClickListener(this)
|
||||
binding.aboutContent.cardSocial.instagramLink.setOnClickListener(this)
|
||||
binding.aboutContent.cardSocial.twitterLink.setOnClickListener(this)
|
||||
binding.aboutContent.cardSocial.pinterestLink.setOnClickListener(this)
|
||||
binding.aboutContent.cardSocial.websiteLink.setOnClickListener(this)
|
||||
|
||||
binding.aboutContent.cardOther.changelog.setOnClickListener(this)
|
||||
binding.aboutContent.cardOther.openSource.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.changelog.setOnClickListener(this)
|
||||
binding.aboutContent.cardRetroInfo.openSource.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.pinterestLink -> openUrl(Constants.PINTEREST)
|
||||
R.id.faqLink -> openUrl(Constants.FAQ_LINK)
|
||||
R.id.telegramLink -> openUrl(Constants.APP_TELEGRAM_LINK)
|
||||
R.id.appGithub -> openUrl(Constants.GITHUB_PROJECT)
|
||||
R.id.appTranslation -> openUrl(Constants.TRANSLATE)
|
||||
R.id.appRate -> openUrl(Constants.RATE_ON_GOOGLE_PLAY)
|
||||
R.id.appShare -> shareApp()
|
||||
R.id.instagramLink -> openUrl(Constants.APP_INSTAGRAM_LINK)
|
||||
R.id.twitterLink -> openUrl(Constants.APP_TWITTER_LINK)
|
||||
R.id.changelog -> NavigationUtil.gotoWhatNews(requireActivity())
|
||||
R.id.openSource -> NavigationUtil.goToOpenSource(requireActivity())
|
||||
R.id.bugReportLink -> NavigationUtil.bugReport(requireActivity())
|
||||
R.id.websiteLink -> openUrl(Constants.WEBSITE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAppVersion(): String {
|
||||
return try {
|
||||
val isPro = "Pro"
|
||||
val packageInfo =
|
||||
requireActivity().packageManager.getPackageInfo(requireActivity().packageName, 0)
|
||||
"${packageInfo.versionName} $isPro"
|
||||
requireActivity().packageManager.getPackageInfo(requireActivity().packageName, 0).versionName
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
e.printStackTrace()
|
||||
"0.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
private fun shareApp() {
|
||||
ShareCompat.IntentBuilder(requireActivity()).setType("text/plain")
|
||||
.setChooserTitle(R.string.share_app)
|
||||
.setText(String.format(getString(R.string.app_share), requireActivity().packageName))
|
||||
.startChooser()
|
||||
}
|
||||
|
||||
private fun loadContributors() {
|
||||
val contributorAdapter = ContributorAdapter(emptyList())
|
||||
binding.aboutContent.cardCredit.recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
adapter = contributorAdapter
|
||||
}
|
||||
libraryViewModel.fetchContributors().observe(viewLifecycleOwner) { contributors ->
|
||||
contributorAdapter.swapData(contributors)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package io.github.muntashirakon.music.repository
|
||||
|
||||
import android.content.Context
|
||||
import io.github.muntashirakon.music.model.Contributor
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
interface LocalDataRepository {
|
||||
fun contributors(): List<Contributor>
|
||||
}
|
||||
|
||||
class RealLocalDataRepository(
|
||||
private val context: Context
|
||||
) : LocalDataRepository {
|
||||
|
||||
override fun contributors(): List<Contributor> {
|
||||
val jsonString = context.assets.open("contributors.json")
|
||||
.bufferedReader().use { it.readText() }
|
||||
|
||||
val gsonBuilder = GsonBuilder()
|
||||
val gson = gsonBuilder.create()
|
||||
val listContributorType = object : TypeToken<List<Contributor>>() {}.type
|
||||
return gson.fromJson(jsonString, listContributorType)
|
||||
}
|
||||
}
|
|
@ -105,7 +105,6 @@ interface Repository {
|
|||
suspend fun playCountSongs(): List<PlayCountEntity>
|
||||
suspend fun blackListPaths(): List<BlackListStoreEntity>
|
||||
suspend fun deleteSongs(songs: List<Song>)
|
||||
suspend fun contributor(): List<Contributor>
|
||||
suspend fun searchArtists(query: String): List<Artist>
|
||||
suspend fun searchSongs(query: String): List<Song>
|
||||
suspend fun searchAlbums(query: String): List<Album>
|
||||
|
@ -126,14 +125,11 @@ class RealRepository(
|
|||
private val searchRepository: RealSearchRepository,
|
||||
private val topPlayedRepository: TopPlayedRepository,
|
||||
private val roomRepository: RoomRepository,
|
||||
private val localDataRepository: LocalDataRepository
|
||||
) : Repository {
|
||||
|
||||
|
||||
override suspend fun deleteSongs(songs: List<Song>) = roomRepository.deleteSongs(songs)
|
||||
|
||||
override suspend fun contributor(): List<Contributor> = localDataRepository.contributors()
|
||||
|
||||
override suspend fun searchSongs(query: String): List<Song> = songRepository.songs(query)
|
||||
|
||||
override suspend fun searchAlbums(query: String): List<Album> = albumRepository.albums(query)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue