diff --git a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java index b9c1ee7..d68ffe4 100644 --- a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java @@ -19,16 +19,17 @@ package net.schueller.peertube.activity; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.content.res.Resources; import android.os.Bundle; import android.preference.PreferenceManager; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.app.AppCompatDelegate; - import net.schueller.peertube.R; import java.util.Locale; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatDelegate; + public class CommonActivity extends AppCompatActivity { @Override @@ -51,21 +52,31 @@ public class CommonActivity extends AppCompatActivity { ); // Set language - String countryCode = sharedPref.getString(getString(R.string.pref_language_app_key), "en"); - assert countryCode != null; - Locale locale = new Locale(countryCode); + String countryCode = sharedPref.getString(getString(R.string.pref_language_app_key), null); + + if (countryCode == null) { + return; + } + + setLocale(countryCode); + } + + + public void setLocale(String languageCode) { + + Locale locale = new Locale(languageCode); //Neither Chinese language choice was working, found this fix on stack overflow - if (countryCode.equals("zh-rCN")) + if (languageCode.equals("zh-rCN")) locale = Locale.SIMPLIFIED_CHINESE; - if (countryCode.equals("zh-rTW")) + if (languageCode.equals("zh-rTW")) locale = Locale.TRADITIONAL_CHINESE; Locale.setDefault(locale); - Configuration config = getBaseContext().getResources().getConfiguration(); - config.locale = locale; - getBaseContext().getResources().updateConfiguration(config, - getBaseContext().getResources().getDisplayMetrics()); - } + Resources resources = getResources(); + Configuration config = resources.getConfiguration(); + config.setLocale(locale); + resources.updateConfiguration(config, resources.getDisplayMetrics()); + } } diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index fbd0b6d..a760c4a 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -70,6 +70,8 @@ import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Locale; import java.util.Set; import retrofit2.Call; @@ -321,7 +323,14 @@ public class VideoListActivity extends CommonActivity { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String nsfw = sharedPref.getBoolean(getString(R.string.pref_show_nsfw_key), false) ? "both" : "false"; - Set languages = sharedPref.getStringSet(getString(R.string.pref_video_language_key), null); + + Locale locale = getResources().getConfiguration().locale; + String country = locale.getLanguage(); + + HashSet countries = new HashSet<>(1); + countries.add(country); + + Set languages = sharedPref.getStringSet(getString(R.string.pref_video_language_key), countries); String apiBaseURL = APIUrlHelper.getUrlWithVersion(this); GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetVideoDataService.class); diff --git a/app/src/main/res/layout/fragment_video_meta.xml b/app/src/main/res/layout/fragment_video_meta.xml index 229eeaa..9463ee1 100644 --- a/app/src/main/res/layout/fragment_video_meta.xml +++ b/app/src/main/res/layout/fragment_video_meta.xml @@ -1,10 +1,11 @@ - + android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" + tools:text="@tools:sample/lorem/random" + android:lines="2" + /> @@ -239,7 +242,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" - + android:gravity="bottom" android:orientation="horizontal"> + android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" + tools:text="@tools:sample/lorem/random" + android:lines="2" + /> @@ -267,7 +272,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" - + android:gravity="bottom" android:orientation="horizontal"> + android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" + tools:text="@tools:sample/lorem" + android:lines="2" + /> @@ -296,7 +303,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" - + android:gravity="bottom" android:orientation="horizontal"> + android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" + tools:text="@tools:sample/lorem/random" + android:lines="2" + /> @@ -324,7 +333,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" - + android:gravity="bottom" android:orientation="horizontal"> diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index d799535..01208b9 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -353,4 +353,11 @@ Пауза на кнопку Назад Ошибка доступа к сети, проверьте подключение Список фильтров + Да + Нет + Отключить проверку SSL сертификата + Дополнительно + Внимание! + Игнорировать незащищенные соединения. Используйте только если знаете сервер к которому подключаетесь. Требуется перезапуск приложения. + "Вы собираетесь отключить валидацию всех SSL сертификатов в Thorium. Это может быть очень опасно если peertube сервер вами не контролируется, потому что \"атака посредника\" может направить трафик на другой сервер. Злоумышленник может записывать пароли и другие личные данные." \ No newline at end of file diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 3612f77..8fcc9d4 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -347,4 +347,11 @@ Сервер Увійти Параметри + Вимкнути перевірку SSL сертифіката + Ігнорувати незахищені з\'єднання. Використовуйте це лише якщо знаєте сервер до якого підключаєтесь. Перезапустіть застосунок, щоб зміни набули чинності. + Так + Ні + Увага! + "Ви збираєтеся вимкнути всі перевірки сертифікації SSL у Thorium. Це може бути дуже небезпечно якщо peertube сервер вами не контролюється, оскільки атака \"людина посередині\" може направити трафік на інший сервер без вашого відома. Зловмисник може записувати паролі та інші особисті дані. " + Додатково \ No newline at end of file diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml index 6b29bef..7feb602 100644 --- a/app/src/main/res/values/constants.xml +++ b/app/src/main/res/values/constants.xml @@ -534,6 +534,7 @@ ru sv tr + uk zh-rCN zh-rTW @@ -560,6 +561,7 @@ @string/ru @string/sv @string/tr + @string/uk @string/zh @string/tw diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index e96fdd9..96736b3 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -4,7 +4,6 @@