From c434e9717f5cb5b6629e6ed1d88aaa7f6d0b1850 Mon Sep 17 00:00:00 2001 From: fyf Date: Tue, 29 Aug 2023 10:15:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=A6=81=E6=AD=A2=E5=B1=8F=E5=B9=95=E6=97=8B?= =?UTF-8?q?=E8=BD=AC=202.=E5=A2=9E=E5=8A=A0=E6=A8=AA=E5=B1=8F=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E3=80=81=E8=B0=83=E6=95=B4=E6=A8=AA=E5=B1=8F=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/ConfigName.java | 2 + .../bnframework/common/utils/ScreenUtils.java | 27 +++ .../manager/ActivityLifecycleManager.java | 2 +- .../modules/home/fragment/Home2Fragment.java | 12 ++ .../home/fragment/from/CpActivity.java | 12 +- .../welcome/activity/LoginActivity.java | 13 ++ .../welcome/activity/WelcomeActivity.java | 5 + app/src/main/res/layout/activity_cp.xml | 5 +- app/src/main/res/layout/activity_cpxz.xml | 3 +- app/src/main/res/layout/activity_diy.xml | 11 +- .../main/res/layout/activity_diy_update.xml | 8 +- app/src/main/res/layout/activity_login.xml | 31 ++-- app/src/main/res/layout/fragment_home1.xml | 5 +- app/src/main/res/layout/fragment_home2.xml | 1 + app/src/main/res/layout/fragment_my.xml | 154 +++++++++--------- 15 files changed, 183 insertions(+), 108 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/utils/ScreenUtils.java diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 93db70e9..93b38d1e 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -15,6 +15,7 @@ import com.bonait.bnframework.common.model.mode.OrganizeMode; import com.bonait.bnframework.common.model.mode.ProcessT; import com.bonait.bnframework.common.model.mode.ResALLData; import com.bonait.bnframework.common.model.mode.VersionSelectionEnum; +import com.bonait.bnframework.common.utils.ScreenUtils; import java.util.ArrayList; import java.util.Arrays; @@ -47,6 +48,7 @@ public class ConfigName { public Context dishesCon; public Context Home; public Application app; + public boolean IsPortraitScreen=true;//是否竖屏 //endregion //region SD卡路径设置 diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/ScreenUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/ScreenUtils.java new file mode 100644 index 00000000..9e8aa8aa --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/utils/ScreenUtils.java @@ -0,0 +1,27 @@ +package com.bonait.bnframework.common.utils; + +import android.app.Activity; +import android.util.DisplayMetrics; + +public class ScreenUtils { + /** + * 是否竖屏 + * + * @return + */ + public static boolean IsPortraitScreen(Activity mLauncher) { + boolean su = false; + DisplayMetrics dm = new DisplayMetrics(); + mLauncher.getWindowManager().getDefaultDisplay().getMetrics(dm); + int mWidth = dm.widthPixels; + int mHeight = dm.heightPixels; + if (mHeight > mWidth) {//layout port + // 竖屏 ....... + su = true; + } else {//layout land + // 横屏 ....... + su = false; + } + return su; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java b/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java index c1a7a016..91f0999c 100644 --- a/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java +++ b/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java @@ -185,7 +185,7 @@ public class ActivityLifecycleManager implements Application.ActivityLifecycleCa */ pushActivity(activity); // 设置禁止随屏幕旋转界面 - activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + //activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java index dbedc3db..396cbaee 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java @@ -1,25 +1,32 @@ package com.bonait.bnframework.modules.home.fragment; +import static com.bonait.bnframework.MainApplication.getContext; + import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.recyclerview.widget.GridLayoutManager; + import android.view.LayoutInflater; import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.utils.ScreenUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.fragment.from.CpActivity; import com.bonait.bnframework.modules.home.fragment.from.DiyActivity; import com.bonait.bnframework.modules.home.fragment.from.SzActivity; import com.bonait.bnframework.modules.home.fragment.from.WhActivity; import com.orhanobut.logger.Logger; +import com.qmuiteam.qmui.widget.QMUIAppBarLayout; import com.qmuiteam.qmui.widget.QMUICollapsingTopBarLayout; import com.qmuiteam.qmui.widget.QMUITopBar; @@ -34,6 +41,9 @@ public class Home2Fragment extends BaseFragment { @BindView(R.id.collapsing_topbar_layout) QMUICollapsingTopBarLayout mCollapsingTopBarLayout; + @BindView(R.id.appbarlayout) + QMUIAppBarLayout appbarlayout; + @BindView(R.id.topbar) QMUITopBar mTopBar; private Context context; @@ -52,6 +62,8 @@ public class Home2Fragment extends BaseFragment { super.onViewCreated(view, savedInstanceState); context = getContext(); initTopBar(); + + appbarlayout.setExpanded(ConfigName.getInstance().IsPortraitScreen); } private void initTopBar() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java index e02ed70c..9c3a6dca 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java @@ -27,6 +27,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.model.mode.CloudGood; +import com.bonait.bnframework.common.utils.ScreenUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.fragment.mode.QDListSectionAdapter; import com.bonait.bnframework.modules.home.fragment.mode.SectionHeader; @@ -175,13 +176,22 @@ public class CpActivity extends BaseActivity { // ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); // } // }; - final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3); + + final GridLayoutManager layoutManager; + if(ConfigName.getInstance().IsPortraitScreen)//竖屏 + { + layoutManager = new GridLayoutManager(getContext(), 3); + }else + { + layoutManager = new GridLayoutManager(getContext(), 5); + } layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int i) { return mAdapter.getItemIndex(i) < 0 ? layoutManager.getSpanCount() : 1; } }); + return layoutManager; } diff --git a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java index 6d2b3e0b..abdf491d 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java @@ -20,6 +20,7 @@ import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ConfigData; @@ -122,6 +123,18 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL { mEtAccount.requestFocus(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + + if(ConfigName.getInstance().IsPortraitScreen)//竖屏 + { + RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(mScrollView.getLayoutParams()); + lp.setMargins(15, 80, 15, 0); + mScrollView.setLayoutParams(lp); + }else + { + RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(mScrollView.getLayoutParams()); + lp.setMargins(15, 40, 15, 0); + mScrollView.setLayoutParams(lp); + } } @OnClick({R.id.iv_clean_account, R.id.clean_password, R.id.iv_show_pwd,R.id.forget_password, R.id.btn_login}) diff --git a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java index 00d09c22..2f682f7d 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java @@ -7,6 +7,8 @@ import android.os.Handler; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.GridLayoutManager; + import android.view.KeyEvent; import com.bonait.bnframework.R; @@ -14,6 +16,7 @@ import com.bonait.bnframework.business.MainInit; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.Constants; +import com.bonait.bnframework.common.utils.ScreenUtils; import com.bonait.bnframework.manager.ActivityLifecycleManager; import com.bonait.bnframework.modules.home.activity.BottomNavigation2Activity; import com.bonait.bnframework.test.TestActivity; @@ -190,6 +193,8 @@ public class WelcomeActivity extends BaseActivity { private void skipToLoginActivity() { //初始化 MainInit.Init(ConfigName.getInstance().app); + ConfigName.getInstance().IsPortraitScreen=ScreenUtils.IsPortraitScreen(this); + // 跳转到登录页面 Intent intent = new Intent(WelcomeActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/app/src/main/res/layout/activity_cp.xml b/app/src/main/res/layout/activity_cp.xml index 401b44ab..e14f14bf 100644 --- a/app/src/main/res/layout/activity_cp.xml +++ b/app/src/main/res/layout/activity_cp.xml @@ -9,9 +9,8 @@ + android:layout_marginTop="80dp" + android:background="@color/activity_background"> diff --git a/app/src/main/res/layout/activity_cpxz.xml b/app/src/main/res/layout/activity_cpxz.xml index 6ba57077..b492ab49 100644 --- a/app/src/main/res/layout/activity_cpxz.xml +++ b/app/src/main/res/layout/activity_cpxz.xml @@ -12,8 +12,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/activity_background" - android:layout_marginTop="?attr/qmui_topbar_height" - android:fitsSystemWindows="true" + android:layout_marginTop="80dp" > + android:layout_marginTop="80dp" + android:background="@color/qmui_config_color_white"> @@ -24,7 +23,8 @@ android:layout_marginRight="30dp" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="vertical" + > + android:layout_height="wrap_content" + android:layout_marginBottom="30dp">