| | |
| | | import android.support.v4.app.FragmentActivity; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.text.TextUtils; |
| | | import android.util.DisplayMetrics; |
| | | import android.util.TypedValue; |
| | | import android.view.Display; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import com.alfeye.readcardlib.readcard.ReadCardUtil; |
| | | import com.basic.security.base.BaseApplication; |
| | | import com.basic.security.base.BaseFragment; |
| | | import com.basic.security.fragment.AccountSettingFragment; |
| | | import com.basic.security.fragment.AdminFaceLoginFragment; |
| | | import com.basic.security.fragment.AdminLogoutFragment; |
| | | import com.basic.security.fragment.AdminPasswordLoginFragment; |
| | |
| | | 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.AccountManager; |
| | | import com.basic.security.manager.BaseSettingManager; |
| | | import com.basic.security.manager.DatabaseManager; |
| | | import com.basic.security.manager.DeviceManager; |
| | |
| | | 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.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.SocketUtil; |
| | | 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; |
| | |
| | | @FragmentById |
| | | public AdminFaceLoginFragment fragment_admin_face_login; |
| | | @FragmentById |
| | | public AccountSettingFragment fragment_account_setting; |
| | | public UserFragment fragment_user; |
| | | @FragmentById |
| | | public ClusterFragment fragment_cluster; |
| | | @FragmentById |
| | |
| | | public void onReceive(Context context, Intent intent) { |
| | | String action = intent.getAction(); |
| | | lastTimeDetach = System.currentTimeMillis(); |
| | | System.out.println("MainActivity.onReceive mUsbDetachReceiver "); |
| | | 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; |
| | |
| | | || currentFragment == fragment_door_access_result |
| | | || currentFragment == fragment_admin_face_login |
| | | || currentFragment == fragment_home |
| | | || currentFragment == fragment_account_setting); |
| | | || currentFragment == fragment_user); |
| | | } |
| | | |
| | | |
| | | @SuppressWarnings("all") |
| | | public void addBackgroundAndBorderComponent() { |
| | | if (!Constants.landscape) { |
| | |
| | | background_and_border_fragment.topBackground1, |
| | | background_and_border_fragment.topBlurView1 |
| | | ))); |
| | | backgroundAndBorderViews.put(fragment_account_setting, |
| | | backgroundAndBorderViews.put(fragment_user, |
| | | new HashSet(Arrays.asList( |
| | | background_and_border_fragment.topBackground1, |
| | | background_and_border_fragment.topBlurView1 |
| | |
| | | background_and_border_fragment.topBackground1, |
| | | background_and_border_fragment.topBlurView1 |
| | | ))); |
| | | backgroundAndBorderViews.put(fragment_account_setting, |
| | | backgroundAndBorderViews.put(fragment_user, |
| | | new HashSet(Arrays.asList( |
| | | background_and_border_fragment.topBackground1, |
| | | background_and_border_fragment.topBlurView1 |
| | |
| | | currentFragment == fragment_su_logged_ic_wait_face || |
| | | currentFragment == fragment_su_auto_wait_face || |
| | | currentFragment == fragment_su_logged_nic_wait_face || |
| | | currentFragment == fragment_account_setting || |
| | | currentFragment == fragment_user || |
| | | currentFragment == fragment_door_access_success || |
| | | currentFragment == fragment_door_access_confirm || |
| | | currentFragment == fragment_su_auto_ic_wait_idcard || |
| | |
| | | currentFragment == fragment_su_auto_ic_wait_idcard || |
| | | currentFragment == fragment_su_auto_wait_face || |
| | | currentFragment == fragment_su_logged_nic_wait_face || |
| | | currentFragment == fragment_account_setting || |
| | | 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_account_setting, |
| | | List<BaseFragment> allFragments = Arrays.asList(fragment_user, |
| | | fragment_admin_face_login, |
| | | fragment_admin_password_login, |
| | | fragment_cluster, |
| | |
| | | setupUI(fragment.getView()); |
| | | } |
| | | adminFragments.addAll(Arrays.asList( |
| | | fragment_account_setting, |
| | | fragment_user, |
| | | fragment_base_setting, |
| | | fragment_cluster, |
| | | fragment_org, |
| | |
| | | } |
| | | |
| | | public void setLastAdminClickTime() { |
| | | if (adminFragments.contains(currentFragment) && AccountManager.adminLoggedIn()) { |
| | | if (adminFragments.contains(currentFragment) && UserManager.adminLoggedIn()) { |
| | | lastAdminClickTime = System.currentTimeMillis(); |
| | | } |
| | | } |
| | |
| | | } |
| | | 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 |
| | |
| | | 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); |
| | | // 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; |
| | |
| | | previewFragment = currentFragment; |
| | | LogFileUtils.logStacktraceToFile(this); |
| | | if (currentFragment == fragment_home) { |
| | | System.out.println(""); |
| | | System1.out.println(""); |
| | | } |
| | | FaceTitleAndTipsManager.clearFaceTitle(); |
| | | FaceTitleAndTipsManagerS.clearFaceTitle(); |
| | |
| | | |
| | | public void addFragments() { |
| | | addFragment( |
| | | fragment_account_setting, |
| | | fragment_user, |
| | | fragment_base_setting, |
| | | fragment_device, |
| | | fragment_cluster, |
| | |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | | while (true) { |
| | | try { |
| | | if (AccountManager.adminLoggedIn()) { |
| | | if (UserManager.adminLoggedIn()) { |
| | | if ((System.currentTimeMillis() - lastAdminClickTime) * 1.0 / 1000 / 60 > BaseSettingManager.getLoginExpireInMinutes()) { |
| | | AccountManager.setAdminAccount(null); |
| | | UserManager.setAdminUser(null); |
| | | if (adminFragments.contains(currentFragment)) { |
| | | showFragment(fragment_home); |
| | | } |
| | |
| | | fragmentsHasSystemSettingTabs.add(fragment_device); |
| | | fragmentsHasSystemSettingTabs.add(fragment_cluster); |
| | | fragmentsHasSystemSettingTabs.add(fragment_org); |
| | | fragmentsHasSystemSettingTabs.add(fragment_account_setting); |
| | | fragmentsHasSystemSettingTabs.add(fragment_user); |
| | | fragmentsHasSystemSettingTabs.add(fragment_hint_tab); |
| | | fragmentsHasSystemSettingTabs.add(fragment_time_rule); |
| | | fragmentsHasSystemSettingTabs.add(fragment_time_rule_add); |
| | |
| | | )); |
| | | Set<View> logout_menu = new HashSet<>(Arrays.asList( |
| | | fragment_toolbar.logout, |
| | | fragment_toolbar.admin_msg, |
| | | fragment_toolbar.person_manage, |
| | | fragment_toolbar.visit_records, |
| | | fragment_toolbar.system_setting, |
| | | fragment_toolbar.visitor_model |
| | | 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_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_account_setting, 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); |
| | |
| | | } |
| | | |
| | | 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) { |
| | |
| | | super.onDestroy(); |
| | | unregisterReceiver(mUsbDetachReceiver); |
| | | unregisterReceiver(mUsbAttachReceiver); |
| | | if (Constants.isWhiteDevice) { |
| | | WhiteDevice.close(); |
| | | } |
| | | } |
| | | private static String getScreenResolution(Context context) { |
| | | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); |
| | | Display display = wm.getDefaultDisplay(); |
| | | DisplayMetrics metrics = new DisplayMetrics(); |
| | | display.getMetrics(metrics); |
| | | int width = metrics.widthPixels; |
| | | int height = metrics.heightPixels; |
| | | |
| | | return "{" + width + "," + height + "}"; |
| | | } |
| | | @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; |
| | | System.out.println("MainActivity.afterViews getScreenResolution=" + getScreenResolution(this)); |
| | | IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_ATTACHED); |
| | | registerReceiver(mUsbAttachReceiver, filter); |
| | | filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED); |
| | |
| | | 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_su_logged_ic_wait_idcard); |
| | | hideOneFragment(fragment_su_logged_ic_compare_success); |
| | | hideOneFragment(fragment_background_and_border); |
| | | hideOneFragment(fragment_advertising_image_view); |
| | | if (Constants.isOutdoor) { |
| | | showFragment(fragment_home); |
| | | } |
| | |
| | | new ANRWatchDog().start(); |
| | | } |
| | | RecognizeManager.sendKeepLife(); |
| | | if (Constants.isWhiteDevice) { |
| | | WhiteDevice.initWhiteDevice(); |
| | | } |
| | | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
| | | } |
| | | |
| | | protected void onResume() { |
| | |
| | | }); |
| | | } |
| | | |
| | | // public void answerCall() { |
| | | // Intent launchIntent = getPackageManager().getLaunchIntentForPackage("org.appspot.apprtc"); |
| | | // if (launchIntent != null) { |
| | | // launchIntent.putExtra("ip", SocketUtil.getRpcCallIp()); |
| | | // launchIntent.putExtra("cameraIndex", "0"); |
| | | // launchIntent.putExtra("orientation", "landscape"); |
| | | // launchIntent.putExtra("localCameraRotation", "0"); |
| | | // launchIntent.putExtra("remoteCameraRotation", "270"); |
| | | // startActivity(launchIntent); |
| | | // } |
| | | // } |
| | | |
| | | public boolean needCopyCameraData() { |
| | | return true; |
| | | } |
| | |
| | | public int getTimeoutSeconds(); |
| | | } |
| | | |
| | | |
| | | public class TimeoutToBlank { |
| | | public int fixedTimeoutSeconds; |
| | | public BaseFragment from_fragment; |