From c2c780f58e5df70a1ba6ec6460090f800d7f3b04 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 2 Dec 2022 09:57:23 +0100 Subject: [PATCH] Some fixes with the theme --- .../fedilab/android/activities/BaseActivity.java | 12 ++++++++++++ .../java/app/fedilab/android/helper/Helper.java | 15 +++++++++++++++ .../timeline/FragmentNotificationContainer.java | 5 +++-- .../main/res/layout/activity_followed_tags.xml | 3 +-- .../layout/fragment_notification_container.xml | 11 ++++++----- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseActivity.java index fec63c0a..be483f80 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseActivity.java @@ -38,6 +38,8 @@ import app.fedilab.android.helper.ThemeHelper; @SuppressLint("Registered") public class BaseActivity extends AppCompatActivity { + public static int currentThemeId; + static { Helper.installProvider(); EmojiManager.install(new EmojiOneProvider()); @@ -58,9 +60,11 @@ public class BaseActivity extends AppCompatActivity { switch (defaultLight) { case "LIGHT": setTheme(R.style.AppTheme); + currentThemeId = R.style.AppTheme; break; case "SOLARIZED_LIGHT": setTheme(R.style.SolarizedAppTheme); + currentThemeId = R.style.SolarizedAppTheme; break; } break; @@ -69,12 +73,15 @@ public class BaseActivity extends AppCompatActivity { switch (defaultDark) { case "DARK": setTheme(R.style.AppTheme); + currentThemeId = R.style.AppTheme; break; case "SOLARIZED_DARK": setTheme(R.style.SolarizedAppTheme); + currentThemeId = R.style.SolarizedAppTheme; break; case "BLACK": setTheme(R.style.BlackAppTheme); + currentThemeId = R.style.BlackAppTheme; break; } break; @@ -84,22 +91,27 @@ public class BaseActivity extends AppCompatActivity { case "LIGHT": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setTheme(R.style.AppTheme); + currentThemeId = R.style.AppTheme; break; case "DARK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.AppTheme); + currentThemeId = R.style.AppTheme; break; case "SOLARIZED_LIGHT": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setTheme(R.style.SolarizedAppTheme); + currentThemeId = R.style.SolarizedAppTheme; break; case "SOLARIZED_DARK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.SolarizedAppTheme); + currentThemeId = R.style.SolarizedAppTheme; break; case "BLACK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.BlackAppTheme); + currentThemeId = R.style.BlackAppTheme; break; } } diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 71977da1..c46702ca 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -16,6 +16,7 @@ package app.fedilab.android.helper; import static android.content.Context.DOWNLOAD_SERVICE; import static app.fedilab.android.BaseMainActivity.currentAccount; +import static app.fedilab.android.activities.BaseActivity.currentThemeId; import static app.fedilab.android.helper.LogoHelper.getNotificationIcon; import static app.fedilab.android.webview.ProxyHelper.setProxy; @@ -31,6 +32,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; @@ -1984,6 +1986,19 @@ public class Helper { } + public static int dialogStyle() { + PackageInfo packageInfo = null; + if (R.style.AppThemeBar == currentThemeId || R.style.AppTheme == currentThemeId) { + return R.style.AppThemeAlertDialog; + } else if (R.style.SolarizedAppThemeBar == currentThemeId || R.style.SolarizedAppTheme == currentThemeId) { + return R.style.SolarizedAlertDialog; + } else if (R.style.BlackAppThemeBar == currentThemeId || R.style.BlackAppTheme == currentThemeId) { + return R.style.BlackAlertDialog; + } + return R.style.AppTheme; + } + + //Enum that described actions to replace inside a toot content public enum PatternType { MENTION, diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java index 2b466ff5..9b459689 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java @@ -43,6 +43,7 @@ import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.databinding.FragmentNotificationContainerBinding; import app.fedilab.android.databinding.PopupNotificationSettingsBinding; +import app.fedilab.android.helper.Helper; import app.fedilab.android.ui.pageadapter.FedilabNotificationPageAdapter; import app.fedilab.android.viewmodel.mastodon.NotificationsVM; import es.dmoral.toasty.Toasty; @@ -85,13 +86,13 @@ public class FragmentNotificationContainer extends Fragment { } AtomicBoolean changes = new AtomicBoolean(false); binding.settings.setOnClickListener(v -> { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireActivity()); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireActivity(), Helper.dialogStyle()); PopupNotificationSettingsBinding dialogView = PopupNotificationSettingsBinding.inflate(getLayoutInflater()); dialogBuilder.setView(dialogView.getRoot()); dialogView.clearAllNotif.setOnClickListener(v1 -> { - AlertDialog.Builder db = new AlertDialog.Builder(requireActivity()); + AlertDialog.Builder db = new AlertDialog.Builder(requireActivity(), Helper.dialogStyle()); db.setTitle(R.string.delete_notification_ask_all); db.setMessage(R.string.delete_notification_all_warning); db.setPositiveButton(R.string.delete_all, (dialog, id) -> { diff --git a/app/src/main/res/layout/activity_followed_tags.xml b/app/src/main/res/layout/activity_followed_tags.xml index 86677674..d3ce5ec5 100644 --- a/app/src/main/res/layout/activity_followed_tags.xml +++ b/app/src/main/res/layout/activity_followed_tags.xml @@ -2,8 +2,7 @@ + android:orientation="vertical"> - + app:icon="@drawable/ic_more" />