diff --git a/android/lib/src/main/java/com/ern/api/impl/core/ActivityDelegateConstants.java b/android/lib/src/main/java/com/ern/api/impl/core/ActivityDelegateConstants.java index 7a9f4430..ae3d022f 100644 --- a/android/lib/src/main/java/com/ern/api/impl/core/ActivityDelegateConstants.java +++ b/android/lib/src/main/java/com/ern/api/impl/core/ActivityDelegateConstants.java @@ -20,6 +20,7 @@ public class ActivityDelegateConstants { public static final String KEY_MINI_APP_COMPONENT_NAME = "miniAppComponentName"; public static final String KEY_MINI_APP_FRAGMENT_TAG = "miniAppFragmentTag"; public static final String KEY_MINI_APP_FRAGMENT_SHOW_UP_ENABLED = "displayHomeAsUpEnabled"; + public static final String KEY_MINI_APP_FRAGMENT_HIDE_UP_INDICATOR = "hideUpIndicatorIcon"; public static final String KEY_REGISTER_NAV_VIEW_MODEL = "shouldRegisterNavViewModel"; } diff --git a/android/lib/src/main/java/com/ern/api/impl/core/ElectrodeBaseActivityDelegate.java b/android/lib/src/main/java/com/ern/api/impl/core/ElectrodeBaseActivityDelegate.java index 42c03b08..9fe2b8a7 100644 --- a/android/lib/src/main/java/com/ern/api/impl/core/ElectrodeBaseActivityDelegate.java +++ b/android/lib/src/main/java/com/ern/api/impl/core/ElectrodeBaseActivityDelegate.java @@ -136,6 +136,9 @@ public void startMiniAppFragment(@NonNull String componentName, @NonNull LaunchC Bundle props = launchConfig.mInitialProps != null ? launchConfig.mInitialProps : new Bundle(); props.putString(ActivityDelegateConstants.KEY_MINI_APP_COMPONENT_NAME, componentName); props.putBoolean(ActivityDelegateConstants.KEY_MINI_APP_FRAGMENT_SHOW_UP_ENABLED, shouldShowUpEnabled(launchConfig.mForceUpEnabled)); + if (!launchConfig.mForceUpEnabled) { + props.putBoolean(ActivityDelegateConstants.KEY_MINI_APP_FRAGMENT_HIDE_UP_INDICATOR, launchConfig.mHideUpIndicatorIcon); + } fragment.setArguments(props); Logger.d(TAG, "starting fragment: fragmentClass->%s, props->%s", fragment.getClass().getSimpleName(), props); diff --git a/android/lib/src/main/java/com/ern/api/impl/core/LaunchConfig.java b/android/lib/src/main/java/com/ern/api/impl/core/LaunchConfig.java index 5ced0374..2774b639 100644 --- a/android/lib/src/main/java/com/ern/api/impl/core/LaunchConfig.java +++ b/android/lib/src/main/java/com/ern/api/impl/core/LaunchConfig.java @@ -58,6 +58,11 @@ public class LaunchConfig { */ boolean mForceUpEnabled; + /** + * Set this to true if you want to hide the up indicator for a component + */ + boolean mHideUpIndicatorIcon; + /** * Shows your next page view component as an overLay on top of the existing screen * This flag is ignored if the component is the root component. @@ -157,6 +162,23 @@ public void setForceUpEnabled(boolean forceUpEnabled) { mForceUpEnabled = forceUpEnabled; } + /** + * Set this to true will hide the up indicator for a given page. + * Setting this to false will do nothing but falling back to the default ActionBar behavior. + * i.e, if the app bar has an icon then it will show up and vice versa. + */ + public void setHideUpIndicatorIcon(boolean mHideUpIndicatorIcon) { + this.mHideUpIndicatorIcon = mHideUpIndicatorIcon; + } + + /** + * Should hide up indicator for a component + * * @return true | false + */ + public boolean isHideUpIndicatorIcon() { + return mHideUpIndicatorIcon; + } + /** * Shows your next page view component as an overLay on top of the existing screen * This flag is ignored if the component is the root component. diff --git a/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeBaseActivity.java b/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeBaseActivity.java index 532d6a3a..36ca9646 100644 --- a/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeBaseActivity.java +++ b/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeBaseActivity.java @@ -106,6 +106,7 @@ protected LaunchConfig createDefaultLaunchConfig() { defaultLaunchConfig.setFragmentContainerId(getFragmentContainerId()); defaultLaunchConfig.setFragmentManager(getSupportFragmentManager()); defaultLaunchConfig.updateInitialProps(getProps()); + defaultLaunchConfig.setHideUpIndicatorIcon(true); return defaultLaunchConfig; } diff --git a/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeNavigationFragmentDelegate.java b/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeNavigationFragmentDelegate.java index faeacf7b..4d977e6b 100644 --- a/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeNavigationFragmentDelegate.java +++ b/android/lib/src/main/java/com/ern/api/impl/navigation/ElectrodeNavigationFragmentDelegate.java @@ -383,10 +383,15 @@ private void updateHomeAsUpIndicator(@Nullable NavigationBarLeftButton leftButto } //Default action - if (mFragment.getArguments() != null && mFragment.getArguments().getBoolean(ActivityDelegateConstants.KEY_MINI_APP_FRAGMENT_SHOW_UP_ENABLED)) { - Logger.d(TAG, "Defaulting up indicator for component: %s", getReactComponentName()); - supportActionBar.setHomeAsUpIndicator(0); - supportActionBar.setDisplayHomeAsUpEnabled(true); + if (mFragment.getArguments() != null) { + if (mFragment.getArguments().getBoolean(ActivityDelegateConstants.KEY_MINI_APP_FRAGMENT_SHOW_UP_ENABLED)) { + Logger.d(TAG, "Enabling up indicator for component: %s", getReactComponentName()); + supportActionBar.setHomeAsUpIndicator(0); + supportActionBar.setDisplayHomeAsUpEnabled(true); + } else if (mFragment.getArguments().getBoolean(ActivityDelegateConstants.KEY_MINI_APP_FRAGMENT_HIDE_UP_INDICATOR)) { + Logger.d(TAG, "Hiding up indicator for component: %s", getReactComponentName()); + supportActionBar.setDisplayHomeAsUpEnabled(false); + } } } else { Logger.i(TAG, "Action bar is null, skipping updateHomeAsUpIndicator");