diff --git a/app/src/main/java/org/bepass/oblivion/ui/SettingsActivity.java b/app/src/main/java/org/bepass/oblivion/ui/SettingsActivity.java index 8dcab339..a2d21149 100644 --- a/app/src/main/java/org/bepass/oblivion/ui/SettingsActivity.java +++ b/app/src/main/java/org/bepass/oblivion/ui/SettingsActivity.java @@ -156,15 +156,14 @@ public void onNothingSelected(AdapterView parent) { FileManager.set("USERSETTING_proxymode", isChecked); }; - binding.txtDarkMode.setOnClickListener(view -> binding.checkBoxDarkMode.setChecked(!binding.checkBoxDarkMode.isChecked())); - - // Set the initial state of the checkbox based on the current theme - binding.checkBoxDarkMode.setChecked(ThemeHelper.getInstance().getCurrentTheme() == ThemeHelper.Theme.DARK); - // Set up the listener to change the theme when the checkbox is toggled - binding.checkBoxDarkMode.setOnCheckedChangeListener((buttonView, isChecked) -> { - // Determine the new theme based on the checkbox state - ThemeHelper.Theme newTheme = isChecked ? ThemeHelper.Theme.DARK : ThemeHelper.Theme.LIGHT; - + binding.txtDarkMode.setOnClickListener(view -> binding.switchDarkMode.setChecked(!binding.switchDarkMode.isActivated())); + + // Set the initial state of the switch based on the current theme + binding.switchDarkMode.setChecked(ThemeHelper.getInstance().getCurrentTheme() == ThemeHelper.Theme.DARK); + // Set up the listener to change the theme when the switch is toggled + binding.switchDarkMode.setOnCheckedChangeListener((buttonView, isActive) -> { + // Determine the new theme based on the switch state + ThemeHelper.Theme newTheme = isActive ? ThemeHelper.Theme.DARK : ThemeHelper.Theme.LIGHT; // Use ThemeHelper to apply the new theme ThemeHelper.getInstance().select(newTheme); }); @@ -195,7 +194,13 @@ private void settingBasicValuesFromSPF() { binding.license.setText(FileManager.getString("USERSETTING_license")); int index = FileManager.getInt("USERSETTING_country_index"); - ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.countries, R.layout.country_item_layout); + String[] countryList = getResources().getStringArray(R.array.countries); + String[] countryLocaleList = getResources().getStringArray(R.array.localeCountries); + String[] countryFlagList = new String[countryList.length]; + for (int i= 0;i adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,countryFlagList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); binding.country.post(() -> { binding.country.setAdapter(adapter); diff --git a/app/src/main/java/org/bepass/oblivion/utils/CountryUtils.java b/app/src/main/java/org/bepass/oblivion/utils/CountryUtils.java index 8c071599..7195dc6f 100644 --- a/app/src/main/java/org/bepass/oblivion/utils/CountryUtils.java +++ b/app/src/main/java/org/bepass/oblivion/utils/CountryUtils.java @@ -35,6 +35,17 @@ public static Triple getCountryCode(Context context, St // Return the triple of country code, full country name, and index return new Triple<>(countryCode, countryCodeAndName.component2(), countryCodeAndName.component3()); } + + public static String localeToFlagEmoji(String locale) { + // Convert the country code to the flag emoji + StringBuilder flagEmoji = new StringBuilder(); + for (char character : locale.toCharArray()) { + // Convert each character to the corresponding regional indicator symbol + flagEmoji.append(Character.toChars(character + 127397)); + } + + return flagEmoji.toString(); + } private static Triple translateToEnglish(String name, String[] translatedNames, String[] englishNames) { for (int i = 0; i < translatedNames.length; i++) { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 5a978869..7a39117c 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -420,15 +420,12 @@ android:layout_height="wrap_content" android:layout_weight="2"> - + + United Kingdom United States + + AU + AT + BE + BG + CA + HR + CZ + DK + EE + FI + FR + DE + HU + IN + IE + IT + JP + LV + NL + NO + PL + PT + RO + RS + SG + SK + ES + SE + CH + GB + US + Auto IPv4