From fc3589288383b51256cd326e4c1e7a0ecbe3abba Mon Sep 17 00:00:00 2001 From: cepprice Date: Mon, 29 Mar 2021 22:50:51 +0500 Subject: [PATCH] Fix nigth mode for cards --- .../plus/routepreparationmenu/cards/BaseCard.java | 6 +++++- .../settings/fragments/SubscriptionsCard.java | 2 +- .../settings/fragments/SubscriptionsListCard.java | 2 +- .../TroubleshootingOrPurchasingCard.java | 15 +++++++-------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java index d4101e58ec..fc24f9bace 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java @@ -39,9 +39,13 @@ public abstract class BaseCard { } public BaseCard(@NonNull MapActivity mapActivity) { + this(mapActivity, true); + } + + public BaseCard(@NonNull MapActivity mapActivity, boolean usedOnMap) { this.mapActivity = mapActivity; this.app = mapActivity.getMyApplication(); - nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls(); + nightMode = usedOnMap ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent(); } public abstract int getCardLayoutId(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java index 100bab00df..3b5e537196 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java @@ -40,7 +40,7 @@ public class SubscriptionsCard extends BaseCard { } public SubscriptionsCard(@NonNull MapActivity mapActivity, @NonNull Fragment target, @NonNull InAppPurchaseHelper purchaseHelper) { - super(mapActivity); + super(mapActivity, false); this.target = target; this.purchaseHelper = purchaseHelper; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java index 9d8d4f9568..645a68b037 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java @@ -39,7 +39,7 @@ public class SubscriptionsListCard extends BaseCard { } public SubscriptionsListCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper) { - super(mapActivity); + super(mapActivity, false); this.purchaseHelper = purchaseHelper; this.dateFormat = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java index c53950ee2b..44fb4a980b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java @@ -20,7 +20,6 @@ import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.wikipedia.WikipediaDialogFragment; -import androidx.annotation.IdRes; import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; import androidx.core.content.ContextCompat; @@ -41,15 +40,15 @@ public class TroubleshootingOrPurchasingCard extends BaseCard { } public TroubleshootingOrPurchasingCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper, boolean isPaidVersion) { - super(mapActivity); + super(mapActivity, false); this.purchaseHelper = purchaseHelper; this.isPaidVersion = isPaidVersion; } @Override protected void updateContent() { - setupRestorePurchasesBtn(R.id.restore_purchases); - setupNewDeviceOrAccountBtn(R.id.new_device_account_container); + setupRestorePurchasesBtn(); + setupNewDeviceOrAccountBtn(); setupSupportDescription(); setupContactUsLink(); @@ -82,8 +81,8 @@ public class TroubleshootingOrPurchasingCard extends BaseCard { } } - protected void setupRestorePurchasesBtn(@IdRes int btnId) { - View purchasesRestore = view.findViewById(btnId); + protected void setupRestorePurchasesBtn() { + View purchasesRestore = view.findViewById(R.id.restore_purchases); purchasesRestore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -94,8 +93,8 @@ public class TroubleshootingOrPurchasingCard extends BaseCard { }); } - protected void setupNewDeviceOrAccountBtn(@IdRes int btnId) { - View newDeviceAccountContainer = view.findViewById(btnId); + protected void setupNewDeviceOrAccountBtn() { + View newDeviceAccountContainer = view.findViewById(R.id.new_device_account_container); newDeviceAccountContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {