Merge branch 'master' into weblate-libretube-libretube

This commit is contained in:
Farbod 2022-05-06 16:47:04 +04:30 committed by GitHub
commit 517b1d8afd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 126 additions and 17 deletions

View File

@ -209,7 +209,7 @@ class ChannelFragment : Fragment() {
runOnUiThread {
view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE
view.findViewById<TextView>(R.id.channel_name).text=response.name
view.findViewById<TextView>(R.id.channel_subs).text=response.subscriberCount.formatShort() + " subscribers"
view.findViewById<TextView>(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort())
view.findViewById<TextView>(R.id.channel_description).text=response.description
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
val channelImage = view.findViewById<ImageView>(R.id.channel_image)

View File

@ -2,6 +2,7 @@ package com.github.libretube
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.net.Uri
@ -27,6 +28,7 @@ import androidx.navigation.ui.setupWithNavController
import androidx.preference.PreferenceManager
import com.google.android.material.color.DynamicColors
import java.lang.Exception
import java.util.*
class MainActivity : AppCompatActivity() {
val TAG = "MainActivity"
@ -40,6 +42,20 @@ class MainActivity : AppCompatActivity() {
RetrofitInstance.url = sharedPreferences.getString("instance", "https://pipedapi.kavin.rocks/")!!
DynamicColors.applyToActivitiesIfAvailable(application)
setContentView(R.layout.activity_main)
val languageName = sharedPreferences.getString("language", "sys")
if (languageName != "") {
var locale = if (languageName != "sys") {
Locale(languageName)
} else {
Locale.getDefault()
}
val res = resources
val dm = res.displayMetrics
val conf = res.configuration
conf.setLocale(locale)
Locale.setDefault(locale)
res.updateConfiguration(conf, dm)
}
when (sharedPreferences.getString("theme_togglee", "A")!!) {
"A" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
"L" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

View File

@ -8,6 +8,7 @@ import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.LocaleList
import android.text.TextUtils
import android.util.Log
import android.widget.Toast
@ -16,6 +17,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.os.LocaleListCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference
@ -27,8 +29,10 @@ import org.json.JSONTokener
import retrofit2.HttpException
import java.io.IOException
import java.io.InputStream
import java.util.*
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import kotlin.collections.ArrayList
class Settings : PreferenceFragmentCompat() {
@ -189,6 +193,14 @@ class Settings : PreferenceFragmentCompat() {
}
true
}
val changeLanguage = findPreference<ListPreference>("language")
changeLanguage?.setOnPreferenceChangeListener { _, _ ->
val refresh = Intent(context, MainActivity::class.java)
startActivity(refresh)
true
}
val about = findPreference<Preference>("about")
about?.setOnPreferenceClickListener {
val uri = Uri.parse("https://libre-tube.github.io/")

View File

@ -1,6 +1,5 @@
package com.github.libretube.adapters
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M14.4,6L14,4H5v17h2v-7h5.6l0.4,2h7V6z"/>
</vector>

View File

@ -91,7 +91,7 @@
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:text="Videos"
android:text="@string/videos"
android:textSize="17sp"
android:textStyle="bold" />

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/home2" android:title="Home" android:icon="@drawable/ic_home"/>
<item android:id="@+id/subscriptions" android:title="Subscriptions" android:icon="@drawable/ic_subscriptions"/>
<item android:id="@+id/library" android:title="Library" android:icon="@drawable/ic_library"/>
<item android:id="@+id/home2" android:title="@string/startpage" android:icon="@drawable/ic_home"/>
<item android:id="@+id/subscriptions" android:title="@string/subscriptions" android:icon="@drawable/ic_subscriptions"/>
<item android:id="@+id/library" android:title="@string/library" android:icon="@drawable/ic_library"/>
</menu>

View File

@ -1,7 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="startpage">Trends</string>
<string name="subscriptions">Abos</string>
<string name="library">Bibliothek</string>
<string name="search_hint">Suche</string>
<string name="subscribe">Abonnieren</string>
<string name="subscribe">ABONNIEREN</string>
<string name="unsubscribe">ABONNIERT</string>
<string name="videos">Videos</string>
<string name="share">Teilen</string>
<string name="username">Benutzername</string>
<string name="password">Passwort</string>
@ -40,8 +45,7 @@
<string name="fail">Fehlgeschlagen :(</string>
<string name="choose_quality_dialog">Qualtität wählen:</string>
<string name="login_register">Anmelden/Registrieren</string>
<string name="dlcomplete">Herunterladen abgeschlossen.</string>
<string name="unsubscribe">ABONNIERT</string>
<string name="dlcomplete">Herunterladen abgeschlossen!</string>
<string name="save">Speichern</string>
<string name="already_logged_in">Du bist bereits angemeldet. Du kannst dich hier von deinem Account abmelden.</string>
<string name="please_login">Bitte melde dich zuerst an oder registriere dich in den Einstellungen!</string>
@ -50,6 +54,9 @@
<string name="empty">Benutzername und Passwort können nicht leer sein.</string>
<string name="deletePlaylist">Wiedergabeliste löschen</string>
<string name="areYouSure">Bist du sicher, dass du die Wiedergabeliste löschen möchtest\?</string>
<string name="about">Über</string>
<string name="emptyPlaylistName">Der Name der Wiedergabeliste darf nicht leer sein</string>
<string name="about">Über</string>
<string name="systemDefault">Automatisch</string>
<string name="lightTheme">Hell</string>
<string name="darkTheme">Dunkel</string>
<string name="subscribers">%1$s Abonnenten</string>
</resources>

View File

@ -405,10 +405,56 @@
<item>ZW</item>
</string-array>
<string-array name="languages">
<item>@string/systemLanguage</item>
<item>Arabic</item>
<item>Czech</item>
<item>English</item>
<item>French</item>
<item>German</item>
<item>Hindi</item>
<item>Hungarian</item>
<item>Italian</item>
<item>Korean</item>
<item>Marathi</item>
<item>Norwegian</item>
<item>Persian</item>
<item>Polish</item>
<item>Portuguese</item>
<item>Portuguese (Brazil)</item>
<item>Russian</item>
<item>Sorani</item>
<item>Spanish</item>
<item>Turkish</item>
</string-array>
<string-array name="languagesValue">
<item>sys</item>
<item>ar</item>
<item>cs</item>
<item>en</item>
<item>fr</item>
<item>de</item>
<item>hi</item>
<item>hu</item>
<item>it</item>
<item>ko</item>
<item>mr</item>
<item>nb-rNO</item>
<item>ckb</item>
<item>pl</item>
<item>pt</item>
<item>pr-rBR</item>
<item>ru</item>
<item>fa</item>
<item>es</item>
<item>tr</item>
</string-array>
<string-array name="themes">
<item>System Default</item>
<item>Light Theme</item>
<item>Dark Theme</item>
<item>@string/systemDefault</item>
<item>@string/lightTheme</item>
<item>@string/darkTheme</item>
</string-array>
<string-array name="themesValue">

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="startpage">Home</string>
<string name="subscriptions">Subscriptions</string>
<string name="library">Library</string>
<string name="yes">Yes</string>
<string name="choose_quality_dialog">Choose Quality:</string>
<string name="search_hint">Search</string>
<string name="videos">Videos</string>
<string name="subscribe">Subscribe</string>
<string name="unsubscribe">Unsubscribe</string>
<string name="share">Share</string>
@ -53,4 +57,10 @@
<string name="success">Success!</string>
<string name="fail">Failed :(</string>
<string name="about">About</string>
</resources>
<string name="changeLanguage">Change Language</string>
<string name="systemLanguage">System Language</string>
<string name="systemDefault">System Default</string>
<string name="lightTheme">Light Theme</string>
<string name="darkTheme">Dark Theme</string>
<string name="subscribers">%1$s subscribers</string>
</resources>

View File

@ -8,7 +8,17 @@
app:entryValues="@array/regionsValue"
app:defaultValue="US"
app:useSimpleSummaryProvider="true"
android:icon="@drawable/ic_language"
android:icon="@drawable/ic_region"
/>
<ListPreference
app:key="language"
app:title="@string/changeLanguage"
app:entries="@array/languages"
app:entryValues="@array/languagesValue"
app:defaultValue="sys"
app:useSimpleSummaryProvider="true"
android:icon="@drawable/ic_flag"
/>
<ListPreference