Fix dialog colors in Settings

This commit is contained in:
Thomas 2024-01-16 17:45:55 +01:00
parent aa45683a4f
commit 246bc7e557
8 changed files with 104 additions and 11 deletions

View file

@ -19,6 +19,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.MultiSelectListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
@ -30,6 +31,7 @@ import java.util.Set;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.client.entities.app.Languages;
import app.fedilab.android.mastodon.helper.Helper;
public class FragmentComposeSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -43,12 +45,21 @@ public class FragmentComposeSettings extends PreferenceFragmentCompat implements
private void createPref() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
//Theme for dialogs
ListPreference SET_THREAD_MESSAGE = findPreference(getString(R.string.SET_THREAD_MESSAGE));
if (SET_THREAD_MESSAGE != null) {
SET_THREAD_MESSAGE.getContext().setTheme(Helper.dialogStyle());
}
//---------
EditTextPreference SET_WATERMARK_TEXT = findPreference(getString(R.string.SET_WATERMARK_TEXT));
if (SET_WATERMARK_TEXT != null) {
String val = sharedPreferences.getString(getString(R.string.SET_WATERMARK_TEXT) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance, sharedPreferences.getString(getString(R.string.SET_WATERMARK_TEXT), null));
SET_WATERMARK_TEXT.setText(val);
}
MultiSelectListPreference SET_SELECTED_LANGUAGE = findPreference(getString(R.string.SET_SELECTED_LANGUAGE));
if (SET_SELECTED_LANGUAGE != null) {

View file

@ -25,6 +25,7 @@ import androidx.preference.SwitchPreferenceCompat;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.mastodon.helper.Helper;
public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -41,6 +42,18 @@ public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat impl
addPreferencesFromResource(R.xml.pref_extra_features);
PreferenceScreen preferenceScreen = getPreferenceScreen();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
//Theme for dialogs
ListPreference SET_POST_FORMAT = findPreference(getString(R.string.SET_POST_FORMAT));
if (SET_POST_FORMAT != null) {
SET_POST_FORMAT.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_COMPOSE_LOCAL_ONLY = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW));
if (SET_COMPOSE_LOCAL_ONLY != null) {
SET_COMPOSE_LOCAL_ONLY.getContext().setTheme(Helper.dialogStyle());
}
//---------
SwitchPreferenceCompat SET_EXTAND_EXTRA_FEATURES = findPreference(getString(R.string.SET_EXTAND_EXTRA_FEATURES));
if (SET_EXTAND_EXTRA_FEATURES != null) {
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
@ -69,13 +82,11 @@ public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat impl
SET_DISPLAY_REACTIONS.setChecked(checked);
}
ListPreference SET_POST_FORMAT = findPreference(getString(R.string.SET_POST_FORMAT));
if (SET_POST_FORMAT != null) {
String format = sharedpreferences.getString(getString(R.string.SET_POST_FORMAT) + MainActivity.currentUserID + MainActivity.currentInstance, "text/plain");
SET_POST_FORMAT.setValue(format);
}
ListPreference SET_COMPOSE_LOCAL_ONLY = findPreference(getString(R.string.SET_COMPOSE_LOCAL_ONLY));
if (SET_COMPOSE_LOCAL_ONLY != null) {
int localOnly = sharedpreferences.getInt(getString(R.string.SET_COMPOSE_LOCAL_ONLY) + MainActivity.currentUserID + MainActivity.currentInstance, 0);
SET_COMPOSE_LOCAL_ONLY.setValue(String.valueOf(localOnly));

View file

@ -63,13 +63,21 @@ public class FragmentHomeCacheSettings extends PreferenceFragmentCompat implemen
return;
}
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
//Theme for dialogs
ListPreference SET_FETCH_HOME_DELAY_VALUE = findPreference(getString(R.string.SET_FETCH_HOME_DELAY_VALUE));
if (SET_FETCH_HOME_DELAY_VALUE != null) {
SET_FETCH_HOME_DELAY_VALUE.getContext().setTheme(Helper.dialogStyle());
}
//---------
SwitchPreference SET_FETCH_HOME = findPreference(getString(R.string.SET_FETCH_HOME));
if (SET_FETCH_HOME != null) {
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_FETCH_HOME) + MainActivity.currentUserID + MainActivity.currentInstance, false);
SET_FETCH_HOME.setChecked(checked);
}
ListPreference SET_FETCH_HOME_DELAY_VALUE = findPreference(getString(R.string.SET_FETCH_HOME_DELAY_VALUE));
if (SET_FETCH_HOME_DELAY_VALUE != null) {
String timeRefresh = sharedpreferences.getString(getString(R.string.SET_FETCH_HOME_DELAY_VALUE) + MainActivity.currentUserID + MainActivity.currentInstance, "60");
SET_FETCH_HOME_DELAY_VALUE.setValue(timeRefresh);

View file

@ -33,6 +33,7 @@ import app.fedilab.android.BuildConfig;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.ImageListPreference;
import app.fedilab.android.mastodon.helper.LogoHelper;
import es.dmoral.toasty.Toasty;
@ -54,6 +55,13 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen
Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
return;
}
//Theme for dialogs
ImageListPreference SET_LOGO_LAUNCHER = findPreference(getString(R.string.SET_LOGO_LAUNCHER));
if (SET_LOGO_LAUNCHER != null) {
SET_LOGO_LAUNCHER.getContext().setTheme(Helper.dialogStyle());
}
//---------
SeekBarPreference SET_FONT_SCALE = findPreference(getString(R.string.SET_FONT_SCALE_INT));
if (SET_FONT_SCALE != null) {
SET_FONT_SCALE.setMax(180);
@ -64,7 +72,6 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen
SET_FONT_SCALE_ICON.setMax(180);
SET_FONT_SCALE_ICON.setMin(80);
}
ListPreference SET_LOGO_LAUNCHER = findPreference(getString(R.string.SET_LOGO_LAUNCHER));
if (SET_LOGO_LAUNCHER != null) {
SET_LOGO_LAUNCHER.setIcon(LogoHelper.getDrawable(SET_LOGO_LAUNCHER.getValue()));
}

View file

@ -18,6 +18,7 @@ import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
@ -37,6 +38,14 @@ public class FragmentLanguageSettings extends PreferenceFragmentCompat implement
private void createPref() {
Preference SET_TRANSLATE_VALUES_RESET = findPreference(getString(R.string.SET_TRANSLATE_VALUES_RESET));
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
//Theme for dialogs
ListPreference SET_DEFAULT_LOCALE_NEW = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW));
if (SET_DEFAULT_LOCALE_NEW != null) {
SET_DEFAULT_LOCALE_NEW.getContext().setTheme(Helper.dialogStyle());
}
//---------
if (SET_TRANSLATE_VALUES_RESET != null) {
SET_TRANSLATE_VALUES_RESET.setOnPreferenceClickListener(preference -> {
SharedPreferences.Editor editor = sharedPreferences.edit();

View file

@ -40,6 +40,7 @@ import java.util.ArrayList;
import java.util.List;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.PushHelper;
import app.fedilab.android.mastodon.helper.settings.TimePreference;
import app.fedilab.android.mastodon.helper.settings.TimePreferenceDialogFragment;
@ -76,13 +77,37 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl
getPreferenceScreen().removeAll();
addPreferencesFromResource(R.xml.pref_notifications);
PreferenceScreen preferenceScreen = getPreferenceScreen();
//Theme for dialogs
ListPreference SET_NOTIFICATION_TYPE = findPreference(getString(R.string.SET_NOTIFICATION_TYPE));
if (SET_NOTIFICATION_TYPE != null) {
SET_NOTIFICATION_TYPE.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference(getString(R.string.SET_NOTIFICATION_DELAY_VALUE));
if (SET_NOTIFICATION_DELAY_VALUE != null) {
SET_NOTIFICATION_DELAY_VALUE.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_PUSH_DISTRIBUTOR = findPreference(getString(R.string.SET_PUSH_DISTRIBUTOR));
if (SET_PUSH_DISTRIBUTOR != null) {
SET_PUSH_DISTRIBUTOR.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_LED_COLOUR_VAL_N = findPreference(getString(R.string.SET_LED_COLOUR_VAL_N));
if (SET_LED_COLOUR_VAL_N != null) {
SET_LED_COLOUR_VAL_N.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_NOTIFICATION_ACTION = findPreference(getString(R.string.SET_NOTIFICATION_ACTION));
if (SET_NOTIFICATION_ACTION != null) {
SET_NOTIFICATION_ACTION.getContext().setTheme(Helper.dialogStyle());
}
//---------
if (preferenceScreen == null) {
Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
return;
}
ListPreference SET_NOTIFICATION_TYPE = findPreference(getString(R.string.SET_NOTIFICATION_TYPE));
String[] notificationValues = getResources().getStringArray(R.array.SET_NOTIFICATION_TYPE_VALUE);
if (SET_NOTIFICATION_TYPE != null && SET_NOTIFICATION_TYPE.getValue().equals(notificationValues[2])) {
PreferenceCategory notification_sounds = findPreference("notification_sounds");
@ -97,26 +122,21 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl
if (notification_time_slot != null) {
preferenceScreen.removePreference(notification_time_slot);
}
ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference("SET_NOTIFICATION_DELAY_VALUE");
if (SET_NOTIFICATION_DELAY_VALUE != null) {
preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE");
}
ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR");
if (SET_PUSH_DISTRIBUTOR != null) {
preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR");
}
return;
} else if (SET_NOTIFICATION_TYPE != null && SET_NOTIFICATION_TYPE.getValue().equals(notificationValues[1])) {
ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR");
if (SET_PUSH_DISTRIBUTOR != null) {
preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR");
}
} else {
ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference("SET_NOTIFICATION_DELAY_VALUE");
if (SET_NOTIFICATION_DELAY_VALUE != null) {
preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE");
}
ListPreference SET_PUSH_DISTRIBUTOR = findPreference(getString(R.string.SET_PUSH_DISTRIBUTOR));
if (SET_PUSH_DISTRIBUTOR != null) {
List<String> distributors = UnifiedPush.getDistributors(requireActivity(), new ArrayList<>());
SET_PUSH_DISTRIBUTOR.setValue(UnifiedPush.getDistributor(requireActivity()));

View file

@ -114,6 +114,22 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements
Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
}
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
//Theme for dialogs
ListPreference SET_THEME_BASE = findPreference(getString(R.string.SET_THEME_BASE));
if (SET_THEME_BASE != null) {
SET_THEME_BASE.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_THEME_DEFAULT_LIGHT = findPreference(getString(R.string.SET_THEME_DEFAULT_LIGHT));
if (SET_THEME_DEFAULT_LIGHT != null) {
SET_THEME_DEFAULT_LIGHT.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_THEME_DEFAULT_DARK = findPreference(getString(R.string.SET_THEME_DEFAULT_DARK));
if (SET_THEME_DEFAULT_DARK != null) {
SET_THEME_DEFAULT_DARK.getContext().setTheme(Helper.dialogStyle());
}
//---------
SwitchPreferenceCompat SET_DYNAMIC_COLOR = findPreference(getString(R.string.SET_DYNAMICCOLOR));
SwitchPreferenceCompat SET_CUSTOM_ACCENT = findPreference(getString(R.string.SET_CUSTOM_ACCENT));
ColorPreferenceCompat SET_CUSTOM_ACCENT_DARK_VALUE = findPreference(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE));

View file

@ -48,7 +48,18 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
ListPreference SET_TRANSLATOR = findPreference(getString(R.string.SET_TRANSLATOR));
ListPreference SET_TRANSLATOR_VERSION = findPreference(getString(R.string.SET_TRANSLATOR_VERSION));
//Theme for dialogs
if (SET_TRANSLATOR_VERSION != null) {
SET_TRANSLATOR_VERSION.getContext().setTheme(Helper.dialogStyle());
}
if (SET_TRANSLATOR != null) {
SET_TRANSLATOR.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_LOAD_MEDIA_TYPE = findPreference(getString(R.string.SET_LOAD_MEDIA_TYPE));
if (SET_LOAD_MEDIA_TYPE != null) {
SET_LOAD_MEDIA_TYPE.getContext().setTheme(Helper.dialogStyle());
}
//---------
EditTextPreference SET_TRANSLATOR_API_KEY = findPreference(getString(R.string.SET_TRANSLATOR_API_KEY));
EditTextPreference SET_TRANSLATOR_DOMAIN = findPreference(getString(R.string.SET_TRANSLATOR_DOMAIN));
if (SET_TRANSLATOR != null && !SET_TRANSLATOR.getValue().equals("DEEPL")) {