Some fixes with the theme

This commit is contained in:
Thomas 2022-12-02 09:57:23 +01:00
parent 5fdb654aa2
commit c2c780f58e
5 changed files with 37 additions and 9 deletions

View File

@ -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;
}
}

View File

@ -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,

View File

@ -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) -> {

View File

@ -2,8 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/fab_margin">
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"

View File

@ -23,6 +23,7 @@
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurface"
android:orientation="horizontal">
<com.google.android.material.tabs.TabLayout
@ -33,14 +34,14 @@
app:tabGravity="fill"
app:tabMaxWidth="0dp" />
<androidx.appcompat.widget.AppCompatImageButton
<com.google.android.material.button.MaterialButton
android:id="@+id/settings"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.Material3.Button.OutlinedButton.Icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:minWidth="48dp"
android:src="@drawable/ic_more" />
app:icon="@drawable/ic_more" />
</androidx.appcompat.widget.LinearLayoutCompat>