0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-22 11:15:10 +00:00

language selector fixes

This commit is contained in:
Xinto 2020-11-15 13:49:40 +04:00
parent 2e8ed2cb37
commit c33e069e79
10 changed files with 42 additions and 30 deletions

View file

@ -71,19 +71,24 @@ android {
def getLanguages() {
List<String> langs = new ArrayList<String>()
langs.add("en")
//Add languages with dialects
langs.add("bn_BD")
langs.add("bn_IN")
langs.add("pt_BR")
langs.add("pt_PT")
langs.add("zh_CN")
langs.add("zh_TW")
List<String> exceptions = [ "bn", "pt", "zh"]
Pattern pattern = Pattern.compile("-(\\w+)-")
new File("${projectDir}/src/main/res").eachDir { dir ->
if (dir.name.startsWith("values-") && !dir.name.contains("v23")) {
Matcher matcher = pattern.matcher(dir.name)
if (matcher.find()) {
if (langs.contains(matcher.group(1)))
langs.add(matcher.group(1) + "_${dir.name.substring(dir.name.length() - 2)}")
else
langs.add(matcher.group(1))
if (matcher.find() && !exceptions.any { matcher.group(1) == it } ) {
langs.add(matcher.group(1))
}
}
}
return langs.toArray()
return langs.toArray().toSorted()
}
static def surroundWithQuotes(Object[] arr) {

View file

@ -3,7 +3,7 @@ package com.vanced.manager.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.appcompat.content.res.AppCompatResources
import androidx.recyclerview.widget.RecyclerView
import com.vanced.manager.R
import com.vanced.manager.databinding.ViewSocialLinkBinding
@ -13,49 +13,49 @@ import com.vanced.manager.ui.viewmodels.HomeViewModel
class LinkAdapter(context: Context, private val viewModel: HomeViewModel) : RecyclerView.Adapter<LinkAdapter.LinkViewHolder>() {
private val instagram = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_instagram),
AppCompatResources.getDrawable(context, R.drawable.ic_instagram),
"https://instagram.com/vanced.youtube"
)
private val youtube = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_youtube),
AppCompatResources.getDrawable(context, R.drawable.ic_youtube),
"https://youtube.com/c/YouTubeVanced"
)
private val github = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_github),
AppCompatResources.getDrawable(context, R.drawable.ic_github),
"https://github.com/YTVanced/VancedManager"
)
private val website = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_website),
AppCompatResources.getDrawable(context, R.drawable.ic_website),
"https://vancedapp.com"
)
private val telegram = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_telegram),
AppCompatResources.getDrawable(context, R.drawable.ic_telegram),
"https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w"
)
private val twitter = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_twitter),
AppCompatResources.getDrawable(context, R.drawable.ic_twitter),
"https://twitter.com/YTVanced"
)
private val discord = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_discord),
AppCompatResources.getDrawable(context, R.drawable.ic_discord),
"https://discord.gg/WCGNdRruzb"
)
private val reddit = LinkModel(
ContextCompat.getDrawable(context, R.drawable.ic_reddit),
AppCompatResources.getDrawable(context, R.drawable.ic_reddit),
"https://www.reddit.com/r/Vanced/"
)
val links = arrayOf(instagram, youtube, github, website, telegram, twitter, discord, reddit)
inner class LinkViewHolder(private val binding: ViewSocialLinkBinding) : RecyclerView.ViewHolder(binding.root) {
val logo = binding.linkImage
fun bind(position: Int) {
binding.viewModel = viewModel
binding.linkModel = links[position]
@ -70,6 +70,7 @@ class LinkAdapter(context: Context, private val viewModel: HomeViewModel) : Recy
override fun onBindViewHolder(holder: LinkViewHolder, position: Int) {
holder.bind(position)
holder.logo.setImageDrawable(links[position].linkIcon)
}
override fun getItemCount(): Int = links.size

View file

@ -3,6 +3,7 @@ package com.vanced.manager.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.vanced.manager.R
@ -17,13 +18,13 @@ class SponsorAdapter(
) : RecyclerView.Adapter<SponsorAdapter.LinkViewHolder>() {
private val brave = SponsorModel(
ContextCompat.getDrawable(context, R.drawable.ic_brave),
AppCompatResources.getDrawable(context, R.drawable.ic_brave),
"Brave",
"https://vancedapp.com/brave"
)
private val adguard = SponsorModel(
ContextCompat.getDrawable(context, R.drawable.ic_adguard),
AppCompatResources.getDrawable(context, R.drawable.ic_adguard),
"AdGuard",
"https://adguard.com/?aid=31141&source=manager"
)
@ -33,6 +34,7 @@ class SponsorAdapter(
inner class LinkViewHolder(private val binding: ViewSponsorBinding) : RecyclerView.ViewHolder(
binding.root
) {
val logo = binding.sponsorLogo
fun bind(position: Int) {
binding.viewModel = viewModel
binding.sponsor = sponsors[position]
@ -47,6 +49,7 @@ class SponsorAdapter(
override fun onBindViewHolder(holder: LinkViewHolder, position: Int) {
holder.bind(position)
holder.logo.setImageDrawable(sponsors[position].logo)
}
override fun getItemCount(): Int = 2

View file

@ -7,6 +7,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.edit
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
@ -14,7 +15,10 @@ import androidx.fragment.app.viewModels
import androidx.preference.PreferenceManager
import com.vanced.manager.R
import com.vanced.manager.databinding.FragmentAboutBinding
import com.vanced.manager.ui.dialogs.AppInfoDialog
import com.vanced.manager.ui.viewmodels.AboutViewModel
import com.vanced.manager.utils.Extensions.show
import com.vanced.manager.utils.InternetTools.manager
class AboutFragment : Fragment() {
@ -37,7 +41,7 @@ class AboutFragment : Fragment() {
@SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.aboutHeader.setOnClickListener { AppInfoDialog(getString(R.string.app_name), AppCompatResources.getDrawable(requireActivity(), R.mipmap.ic_launcher), manager.get()?.string("changelog")).show(requireActivity()) }
view.setOnTouchListener { _, event: MotionEvent ->
val eventAction = event.action

View file

@ -5,7 +5,7 @@ import android.content.ComponentName
import android.content.Intent
import android.view.View
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat.startActivity
import androidx.databinding.ObservableField
import androidx.fragment.app.FragmentActivity
@ -126,12 +126,12 @@ open class HomeViewModel(private val activity: FragmentActivity): ViewModel() {
init {
activity.setRefreshing(true)
vanced.set(DataModel(InternetTools.vanced, activity, vancedPkg, activity.getString(R.string.vanced), ContextCompat.getDrawable(activity, R.drawable.ic_vanced)))
vancedRoot.set(DataModel(InternetTools.vanced, activity, vancedRootPkg, activity.getString(R.string.vanced), ContextCompat.getDrawable(activity, R.drawable.ic_vanced)))
music.set(DataModel(InternetTools.music, activity, musicPkg, activity.getString(R.string.music), ContextCompat.getDrawable(activity, R.drawable.ic_music)))
musicRoot.set(DataModel(InternetTools.music, activity, musicRootPkg, activity.getString(R.string.music), ContextCompat.getDrawable(activity, R.drawable.ic_music)))
microg.set(DataModel(InternetTools.microg, activity, microgPkg, activity.getString(R.string.microg), ContextCompat.getDrawable(activity, R.drawable.ic_microg)))
manager.set(DataModel(InternetTools.manager, activity, managerPkg, activity.getString(R.string.app_name), ContextCompat.getDrawable(activity, R.mipmap.ic_launcher)))
vanced.set(DataModel(InternetTools.vanced, activity, vancedPkg, activity.getString(R.string.vanced), AppCompatResources.getDrawable(activity, R.drawable.ic_vanced)))
vancedRoot.set(DataModel(InternetTools.vanced, activity, vancedRootPkg, activity.getString(R.string.vanced), AppCompatResources.getDrawable(activity, R.drawable.ic_vanced)))
music.set(DataModel(InternetTools.music, activity, musicPkg, activity.getString(R.string.music), AppCompatResources.getDrawable(activity, R.drawable.ic_music)))
musicRoot.set(DataModel(InternetTools.music, activity, musicRootPkg, activity.getString(R.string.music), AppCompatResources.getDrawable(activity, R.drawable.ic_music)))
microg.set(DataModel(InternetTools.microg, activity, microgPkg, activity.getString(R.string.microg), AppCompatResources.getDrawable(activity, R.drawable.ic_microg)))
manager.set(DataModel(InternetTools.manager, activity, managerPkg, activity.getString(R.string.app_name), AppCompatResources.getDrawable(activity, R.mipmap.ic_launcher)))
activity.setRefreshing(false)
}

View file

@ -25,7 +25,7 @@
app:layout_constraintTop_toTopOf="parent"
tools:text="About YouTube Vanced" />
<ImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/about_app_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -26,6 +26,7 @@
android:orientation="vertical">
<include
android:id="@+id/about_header"
layout="@layout/include_about_header"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

View file

@ -13,7 +13,7 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/top_header_margin"
android:src="@drawable/ic_launch_text"
app:srcCompat="@drawable/ic_launch_text"
android:textAlignment="center"
app:layout_constraintTop_toTopOf="parent" />

View file

@ -36,7 +36,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@{linkModel.linkIcon}"
app:tint="?colorLinkImage"
tools:src="@drawable/ic_instagram" />

View file

@ -34,7 +34,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:src="@{sponsor.logo}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorLinkImage"