package com.basic.security.activity;
|
|
import android.Manifest;
|
import android.annotation.SuppressLint;
|
import android.content.BroadcastReceiver;
|
import android.content.Context;
|
import android.content.Intent;
|
import android.content.IntentFilter;
|
import android.content.pm.PackageManager;
|
import android.graphics.Bitmap;
|
import android.graphics.BitmapFactory;
|
import android.hardware.display.DisplayManager;
|
import android.hardware.usb.UsbDevice;
|
import android.hardware.usb.UsbManager;
|
import android.media.MediaPlayer;
|
import android.os.Bundle;
|
import android.os.Handler;
|
import android.os.Looper;
|
import android.os.SystemClock;
|
import android.support.annotation.Nullable;
|
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.Fragment;
|
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentManager;
|
import android.text.TextUtils;
|
import android.util.TypedValue;
|
import android.view.Display;
|
import android.view.View;
|
import android.view.ViewGroup;
|
import android.view.WindowManager;
|
import android.widget.Button;
|
import android.widget.EditText;
|
import android.widget.ImageView;
|
import android.widget.LinearLayout;
|
import android.widget.TextView;
|
|
import com.alfeye.readcardlib.readcard.ReadCardUtil;
|
import com.basic.security.base.BaseApplication;
|
import com.basic.security.base.BaseFragment;
|
import com.basic.security.fragment.AdminFaceLoginFragment;
|
import com.basic.security.fragment.AdminLogoutFragment;
|
import com.basic.security.fragment.AdminPasswordLoginFragment;
|
import com.basic.security.fragment.AdvertisingImageViewFragment;
|
import com.basic.security.fragment.BackgroundAndBorderFragment;
|
import com.basic.security.fragment.BaseSettingFragment;
|
import com.basic.security.fragment.BusinessPersonFragment;
|
import com.basic.security.fragment.CameraFragment;
|
import com.basic.security.fragment.ClusterFragment;
|
import com.basic.security.fragment.DeviceFragment;
|
import com.basic.security.fragment.DeviceListDialogFragment;
|
import com.basic.security.fragment.DeviceListDialogSmallFragment;
|
import com.basic.security.fragment.DoorAccessConfirmFragment;
|
import com.basic.security.fragment.DoorAccessFailFragment;
|
import com.basic.security.fragment.DoorAccessResultFragment;
|
import com.basic.security.fragment.DoorAccessSuccessFragment;
|
import com.basic.security.fragment.FaceDetailFragment;
|
import com.basic.security.fragment.FaceListFragment;
|
import com.basic.security.fragment.GuestModeFragment;
|
import com.basic.security.fragment.HintDoorAccessFragment;
|
import com.basic.security.fragment.HintRecognizeFragment;
|
import com.basic.security.fragment.HintSignUpFragment;
|
import com.basic.security.fragment.HintTabFragment;
|
import com.basic.security.fragment.HomeFragment;
|
import com.basic.security.fragment.MenuFragment;
|
import com.basic.security.fragment.OrgFragment;
|
import com.basic.security.fragment.OrgPersonFragment;
|
import com.basic.security.fragment.PasswordOpenDoorFragment;
|
import com.basic.security.fragment.PersonManageFragment;
|
import com.basic.security.fragment.RegisterResultFragment;
|
import com.basic.security.fragment.RuleDetailFragment;
|
import com.basic.security.fragment.RuleListFragment;
|
import com.basic.security.fragment.SuAutoIcCompareSuccessFragment;
|
import com.basic.security.fragment.SuAutoIcWaitIdcardFragment;
|
import com.basic.security.fragment.SuAutoIcWaitPhoneFragment;
|
import com.basic.security.fragment.SuAutoNicWaitDetailFragment;
|
import com.basic.security.fragment.SuAutoWaitAdminFragment;
|
import com.basic.security.fragment.SuAutoWaitFaceFragment;
|
import com.basic.security.fragment.SuLoggedIcCompareSuccessFragment;
|
import com.basic.security.fragment.SuLoggedIcWaitFaceFragment;
|
import com.basic.security.fragment.SuLoggedIcWaitIdcardFragment;
|
import com.basic.security.fragment.SuLoggedNicWaitDetailFragment;
|
import com.basic.security.fragment.SuLoggedNicWaitFaceFragment;
|
import com.basic.security.fragment.SuLoggedWaitFaceFragment;
|
import com.basic.security.fragment.TimeRuleAddFragment;
|
import com.basic.security.fragment.TimeRuleFragment;
|
import com.basic.security.fragment.TimeRuleListDialogFragment;
|
import com.basic.security.fragment.TimeRuleListDialogSmallFragment;
|
import com.basic.security.fragment.ToolbarFragment;
|
import com.basic.security.fragment.UserFragment;
|
import com.basic.security.fragment.VerifyIDCardFragment;
|
import com.basic.security.fragment.VideoViewFragment;
|
import com.basic.security.fragment.VisitListFragment;
|
import com.basic.security.manager.BaseSettingManager;
|
import com.basic.security.manager.DatabaseManager;
|
import com.basic.security.manager.DeviceManager;
|
import com.basic.security.manager.FaceTitleAndTipsManager;
|
import com.basic.security.manager.FaceTitleAndTipsManagerS;
|
import com.basic.security.manager.IdCardManager;
|
import com.basic.security.manager.RecognizeManager;
|
import com.basic.security.manager.SystemInitManager;
|
import com.basic.security.manager.UserManager;
|
import com.basic.security.secondary.SecondaryDisplay;
|
import com.basic.security.service.KeepLifeService;
|
import com.basic.security.utils.ANRWatchDog;
|
import com.basic.security.utils.AudioPlayer;
|
import com.basic.security.utils.Base64Util;
|
import com.basic.security.utils.Constants;
|
import com.basic.security.utils.KeyboardUtil;
|
import com.basic.security.utils.LogFileUtils;
|
import com.basic.security.utils.MultipartUtilityV2;
|
import com.basic.security.utils.PermissionHelper;
|
import com.basic.security.utils.ToastUtil;
|
import com.basic.security.utils.WhiteDevice;
|
import com.basic.security.utils.socket.RelayServerUtil2;
|
import com.basic.security.utils.socket.indoor.IndoorReceiveIpSocketServer;
|
import com.basic.security.widget.Preview;
|
import com.firefly.api.FireflyApi;
|
|
import org.androidannotations.annotations.AfterViews;
|
import org.androidannotations.annotations.Click;
|
import org.androidannotations.annotations.EActivity;
|
import org.androidannotations.annotations.FragmentById;
|
import org.androidannotations.annotations.UiThread;
|
import org.androidannotations.annotations.ViewById;
|
import org.apache.commons.io.FileUtils;
|
|
import java.io.File;
|
import java.io.OutputStream;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.HashMap;
|
import java.util.HashSet;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
|
import cn.com.aratek.idcard.IDCardReader;
|
|
import static com.basic.security.utils.Constants.isNewIDCardReader;
|
import static com.basic.security.utils.Constants.landscape;
|
|
@EActivity
|
public class MainActivity extends FragmentActivity {
|
public static final int REQUEST_CAMERA_PERMISSION = 200;
|
public static TimeoutToBlank noFaceDelayTimeoutToBlank;
|
public static boolean faceDbInitComplete = false;
|
public static long lastTimeDetectedFace = 0;
|
public static boolean mainActivityInitComplete = false;
|
public static boolean allUiLoaded = false;
|
private static FireflyApi mFireflyApi;
|
private final Handler _uiHandler1 = new Handler(Looper.getMainLooper());
|
public Map<BaseFragment, Set<View>> backgroundAndBorderViews = new HashMap<>();
|
@ViewById
|
public TextView currentFragmentTextView;
|
@FragmentById
|
public BaseFragment fragment_system_setting_tabs;
|
@FragmentById
|
public AdminFaceLoginFragment fragment_admin_face_login;
|
@FragmentById
|
public UserFragment fragment_user;
|
@FragmentById
|
public ClusterFragment fragment_cluster;
|
@FragmentById
|
public BaseSettingFragment fragment_base_setting;
|
@FragmentById
|
public DeviceFragment fragment_device;
|
@FragmentById
|
public AdminPasswordLoginFragment fragment_admin_password_login;
|
@FragmentById
|
public HomeFragment fragment_home;
|
@FragmentById
|
public MenuFragment fragment_menu;
|
@FragmentById
|
public RuleDetailFragment fragment_rule_detail;
|
@FragmentById
|
public RuleListFragment fragment_rule_list;
|
@FragmentById
|
public SuAutoIcCompareSuccessFragment fragment_su_auto_ic_compare_success;
|
@FragmentById
|
public SuAutoIcWaitIdcardFragment fragment_su_auto_ic_wait_idcard;
|
@FragmentById
|
public SuLoggedIcCompareSuccessFragment fragment_su_logged_ic_compare_success;
|
@FragmentById
|
public SuLoggedIcWaitFaceFragment fragment_su_logged_ic_wait_face;
|
@FragmentById
|
public SuLoggedIcWaitIdcardFragment fragment_su_logged_ic_wait_idcard;
|
@FragmentById
|
public SuLoggedNicWaitFaceFragment fragment_su_logged_nic_wait_face;
|
@FragmentById
|
public SuLoggedNicWaitDetailFragment fragment_su_logged_nic_wait_detail;
|
@FragmentById
|
public SuAutoWaitAdminFragment fragment_su_auto_wait_admin;
|
@FragmentById
|
public SuAutoWaitFaceFragment fragment_su_auto_wait_face;
|
@FragmentById
|
public ToolbarFragment fragment_toolbar;
|
@FragmentById
|
public PersonManageFragment fragment_person_manage;
|
@FragmentById
|
public VideoViewFragment fragment_video_view;
|
@FragmentById
|
public CameraFragment fragment_camera;
|
@FragmentById
|
public FaceListFragment fragment_face_list;
|
@FragmentById
|
public FaceDetailFragment fragment_face_detail;
|
@FragmentById
|
public TimeRuleListDialogFragment fragment_time_rule_list_dialog;
|
@FragmentById
|
public TimeRuleListDialogSmallFragment fragment_time_rule_list_dialog_small;
|
@FragmentById
|
public DeviceListDialogFragment fragment_device_list_dialog;
|
@FragmentById
|
public DeviceListDialogSmallFragment fragment_device_list_dialog_small;
|
@FragmentById
|
public SuAutoIcWaitPhoneFragment fragment_su_auto_ic_wait_phone;
|
@FragmentById
|
public BackgroundAndBorderFragment fragment_background_and_border;
|
@FragmentById
|
public SuAutoNicWaitDetailFragment fragment_su_auto_nic_wait_detail;
|
@FragmentById
|
public RegisterResultFragment fragment_sign_up_success;
|
@FragmentById
|
public SuLoggedWaitFaceFragment fragment_su_logged_wait_face;
|
@FragmentById
|
public VisitListFragment fragment_visit_list;
|
@FragmentById
|
public DoorAccessSuccessFragment fragment_door_access_success;
|
@FragmentById
|
public DoorAccessFailFragment fragment_door_access_fail;
|
@FragmentById
|
public DoorAccessConfirmFragment fragment_door_access_confirm;
|
@FragmentById
|
public DoorAccessResultFragment fragment_door_access_result;
|
@FragmentById
|
public HintTabFragment fragment_hint_tab;
|
@FragmentById
|
public HintDoorAccessFragment fragment_hint_door_access;
|
@FragmentById
|
public HintRecognizeFragment fragment_hint_recognize;
|
@FragmentById
|
public HintSignUpFragment fragment_hint_sign_up;
|
@FragmentById
|
public TimeRuleFragment fragment_time_rule;
|
@FragmentById
|
public TimeRuleAddFragment fragment_time_rule_add;
|
@FragmentById
|
public BusinessPersonFragment fragment_business_person;
|
@FragmentById
|
public VerifyIDCardFragment fragment_verify_id_card;
|
@FragmentById
|
public GuestModeFragment fragment_guest_mode;
|
@FragmentById
|
public OrgFragment fragment_org;
|
@FragmentById
|
public OrgPersonFragment fragment_org_person;
|
@ViewById
|
public View importAnimation;
|
@ViewById
|
public ImageView camera11;
|
@FragmentById
|
public PasswordOpenDoorFragment fragment_password_open_door;
|
@FragmentById
|
public AdvertisingImageViewFragment fragment_advertising_image_view;
|
@FragmentById
|
public AdminLogoutFragment fragment_admin_logout;
|
public Set<Fragment> fragmentHasCamera = new HashSet<>();
|
@ViewById
|
public ImageView test_image_rgb, test_image_gray, test_remote_camera, test_remote_camera2;
|
@ViewById
|
public View showCapturedImagesLL;
|
public long lastAdminClickTime = 0;
|
@ViewById
|
public Button saveDeviceIdButton;
|
@ViewById
|
public EditText deviceIdEditText;
|
@ViewById
|
public View device_id_ll;
|
public Set<Fragment> fragmentHasFaceList = new HashSet<>();
|
public Set<Fragment> fragmentHasFaceDetail = new HashSet<>();
|
public BaseFragment currentFragment;
|
public List<BaseFragment> fragments = new ArrayList<>();
|
public Set<Fragment> fragmentHasIdCardPhone = new HashSet<>();
|
public Set<BaseFragment> fragmentsHasPersonManager = new HashSet<>();
|
public Set<BaseFragment> fragmentsHasSystemSettingTabs = new HashSet<>();
|
public Set<BaseFragment> fragmentsHasSystemSettingHintTabs = new HashSet<>();
|
public long currentFragmentShowTime;
|
public int defaultTimeoutSeconds = 5;
|
public Map<BaseFragment, Set<View>> fragmentToolbarButtons = new HashMap<>();
|
public Set<Fragment> fragmentsHasVideoView = new HashSet<>();
|
public Set<Fragment> fragmentsHasAdvertisingImageView = new HashSet<>();
|
//新的pad 白色 身份证读卡器
|
public ReadCardUtil readCardUtil;
|
@ViewById
|
public View long_click_view;
|
public DisplayManager displayManager = null;
|
public Display[] presentationDisplays = null;
|
public SecondaryDisplay secondaryDisplay;
|
public long startTime = 0;
|
protected Set<BaseFragment> adminFragments = new HashSet<>();
|
BaseFragment previewFragment;
|
Map<BaseFragment, TimeoutToBlank> timeoutToBlankMap = new HashMap();
|
@ViewById
|
LinearLayout id111;
|
BroadcastReceiver mUsbAttachReceiver = new BroadcastReceiver() {
|
public void onReceive(Context context, Intent intent) {
|
String action = intent.getAction();
|
BaseApplication.getApplication().executorService.execute(() -> {
|
SystemClock.sleep(6 * 1000);
|
try {
|
BaseApplication.getApplication().activity.runOnUiThread(() -> {
|
fragment_camera.resetCamera();
|
if (!fragment_camera.rgb_camera.resetCamera) {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
SystemClock.sleep(6 * 1000);
|
BaseApplication.getApplication().activity.runOnUiThread(() -> {
|
fragment_camera.resetCamera();
|
});
|
});
|
}
|
});
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
});
|
}
|
};
|
long lastTimeDetach = 0;
|
BroadcastReceiver mUsbDetachReceiver = new BroadcastReceiver() {
|
public void onReceive(Context context, Intent intent) {
|
String action = intent.getAction();
|
lastTimeDetach = System.currentTimeMillis();
|
System1.out.println("MainActivity.onReceive mUsbDetachReceiver ");
|
if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
|
UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
if (device != null) {
|
}
|
}
|
}
|
};
|
MediaPlayer mediaPlayer;
|
|
|
public MainActivity() {
|
BaseApplication.getApplication().activity = (MainActivity) this;
|
Base64Util.init();
|
DatabaseManager.setCustomDatabaseFiles(this);
|
}
|
|
public static FireflyApi getFireflyApi() {
|
return mFireflyApi;
|
}
|
|
public boolean needLight() {
|
return Constants.useLight && (currentFragment == fragment_su_auto_wait_face
|
|| currentFragment == fragment_su_logged_wait_face
|
|| currentFragment == fragment_su_logged_nic_wait_face
|
|| currentFragment == fragment_su_logged_ic_wait_face
|
|| currentFragment == fragment_door_access_result
|
|| currentFragment == fragment_admin_face_login
|
|| currentFragment == fragment_home
|
|| currentFragment == fragment_user);
|
}
|
|
|
@SuppressWarnings("all")
|
public void addBackgroundAndBorderComponent() {
|
if (!Constants.landscape) {
|
BackgroundAndBorderFragment background_and_border_fragment = (BackgroundAndBorderFragment) fragment_background_and_border;
|
backgroundAndBorderViews.put(
|
fragment_su_auto_nic_wait_detail,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground2,
|
background_and_border_fragment.topBlurView2
|
))
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_nic_wait_detail,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.bottomBackground2,
|
background_and_border_fragment.bottomBlurView2
|
))
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_ic_wait_idcard,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.bottomBackground2,
|
background_and_border_fragment.bottomBlurView2
|
))
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_ic_compare_success,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.bottomBackground2,
|
background_and_border_fragment.bottomBlurView2
|
))
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_ic_wait_face,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.bottomBackground2,
|
background_and_border_fragment.bottomBlurView2
|
))
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_nic_wait_face,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.bottomBackground2,
|
background_and_border_fragment.bottomBlurView2
|
))
|
);
|
backgroundAndBorderViews.put(fragment_admin_password_login,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground2,
|
background_and_border_fragment.topBlurView2
|
)));
|
backgroundAndBorderViews.put(fragment_admin_password_login,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground2,
|
background_and_border_fragment.topBlurView2
|
)));
|
backgroundAndBorderViews.put(fragment_su_auto_ic_compare_success,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground2,
|
background_and_border_fragment.topBlurView2
|
)));
|
backgroundAndBorderViews.put(fragment_person_manage,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground2,
|
background_and_border_fragment.topBlurView2,
|
background_and_border_fragment.bottomBackground2,
|
background_and_border_fragment.bottomBlurView2
|
)));
|
backgroundAndBorderViews.put(fragment_rule_detail,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.fullscreenBackground,
|
background_and_border_fragment.fullscreenBlurView
|
)));
|
backgroundAndBorderViews.put(fragment_visit_list,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground3,
|
background_and_border_fragment.topBlurView3,
|
background_and_border_fragment.bottomBackground3,
|
background_and_border_fragment.bottomBlurView3
|
)));
|
backgroundAndBorderViews.put(fragment_rule_list,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.fullscreenBackground,
|
background_and_border_fragment.fullscreenBlurView
|
)));
|
backgroundAndBorderViews.put(fragment_base_setting,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_device,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_cluster,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_org,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_user,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_hint_recognize,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_hint_sign_up,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_hint_door_access,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_time_rule,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_time_rule_add,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_business_person,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground4,
|
background_and_border_fragment.topBlurView4,
|
background_and_border_fragment.bottomBackground4,
|
background_and_border_fragment.bottomBlurView4
|
)));
|
backgroundAndBorderViews.put(fragment_guest_mode,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground5,
|
background_and_border_fragment.topBlurView5,
|
background_and_border_fragment.bottomBackground5,
|
background_and_border_fragment.bottomBlurView5,
|
background_and_border_fragment.bottomBackground6,
|
background_and_border_fragment.bottomBlurView6
|
)));
|
}
|
if (landscape) {
|
BackgroundAndBorderFragment background_and_border_fragment = (BackgroundAndBorderFragment) fragment_background_and_border;
|
if (Constants.landscape) {
|
HashSet<View> leftRight =
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBlurView7_left,
|
background_and_border_fragment.topBlurView7_right,
|
background_and_border_fragment.topBackground7_left,
|
background_and_border_fragment.topBackground7_right
|
));
|
HashSet<View> left =
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBlurView7_left,
|
background_and_border_fragment.topBackground7_left
|
));
|
HashSet<View> right =
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBlurView7_right,
|
background_and_border_fragment.topBackground7_right
|
));
|
backgroundAndBorderViews.put(
|
fragment_su_auto_nic_wait_detail, right
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_nic_wait_detail, right
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_ic_wait_idcard, right
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_ic_compare_success, right
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_ic_wait_face, right
|
);
|
backgroundAndBorderViews.put(
|
fragment_su_logged_nic_wait_face, right
|
);
|
backgroundAndBorderViews.put(fragment_admin_password_login, new HashSet(Arrays.asList(
|
background_and_border_fragment.fullscreenBackground,
|
background_and_border_fragment.fullscreenBlurView
|
)));
|
backgroundAndBorderViews.put(fragment_su_auto_ic_compare_success, leftRight);
|
backgroundAndBorderViews.put(fragment_person_manage, leftRight);
|
backgroundAndBorderViews.put(fragment_rule_detail,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.fullscreenBackground,
|
background_and_border_fragment.fullscreenBlurView
|
)));
|
backgroundAndBorderViews.put(fragment_visit_list, leftRight);
|
backgroundAndBorderViews.put(fragment_rule_list,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.fullscreenBackground,
|
background_and_border_fragment.fullscreenBlurView
|
)));
|
backgroundAndBorderViews.put(fragment_base_setting,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_device,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_cluster,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_org,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_user,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_hint_recognize,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_hint_sign_up,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_hint_door_access,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_time_rule,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_time_rule_add,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground1,
|
background_and_border_fragment.topBlurView1
|
)));
|
backgroundAndBorderViews.put(fragment_business_person,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.fullscreenBackground,
|
background_and_border_fragment.fullscreenBlurView
|
)));
|
if (!Constants.indoorOutdoorInOne) {
|
backgroundAndBorderViews.put(fragment_guest_mode,
|
new HashSet(Arrays.asList(
|
background_and_border_fragment.topBackground2,
|
background_and_border_fragment.topBlurView2
|
)));
|
} else {
|
}
|
} else {
|
}
|
}
|
}
|
|
public void toggleBackgroundAndBorderComponent(BaseFragment showFragment) {
|
if (backgroundAndBorderViews.containsKey(showFragment)) {
|
showOneFragment(fragment_background_and_border);
|
} else {
|
hideOneFragment(fragment_background_and_border);
|
}
|
}
|
|
public void hideSystemUI() {
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
}
|
|
public void addListener() {
|
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> hideSystemUI());
|
}
|
|
@UiThread
|
public void hideSystemUIThread() {
|
hideSystemUI();
|
addListener();
|
}
|
|
public void toggleCamera(BaseFragment showFragment) {
|
if (!fragmentHasCamera.contains(showFragment)) {
|
fragment_camera.showOverlay();
|
} else {
|
fragment_camera.hideOverlay();
|
}
|
}
|
|
@Click
|
public void get_video() {
|
}
|
|
@UiThread
|
public void setRemoteVideoImage(Bitmap bitmap) {
|
test_remote_camera.setImageBitmap(bitmap);
|
}
|
|
@UiThread
|
public void setRemoteVideoImage2(Bitmap bitmap) {
|
test_remote_camera2.setImageBitmap(bitmap);
|
}
|
|
public void startViewCameraThread() {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
while (true) {
|
try {
|
SystemClock.sleep(2000);
|
if (BaseApplication.getApplication().activity != null &&
|
BaseApplication.getApplication().activity.mainActivityInitComplete) {
|
updateCameraImages();
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
});
|
}
|
|
@UiThread
|
public void updateCameraImages() {
|
try {
|
Bitmap image_rgb = BitmapFactory.decodeFile("/data/data/com.basic.security/files/image_rgb.jpg");
|
Bitmap image_gray = BitmapFactory.decodeFile("/data/data/com.basic.security/files/image_gray.jpg");
|
if (image_rgb != null) {
|
test_image_rgb.setImageBitmap(image_rgb);
|
}
|
if (image_gray != null) {
|
test_image_gray.setImageBitmap(image_gray);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
public void addCameras() {
|
if (ActivityCompat.checkSelfPermission(this,
|
Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED
|
&& ActivityCompat.checkSelfPermission(this,
|
Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CAMERA_PERMISSION);
|
}
|
if (Constants.showCapturedImages) {
|
showCapturedImagesLL.setVisibility(View.VISIBLE);
|
startViewCameraThread();
|
}
|
}
|
|
public void addCameraToFragment() {
|
fragmentHasCamera.add(fragment_su_auto_wait_face);
|
fragmentHasCamera.add(fragment_admin_face_login);
|
fragmentHasCamera.add(fragment_home);
|
fragmentHasCamera.add(fragment_door_access_success);
|
fragmentHasCamera.add(fragment_door_access_confirm);
|
fragmentHasCamera.add(fragment_door_access_fail);
|
fragmentHasCamera.add(fragment_door_access_result);
|
fragmentHasCamera.add(fragment_su_logged_ic_wait_face);
|
fragmentHasCamera.add(fragment_su_logged_nic_wait_face);
|
fragmentHasCamera.add(fragment_su_auto_ic_wait_idcard);
|
fragmentHasCamera.add(fragment_su_auto_wait_admin);
|
fragmentHasCamera.add(fragment_su_logged_ic_wait_idcard);
|
fragmentHasCamera.add(fragment_sign_up_success);
|
fragmentHasCamera.add(fragment_su_logged_nic_wait_detail);
|
fragmentHasCamera.add(fragment_su_logged_wait_face);
|
fragmentHasCamera.add(fragment_su_logged_ic_compare_success);
|
if (Constants.indoorOutdoorInOne) {
|
fragmentHasCamera.add(fragment_guest_mode);
|
}
|
}
|
|
public boolean shouldDetectFace() {
|
if (Constants.indoorOutdoorInOne) {
|
return true;
|
}
|
boolean shouldDetectFace = false;
|
if (currentFragment == fragment_admin_face_login ||
|
currentFragment == fragment_home ||
|
currentFragment == fragment_su_logged_ic_wait_face ||
|
currentFragment == fragment_su_auto_wait_face ||
|
currentFragment == fragment_su_logged_nic_wait_face ||
|
currentFragment == fragment_user ||
|
currentFragment == fragment_door_access_success ||
|
currentFragment == fragment_door_access_confirm ||
|
currentFragment == fragment_su_auto_ic_wait_idcard ||
|
currentFragment == fragment_su_auto_wait_admin ||
|
currentFragment == fragment_su_logged_ic_wait_idcard ||
|
currentFragment == fragment_door_access_fail ||
|
currentFragment == fragment_door_access_result ||
|
currentFragment == fragment_sign_up_success ||
|
currentFragment == fragment_su_logged_nic_wait_detail ||
|
currentFragment == fragment_su_logged_ic_compare_success ||
|
currentFragment == fragment_verify_id_card ||
|
currentFragment == fragment_su_auto_nic_wait_detail
|
) {
|
shouldDetectFace = true;
|
}
|
if (currentFragment == fragment_guest_mode && Constants.isOutdoor) {
|
shouldDetectFace = true;
|
}
|
return shouldDetectFace;
|
}
|
|
public boolean needCompareFeature() {
|
return currentFragment == fragment_admin_face_login ||
|
currentFragment == fragment_su_logged_ic_wait_face ||
|
currentFragment == fragment_su_auto_ic_wait_idcard ||
|
currentFragment == fragment_su_auto_wait_face ||
|
currentFragment == fragment_su_logged_nic_wait_face ||
|
currentFragment == fragment_user ||
|
currentFragment == fragment_su_logged_ic_compare_success ||
|
currentFragment == fragment_su_logged_ic_wait_idcard;
|
}
|
|
public void setUpClickHook() {
|
List<BaseFragment> allFragments = Arrays.asList(fragment_user,
|
fragment_admin_face_login,
|
fragment_admin_password_login,
|
fragment_cluster,
|
fragment_org,
|
fragment_base_setting,
|
fragment_device,
|
fragment_home,
|
fragment_menu,
|
fragment_rule_detail,
|
fragment_rule_list,
|
fragment_su_auto_ic_compare_success,
|
fragment_su_auto_ic_wait_idcard,
|
fragment_su_auto_nic_wait_detail,
|
fragment_su_logged_ic_compare_success,
|
fragment_su_logged_ic_wait_face,
|
fragment_su_logged_ic_wait_idcard,
|
fragment_su_logged_nic_wait_face,
|
fragment_su_auto_wait_admin,
|
fragment_su_auto_wait_face,
|
fragment_toolbar,
|
fragment_person_manage,
|
fragment_video_view,
|
fragment_advertising_image_view,
|
fragment_camera,
|
fragment_guest_mode,
|
fragment_face_list,
|
fragment_face_detail,
|
fragment_time_rule_list_dialog,
|
fragment_device_list_dialog,
|
fragment_device_list_dialog_small,
|
fragment_org);
|
for (BaseFragment fragment : allFragments) {
|
setupUI(fragment.getView());
|
}
|
adminFragments.addAll(Arrays.asList(
|
fragment_user,
|
fragment_base_setting,
|
fragment_cluster,
|
fragment_org,
|
fragment_device,
|
fragment_person_manage,
|
fragment_rule_detail,
|
fragment_rule_list,
|
fragment_su_logged_ic_compare_success,
|
fragment_su_logged_ic_wait_face,
|
fragment_su_logged_ic_wait_idcard,
|
fragment_su_logged_nic_wait_detail,
|
fragment_su_logged_nic_wait_face,
|
fragment_su_logged_nic_wait_detail,
|
fragment_system_setting_tabs,
|
fragment_face_detail,
|
fragment_time_rule_list_dialog_small,
|
fragment_device_list_dialog_small,
|
fragment_face_list,
|
fragment_business_person,
|
fragment_hint_door_access,
|
fragment_hint_recognize,
|
fragment_hint_sign_up,
|
fragment_rule_detail,
|
fragment_rule_list,
|
fragment_time_rule,
|
fragment_time_rule_add,
|
fragment_visit_list,
|
fragment_visit_list
|
));
|
}
|
|
public void onUserInteraction() {
|
setLastAdminClickTime();
|
}
|
|
public void setLastAdminClickTime() {
|
if (adminFragments.contains(currentFragment) && UserManager.adminLoggedIn()) {
|
lastAdminClickTime = System.currentTimeMillis();
|
}
|
}
|
|
public void setupUIs(View... views) {
|
for (View view : views) {
|
setupUI(view);
|
}
|
}
|
|
@SuppressLint("ClickableViewAccessibility")
|
public void setupUI(final View view) {
|
if (!(view instanceof EditText)) {
|
view.setOnTouchListener((v, event) -> {
|
setLastAdminClickTime();
|
((MainActivity.this)).refreshCurrentFragmentShowTime();
|
KeyboardUtil.hideSoftKeyboard();
|
return false;
|
});
|
}
|
if (view instanceof EditText) {
|
view.setOnFocusChangeListener((v, hasFocus) -> {
|
if (hasFocus) {
|
KeyboardUtil.showKeyboard();
|
} else {
|
KeyboardUtil.hideSoftKeyboard();
|
}
|
});
|
}
|
view.setOnTouchListener((v, event) -> {
|
if (v == fragment_rule_detail.rl_check_hint) {
|
return true;
|
}
|
if (v == fragment_time_rule_list_dialog.rl_check_pass_time) {
|
return true;
|
}
|
setLastAdminClickTime();
|
((MainActivity.this)).refreshCurrentFragmentShowTime();
|
if (view == fragment_toolbar.menu) {
|
} else {
|
if (fragment_menu.isVisible()) {
|
hideOneFragment(fragment_menu);
|
}
|
}
|
if (view != fragment_face_list.face_filter_identity_parent
|
&& view != fragment_face_list.face_filter_identity
|
&& view != fragment_face_list.face_filter_identity_ok
|
) {
|
fragment_face_list.hideFaceFilterIdentityFromNotOkButton();
|
}
|
if (view != fragment_face_list.face_filter_org
|
&& view != fragment_face_list.face_filter_org_parent
|
) {
|
fragment_face_list.hideFaceFilterOrgParent();
|
}
|
if (view != fragment_face_detail.face_detail_org
|
&& view != fragment_face_detail.face_detail_org_parent
|
) {
|
fragment_face_detail.hideOrgParent();
|
}
|
if (view == fragment_face_list.face_filter_org_parent) {
|
return true;
|
}
|
if (view == fragment_face_list.face_filter_identity_parent) {
|
return true;
|
}
|
if (!Constants.indoorOutdoorInOne) {
|
// if (view != fragment_guest_mode.ll_temp_person_check_identity
|
// && view != fragment_guest_mode.gv_temp_person
|
// && view != fragment_guest_mode.temporary_person_identity_ok
|
// ) {
|
// fragment_guest_mode.ll_temp_person_check_identity.setVisibility(View.GONE);
|
// }
|
// if (view == fragment_guest_mode.ll_temp_person_check_identity) {
|
// return true;
|
// }
|
}
|
if (view != fragment_guest_mode.rl_show_organization
|
&& view != fragment_guest_mode.respondent_org
|
) {
|
fragment_guest_mode.rl_show_organization.setVisibility(View.GONE);
|
}
|
if (view == fragment_guest_mode.rl_show_organization) {
|
return true;
|
}
|
if (!(view instanceof EditText)) {
|
KeyboardUtil.hideSoftKeyboard();
|
}
|
return false;
|
});
|
if (view instanceof ViewGroup) {
|
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
|
View innerView = ((ViewGroup) view).getChildAt(i);
|
setupUI(innerView);
|
}
|
}
|
}
|
|
@Click
|
public void saveDeviceIdButton() {
|
String deviceId = deviceIdEditText.getText().toString().trim();
|
if (deviceId.length() >= 1) {
|
DeviceManager.writeDeviceId(deviceId);
|
device_id_ll.setVisibility(View.GONE);
|
}
|
}
|
|
@UiThread
|
public void showInputDeviceId() {
|
device_id_ll.setVisibility(View.VISIBLE);
|
}
|
|
@UiThread
|
public void hideInputDeviceId() {
|
device_id_ll.setVisibility(View.GONE);
|
}
|
|
public void checkDeviceId() {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
SystemClock.sleep(2000);
|
String deviceId = DeviceManager.getDeviceId();
|
if (TextUtils.isEmpty(deviceId)) {
|
showInputDeviceId();
|
} else {
|
hideInputDeviceId();
|
}
|
});
|
}
|
|
public void addFaceComponents() {
|
fragmentHasFaceList.add(fragment_person_manage);
|
fragmentHasFaceDetail.add(fragment_su_logged_nic_wait_detail);
|
fragmentHasFaceDetail.add(fragment_su_logged_ic_compare_success);
|
fragmentHasFaceDetail.add(fragment_person_manage);
|
fragmentHasFaceDetail.add(fragment_su_logged_ic_wait_face);
|
fragmentHasFaceDetail.add(fragment_su_logged_nic_wait_face);
|
fragmentHasFaceDetail.add(fragment_su_logged_ic_wait_idcard);
|
}
|
|
public void toggleFaceComponent(BaseFragment showFragment) {
|
if (fragmentHasFaceList.contains(showFragment)) {
|
showOneFragment(fragment_face_list);
|
} else {
|
hideOneFragment(fragment_face_list);
|
}
|
if (fragmentHasFaceDetail.contains(showFragment)) {
|
showOneFragment(fragment_face_detail);
|
} else {
|
hideOneFragment(fragment_face_detail);
|
}
|
}
|
|
public void showFace(BaseFragment showFragment) {
|
if (fragmentHasFaceList.contains(showFragment)) {
|
if (!fragment_face_list.isShowing()) {
|
showOneFragment(fragment_face_list);
|
}
|
}
|
if (fragmentHasFaceDetail.contains(showFragment)) {
|
if (!fragment_face_detail.isShowing()) {
|
showOneFragment(fragment_face_detail);
|
}
|
}
|
}
|
|
public void showFragment(BaseFragment showFragment) {
|
if (showFragment == fragment_su_logged_ic_wait_face || showFragment == fragment_su_logged_nic_wait_face) {
|
BaseFragment.detectedResult = null;
|
// BaseApplication.getApplication().activity.fragment_face_detail.updateDetailUI(null);
|
// BaseApplication.getApplication().activity.fragment_face_detail.updateIdentityListUI(null);
|
}
|
if (showFragment == fragment_su_auto_wait_face) {
|
BaseFragment.detectedResult = null;
|
}
|
showFragment(showFragment, false);
|
}
|
|
public void showFragment(final BaseFragment showFragment, boolean forceRefresh) {
|
previewFragment = currentFragment;
|
LogFileUtils.logStacktraceToFile(this);
|
if (currentFragment == fragment_home) {
|
System1.out.println("");
|
}
|
FaceTitleAndTipsManager.clearFaceTitle();
|
FaceTitleAndTipsManagerS.clearFaceTitle();
|
BaseApplication.getApplication().activity.runOnUiThread(() -> {
|
// currentFragmentTextView.setText(showFragment.toString().split("_")[0]);
|
if (currentFragment == showFragment && !forceRefresh) {
|
return;
|
}
|
((MainActivity.this)).refreshCurrentFragmentShowTime(showFragment);
|
togglePasswordOpenDoorFragment(showFragment);
|
((MainActivity.this)).toggleFaceComponent(showFragment);
|
((MainActivity.this)).toggleCamera(showFragment);
|
((MainActivity.this)).toggleVideoView(showFragment);
|
((MainActivity.this)).toggleAdvertisingImageView(showFragment);
|
((MainActivity.this)).toggleToolbarButtons(showFragment);
|
((MainActivity.this)).toggleIdCardPhoneComponent(showFragment);
|
((MainActivity.this)).toggleBackgroundAndBorderComponent(showFragment);
|
((MainActivity.this)).toggleSystemSettingTabsComponent(showFragment);
|
KeyboardUtil.hideSoftKeyboard();
|
for (BaseFragment fragment : fragments) {
|
if (fragment != showFragment) {
|
hideOneFragment(fragment);
|
}
|
}
|
SystemClock.sleep(100);
|
for (BaseFragment fragment : fragments) {
|
if (fragment == showFragment) {
|
hideOneFragment(fragment);
|
showOneFragment(fragment);
|
}
|
}
|
((MainActivity.this)).toggleSystemSettingHintTabsComponent(showFragment);
|
((MainActivity.this)).togglePersonManagerComponent(showFragment);
|
if ((previewFragment != fragment_su_auto_wait_face
|
&& previewFragment != fragment_door_access_result
|
&& previewFragment != fragment_su_auto_wait_admin
|
) || currentFragment == fragment_admin_face_login) {
|
FaceTitleAndTipsManager.clearFaceTitle();
|
FaceTitleAndTipsManagerS.clearFaceTitle();
|
((CameraFragment) fragment_camera).drawFaceRect(CameraFragment.lastDetectedResult);
|
}
|
});
|
}
|
|
private void togglePasswordOpenDoorFragment(BaseFragment showFragment) {
|
if (showFragment == fragment_su_auto_wait_face
|
|| showFragment == fragment_door_access_result
|
|| showFragment == fragment_su_auto_wait_admin
|
) {
|
showOneFragment(fragment_password_open_door);
|
} else {
|
hideOneFragment(fragment_password_open_door);
|
fragment_password_open_door.hideKeyboard();
|
}
|
}
|
|
public void showOneFragment(BaseFragment fragment) {
|
if (!fragment.isShow || !fragment.getUserVisibleHint()) {
|
View view = fragment.getView();
|
if (view != null) {
|
view.setVisibility(View.VISIBLE);
|
}
|
FragmentManager fm = getSupportFragmentManager();
|
fm.beginTransaction()
|
.show(fragment)
|
.commitAllowingStateLoss();
|
fragment.setUserVisibleHint(true);
|
}
|
fragment.show();
|
}
|
|
public void hideOneFragment(BaseFragment fragment) {
|
if (fragment.isShow || fragment.getUserVisibleHint()) {
|
View view = fragment.getView();
|
if (view != null) {
|
view.setVisibility(View.INVISIBLE);
|
}
|
fragment.hide();
|
FragmentManager fm = getSupportFragmentManager();
|
fm.beginTransaction()
|
.hide(fragment)
|
.commitAllowingStateLoss();
|
fragment.setUserVisibleHint(false);
|
}
|
}
|
|
public void addFragment(BaseFragment... fragmentList) {
|
for (BaseFragment fragment : fragmentList) {
|
if (fragment != fragment_home) {
|
hideOneFragment(fragment);
|
}
|
}
|
fragments.addAll(Arrays.asList(fragmentList));
|
}
|
|
public void addFragments() {
|
addFragment(
|
fragment_user,
|
fragment_base_setting,
|
fragment_device,
|
fragment_cluster,
|
fragment_org,
|
fragment_admin_face_login,
|
fragment_admin_password_login,
|
fragment_home,
|
fragment_rule_detail,
|
fragment_time_rule_list_dialog, fragment_device_list_dialog,
|
fragment_time_rule_list_dialog_small, fragment_device_list_dialog_small,
|
fragment_rule_list,
|
fragment_su_auto_ic_compare_success,
|
fragment_su_auto_ic_wait_idcard,
|
fragment_su_logged_ic_compare_success,
|
fragment_su_logged_ic_wait_face,
|
fragment_su_logged_ic_wait_idcard,
|
fragment_su_logged_nic_wait_face,
|
fragment_su_logged_nic_wait_detail,
|
fragment_su_auto_wait_admin,
|
fragment_su_auto_wait_face,
|
fragment_person_manage,
|
fragment_door_access_fail,
|
fragment_door_access_result,
|
fragment_visit_list,
|
fragment_door_access_success,
|
fragment_door_access_confirm,
|
fragment_sign_up_success,
|
fragment_su_logged_wait_face,
|
fragment_su_auto_nic_wait_detail,
|
fragment_hint_tab,
|
fragment_hint_door_access,
|
fragment_hint_recognize,
|
fragment_hint_sign_up,
|
fragment_time_rule,
|
fragment_business_person,
|
fragment_time_rule_add,
|
fragment_admin_logout,
|
fragment_guest_mode
|
);
|
}
|
|
public void addIdCardPhoneComponent() {
|
}
|
|
public void toggleIdCardPhoneComponent(BaseFragment showFragment) {
|
if (fragmentHasIdCardPhone.contains(showFragment)) {
|
} else {
|
hideOneFragment(fragment_su_auto_ic_wait_phone);
|
}
|
}
|
|
public void logoutChecker() {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
while (true) {
|
try {
|
if (UserManager.adminLoggedIn()) {
|
if ((System.currentTimeMillis() - lastAdminClickTime) * 1.0 / 1000 / 60 > BaseSettingManager.getLoginExpireInMinutes()) {
|
UserManager.setAdminUser(null);
|
if (adminFragments.contains(currentFragment)) {
|
showFragment(fragment_home);
|
}
|
}
|
}
|
SystemClock.sleep(5 * 1000);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
});
|
}
|
|
@SuppressWarnings("all")
|
public void addPersonManagerComponents() {
|
fragmentsHasPersonManager.add(fragment_person_manage);
|
fragmentsHasPersonManager.add(fragment_su_logged_ic_wait_idcard);
|
fragmentsHasPersonManager.add(fragment_su_logged_ic_compare_success);
|
fragmentsHasPersonManager.add(fragment_su_logged_nic_wait_detail);
|
}
|
|
public void togglePersonManagerComponent(BaseFragment showFragment) {
|
if (fragmentsHasPersonManager.contains(showFragment)) {
|
showOneFragment(fragment_person_manage);
|
} else {
|
hideOneFragment(fragment_person_manage);
|
}
|
}
|
|
@SuppressWarnings("all")
|
public void addSystemSettingTabs() {
|
fragmentsHasSystemSettingTabs.add(fragment_base_setting);
|
fragmentsHasSystemSettingTabs.add(fragment_device);
|
fragmentsHasSystemSettingTabs.add(fragment_cluster);
|
fragmentsHasSystemSettingTabs.add(fragment_org);
|
fragmentsHasSystemSettingTabs.add(fragment_user);
|
fragmentsHasSystemSettingTabs.add(fragment_hint_tab);
|
fragmentsHasSystemSettingTabs.add(fragment_time_rule);
|
fragmentsHasSystemSettingTabs.add(fragment_time_rule_add);
|
fragmentsHasSystemSettingTabs.add(fragment_hint_recognize);
|
fragmentsHasSystemSettingTabs.add(fragment_hint_door_access);
|
fragmentsHasSystemSettingTabs.add(fragment_hint_sign_up);
|
}
|
|
public void toggleSystemSettingTabsComponent(BaseFragment showFragment) {
|
if (fragmentsHasSystemSettingTabs.contains(showFragment)) {
|
showOneFragment(fragment_system_setting_tabs);
|
} else {
|
hideOneFragment(fragment_system_setting_tabs);
|
}
|
}
|
|
@SuppressWarnings("all")
|
public void addSystemSettingHintTabs() {
|
fragmentsHasSystemSettingHintTabs.add(fragment_hint_tab);
|
fragmentsHasSystemSettingHintTabs.add(fragment_hint_recognize);
|
fragmentsHasSystemSettingHintTabs.add(fragment_hint_door_access);
|
fragmentsHasSystemSettingHintTabs.add(fragment_hint_sign_up);
|
}
|
|
public void toggleSystemSettingHintTabsComponent(BaseFragment showFragment) {
|
if (fragmentsHasSystemSettingHintTabs.contains(showFragment)) {
|
showOneFragment(fragment_hint_tab);
|
} else {
|
hideOneFragment(fragment_hint_tab);
|
}
|
}
|
|
public void refreshCurrentFragmentShowTime(BaseFragment showFragment) {
|
currentFragment = showFragment;
|
refreshCurrentFragmentShowTime();
|
}
|
|
public void refreshCurrentFragmentShowTime() {
|
currentFragmentShowTime = System.currentTimeMillis();
|
}
|
|
public boolean isTimeout(int timeoutSeconds) {
|
return System.currentTimeMillis() > (currentFragmentShowTime + timeoutSeconds * 1000);
|
}
|
|
public void addTimeoutToBlank() {
|
timeoutToBlankMap.put(fragment_door_access_result, new TimeoutToBlank(3, fragment_door_access_result, fragment_su_auto_wait_face));
|
timeoutToBlankMap.put(fragment_door_access_fail, new TimeoutToBlank(3, fragment_door_access_fail, fragment_su_auto_wait_face));
|
timeoutToBlankMap.put(fragment_door_access_success, new TimeoutToBlank(3, fragment_door_access_success, fragment_su_auto_wait_face));
|
noFaceDelayTimeoutToBlank = new TimeoutToBlank(() -> {
|
return BaseSettingManager.getNoFaceDelay();
|
}, fragment_su_auto_wait_face, fragment_home);
|
timeoutToBlankMap.put(fragment_su_auto_wait_face, noFaceDelayTimeoutToBlank);
|
timeoutToBlankMap.put(fragment_su_auto_wait_admin, new TimeoutToBlank(3, fragment_su_auto_wait_admin, fragment_su_auto_wait_face));
|
timeoutToBlankMap.put(fragment_su_auto_ic_wait_idcard, new TimeoutToBlank(20, fragment_su_auto_ic_wait_idcard, fragment_su_auto_wait_face));
|
timeoutToBlankMap.put(fragment_sign_up_success, new TimeoutToBlank(5, fragment_sign_up_success, fragment_su_auto_wait_face));
|
timeoutToBlankMap.put(fragment_admin_password_login, new TimeoutToBlank(() -> {
|
return BaseSettingManager.getBackToHomeInSeconds();
|
}, fragment_admin_password_login, fragment_admin_logout));
|
timeoutToBlankMap.put(fragment_admin_face_login, new TimeoutToBlank(() -> {
|
return BaseSettingManager.getNoFaceDelay();
|
}, fragment_admin_face_login, fragment_home));
|
timeoutToBlankMap.put(fragment_su_auto_nic_wait_detail, new TimeoutToBlank(25, fragment_su_auto_nic_wait_detail, fragment_home));
|
timeoutToBlankMap.put(fragment_su_auto_ic_compare_success, new TimeoutToBlank(25, fragment_su_auto_ic_compare_success, fragment_home));
|
}
|
|
public boolean needTimeoutToBlank() {
|
if (timeoutToBlankMap == null) {
|
return false;
|
}
|
try {
|
defaultTimeoutSeconds = BaseSettingManager.getBackToHomeInSeconds();
|
TimeoutToBlank timeoutToBlank = timeoutToBlankMap.get(currentFragment);
|
if (timeoutToBlank != null) {
|
timeoutToBlank.toFragment();
|
return true;
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return false;
|
}
|
|
public void addToolbarButtonsToFragment() {
|
Set<View> home_login = new HashSet<>(Arrays.asList(
|
fragment_toolbar.login
|
));
|
Set<View> home = new HashSet<>(Arrays.asList(
|
));
|
Set<View> login = new HashSet<>(Arrays.asList(
|
fragment_toolbar.login
|
));
|
Set<View> logout_menu = new HashSet<>(Arrays.asList(
|
fragment_toolbar.logout,
|
fragment_toolbar.admin_msg
|
));
|
if (Constants.indoorOutdoorInOne) {
|
logout_menu.addAll(Arrays.asList(
|
fragment_toolbar.person_manage,
|
fragment_toolbar.visit_records,
|
fragment_toolbar.system_setting,
|
fragment_toolbar.visitor_model
|
));
|
} else {
|
logout_menu.add(fragment_toolbar.menu);
|
}
|
fragmentToolbarButtons.put(fragment_rule_detail, logout_menu);
|
fragmentToolbarButtons.put(fragment_rule_list, logout_menu);
|
fragmentToolbarButtons.put(fragment_person_manage, logout_menu);
|
fragmentToolbarButtons.put(fragment_visit_list, logout_menu);
|
fragmentToolbarButtons.put(fragment_guest_mode, logout_menu);
|
fragmentToolbarButtons.put(fragment_su_auto_wait_admin, home_login);
|
fragmentToolbarButtons.put(fragment_su_auto_ic_compare_success, home_login);
|
fragmentToolbarButtons.put(fragment_su_auto_ic_wait_idcard, home_login);
|
fragmentToolbarButtons.put(fragment_su_auto_nic_wait_detail, home_login);
|
fragmentToolbarButtons.put(fragment_admin_face_login, home);
|
fragmentToolbarButtons.put(fragment_admin_password_login, home);
|
fragmentToolbarButtons.put(fragment_home, login);
|
fragmentToolbarButtons.put(fragment_su_auto_wait_face, home_login);
|
fragmentToolbarButtons.put(fragment_su_logged_ic_compare_success, logout_menu);
|
fragmentToolbarButtons.put(fragment_su_logged_ic_wait_face, logout_menu);
|
fragmentToolbarButtons.put(fragment_su_logged_ic_wait_idcard, logout_menu);
|
fragmentToolbarButtons.put(fragment_su_logged_nic_wait_face, logout_menu);
|
fragmentToolbarButtons.put(fragment_user, logout_menu);
|
fragmentToolbarButtons.put(fragment_device, logout_menu);
|
fragmentToolbarButtons.put(fragment_base_setting, logout_menu);
|
fragmentToolbarButtons.put(fragment_cluster, logout_menu);
|
fragmentToolbarButtons.put(fragment_org, logout_menu);
|
fragmentToolbarButtons.put(fragment_su_logged_nic_wait_detail, logout_menu);
|
fragmentToolbarButtons.put(fragment_door_access_fail, home_login);
|
fragmentToolbarButtons.put(fragment_door_access_result, home_login);
|
fragmentToolbarButtons.put(fragment_door_access_success, home_login);
|
fragmentToolbarButtons.put(fragment_sign_up_success, home_login);
|
fragmentToolbarButtons.put(fragment_hint_tab, logout_menu);
|
fragmentToolbarButtons.put(fragment_hint_recognize, logout_menu);
|
fragmentToolbarButtons.put(fragment_hint_door_access, logout_menu);
|
fragmentToolbarButtons.put(fragment_hint_sign_up, logout_menu);
|
fragmentToolbarButtons.put(fragment_time_rule, logout_menu);
|
fragmentToolbarButtons.put(fragment_time_rule_add, logout_menu);
|
fragmentToolbarButtons.put(fragment_business_person, logout_menu);
|
}
|
|
public void toggleToolbarButtons(BaseFragment showFragment) {
|
Set<View> visibleToolbarButtons = fragmentToolbarButtons.get(showFragment);
|
fragment_toolbar.showButtons(visibleToolbarButtons);
|
}
|
|
public void addVideoViewToFragment() {
|
if (!Constants.indoorOutdoorInOne) {
|
fragmentsHasVideoView.add(fragment_home);
|
fragmentsHasVideoView.add(fragment_su_auto_wait_face);
|
fragmentsHasVideoView.add(fragment_su_auto_wait_admin);
|
fragmentsHasVideoView.add(fragment_su_auto_ic_wait_idcard);
|
fragmentsHasVideoView.add(fragment_su_auto_ic_compare_success);
|
fragmentsHasVideoView.add(fragment_admin_face_login);
|
fragmentsHasVideoView.add(fragment_admin_password_login);
|
fragmentsHasVideoView.add(fragment_door_access_fail);
|
fragmentsHasVideoView.add(fragment_door_access_result);
|
fragmentsHasVideoView.add(fragment_door_access_success);
|
fragmentsHasVideoView.add(fragment_door_access_confirm);
|
fragmentsHasVideoView.add(fragment_sign_up_success);
|
fragmentsHasVideoView.add(fragment_su_logged_wait_face);
|
fragmentsHasVideoView.add(fragment_su_auto_nic_wait_detail);
|
}
|
}
|
|
public void toggleVideoView(BaseFragment showFragment) {
|
if (!fragmentsHasVideoView.contains(showFragment)) {
|
fragment_video_view.showOverlay();
|
} else {
|
fragment_video_view.hideOverlay();
|
}
|
}
|
|
public void toggleAdvertisingImageView(BaseFragment showFragment) {
|
if (!fragmentsHasAdvertisingImageView.contains(showFragment)) {
|
hideOneFragment(showFragment);
|
} else {
|
showOneFragment(showFragment);
|
}
|
}
|
|
@Override
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
if (requestCode == VisitListFragment.REQUEST_CODE || 1 == 1) {
|
if (resultCode != RESULT_OK) {
|
return;
|
}
|
try {
|
OutputStream outputStream = getContentResolver().openOutputStream(data.getData());
|
FileUtils.copyFile(new File("/sdcard/visit_list.xlsx"), outputStream);
|
outputStream.flush();
|
outputStream.close();
|
ToastUtil.show("导出成功");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
@UiThread
|
public void updateCameraImagesInSecondDisplay(Bitmap bitmap) {
|
try {
|
secondaryDisplay = SystemInitManager.secondaryDisplay;
|
if (secondaryDisplay != null) {
|
if (secondaryDisplay.cameraImage != null) {
|
if (bitmap != null) {
|
secondaryDisplay.cameraImage.setImageBitmap(bitmap);
|
}
|
Preview.secondDisplayRunnable.isRunning = false;
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Override
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
IdCardManager.mReader = IDCardReader.getInstance(this);
|
setContentView(com.basic.security.utils.ResolutionAdaptation.activity_main());
|
}
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
unregisterReceiver(mUsbDetachReceiver);
|
unregisterReceiver(mUsbAttachReceiver);
|
if (Constants.isWhiteDevice) {
|
WhiteDevice.close();
|
}
|
}
|
|
@AfterViews
|
protected void afterViews() {
|
BaseApplication.getApplication().executorService.execute(new Runnable() {
|
@Override
|
public void run() {
|
try {
|
MultipartUtilityV2.uploadCrashDirectory();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
});
|
int pixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
1, this.getResources().getDisplayMetrics());
|
// System.out.println("MainActivity.afterViews 1dp=" + pixels);
|
allUiLoaded = true;
|
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_ATTACHED);
|
registerReceiver(mUsbAttachReceiver, filter);
|
filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
|
registerReceiver(mUsbDetachReceiver, filter);
|
if (Constants.isOutdoor) {
|
RelayServerUtil2.startOpenDoorThread();
|
}
|
if (!PermissionHelper.hasWriteStoragePermission(this)) {
|
PermissionHelper.requestWriteStoragePermission(this);
|
}
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 保持屏幕常亮
|
hideSystemUIThread();
|
addFragments();
|
addCameraToFragment();
|
addVideoViewToFragment();
|
addToolbarButtonsToFragment();
|
addTimeoutToBlank();
|
addIdCardPhoneComponent();
|
addBackgroundAndBorderComponent();
|
addCameras();
|
setUpClickHook();
|
addFaceComponents();
|
addSystemSettingTabs();
|
addSystemSettingHintTabs();
|
addPersonManagerComponents();
|
logoutChecker();
|
hideOneFragment(fragment_advertising_image_view);
|
hideOneFragment(fragment_admin_logout);
|
hideOneFragment(fragment_password_open_door);
|
hideOneFragment(fragment_menu);
|
hideOneFragment(fragment_face_list);
|
hideOneFragment(fragment_face_detail);
|
hideOneFragment(fragment_org_person);
|
hideOneFragment(fragment_system_setting_tabs);
|
hideOneFragment(fragment_su_auto_ic_wait_phone);
|
hideOneFragment(fragment_su_logged_ic_wait_idcard);
|
hideOneFragment(fragment_su_logged_ic_compare_success);
|
hideOneFragment(fragment_background_and_border);
|
if (Constants.isOutdoor) {
|
showFragment(fragment_home);
|
}
|
if (Constants.isIndoor) {
|
showFragment(fragment_guest_mode);
|
}
|
checkDeviceId();
|
stopService(new Intent(this, KeepLifeService.class));
|
// stopService(new Intent(this, UpgradeAppService.class));
|
// stopService(new Intent(this, NodeNameService.class));
|
startService(new Intent(this, KeepLifeService.class));
|
// startService(new Intent(this, UpgradeAppService.class));
|
// startService(new Intent(this, NodeNameService.class));
|
if (Constants.isIndoor) {
|
IndoorReceiveIpSocketServer.startServer();
|
}
|
mainActivityInitComplete = true;
|
if (Constants.autoRestart) {
|
new ANRWatchDog().start();
|
}
|
RecognizeManager.sendKeepLife();
|
if (Constants.isWhiteDevice) {
|
WhiteDevice.initWhiteDevice();
|
}
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
}
|
|
protected void onResume() {
|
super.onResume();
|
if (Constants.indoorOutdoorInOne) {
|
openDevice();
|
} else if (Constants.needIdCardModule) {
|
Intent intent1 = new Intent();
|
intent1.setPackage("com.basic.project.idcardservice");
|
intent1.setAction("com.basic.read.IDCard");
|
intent1.putExtra("type", "start_service");
|
intent1.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
startService(intent1);
|
}
|
}
|
|
public void onBackPressed() {
|
long currentTime = System.currentTimeMillis();
|
if ((currentTime - startTime) >= 2000) {
|
ToastUtil.show("再按一次退出");
|
startTime = currentTime;
|
} else {
|
exitApp();
|
}
|
}
|
|
private void exitApp() {
|
if (Constants.needIdCardModule) {
|
if (Constants.needIdCardModule) {
|
if (isNewIDCardReader) {
|
if (readCardUtil != null) {
|
readCardUtil.stopReadCard();
|
readCardUtil.destroy();
|
}
|
} else {
|
IdCardManager.unRegisterBroadcast(this);
|
}
|
}
|
}
|
finish();
|
System.exit(0);
|
}
|
|
private void openDevice() {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
synchronized (MainActivity.this) {
|
int error;
|
if ((error = IdCardManager.mReader.powerOn()) != IDCardReader.RESULT_OK) {
|
}
|
if ((error = IdCardManager.mReader.open()) != IDCardReader.RESULT_OK) {
|
} else {
|
}
|
}
|
});
|
}
|
|
private void closeDevice() {
|
BaseApplication.getApplication().executorService.execute(new Runnable() {
|
@Override
|
public void run() {
|
synchronized (MainActivity.this) {
|
int error;
|
if ((error = IdCardManager.mReader.close()) != IDCardReader.RESULT_OK) {
|
} else {
|
}
|
if ((error = IdCardManager.mReader.powerOff()) != IDCardReader.RESULT_OK) {
|
}
|
}
|
}
|
});
|
}
|
|
protected void onPause() {
|
super.onPause();
|
if (Constants.indoorOutdoorInOne) {
|
closeDevice();
|
}
|
KeyboardUtil.hideSoftKeyboard();
|
}
|
|
protected void onStop() {
|
super.onStop();
|
}
|
|
@Click
|
public void batch_move_to_org() {
|
fragment_face_list.batch_move_to_org();
|
}
|
|
@Click
|
public void batch_delete_person() {
|
fragment_face_list.batch_delete_person();
|
}
|
|
@Click
|
public void batch_cancel() {
|
fragment_face_list.exitBatchMode();
|
}
|
|
public String requestFrame() {
|
return currentFragment == fragment_guest_mode ? Constants.TRUE : Constants.FALSE;
|
}
|
|
@UiThread
|
public void showAnswerCall(boolean show) {
|
BaseApplication.getApplication().executorService.execute(new Runnable() {
|
@Override
|
public void run() {
|
if (show) {
|
mediaPlayer = AudioPlayer.play(mediaPlayer);
|
} else {
|
AudioPlayer.stop(mediaPlayer);
|
mediaPlayer = null;
|
}
|
}
|
});
|
}
|
|
public boolean needCopyCameraData() {
|
return true;
|
}
|
|
public interface Timeout {
|
public int getTimeoutSeconds();
|
}
|
|
|
public class TimeoutToBlank {
|
public int fixedTimeoutSeconds;
|
public BaseFragment from_fragment;
|
public BaseFragment to_fragment;
|
Timeout timeout;
|
boolean useDefaultTimeout = true;
|
|
public TimeoutToBlank(int fixedTimeoutSeconds, BaseFragment from_fragment, BaseFragment to_fragment) {
|
useDefaultTimeout = false;
|
this.from_fragment = from_fragment;
|
this.fixedTimeoutSeconds = fixedTimeoutSeconds;
|
this.to_fragment = to_fragment;
|
}
|
|
public TimeoutToBlank(Timeout timeout, BaseFragment from_fragment, BaseFragment to_fragment) {
|
this.timeout = timeout;
|
useDefaultTimeout = false;
|
this.from_fragment = from_fragment;
|
this.fixedTimeoutSeconds = fixedTimeoutSeconds;
|
this.to_fragment = to_fragment;
|
}
|
|
public TimeoutToBlank(BaseFragment from_fragment, BaseFragment to_fragment) {
|
this.from_fragment = from_fragment;
|
this.to_fragment = to_fragment;
|
}
|
|
public int getTimeoutSeconds() {
|
if (timeout != null) {
|
int timeoutSeconds = timeout.getTimeoutSeconds();
|
return timeoutSeconds;
|
}
|
if (useDefaultTimeout) {
|
return defaultTimeoutSeconds;
|
} else {
|
return fixedTimeoutSeconds;
|
}
|
}
|
|
public void toFragment() {
|
if (isTimeout(getTimeoutSeconds())) {
|
if (currentFragment == from_fragment) {
|
showFragment(to_fragment);
|
}
|
}
|
}
|
}
|
}
|