diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java
index 8f484ee..b46b757 100644
--- a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java
+++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java
@@ -55,9 +55,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setLocale("de");
-
- //getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
+ //getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); TODO: enable secure flag
Integer themeID = SettingsUtil.THEMES.get(SettingsUtil.getTheme(this));
if(themeID != null) {
@@ -66,6 +64,8 @@ public class MainActivity extends AppCompatActivity {
setTheme(R.style.Theme_CringeAuthenticator_Blue_Green);
}
+ setLocale(SettingsUtil.getLocale(this));
+
Executor executor = ContextCompat.getMainExecutor(this);
BiometricPrompt prompt = new BiometricPrompt(this, executor, new BiometricPrompt.AuthenticationCallback() {
@Override
@@ -110,8 +110,7 @@ public class MainActivity extends AppCompatActivity {
});
}
- private void setLocale(String lang) {
- Locale locale = new Locale(lang);
+ public void setLocale(Locale locale) {
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java
index 09e1187..6c7afd1 100644
--- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java
+++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java
@@ -14,10 +14,14 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.biometric.BiometricManager;
+import com.cringe_studios.cringe_authenticator.MainActivity;
import com.cringe_studios.cringe_authenticator.databinding.FragmentSettingsBinding;
import com.cringe_studios.cringe_authenticator.util.FabUtil;
import com.cringe_studios.cringe_authenticator.util.SettingsUtil;
+import java.util.Arrays;
+import java.util.Locale;
+
public class SettingsFragment extends NamedFragment {
private FragmentSettingsBinding binding;
@@ -32,6 +36,32 @@ public class SettingsFragment extends NamedFragment {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentSettingsBinding.inflate(inflater);
+ Locale[] locales = new Locale[] {Locale.ENGLISH, Locale.GERMAN};
+
+ String[] localeNames = new String[locales.length];
+ for(int i = 0; i < locales.length; i++) {
+ localeNames[i] = locales[i].getDisplayName(locales[i]);
+ }
+
+ binding.settingsLanguage.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, localeNames));
+ binding.settingsLanguage.setSelection(Arrays.asList(locales).indexOf(SettingsUtil.getLocale(requireContext())));
+ binding.settingsLanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ Locale locale = locales[position];
+ if(locale.equals(SettingsUtil.getLocale(requireContext()))) return;
+
+ SettingsUtil.setLocale(requireContext(), locale);
+ ((MainActivity) requireActivity()).setLocale(locale);
+ requireActivity().recreate();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+
+ }
+ });
+
binding.settingsEnableIntroVideo.setChecked(SettingsUtil.isIntroVideoEnabled(requireContext()));
binding.settingsEnableIntroVideo.setOnCheckedChangeListener((view, checked) -> SettingsUtil.setEnableIntroVideo(requireContext(), checked));
diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java
index afdd207..5aca3d5 100644
--- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java
+++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java
@@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
public class SettingsUtil {
@@ -130,6 +131,15 @@ public class SettingsUtil {
return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getString("theme", THEME_NAMES.get(0));
}
+ public static void setLocale(Context ctx, Locale locale) {
+ SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE);
+ prefs.edit().putString("locale", locale.getLanguage()).apply();
+ }
+
+ public static Locale getLocale(Context ctx) {
+ return new Locale(ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getString("locale", Locale.ENGLISH.getLanguage()));
+ }
+
public static void enableSuperSecretHamburgers(Context ctx) {
ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).edit().putBoolean("iLikeHamburgers", true).apply();
}
diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml
index 7dec78d..e0e9e69 100644
--- a/app/src/main/res/layout/fragment_settings.xml
+++ b/app/src/main/res/layout/fragment_settings.xml
@@ -11,17 +11,24 @@
android:padding="16dp"
android:orientation="vertical">
+
+
+ android:text="@string/settings_enable_intro_video" />
+ android:text="@string/settings_biometric_lock" />
Löschen?
OTP löschen?
Gruppe bearbeiten
+ Intro-Video zeigen
+ Biometrische Authentifizierung aktivieren
- Anzeigen
- Bearbeiten
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e7f76ba..77b25c3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -74,6 +74,8 @@
Delete?
Delete this?
Edit Group
+ Enable intro video
+ Require biometric unlock
- View
- Edit