Skip to content

Commit

Permalink
tabbar折叠屏适配
Browse files Browse the repository at this point in the history
Signed-off-by: louzixuan <zixuan.lou@vivo.com>
  • Loading branch information
louzixuan committed Jul 22, 2024
1 parent 48a586d commit e6ad74a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public class Display implements ConfigurationManager.ConfigurationListener {
private MenubarView.MenubarLifeCycleCallback mMenubarLifeCycleCallback = null;
private String mTipsContent = "";
private int mTipsShowTime = MenubarView.MENUBAR_TIPS_SHOW_TIME_DURATION;
private boolean mIsLastFolding = false;

public Display(DecorLayout decorLayout, Window window, Page page, RootView rootView) {
mContext = decorLayout.getContext().getApplicationContext();
Expand Down Expand Up @@ -449,6 +450,9 @@ void setupStatusBar() {
> BRIGHTNESS_THRESHOLD;
break;
}
if (isFoldableDevice(mContext)) {
mIsLastFolding = isFoldStatus(mContext);
}
if (DarkThemeUtil.isDarkMode()) {
lightStatusBar = false;
}
Expand Down Expand Up @@ -2041,11 +2045,44 @@ public View getStatusBarView() {

@Override
public void onConfigurationChanged(HapConfiguration newConfig) {
refreshOnFoldChange(newConfig);
if (newConfig.getLastUiMode() != newConfig.getUiMode()) {
setupStatusBar();
}
}

private void refreshOnFoldChange(HapConfiguration newConfig) {
if (!isFoldableDevice(mContext)) {
return;
}
refreshTabBar(newConfig);
if (null != mContext
&& null != mRootView
&& mIsLastFolding != isFoldStatus(mContext)) {
setupOrientation();
}
}

private void refreshTabBar(HapConfiguration newConfig) {
if (isFoldableDevice(mContext)
&& (mIsLastFolding != isFoldStatus(mContext) || (null != newConfig &&
!isFoldStatus(mContext) &&
newConfig.getLastOrientation() != newConfig.getOrientation()))
&& null != mRootView) {
mRootView.refreshTabBar();
}
}

private boolean isFoldableDevice(Context context) {
SysOpProvider sysOpProvider = ProviderManager.getDefault().getProvider(SysOpProvider.NAME);
return sysOpProvider.isFoldableDevice(context);
}

private boolean isFoldStatus(Context context) {
SysOpProvider sysOpProvider = ProviderManager.getDefault().getProvider(SysOpProvider.NAME);
return sysOpProvider.isFoldStatusByDisplay(context);
}

private static class ProgressBarController {
private static final int MESSAGE_PROGRESS_UPDATE = 1;
private static final int PROGRESS_UPDATE_TIME = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,14 @@ public boolean prepareTabBarPath(boolean isTabBarPage, String path) {
return isValid;
}

public void refreshTabBar() {
if (null != mTabBar && mTabBar.isTabBarViewValid()) {
mTabBar.refreshTabBar(this);
} else {
Log.w(TAG, "refreshTabBar mTabBar is null.");
}
}

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
super.addView(child, index, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ public void initTabBarView(RootView rootView) {
initTabBarList(context, rootView, mTabBarView, appInfo);
}

public void refreshTabBar(RootView rootView) {
if (null != rootView && null != mTabBarView && mTabBarView.getVisibility() == View.VISIBLE) {
Context context = rootView.getContext();
initTabBarList(context, rootView, mTabBarView, rootView.getAppInfo());
} else {
Log.w(TAG, "refreshTabBar params is not valid.");
}
}

public boolean isTabBarViewValid() {
return null != mTabBarView && mTabBarView.getVisibility() == View.VISIBLE;
}

public void updateTabBarData(RootView rootView, JSONObject tabbarData) {
if (null == tabbarData || null == rootView) {
Log.w(TAG, "updateTabBarData tabbarData or rootView is null.");
Expand Down

0 comments on commit e6ad74a

Please sign in to comment.