Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e726a4f3 authored by Erica Chang's avatar Erica Chang
Browse files

Contacts : fix FAB when an InCall plugin tab is in focus

There was an issue where the FAB was not updated onResume right after
an InCall plugin auth state change. onPrepareOptionsMenu is always called
upon onResume to update the InCall plugin FAB, but it's always called before
the plugin update callback and was checking stale plugin auth info. This fix
ensures updatePluginFab is always called
-a plugin tab is in focus
-in the end of updatePlugins (to check against the latest plugin auth info)

Issue-id: FEIJ-691

Change-Id: I0e09eb7149c70a0eb16b5b3ad23c7032d94d64da
(cherry picked from commit f05914c8)
parent 5b254b71
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -1371,15 +1371,7 @@ public class PeopleActivity extends ContactsActivity implements
                    clearFrequentsMenu.setVisible(false);
            } else if (mPluginLength > 0 && tabPosition >= TabState.GROUPS){
                // plugin tab
                int pluginIndex = tabPosition - TabState.GROUPS;
                InCallPluginInfo pluginInfo = mPluginTabInfo.get(pluginIndex);
                // floating button state
                if (pluginInfo.mCallMethodInfo.mIsAuthenticated ||
                        CallMethodUtils.isSoftLoggedOut(this, pluginInfo.mCallMethodInfo)) {
                    mFloatingActionButtonContainer.setVisibility(View.VISIBLE);
                } else {
                    mFloatingActionButtonContainer.setVisibility(View.GONE);
                }
                updatePluginFab(tabPosition);
                // menu
                addGroupMenu.setVisible(false);
                contactsFilterMenu.setVisible(false);
@@ -1988,5 +1980,23 @@ public class PeopleActivity extends ContactsActivity implements
            mViewPagerTabs.onPageScrolled(mActionBarAdapter.getCurrentTab(), 0, 0);
            onResumeInit();
        }
        updatePluginFab(getTabPositionForTextDirection(mActionBarAdapter.getCurrentTab()));
    }

    private void updatePluginFab(int tabPosition) {
        if (mPluginLength > 0 && tabPosition >= TabState.GROUPS && tabPosition < mTabStateGroup) {
            // it's a plugin tab, update the FAB
            int pluginIndex = tabPosition - TabState.GROUPS;
            if (pluginIndex < mPluginTabInfo.size()) {
                InCallPluginInfo pluginInfo = mPluginTabInfo.get(pluginIndex);
                // floating button state
                if (pluginInfo.mCallMethodInfo.mIsAuthenticated ||
                        CallMethodUtils.isSoftLoggedOut(this, pluginInfo.mCallMethodInfo)) {
                    mFloatingActionButtonContainer.setVisibility(View.VISIBLE);
                } else {
                    mFloatingActionButtonContainer.setVisibility(View.GONE);
                }
            }
        }
    }
}