diff --git a/app/build.gradle b/app/build.gradle
index 7f6a1ae..945a754 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,8 +11,8 @@ android {
applicationId "com.swatian.nexnotes"
minSdk 27
targetSdk 34
- versionCode 16
- versionName "1.6"
+ versionCode 17
+ versionName "1.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/java/com/swatian/nexnotes/activities/BaseActivity.java b/app/src/main/java/com/swatian/nexnotes/activities/BaseActivity.java
index 9b53434..8b41b3a 100644
--- a/app/src/main/java/com/swatian/nexnotes/activities/BaseActivity.java
+++ b/app/src/main/java/com/swatian/nexnotes/activities/BaseActivity.java
@@ -26,15 +26,25 @@ public void onCreate(Bundle savedInstanceState) {
AppSettingsInit.updateSettingsValue(
getApplicationContext(), "false", AppSettingsInit.APP_BIOMETRIC_LIFE_CYCLE_KEY);
- String[] locale =
- AppSettingsInit.getSettingsValue(ctx, AppSettingsInit.APP_LOCALE_KEY).split("\\|");
-
- if (locale[0].equals("0")) {
- Utils.setAppLocale(
- ctx.getResources().getConfiguration().getLocales().get(0).getLanguage());
- } else {
- Utils.setAppLocale(locale[1]);
- }
+ applyLocale();
+ }
+
+ private void applyLocale() {
+
+ String savedLocale =
+ getSharedPreferences("nexnotes_preferences", MODE_PRIVATE)
+ .getString("app_locale", "en");
+ Utils.setLocale(this, savedLocale);
+ }
+
+ @Override
+ protected void attachBaseContext(Context base) {
+ super.attachBaseContext(Utils.setLocale(base, getCurrentLocaleFromPreferences(base)));
+ }
+
+ private String getCurrentLocaleFromPreferences(Context context) {
+ return context.getSharedPreferences("nexnotes_preferences", MODE_PRIVATE)
+ .getString("app_locale", "en");
}
public void onResume() {
diff --git a/app/src/main/java/com/swatian/nexnotes/fragments/SettingsFragment.java b/app/src/main/java/com/swatian/nexnotes/fragments/SettingsFragment.java
index 3f61394..9b28416 100644
--- a/app/src/main/java/com/swatian/nexnotes/fragments/SettingsFragment.java
+++ b/app/src/main/java/com/swatian/nexnotes/fragments/SettingsFragment.java
@@ -1,10 +1,12 @@
package com.swatian.nexnotes.fragments;
+import static android.content.Context.MODE_PRIVATE;
import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG;
import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL;
import android.app.KeyguardManager;
import android.content.Context;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -110,12 +112,33 @@ public View onCreateView(
i + "|" + selectedLanguage,
AppSettingsInit.APP_LOCALE_KEY);
+ /*if (selectedLanguage.equalsIgnoreCase("sys")) {
+ selectedLanguage =
+ requireContext()
+ .getResources()
+ .getConfiguration()
+ .getLocales()
+ .get(0)
+ .getLanguage();
+ }*/
+
+ String[] multiCodeLang =
+ selectedLanguage.split("-");
+ if (selectedLanguage.contains("-")) {
+ selectedLanguage = multiCodeLang[0];
+ }
+
+ SharedPreferences prefs =
+ requireContext()
+ .getSharedPreferences(
+ "nexnotes_preferences",
+ MODE_PRIVATE);
+ prefs.edit()
+ .putString("app_locale", selectedLanguage)
+ .apply();
+
+ Utils.setLocale(requireContext(), selectedLanguage);
dialogInterface.dismiss();
- Snackbar.info(
- requireActivity(),
- requireActivity()
- .findViewById(R.id.nav_view),
- getString(R.string.settings_saved));
requireActivity().recreate();
});
diff --git a/app/src/main/java/com/swatian/nexnotes/helpers/AppSettingsInit.java b/app/src/main/java/com/swatian/nexnotes/helpers/AppSettingsInit.java
index 6a20b30..6692a41 100644
--- a/app/src/main/java/com/swatian/nexnotes/helpers/AppSettingsInit.java
+++ b/app/src/main/java/com/swatian/nexnotes/helpers/AppSettingsInit.java
@@ -11,7 +11,7 @@
public class AppSettingsInit {
public static String APP_LOCALE_KEY = "app_locale";
- public static String APP_LOCALE_KEY_DEFAULT = "0|sys";
+ public static String APP_LOCALE_KEY_DEFAULT = "1|en";
public static String APP_BIOMETRIC_KEY = "app_biometric";
public static String APP_BIOMETRIC_DEFAULT = "false";
public static String APP_BIOMETRIC_LIFE_CYCLE_KEY = "app_biometric_life_cycle";
diff --git a/app/src/main/java/com/swatian/nexnotes/helpers/Utils.java b/app/src/main/java/com/swatian/nexnotes/helpers/Utils.java
index aed0e98..2272192 100644
--- a/app/src/main/java/com/swatian/nexnotes/helpers/Utils.java
+++ b/app/src/main/java/com/swatian/nexnotes/helpers/Utils.java
@@ -8,11 +8,11 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.net.Uri;
import android.view.View;
-import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.content.pm.PackageInfoCompat;
-import androidx.core.os.LocaleListCompat;
import com.swatian.nexnotes.R;
import java.util.ArrayList;
import java.util.List;
@@ -24,15 +24,16 @@
*/
public class Utils {
- public static void setAppLocale(String locCode) {
+ public static Context setLocale(Context context, String languageCode) {
- String[] multiCodeLang = locCode.split("-");
- if (locCode.contains("-")) {
- locCode = multiCodeLang[0];
- }
+ Locale locale = new Locale(languageCode);
+ Locale.setDefault(locale);
+
+ Resources resources = context.getResources();
+ Configuration config = resources.getConfiguration();
- AppCompatDelegate.setApplicationLocales(
- LocaleListCompat.create(Locale.forLanguageTag(locCode)));
+ config.setLocale(locale);
+ return context.createConfigurationContext(config);
}
public static int getAppBuildNo(Context context) {
diff --git a/app/src/main/res/values-be-rBY/strings.xml b/app/src/main/res/values-be-rBY/strings.xml
new file mode 100644
index 0000000..9a5e52d
--- /dev/null
+++ b/app/src/main/res/values-be-rBY/strings.xml
@@ -0,0 +1,76 @@
+
+
+ Біяметрычны замок
+ Стварылі %s
+ Абноўлены %s
+ Нічога не знойдзена
+ Вы сапраўды хочаце выдаліць гэтую нататку?
+
+ - Нататка паспяхова выдалена
+ - Нататкі паспяхова выдалены
+ - Нататкі паспяхова выдалены
+ - Нататкі паспяхова выдалены
+
+ Вы ўсё зрабілі
+ Выдаліць усе нататкі
+ Пачніце рабіць нататкі тут…
+ Гэта выдаліць усе вашы нататкі. Гэта дзеянне нельга адмяніць.
+ Вы збіраецеся выдаліць тэму. Націсніце \"Выдаліць\", каб працягнуць.
+ Тэма паспяхова выдалена
+ Тэма створана
+ Біяметрычная аўтэнтыфікацыя
+ Разблакіраваць з дапамогай біяметрычных уліковых дадзеных
+ Налады захаваны
+ Зарэгістраваць біяметрыю з налад тэлефона
+ На гэтай прыладзе няма біяметрычных функцый
+ Біяметрычныя функцыі зараз недаступныя
+ Выберыце мову
+ Зыходны код
+
+ Нешта пайшло не так
+ Не знойдзена праграма для адкрыцця гэтай спасылкі
+ Тэма ўжо існуе
+ Тэма павінна быць не менш за 2 сімвалы
+
+
+ Нататкі
+ Тэмы
+ Тэма
+ Налады
+ Апавяшчэнні
+ Прыкладанне
+ малюнак
+ Адмяніць
+ Абнаўленне
+ Дадаць
+ Новая
+ памылка
+ Добра
+ Працягвайце
+ Тэма
+ Мова
+ Актыўны
+ Выдаліць
+ Колькасць
+ Правіць
+ Выдаліць
+ Імя
+ Аб
+ Сайт
+ Сістэма
+ Пошук
+ Адлюстраванне
+ Знешні выгляд
+ Пераклад
+ Бяспека
+ Версія
+ Спасылкі
+ Зачыніць
+ Апісанне
+ Стварыць
+ База дадзеных
+ Назва (абавязкова)
+ Галоўны
+ Захаваць
+
+
diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml
index e134083..9c356fb 100644
--- a/app/src/main/res/values-ru-rRU/strings.xml
+++ b/app/src/main/res/values-ru-rRU/strings.xml
@@ -60,6 +60,7 @@
Системный
Поиск
Отобразить
+ Внешний вид
Перевод
Охрана
Версия
@@ -70,5 +71,6 @@
База данных
Заголовок (обязательно)
В целом
+ Сохранить
diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml
index d3b3d41..335e512 100644
--- a/app/src/main/res/values/settings.xml
+++ b/app/src/main/res/values/settings.xml
@@ -6,5 +6,6 @@
- ru
- zh
- fr
+ - be
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 5bab80a..4bc5df0 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,22 +1,22 @@
[versions]
agp = "8.4.2"
junit = "4.13.2"
-junitVersion = "1.2.0"
-espressoCore = "3.6.0"
+junitVersion = "1.2.1"
+espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
constraintlayout = "2.1.4"
-lifecycleLivedataKtx = "2.8.2"
-lifecycleViewmodelKtx = "2.8.2"
-navigationFragment = "2.7.7"
-navigationUi = "2.7.7"
+lifecycleLivedataKtx = "2.8.6"
+lifecycleViewmodelKtx = "2.8.6"
+navigationFragment = "2.8.2"
+navigationUi = "2.8.2"
notiesMarkwon = "4.6.2"
prettytime = "5.0.7.Final"
roomDB = "2.6.1"
biometric = "1.1.0"
-annotation = "1.8.0"
+annotation = "1.8.2"
swiperefreshlayout = "1.1.0"
-desugar_jdk_libs = "2.0.4"
+desugar_jdk_libs = "2.1.2"
emoji-java = "v5.1.2"
browser = "1.8.0"
diff --git a/metadata/en-US/changelogs/17.txt b/metadata/en-US/changelogs/17.txt
new file mode 100644
index 0000000..9bd836e
--- /dev/null
+++ b/metadata/en-US/changelogs/17.txt
@@ -0,0 +1,6 @@
+1.7
+
+- Add new languages and translation updates
+- Fix switching languages in Android 12 and below
+
+https://github.com/Swatian/nexnotes/releases
\ No newline at end of file