Browse Source

提交类型 新家需求
提交内容 添加人脸管理的需求

Bitliker 7 years ago
parent
commit
6e1da77fa1

+ 19 - 13
app_core/common/src/main/res/layout/pop_work_activity.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
-    style="@style/commonPopView"
-    xmlns:android="http://schemas.android.com/apk/res/android">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    style="@style/commonPopView">
 
 
     <LinearLayout
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
@@ -12,8 +11,7 @@
         <TextView
         <TextView
             android:id="@+id/super_setting_tv"
             android:id="@+id/super_setting_tv"
             style="@style/commonPopItemTop"
             style="@style/commonPopItemTop"
-            android:text="@string/super_setting"
-            />
+            android:text="@string/super_setting" />
 
 
         <View
         <View
             android:id="@+id/super_setting_line"
             android:id="@+id/super_setting_line"
@@ -24,8 +22,7 @@
         <TextView
         <TextView
             android:id="@+id/work_setting_tv"
             android:id="@+id/work_setting_tv"
             style="@style/commonPopItem"
             style="@style/commonPopItem"
-            android:text="@string/work_setting"
-            />
+            android:text="@string/work_setting" />
 
 
         <View
         <View
             android:id="@+id/work_setting_line"
             android:id="@+id/work_setting_line"
@@ -33,11 +30,22 @@
             android:layout_height="0.3dp"
             android:layout_height="0.3dp"
             android:background="@color/button_invalid" />
             android:background="@color/button_invalid" />
 
 
+
+        <TextView
+            android:id="@+id/face_setting_tv"
+            style="@style/commonPopItem"
+            android:text="@string/face_setting" />
+
+        <View
+            android:id="@+id/face_setting_line"
+            android:layout_width="match_parent"
+            android:layout_height="0.3dp"
+            android:background="@color/button_invalid" />
+
         <TextView
         <TextView
             android:id="@+id/office_addr_setting_tv"
             android:id="@+id/office_addr_setting_tv"
             style="@style/commonPopItem"
             style="@style/commonPopItem"
-            android:text="@string/office_addr_setting"
-            />
+            android:text="@string/office_addr_setting" />
 
 
         <View
         <View
             android:id="@+id/office_addr_setting_line"
             android:id="@+id/office_addr_setting_line"
@@ -48,15 +56,13 @@
         <TextView
         <TextView
             android:id="@+id/my_rule_setting_tv"
             android:id="@+id/my_rule_setting_tv"
             style="@style/commonPopSingleItem"
             style="@style/commonPopSingleItem"
-            android:text="@string/my_rule_setting"
-            />
+            android:text="@string/my_rule_setting" />
 
 
     </LinearLayout>
     </LinearLayout>
 
 
     <TextView
     <TextView
         android:id="@+id/cancel_tv"
         android:id="@+id/cancel_tv"
         style="@style/commonPopCancelItem"
         style="@style/commonPopCancelItem"
-        android:text="@string/common_cancel"
-        />
+        android:text="@string/common_cancel" />
 
 
 </LinearLayout>
 </LinearLayout>

+ 1 - 0
app_core/common/src/main/res/values/strings.xml

@@ -614,6 +614,7 @@
     <!-- start 打卡签到 oasign_title-->
     <!-- start 打卡签到 oasign_title-->
     <string name="super_setting">高级设置</string>
     <string name="super_setting">高级设置</string>
     <string name="work_setting">排班设置</string>
     <string name="work_setting">排班设置</string>
+    <string name="face_setting">人脸照片管理</string>
     <string name="office_addr_setting">办公地址设置</string>
     <string name="office_addr_setting">办公地址设置</string>
     <string name="my_rule_setting">我的考勤规则</string>
     <string name="my_rule_setting">我的考勤规则</string>
     <string name="sm_cancel_title">取消</string>
     <string name="sm_cancel_title">取消</string>

+ 5 - 1
app_modular/applocation/src/main/java/com/uas/applocation/utils/LocationNeerHelper.java

@@ -151,7 +151,11 @@ public class LocationNeerHelper {
                             List<PoiInfo> poiLists = poiResult.getAllPoi();
                             List<PoiInfo> poiLists = poiResult.getAllPoi();
                             List<UASLocation> mUASLocations = new ArrayList<>();
                             List<UASLocation> mUASLocations = new ArrayList<>();
                             for (PoiInfo e : poiLists) {
                             for (PoiInfo e : poiLists) {
-                                mUASLocations.add(ModelChangeUtils.poiInfo2Location(e));
+                                UASLocation model = ModelChangeUtils.poiInfo2Location(e);
+                                if (model==null||(model.getLatitude()==0&&model.getLatitude()==0)){
+                                }else{
+                                    mUASLocations.add(model);
+                                }
                             }
                             }
                             mOnSearchLocationListener.onCallBack(true, mUASLocations);
                             mOnSearchLocationListener.onCallBack(true, mUASLocations);
                         } else {
                         } else {

+ 9 - 1
app_modular/appme/src/main/java/com/uas/appme/settings/activity/SettingActivity.java

@@ -30,6 +30,7 @@ import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.Toast;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.baidu.aip.excep.activity.FaceManageActivity;
 import com.baidu.android.pushservice.PushManager;
 import com.baidu.android.pushservice.PushManager;
 import com.baidu.autoupdatesdk.AppUpdateInfo;
 import com.baidu.autoupdatesdk.AppUpdateInfo;
 import com.baidu.autoupdatesdk.AppUpdateInfoForInstall;
 import com.baidu.autoupdatesdk.AppUpdateInfoForInstall;
@@ -483,7 +484,11 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
             intent = new Intent(mContext, FlightsActivity.class);
             intent = new Intent(mContext, FlightsActivity.class);
             startActivityForResult(intent, 0x12);
             startActivityForResult(intent, 0x12);
             closePopupWindow();
             closePopupWindow();
-        } else if (v.getId() == R.id.office_addr_setting_tv) {
+        }else if (v.getId()==R.id.face_setting_tv){
+            intent = new Intent(mContext, FaceManageActivity.class);
+            startActivityForResult(intent, 0x13);
+            closePopupWindow();
+        }else if (v.getId() == R.id.office_addr_setting_tv) {
             startActivityForResult(new Intent(mContext, OfficeAddressSettingsActivity.class), 0x12);
             startActivityForResult(new Intent(mContext, OfficeAddressSettingsActivity.class), 0x12);
             closePopupWindow();
             closePopupWindow();
         } else if (v.getId() == R.id.my_rule_setting_tv) {
         } else if (v.getId() == R.id.my_rule_setting_tv) {
@@ -656,12 +661,15 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
             viewContext.findViewById(R.id.super_setting_tv).setVisibility(View.GONE);
             viewContext.findViewById(R.id.super_setting_tv).setVisibility(View.GONE);
             viewContext.findViewById(R.id.work_setting_tv).setVisibility(View.GONE);
             viewContext.findViewById(R.id.work_setting_tv).setVisibility(View.GONE);
             viewContext.findViewById(R.id.office_addr_setting_tv).setVisibility(View.GONE);
             viewContext.findViewById(R.id.office_addr_setting_tv).setVisibility(View.GONE);
+            viewContext.findViewById(R.id.face_setting_tv).setVisibility(View.GONE);
+            viewContext.findViewById(R.id.face_setting_line).setVisibility(View.GONE);
             viewContext.findViewById(R.id.super_setting_line).setVisibility(View.GONE);
             viewContext.findViewById(R.id.super_setting_line).setVisibility(View.GONE);
             viewContext.findViewById(R.id.work_setting_line).setVisibility(View.GONE);
             viewContext.findViewById(R.id.work_setting_line).setVisibility(View.GONE);
             viewContext.findViewById(R.id.office_addr_setting_line).setVisibility(View.GONE);
             viewContext.findViewById(R.id.office_addr_setting_line).setVisibility(View.GONE);
         } else {
         } else {
             viewContext.findViewById(R.id.super_setting_tv).setOnClickListener(this);
             viewContext.findViewById(R.id.super_setting_tv).setOnClickListener(this);
             viewContext.findViewById(R.id.work_setting_tv).setOnClickListener(this);
             viewContext.findViewById(R.id.work_setting_tv).setOnClickListener(this);
+            viewContext.findViewById(R.id.face_setting_tv).setOnClickListener(this);
             viewContext.findViewById(R.id.office_addr_setting_tv).setOnClickListener(this);
             viewContext.findViewById(R.id.office_addr_setting_tv).setOnClickListener(this);
         }
         }
         viewContext.findViewById(R.id.my_rule_setting_tv).setOnClickListener(this);
         viewContext.findViewById(R.id.my_rule_setting_tv).setOnClickListener(this);

+ 2 - 0
app_modular/facesdk/src/main/AndroidManifest.xml

@@ -12,6 +12,8 @@
 
 
         <activity android:name="com.baidu.aip.excep.activity.RealTimeDetectFaceActivty"
         <activity android:name="com.baidu.aip.excep.activity.RealTimeDetectFaceActivty"
             android:label="刷脸打卡" />
             android:label="刷脸打卡" />
+        <activity android:name="com.baidu.aip.excep.activity.FaceManageActivity"
+            android:label="人脸照片管理"/>
     </application>
     </application>
 
 
 </manifest>
 </manifest>

+ 336 - 0
app_modular/facesdk/src/main/java/com/baidu/aip/excep/activity/FaceManageActivity.java

@@ -0,0 +1,336 @@
+package com.baidu.aip.excep.activity;
+
+import android.text.Editable;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baidu.aip.excep.utils.FaceConfig;
+import com.common.LogUtil;
+import com.common.data.JSONUtil;
+import com.common.data.ListUtils;
+import com.core.model.EmployeesEntity;
+import com.core.utils.CommonUtil;
+import com.core.utils.ToastUtil;
+import com.core.widget.EmptyLayout;
+import com.core.widget.VoiceSearchView;
+import com.core.widget.listener.EditChangeListener;
+import com.handmark.pulltorefresh.library.PullToRefreshListView;
+import com.me.network.app.http.HttpClient;
+import com.me.network.app.http.Method;
+import com.me.network.app.http.rx.Result2Listener;
+import com.me.network.app.http.rx.ResultSubscriber;
+import com.modular.apputils.activity.BaseNetActivity;
+import com.modular.apputils.manager.ContactsManager;
+import com.modular.apputils.widget.VeriftyDialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import demo.face.aip.baidu.com.facesdk.R;
+
+/**
+ * 管理人脸数据列表
+ */
+public class FaceManageActivity extends BaseNetActivity {
+    private List<EmployeesEntity> allDatas = null;
+    private FaceAdapter mFaceAdapter = null;
+    private PullToRefreshListView refreshListView;
+    private String groupId;
+    private EmptyLayout mEmptyLayout;
+    private VoiceSearchView voiceSearchView;
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.activity_face_manage;
+    }
+
+    @Override
+    protected void init() throws Exception {
+        initView();
+
+    }
+
+    @Override
+    protected String getBaseUrl() {
+        return "https://aip.baidubce.com/";
+    }
+
+    private void initView() {
+        refreshListView = (PullToRefreshListView) findViewById(com.modular.apputils.R.id.refreshListView);
+        mEmptyLayout = new EmptyLayout(this, refreshListView.getRefreshableView());
+        mEmptyLayout.setShowLoadingButton(false);
+        mEmptyLayout.setShowEmptyButton(false);
+        mEmptyLayout.setShowErrorButton(false);
+        voiceSearchView = (VoiceSearchView) findViewById(com.modular.apputils.R.id.voiceSearchView);
+        voiceSearchView.addTextChangedListener(new EditChangeListener() {
+            @Override
+            public void afterTextChanged(Editable s) {
+                search(TextUtils.isEmpty(s) ? "" : s.toString());
+            }
+        });
+        voiceSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+            @Override
+            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                search(TextUtils.isEmpty(v.getText()) ? "" : v.getText().toString());
+                return false;
+            }
+        });
+
+        groupId = CommonUtil.getEnuu(ct);
+        loadFaceList();
+    }
+
+    private void search(String keyWord) {
+        if (!ListUtils.isEmpty(allDatas)) {
+            if (TextUtils.isEmpty(keyWord)) {
+                setAdapter(allDatas);
+            } else {
+                List<EmployeesEntity> showDatas = new ArrayList<>();
+                for (EmployeesEntity e : allDatas) {
+                    String word = e.getEM_MOBILE() + "" + e.getEM_NAME();
+                    if (word.contains(keyWord)) {
+                        showDatas.add(e);
+                    }
+                }
+                setAdapter(showDatas);
+            }
+        }else{
+            setAdapter(allDatas);
+        }
+    }
+
+
+    private void loadFaceList() {
+        showProgress();
+        FaceConfig.loadToken(new FaceConfig.FaceTokenListener() {
+            @Override
+            public void callBack(String accessToken) {
+                LogUtil.i("gong", "accessToken=" + accessToken);
+                httpClient.Api().send(new HttpClient.Builder()
+                        .url("rest/2.0/face/v3/faceset/group/getusers")
+                        .add("access_token", accessToken)
+                        .header("Content-Type", "application/json")
+                        .add("group_id", groupId)
+                        .add("start", 0)
+                        .add("length", 1000)
+                        .isDebug(true)
+                        .method(Method.POST).build(), new ResultSubscriber<>(new Result2Listener<Object>() {
+                    @Override
+                    public void onResponse(Object o) {
+                        try {
+                            LogUtil.i("gong", "o==" + o.toString());
+                            JSONObject object = JSON.parseObject(o.toString());
+                            handlerUserList(JSONUtil.getJSONArray(JSONUtil.getJSONObject(object, "result"), "user_id_list"));
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+
+                    @Override
+                    public void onFailure(Object t) {
+                        LogUtil.i("gong", "onFailure=" + t.toString());
+                        dismissProgress();
+                    }
+                }));
+            }
+        });
+    }
+
+    private void deleteUserFace(final EmployeesEntity model) {
+        showProgress();
+        FaceConfig.loadToken(new FaceConfig.FaceTokenListener() {
+            @Override
+            public void callBack(String accessToken) {
+                LogUtil.i("gong", "accessToken=" + accessToken);
+                httpClient.Api().send(new HttpClient.Builder()
+                        .url("rest/2.0/face/v3/faceset/user/delete")
+                        .add("access_token", accessToken)
+                        .header("Content-Type", "application/json")
+                        .add("group_id", groupId)
+                        .add("user_id", String.valueOf(model.getEm_IMID()))
+                        .isDebug(true)
+                        .method(Method.POST).build(), new ResultSubscriber<>(new Result2Listener<Object>() {
+                    @Override
+                    public void onResponse(Object o) {
+                        try {
+                            LogUtil.i("gong", "o==" + o.toString());
+                            JSONObject object = JSON.parseObject(o.toString());
+                            handlerDelete(JSONUtil.getInt(object, "error_code") == 0, model);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                        dismissProgress();
+                    }
+
+                    @Override
+                    public void onFailure(Object t) {
+                        LogUtil.i("gong", "onFailure=" + t.toString());
+                        dismissProgress();
+                    }
+                }));
+            }
+        });
+    }
+
+    private void handlerDelete(boolean deleteOk, EmployeesEntity model) {
+        if (deleteOk) {
+            allDatas.remove(model);
+            search(TextUtils.isEmpty(voiceSearchView.getText()) ? "" : voiceSearchView.getText().toString());
+        } else {
+         ToastUtil.showToast(ct,R.string.delete_failed);
+        }
+    }
+
+    private void handlerUserList(final JSONArray userListArray) throws Exception {
+        if (ListUtils.isEmpty(userListArray)) {
+            mEmptyLayout.showEmpty();
+            dismissProgress();
+        } else {
+            ContactsManager.getInstance().loadContact(new ContactsManager.OnEmployListener() {
+                @Override
+                public void callback(List<EmployeesEntity> employees) {
+
+                    if (ListUtils.isEmpty(employees)) {
+                        ToastUtil.showToast(ct, R.string.not_load_ok_fefresh);
+                    } else {
+                        List<EmployeesEntity> hasFaceModels = new ArrayList<>();
+                        for (int i = 0; i < userListArray.size(); i++) {
+                            String userId = userListArray.getString(i);
+                            for (EmployeesEntity e : employees) {
+                                String imid = String.valueOf(e.getEm_IMID());
+                                if (e != null && !TextUtils.isEmpty(imid) && !TextUtils.isEmpty(userId) &&
+                                        userId.equals(imid)) {
+                                    hasFaceModels.add(e);
+                                    break;
+                                }
+                            }
+                        }
+                        if (ListUtils.isEmpty(hasFaceModels)) {
+                            ToastUtil.showToast(ct, R.string.not_load_ok_fefresh);
+                        } else {
+                            allDatas = hasFaceModels;
+                            setAdapter(hasFaceModels);
+                        }
+                    }
+                    dismissProgress();
+                }
+            });
+        }
+    }
+
+    private void setAdapter(final List<EmployeesEntity> faceModels) {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                if (ListUtils.isEmpty(faceModels)) {
+                    mEmptyLayout.showEmpty();
+                } else {
+                    if (mFaceAdapter == null) {
+                        mFaceAdapter = new FaceAdapter(faceModels);
+                        refreshListView.setAdapter(mFaceAdapter);
+                    } else {
+                        mFaceAdapter.setFaceModels(faceModels);
+                        mFaceAdapter.notifyDataSetChanged();
+                    }
+                }
+            }
+        });
+
+    }
+
+    private class FaceAdapter extends BaseAdapter {
+        private List<EmployeesEntity> faceModels;
+
+        public FaceAdapter(List<EmployeesEntity> faceModels) {
+            this.faceModels = faceModels;
+        }
+
+        public List<EmployeesEntity> getFaceModels() {
+            return faceModels;
+        }
+
+        public void setFaceModels(List<EmployeesEntity> faceModels) {
+            this.faceModels = faceModels;
+        }
+
+        @Override
+        public int getCount() {
+            return ListUtils.getSize(faceModels);
+        }
+
+        @Override
+        public Object getItem(int position) {
+            return faceModels.get(position);
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            ViewHolder mViewHolder = null;
+            if (convertView == null) {
+                mViewHolder = new ViewHolder();
+                convertView = LayoutInflater.from(ct).inflate(R.layout.item_face_list, null);
+                mViewHolder.deleteTv = (TextView) convertView.findViewById(R.id.deleteTv);
+                mViewHolder.nameTv = (TextView) convertView.findViewById(R.id.nameTv);
+                mViewHolder.phoneTv = (TextView) convertView.findViewById(R.id.phoneTv);
+                convertView.setTag(mViewHolder);
+            } else {
+                mViewHolder = (ViewHolder) convertView.getTag();
+            }
+            EmployeesEntity model = faceModels.get(position);
+            mViewHolder.nameTv.setText(TextUtils.isEmpty(model.getEM_NAME()) ? "" : model.getEM_NAME());
+            mViewHolder.phoneTv.setText(TextUtils.isEmpty(model.getEM_MOBILE()) ? "" : model.getEM_MOBILE());
+            mViewHolder.deleteTv.setTag(model);
+            mViewHolder.deleteTv.setOnClickListener(mOnClickListener);
+            return convertView;
+        }
+
+        private View.OnClickListener mOnClickListener = new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (v != null && v.getTag() != null && v.getTag() instanceof EmployeesEntity) {
+                    EmployeesEntity model = (EmployeesEntity) v.getTag();
+                    showDeleteDialog(model);
+                }
+            }
+        };
+
+        private class ViewHolder {
+            private TextView deleteTv;
+            private TextView nameTv;
+            private TextView phoneTv;
+        }
+    }
+
+
+    private void showDeleteDialog(final EmployeesEntity model) {
+        new VeriftyDialog.Builder(ct)
+                .setTitle(getString(R.string.app_name))
+                .setContent("确定删除" + model.getEM_NAME() + "的脸照?")
+                .setShowCancel(true)
+                .build(new VeriftyDialog.OnDialogClickListener() {
+                    @Override
+                    public void result(boolean clickSure) {
+                        if (clickSure) {
+                            deleteUserFace(model);
+                        }
+                    }
+
+
+                });
+    }
+
+
+}

+ 4 - 0
app_modular/facesdk/src/main/res/drawable/bg_delete_btn.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+</selector>

+ 23 - 0
app_modular/facesdk/src/main/res/layout/activity_face_manage.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:focusableInTouchMode="true"
+    android:orientation="vertical">
+
+    <com.core.widget.VoiceSearchView
+        android:id="@+id/voiceSearchView"
+        android:layout_width="match_parent"
+        android:focusableInTouchMode="false"
+        android:layout_height="48dp" />
+
+    <com.handmark.pulltorefresh.library.PullToRefreshListView
+        android:id="@+id/refreshListView"
+        style="@style/ListViewBasic"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:divider="@color/item_line"
+        android:dividerHeight="@dimen/line"
+        android:scrollbars="none"
+        android:scrollingCache="false" />
+</LinearLayout>

+ 39 - 0
app_modular/facesdk/src/main/res/layout/item_face_list.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@color/white"
+    android:orientation="vertical"
+    android:padding="@dimen/padding">
+
+    <TextView
+        android:id="@+id/deleteTv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_centerVertical="true"
+        android:background="@drawable/selector_confirm_bg"
+        android:clickable="true"
+        android:padding="@dimen/paddingMin"
+        android:text="重置照片"
+        android:textColor="#FFFFFFFF"
+        android:textSize="10sp" />
+
+    <TextView
+        android:id="@+id/nameTv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="陈劲松"
+        android:textColor="#FF333333"
+        android:textSize="15sp" />
+
+    <TextView
+        android:id="@+id/phoneTv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/nameTv"
+        android:layout_marginTop="@dimen/paddingMin"
+        android:text="13456789876"
+        android:textColor="#FF999999"
+        android:textSize="12sp" />
+</RelativeLayout>