2 Revize 64692c7995 ... f4faa54715

Autor SHA1 Zpráva Datum
  ifengouy f4faa54715 显示网络状态 před 2 roky
  ifengouy 2701b32e21 首页状态显示 před 2 roky

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -8,6 +8,7 @@
 
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 
     <!-- 显示系统窗口权限 -->
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

+ 1 - 0
app/src/main/java/com/sunwin/visitorapp/SplashActivity.java

@@ -145,6 +145,7 @@ public class SplashActivity extends AppCompatActivity {
         permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
         permissions.add(Manifest.permission.READ_PHONE_STATE);
         permissions.add(Manifest.permission.CAMERA);
+        permissions.add(Manifest.permission.ACCESS_NETWORK_STATE);
 
     }
 

+ 26 - 4
app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java

@@ -2,6 +2,7 @@ package com.sunwin.visitorapp.activity;
 
 import android.content.Intent;
 import android.os.Bundle;
+import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
@@ -19,6 +20,8 @@ import com.sunwin.visitorapp.fragment.HomeFr;
 import com.sunwin.visitorapp.fragment.RegTypeFragment;
 import com.sunwin.visitorapp.fragment.VisitSignFragment;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.NetUtils;
+import com.sunwin.visitorapp.utils.PopupWindowHelper;
 import com.sunwin.visitorapp.utils.SharePrefenceUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.UINav;
@@ -31,12 +34,16 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
     private TextView tv_loginOut;
     private LinearLayout mViewMenu;
     private ImageView mImageSetting;
+    private ImageView ImageStatus;
+    private TextView mTvNetStatus;
+    private TextView mTvCameraStatus;
+    private TextView mTvIdcardStatus;
+    private PopupWindowHelper popupWindowHelper;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_home);
-
         FragmentManager fragmentManager = getSupportFragmentManager();
         FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
         //添加fragment
@@ -101,17 +108,22 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
                 startActivity(new Intent(mContext, LoginActivity.class));
                 finish();
                 break;
+            case R.id.ImageStatus:
+                mTvNetStatus.setText(NetUtils.isConnected(this)?"正常":"未连接网络");
+                popupWindowHelper.showAsDropDown(ImageStatus);
+                break;
         }
     }
 
     private void initView() {
-        mUINav = (UINav) findViewById(R.id.UINav);
-        mLlHomeTitle = (RelativeLayout) findViewById(R.id.ll_home_title);
-        mLlHomeTitle = (RelativeLayout) findViewById(R.id.ll_home_title);
+        mUINav = findViewById(R.id.UINav);
+        mLlHomeTitle = findViewById(R.id.ll_home_title);
+        mLlHomeTitle = findViewById(R.id.ll_home_title);
         tv_loginOut = findViewById(R.id.tv_loginOut);
         mTextTitle = findViewById(R.id.TextTitle);
         mViewMenu = findViewById(R.id.ViewMenu);
         mImageSetting = findViewById(R.id.ImageSetting);
+        ImageStatus = findViewById(R.id.ImageStatus);
 
         findViewById(R.id.MenuItemRecord).setOnClickListener(this);
         findViewById(R.id.MenuItemSign).setOnClickListener(this);
@@ -120,12 +132,22 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
         findViewById(R.id.MenuItemCheck).setOnClickListener(this);
         findViewById(R.id.ImageSetting).setOnClickListener(this);
         tv_loginOut.setOnClickListener(this);
+        ImageStatus.setOnClickListener(this);
         showHome(true);
 
         mViewMenu.setVisibility(isLogin ? View.VISIBLE : View.INVISIBLE);
         mImageSetting.setVisibility(isLogin ? View.VISIBLE : View.INVISIBLE);
 
+        initPopWindow();
+    }
+
+    private void initPopWindow() {
+        View popView = LayoutInflater.from(this).inflate(R.layout.view_popwindow, null);
 
+        mTvNetStatus = popView.findViewById(R.id.tv_net_status);
+        mTvCameraStatus = popView.findViewById(R.id.tv_camera_status);
+        mTvIdcardStatus = popView.findViewById(R.id.tv_idcard_status);
+        popupWindowHelper = new PopupWindowHelper(popView);
     }
 
     private void showHome(boolean showHome) {

+ 3 - 2
app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegisterAc.java

@@ -34,6 +34,7 @@ import com.sunwin.visitorapp.utils.AppManager;
 import com.sunwin.visitorapp.utils.AppUtil;
 import com.sunwin.visitorapp.utils.BitmapUtils;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.DigitUtil;
 import com.sunwin.visitorapp.utils.FileUtil;
 import com.sunwin.visitorapp.utils.LogUtil;
 import com.sunwin.visitorapp.utils.TimeUtils;
@@ -161,8 +162,8 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
     private void initViewInfo() {
         //
         showHead(currentFacePath, mImageVisitorPhoto);
-        mTextVisitorIdCode.setText(userInfo.getIdNum());
-        mTextVisitorName.setText(userInfo.getPerson_name());
+        mTextVisitorIdCode.setText(DigitUtil.idCardHide(userInfo.getIdNum()));
+        mTextVisitorName.setText(DigitUtil.nameHide(userInfo.getPerson_name()));
 
         mEditVisitTimeBegin.setText(TimeUtils.stampToDate(System.currentTimeMillis()));
         mEditVisitTimeEnd.setText(TimeUtils.stampToDate(System.currentTimeMillis()));

+ 104 - 0
app/src/main/java/com/sunwin/visitorapp/utils/PopupWindowHelper.java

@@ -0,0 +1,104 @@
+package com.sunwin.visitorapp.utils;
+
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.PopupWindow;
+
+import com.sunwin.visitorapp.R;
+
+public class PopupWindowHelper {
+
+    private View popupView;
+    private PopupWindow mPopupWindow;
+    private static final int TYPE_WRAP_CONTENT = 0, TYPE_MATCH_PARENT = 1;
+
+    public PopupWindowHelper(View view) {
+        popupView = view;
+    }
+
+    public void showAsDropDown(View anchor) {
+        initPopupWindow(TYPE_WRAP_CONTENT);
+        mPopupWindow.showAsDropDown(anchor);
+    }
+
+    public void showAsDropDown(View anchor, int xoff, int yoff) {
+        initPopupWindow(TYPE_WRAP_CONTENT);
+        mPopupWindow.showAsDropDown(anchor, xoff, yoff);
+    }
+
+    public void showAtLocation(View parent, int gravity, int x, int y) {
+        initPopupWindow(TYPE_WRAP_CONTENT);
+        mPopupWindow.showAtLocation(parent, gravity, x, y);
+    }
+
+    public void dismiss() {
+        if (mPopupWindow.isShowing()) {
+            mPopupWindow.dismiss();
+        }
+    }
+
+    public void showAsPopUp(View anchor) {
+        showAsPopUp(anchor, 0, 0,Gravity.TOP);
+    }
+    public void showAsPopDown(View anchor) {
+        showAsPopUp(anchor, 0, 0,Gravity.BOTTOM);
+    }
+
+    public void showAsPopUp(View anchor, int xoff, int yoff,int topDown) {
+        initPopupWindow(TYPE_WRAP_CONTENT);
+        mPopupWindow.setWidth(anchor.getMeasuredWidth());
+//        mPopupWindow.setAnimationStyle(R.style.dialog_with_alpha);
+        popupView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        int height = popupView.getMeasuredHeight();
+        int[] location = new int[2];
+        anchor.getLocationInWindow(location);
+        mPopupWindow.showAtLocation(anchor, Gravity.LEFT | topDown, location[0] - xoff, location[1] - height - yoff);
+    }
+
+    public void showFromBottom(View anchor) {
+        initPopupWindow(TYPE_MATCH_PARENT);
+        mPopupWindow.setAnimationStyle(R.style.dialog_with_alpha);
+        mPopupWindow.showAtLocation(anchor, Gravity.LEFT | Gravity.BOTTOM, 0, 0);
+    }
+
+    public void showFromTop(View anchor) {
+        initPopupWindow(TYPE_MATCH_PARENT);
+        mPopupWindow.setAnimationStyle(R.style.dialog_with_alpha);
+        mPopupWindow.showAtLocation(anchor, Gravity.LEFT | Gravity.TOP, 0, getStatusBarHeight());
+    }
+
+    /**
+     * touch outside dismiss the popupwindow, default is ture
+     *
+     * @param isCancelable
+     */
+    public void setCancelable(boolean isCancelable) {
+        if (isCancelable) {
+            mPopupWindow.setOutsideTouchable(true);
+            mPopupWindow.setFocusable(true);
+        } else {
+            mPopupWindow.setOutsideTouchable(false);
+            mPopupWindow.setFocusable(false);
+        }
+    }
+
+    public void initPopupWindow(int type) {
+        if (type == TYPE_WRAP_CONTENT) {
+
+            mPopupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+
+        } else if (type == TYPE_MATCH_PARENT) {
+            mPopupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        }
+        mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#dedede")));
+        setCancelable(true);
+    }
+
+    private int getStatusBarHeight() {
+        return Math.round(25 * Resources.getSystem().getDisplayMetrics().density);
+    }
+}

+ 109 - 0
app/src/main/res/layout/view_popwindow.xml

@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="100dp"
+    android:layout_height="wrap_content"
+    android:background="@color/white"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:gravity="center"
+        android:padding="10dp"
+        android:text="状态"
+        android:textColor="@color/black"
+        android:textSize="@dimen/sp_20" />
+
+    <View
+        android:layout_width="wrap_content"
+        android:layout_height="1dp"
+        android:background="@color/bg_color" />
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/white"
+        android:paddingLeft="10dp"
+        android:paddingRight="10dp">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:padding="10dp"
+            android:text="网络"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_net_status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:gravity="center"
+            android:padding="10dp"
+            android:text="正常"
+            android:textColor="@color/colorPrimary"
+            android:textSize="@dimen/sp_20" />
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="1dp"
+        android:background="@color/white"
+        android:paddingLeft="10dp"
+        android:paddingRight="10dp">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:padding="10dp"
+            android:text="摄像头"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_camera_status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:gravity="center"
+            android:padding="10dp"
+            android:text="正常"
+            android:textColor="@color/colorPrimary"
+            android:textSize="@dimen/sp_20" />
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="1dp"
+        android:background="@color/white"
+        android:paddingLeft="10dp"
+        android:paddingRight="10dp">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:padding="10dp"
+            android:text="身份证阅读器"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_idcard_status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:gravity="center"
+            android:padding="10dp"
+            android:text="正常"
+            android:textColor="@color/colorPrimary"
+            android:textSize="@dimen/sp_20" />
+    </RelativeLayout>
+
+</LinearLayout>

+ 1 - 0
app/src/main/res/values/colors.xml

@@ -11,4 +11,5 @@
     <color name="color_333333">#333</color>
     <color name="bantranspant">#11000000</color>
     <color name="color_efeeee">#efeeee</color>
+    <color name="bg_color">#dedede</color>
 </resources>

+ 20 - 0
app/src/main/res/values/style.xml

@@ -116,4 +116,24 @@
         <item name="android:paddingHorizontal">25dp</item>
 
     </style>
+
+    <!-- 自定义Dialog弹出样式(底部有动画效果) -->
+    <style name="dialog_with_alpha" parent="@android:style/Theme.Dialog">
+        <item name="android:windowFrame">@null</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:windowIsTranslucent">true</item><!-- 是否半透明 -->
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowAnimationStyle">@style/dialogstyleanim</item>
+
+        <!-- 背景透明 -->
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <!-- <item name="android:backgroundDimEnabled">false</item>-->
+        <item name="android:backgroundDimAmount">0.6</item>
+    </style>   <!--dialog的动画-->
+    <style name="dialogstyleanim" parent="android:Animation">
+        <item name="android:windowEnterAnimation">@anim/slide_in_from_bottom</item>
+        <!-- 进入时的动画 -->
+        <item name="android:windowExitAnimation">@anim/slide_out_from_bottom</item>
+        <!-- 退出时的动画 -->
+    </style>
 </resources>