fix issue #23 - Theme changing does not work

This commit is contained in:
Thomas 2022-05-05 18:55:28 +02:00
parent 0d5cf035a9
commit 8523f7340a
10 changed files with 24 additions and 6 deletions

View file

@ -61,9 +61,9 @@ public class MainApplication extends MultiDexApplication {
List<CyaneaTheme> list = CyaneaTheme.Companion.from(getAssets(), "themes/cyanea_themes.json");
int theme = sharedpreferences.getInt(getString(R.string.SET_THEME), 0);
boolean custom_theme = sharedpreferences.getBoolean("use_custom_theme", false);
if (!custom_theme) {
/*if (!custom_theme) {
list.get(theme).apply(Cyanea.getInstance());
}
}*/
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());

View file

@ -101,6 +101,14 @@ public class ThemeHelper {
}
}
public static int getBackgroundColor(Context context) {
if (Cyanea.getInstance().isDark()) {
return ContextCompat.getColor(context, R.color.cyanea_background_dark);
} else {
return ContextCompat.getColor(context, R.color.cyanea_background_light);
}
}
public static void applyThemeBar(BaseActivity activity) {
if (Cyanea.getInstance().isDark()) {
activity.setTheme(R.style.AppThemeBarDark);

View file

@ -40,6 +40,7 @@ import app.fedilab.android.client.mastodon.entities.RelationShip;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MastodonHelper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.AccountAdapter;
import app.fedilab.android.ui.pageadapter.FedilabProfileTLPageAdapter;
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
@ -70,7 +71,7 @@ public class FragmentMastodonAccount extends Fragment {
viewModelKey = getArguments().getString(Helper.ARG_VIEW_MODEL_KEY, "");
timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE);
}
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
flagLoading = false;
binding = FragmentPaginationBinding.inflate(inflater, container, false);
return binding.getRoot();

View file

@ -36,6 +36,7 @@ import app.fedilab.android.client.mastodon.entities.Status;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.helper.DividerDecoration;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.StatusAdapter;
import app.fedilab.android.viewmodel.mastodon.StatusesVM;
@ -68,7 +69,7 @@ public class FragmentMastodonContext extends Fragment {
binding.swipeContainer.setColorSchemeColors(
c1, c1, c1
);
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
statusesVM = new ViewModelProvider(FragmentMastodonContext.this).get(StatusesVM.class);
binding.recyclerView.setNestedScrollingEnabled(true);
this.statuses = new ArrayList<>();

View file

@ -36,6 +36,7 @@ import app.fedilab.android.client.mastodon.entities.Conversation;
import app.fedilab.android.client.mastodon.entities.Conversations;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.helper.MastodonHelper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.ConversationAdapter;
import app.fedilab.android.viewmodel.mastodon.TimelinesVM;
@ -56,6 +57,7 @@ public class FragmentMastodonConversation extends Fragment {
currentFragment = this;
flagLoading = false;
binding = FragmentPaginationBinding.inflate(inflater, container, false);
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
return binding.getRoot();
}

View file

@ -40,6 +40,7 @@ import app.fedilab.android.client.mastodon.entities.Notifications;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MastodonHelper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.NotificationAdapter;
import app.fedilab.android.viewmodel.mastodon.NotificationsVM;
@ -67,6 +68,7 @@ public class FragmentMastodonNotification extends Fragment {
if (getArguments() != null) {
notificationType = (NotificationTypeEnum) getArguments().get(Helper.ARG_NOTIFICATION_TYPE);
}
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
String excludedCategories = sharedpreferences.getString(getString(R.string.SET_EXCLUDED_NOTIFICATIONS_TYPE) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance, null);
int c1 = getResources().getColor(R.color.cyanea_accent_reference);

View file

@ -34,6 +34,7 @@ import app.fedilab.android.client.mastodon.entities.Tag;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MastodonHelper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.TagAdapter;
import app.fedilab.android.viewmodel.mastodon.SearchVM;
@ -52,6 +53,7 @@ public class FragmentMastodonTag extends Fragment {
}
binding = FragmentPaginationBinding.inflate(inflater, container, false);
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
return binding.getRoot();
}

View file

@ -51,6 +51,7 @@ import app.fedilab.android.client.mastodon.entities.Statuses;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MastodonHelper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.StatusAdapter;
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
import app.fedilab.android.viewmodel.mastodon.SearchVM;
@ -162,6 +163,7 @@ public class FragmentMastodonTimeline extends Fragment {
}
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION));
binding = FragmentPaginationBinding.inflate(inflater, container, false);
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
return binding.getRoot();
}

View file

@ -15,7 +15,7 @@
see <http://www.gnu.org/licenses>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/cyanea_background_dark"
android:layout_width="match_parent"
android:layout_height="match_parent">

View file

@ -5,7 +5,7 @@
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="card_margin">12dp</dimen>
<dimen name="card_margin">6dp</dimen>
<dimen name="drawer_padding">2dp</dimen>
<dimen name="toot_padding">10dp</dimen>
<bool name="isTablet">false</bool>