Merge branch 'develop' into feature/add_edit_server_in_server_book

This commit is contained in:
kosharskiy 2021-01-14 23:02:11 +02:00
commit 53e4a12056
7 changed files with 75 additions and 31 deletions

View File

@ -19,16 +19,17 @@ package net.schueller.peertube.activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import net.schueller.peertube.R; import net.schueller.peertube.R;
import java.util.Locale; import java.util.Locale;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
public class CommonActivity extends AppCompatActivity { public class CommonActivity extends AppCompatActivity {
@Override @Override
@ -51,21 +52,31 @@ public class CommonActivity extends AppCompatActivity {
); );
// Set language // Set language
String countryCode = sharedPref.getString(getString(R.string.pref_language_app_key), "en"); String countryCode = sharedPref.getString(getString(R.string.pref_language_app_key), null);
assert countryCode != null;
Locale locale = new Locale(countryCode); 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 //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; locale = Locale.SIMPLIFIED_CHINESE;
if (countryCode.equals("zh-rTW")) if (languageCode.equals("zh-rTW"))
locale = Locale.TRADITIONAL_CHINESE; locale = Locale.TRADITIONAL_CHINESE;
Locale.setDefault(locale); 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());
}
} }

View File

@ -70,6 +70,8 @@ import net.schueller.peertube.service.VideoPlayerService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import retrofit2.Call; import retrofit2.Call;
@ -321,7 +323,14 @@ public class VideoListActivity extends CommonActivity {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String nsfw = sharedPref.getBoolean(getString(R.string.pref_show_nsfw_key), false) ? "both" : "false"; String nsfw = sharedPref.getBoolean(getString(R.string.pref_show_nsfw_key), false) ? "both" : "false";
Set<String> languages = sharedPref.getStringSet(getString(R.string.pref_video_language_key), null);
Locale locale = getResources().getConfiguration().locale;
String country = locale.getLanguage();
HashSet<String> countries = new HashSet<>(1);
countries.add(country);
Set<String> languages = sharedPref.getStringSet(getString(R.string.pref_video_language_key), countries);
String apiBaseURL = APIUrlHelper.getUrlWithVersion(this); String apiBaseURL = APIUrlHelper.getUrlWithVersion(this);
GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetVideoDataService.class); GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetVideoDataService.class);

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:padding="6dp"> android:padding="6dp">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="72dp" android:layout_width="72dp"
android:layout_height="72dp" android:layout_height="72dp"
@ -210,7 +211,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -229,8 +230,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center|start" android:gravity="center|start"
android:text="" android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" /> tools:text="@tools:sample/lorem/random"
android:lines="2"
/>
</LinearLayout> </LinearLayout>
@ -239,7 +242,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -258,8 +261,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center|start" android:gravity="center|start"
android:text="" android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" /> tools:text="@tools:sample/lorem/random"
android:lines="2"
/>
</LinearLayout> </LinearLayout>
@ -267,7 +272,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -286,8 +291,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center|start" android:gravity="center|start"
android:text="" android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" /> tools:text="@tools:sample/lorem"
android:lines="2"
/>
</LinearLayout> </LinearLayout>
@ -296,7 +303,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -315,8 +322,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center|start" android:gravity="center|start"
android:text="" android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" /> tools:text="@tools:sample/lorem/random"
android:lines="2"
/>
</LinearLayout> </LinearLayout>
@ -324,7 +333,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -343,7 +352,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center|start" android:gravity="center|start"
android:text="" tools:text="@tools:sample/lorem/random"
android:lines="2"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" /> android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" />
</LinearLayout> </LinearLayout>

View File

@ -353,4 +353,11 @@
<string name="pref_title_back_pause">Пауза на кнопку Назад</string> <string name="pref_title_back_pause">Пауза на кнопку Назад</string>
<string name="network_error">Ошибка доступа к сети, проверьте подключение</string> <string name="network_error">Ошибка доступа к сети, проверьте подключение</string>
<string name="server_selection_filter_hint">Список фильтров</string> <string name="server_selection_filter_hint">Список фильтров</string>
<string name="pref_insecure_confirm_yes">Да</string>
<string name="pref_insecure_confirm_no">Нет</string>
<string name="pref_title_accept_insecure">Отключить проверку SSL сертификата</string>
<string name="settings_activity_advanced_category_title">Дополнительно</string>
<string name="pref_insecure_confirm_title">Внимание!</string>
<string name="pref_description_accept_insecure">Игнорировать незащищенные соединения. Используйте только если знаете сервер к которому подключаетесь. Требуется перезапуск приложения.</string>
<string name="pref_insecure_confirm_message">"Вы собираетесь отключить валидацию всех SSL сертификатов в Thorium. Это может быть очень опасно если peertube сервер вами не контролируется, потому что \"атака посредника\" может направить трафик на другой сервер. Злоумышленник может записывать пароли и другие личные данные."</string>
</resources> </resources>

View File

@ -347,4 +347,11 @@
<string name="prompt_server">Сервер</string> <string name="prompt_server">Сервер</string>
<string name="title_activity_login">Увійти</string> <string name="title_activity_login">Увійти</string>
<string name="title_activity_settings">Параметри</string> <string name="title_activity_settings">Параметри</string>
<string name="pref_title_accept_insecure">Вимкнути перевірку SSL сертифіката</string>
<string name="pref_description_accept_insecure">Ігнорувати незахищені з\'єднання. Використовуйте це лише якщо знаєте сервер до якого підключаєтесь. Перезапустіть застосунок, щоб зміни набули чинності.</string>
<string name="pref_insecure_confirm_yes">Так</string>
<string name="pref_insecure_confirm_no">Ні</string>
<string name="pref_insecure_confirm_title">Увага!</string>
<string name="pref_insecure_confirm_message">"Ви збираєтеся вимкнути всі перевірки сертифікації SSL у Thorium. Це може бути дуже небезпечно якщо peertube сервер вами не контролюється, оскільки атака \"людина посередині\" може направити трафік на інший сервер без вашого відома. Зловмисник може записувати паролі та інші особисті дані. "</string>
<string name="settings_activity_advanced_category_title">Додатково</string>
</resources> </resources>

View File

@ -534,6 +534,7 @@
<item>ru</item> <item>ru</item>
<item>sv</item> <item>sv</item>
<item>tr</item> <item>tr</item>
<item>uk</item>
<item>zh-rCN</item> <item>zh-rCN</item>
<item>zh-rTW</item> <item>zh-rTW</item>
</string-array> </string-array>
@ -560,6 +561,7 @@
<item>@string/ru</item> <item>@string/ru</item>
<item>@string/sv</item> <item>@string/sv</item>
<item>@string/tr</item> <item>@string/tr</item>
<item>@string/uk</item>
<item>@string/zh</item> <item>@string/zh</item>
<item>@string/tw</item> <item>@string/tw</item>
</string-array> </string-array>

View File

@ -4,7 +4,6 @@
<PreferenceCategory app:title="@string/settings_activity_look_and_feel_category_title" app:iconSpaceReserved="false"> <PreferenceCategory app:title="@string/settings_activity_look_and_feel_category_title" app:iconSpaceReserved="false">
<ListPreference <ListPreference
app:defaultValue="@array/empty_array"
app:entries="@array/supportedLanguagesArray" app:entries="@array/supportedLanguagesArray"
app:entryValues="@array/supportedLanguagesValues" app:entryValues="@array/supportedLanguagesValues"
app:key="@string/pref_language_app_key" app:key="@string/pref_language_app_key"
@ -40,7 +39,6 @@
app:iconSpaceReserved="false"/> app:iconSpaceReserved="false"/>
<MultiSelectListPreference <MultiSelectListPreference
app:defaultValue="@array/empty_array"
app:entries="@array/languageArray" app:entries="@array/languageArray"
app:entryValues="@array/languageValues" app:entryValues="@array/languageValues"
app:key="@string/pref_video_language_key" app:key="@string/pref_video_language_key"