Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabbar折叠屏适配 #673

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading