Browse Source

1.禁止屏幕旋转

2.增加横屏效果、调整横屏效果
tags/old_version_1
fyf 1 year ago
parent
commit
c434e9717f
15 changed files with 183 additions and 108 deletions
  1. +2
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  2. +27
    -0
      app/src/main/java/com/bonait/bnframework/common/utils/ScreenUtils.java
  3. +1
    -1
      app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java
  4. +12
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java
  5. +11
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java
  6. +13
    -0
      app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java
  7. +5
    -0
      app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java
  8. +2
    -3
      app/src/main/res/layout/activity_cp.xml
  9. +1
    -2
      app/src/main/res/layout/activity_cpxz.xml
  10. +6
    -5
      app/src/main/res/layout/activity_diy.xml
  11. +4
    -4
      app/src/main/res/layout/activity_diy_update.xml
  12. +15
    -16
      app/src/main/res/layout/activity_login.xml
  13. +2
    -3
      app/src/main/res/layout/fragment_home1.xml
  14. +1
    -0
      app/src/main/res/layout/fragment_home2.xml
  15. +81
    -73
      app/src/main/res/layout/fragment_my.xml

+ 2
- 0
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -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卡路径设置


+ 27
- 0
app/src/main/java/com/bonait/bnframework/common/utils/ScreenUtils.java View File

@@ -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;
}
}

+ 1
- 1
app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java View File

@@ -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


+ 12
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java View File

@@ -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() {


+ 11
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java View File

@@ -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;
}



+ 13
- 0
app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java View File

@@ -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})


+ 5
- 0
app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java View File

@@ -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);


+ 2
- 3
app/src/main/res/layout/activity_cp.xml View File

@@ -9,9 +9,8 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/activity_background"
android:fitsSystemWindows="true">
android:layout_marginTop="80dp"
android:background="@color/activity_background">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">


+ 1
- 2
app/src/main/res/layout/activity_cpxz.xml View File

@@ -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"
>
<LinearLayout
android:layout_width="match_parent"


+ 6
- 5
app/src/main/res/layout/activity_diy.xml View File

@@ -13,9 +13,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_white"
android:fitsSystemWindows="true">
android:layout_marginTop="80dp"
android:background="@color/qmui_config_color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -24,7 +23,8 @@
android:layout_marginRight="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
>
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_width="match_parent"
@@ -280,7 +280,8 @@
<RelativeLayout
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginBottom="30dp">
<Button
android:id="@+id/shengchengcaipu"
android:layout_width="match_parent"


+ 4
- 4
app/src/main/res/layout/activity_diy_update.xml View File

@@ -12,9 +12,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_white"
android:fitsSystemWindows="true">
android:layout_marginTop="80dp"
android:background="@color/qmui_config_color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -279,7 +278,8 @@
<RelativeLayout
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginBottom="30dp">
<LinearLayout
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"


+ 15
- 16
app/src/main/res/layout/activity_login.xml View File

@@ -13,20 +13,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.bonait.bnframework.common.bg.SnowView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"/>
<ImageView
android:id="@+id/logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="80dp"
android:background="@null"
android:scaleType="centerCrop"
android:src="@mipmap/ico"/>
<!-- <com.bonait.bnframework.common.bg.SnowView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:background="@color/transparent"/>-->

<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
@@ -35,6 +26,7 @@
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="80dp"
android:fillViewport="true"
android:scrollbarThumbVertical="@android:color/transparent"
android:scrollbars="vertical">
@@ -43,11 +35,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ImageView
android:id="@+id/logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="@null"
android:scaleType="centerCrop"
android:src="@mipmap/ico"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="200dp"
android:gravity="center_vertical"
android:orientation="horizontal">



+ 2
- 3
app/src/main/res/layout/fragment_home1.xml View File

@@ -10,9 +10,8 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/activity_background"
android:fitsSystemWindows="true">
android:layout_marginTop="80dp"
android:background="@color/activity_background">

<RelativeLayout
android:layout_width="match_parent"


+ 1
- 0
app/src/main/res/layout/fragment_home2.xml View File

@@ -11,6 +11,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.qmuiteam.qmui.widget.QMUIAppBarLayout
android:id="@+id/appbarlayout"
android:layout_width="match_parent"
android:layout_height="256dp"
android:fitsSystemWindows="true">


+ 81
- 73
app/src/main/res/layout/fragment_my.xml View File

@@ -14,7 +14,8 @@

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
android:layout_height="0dp"
android:layout_weight="0.3">

<ImageView
android:id="@+id/h_background"
@@ -43,83 +44,90 @@

</RelativeLayout>

<ScrollView
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:id="@+id/information_layout"
android:layout_height="0dp"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/main_background"
android:orientation="vertical">
android:layout_height="wrap_content">

<com.allen.library.SuperTextView
android:id="@+id/stv_user_name"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/icon_personal_user"
stv:sLeftTextString="用户名"
stv:sRightIconRes="@drawable/icon_right"
stv:sRightTextColor="@color/gray"
stv:sRightTextString="用户" />

<com.allen.library.SuperTextView
android:id="@+id/stv_user_sign"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sLeftIconRes="@drawable/icon_personal_sign"
stv:sLeftTextString="签名"
stv:sRightIconRes="@drawable/icon_right"
stv:sRightTextColor="@color/gray"
stv:sRightTextString="" />

<com.allen.library.SuperTextView
android:id="@+id/stv_change_pwd"
<LinearLayout
android:id="@+id/information_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
android:layout_marginTop="@dimen/dp_10"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/icon_personal_pwd"
stv:sLeftTextString="更改密码"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_announcement"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/icon_personal_announcement"
stv:sLeftTextString="通知"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_update"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sLeftIconRes="@drawable/icon_personal_update"
stv:sLeftTextString="版本更新"
stv:sRightIconRes="@drawable/icon_right" />
android:layout_height="wrap_content"
android:background="@color/main_background"
android:orientation="vertical">

<com.allen.library.SuperTextView
android:id="@+id/stv_user_name"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/icon_personal_user"
stv:sLeftTextString="用户名"
stv:sRightIconRes="@drawable/icon_right"
stv:sRightTextColor="@color/gray"
stv:sRightTextString="用户" />

<com.allen.library.SuperTextView
android:id="@+id/stv_user_sign"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sLeftIconRes="@drawable/icon_personal_sign"
stv:sLeftTextString="签名"
stv:sRightIconRes="@drawable/icon_right"
stv:sRightTextColor="@color/gray"
stv:sRightTextString="" />

<com.allen.library.SuperTextView
android:id="@+id/stv_change_pwd"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
android:layout_marginTop="@dimen/dp_10"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/icon_personal_pwd"
stv:sLeftTextString="更改密码"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_announcement"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/icon_personal_announcement"
stv:sLeftTextString="通知"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_update"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sLeftIconRes="@drawable/icon_personal_update"
stv:sLeftTextString="版本更新"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_huifu"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sLeftIconRes="@drawable/hfccsz"
stv:sLeftTextString="恢复出厂设置"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_logout"
android:layout_width="wrap_content"
android:layout_height="@dimen/ll_height"
android:layout_marginTop="@dimen/dp_10"
stv:sCenterTextColor="@color/red_primary"
stv:sCenterTextString="退出登录" />

</LinearLayout>
</ScrollView>
</RelativeLayout>


<com.allen.library.SuperTextView
android:id="@+id/stv_huifu"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sLeftIconRes="@drawable/hfccsz"
stv:sLeftTextString="恢复出厂设置"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_logout"
android:layout_width="wrap_content"
android:layout_height="@dimen/ll_height"
android:layout_marginTop="@dimen/dp_10"
stv:sCenterTextColor="@color/red_primary"
stv:sCenterTextString="退出登录" />

</LinearLayout>
</ScrollView>

</LinearLayout>



Loading…
Cancel
Save