コード例 #1
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   if (mLayout == null) {
     mLayout = new MyProfileFragmentLayout(this, mLayoutEvent);
   }
   View view = mLayout.initView(this, inflater, container, savedInstanceState);
   initBaseValue(mLayout);
   if (!mLayout.isReUsedView()) {
     if (initValue(savedInstanceState) == false) {
       mHandler.postDelayed(
           new Runnable() {
             @Override
             public void run() {
               mToastPopup.show(getString(R.string.none_data), null);
               mScreenControl.backScreen();
             }
           },
           1000);
       return null;
     }
     initActionbar(getString(R.string.myprofile), R.drawable.action_bar_bg);
   }
   return view;
 }
コード例 #2
0
 private void setFingerCount() {
   if (mLayout == null) {
     return;
   }
   if (mUserInfo.fingerprint_templates != null) {
     mLayout.setFingerCount(String.valueOf(mUserInfo.fingerprint_templates.size()));
   } else {
     mLayout.setFingerCount("0");
   }
 }
コード例 #3
0
 private void setCardCount() {
   if (mLayout == null) {
     return;
   }
   if (mUserInfo.cards != null) {
     mLayout.setCardCount(String.valueOf(mUserInfo.cards.size()));
   } else {
     mLayout.setCardCount(String.valueOf("0"));
   }
 }
コード例 #4
0
  private void setImage(Bitmap bmp) {
    if (bmp == null) {
      return;
    }
    mBlurBmp = ImageUtil.fastBlur(bmp, 32);
    mLayout.setBlurBackGroud(mBlurBmp);
    mRbmp = ImageUtil.getRoundedBitmap(bmp, false);
    mLayout.setUserPhoto(mRbmp);

    mPhotoStatus = PhotoStatus.MODIFY;
    mUserInfo.photo = Base64.encodeToString(ImageUtil.bitmapToByteArray(bmp), 0);
    mUserInfo.photo = mUserInfo.photo.replaceAll("\n", "");
    mBackupPhoto = mUserInfo.photo;
  }
コード例 #5
0
 private void setPermission() {
   if (mUserInfo.roles == null || mUserInfo.roles.size() < 1) {
     mLayout.showOperator(false, getString(R.string.none));
   } else {
     int size = mUserInfo.roles.size();
     size--;
     if (size == 0) {
       mLayout.showOperator(true, mUserInfo.roles.get(0).description);
     } else if (size > 0) {
       mLayout.showOperator(
           true, mUserInfo.roles.get(size).description + " + " + mUserInfo.roles.size());
     }
   }
 }
コード例 #6
0
 @Override
 public void showPinPasswodPopup() {
   hideIme(mLayout.getUserIDView());
   if (mPinSwitch.getOn()) {
     MyProfileFragment.this.showPinPasswodPopup();
   } else {
     mPinSwitch.setSwitch(true);
   }
 }
コード例 #7
0
 private void setAccessGroupCount() {
   if (mLayout == null) {
     return;
   }
   int accessGroupCount = 0;
   if (mUserInfo.access_groups != null) {
     accessGroupCount = accessGroupCount + mUserInfo.access_groups.size();
   }
   mLayout.setAccessGroup(String.valueOf(accessGroupCount));
 }
コード例 #8
0
  private void UpdateClone() {
    if (mUserInfo.roles != null && mUserInfo.roles.size() > 0) {
      mUserInfo.password = mPasswordData;
      if (mLayout.getUserLoginID().equals("")) {
        mUserInfo.login_id = null;
      } else {
        mUserInfo.login_id = mLayout.getUserLoginID();
      }
    } else {
      mUserInfo.login_id = null;
      mUserInfo.password = null;
    }

    mUserInfo.name = mLayout.getUserName();
    mUserInfo.email = mLayout.getEmail();
    mUserInfo.phone_number = mLayout.getTelephone();

    if (mPinSwitch.getOn()) {
      if (mPinData != null && mPinData.length() > 3) {
        mUserInfo.pin_exist = true;
        mUserInfo.pin = mPinData;
      }
    } else {
      mUserInfo.pin = "";
    }

    switch (mPhotoStatus) {
      case NOT_MODIFY:
        if (mUserInfo.photo != null) {
          mBackupPhoto = mUserInfo.photo;
        }
        mUserInfo.photo = null;
        break;
      case MODIFY:
        break;
      case DELETE:
        mUserInfo.photo = "";
        break;
    }
  }
コード例 #9
0
        @Override
        public void run() {
          if (Build.VERSION.SDK_INT >= 23) {
            String permissionLabel = "";
            try {
              PackageManager pm = mContext.getPackageManager();
              PermissionGroupInfo pg =
                  pm.getPermissionGroupInfo(
                      Manifest.permission_group.STORAGE, PackageManager.GET_META_DATA);
              permissionLabel = pg.loadLabel(pm).toString();
            } catch (Exception e) {

            }
            if (!permissionLabel.isEmpty()) {
              permissionLabel = "(" + permissionLabel + ")";
            }
            permissionLabel =
                getString(R.string.guide_feature_permission)
                    + " "
                    + getString(R.string.allow_permission)
                    + permissionLabel;
            Snackbar snackbar =
                Snackbar.make(mLayout.getRootView(), permissionLabel, Snackbar.LENGTH_LONG)
                    .setAction(
                        getString(R.string.permission_setting),
                        new View.OnClickListener() {
                          @Override
                          public void onClick(View view) {
                            Intent intent = new Intent();
                            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            intent.setData(Uri.parse("package:" + mContext.getPackageName()));
                            mContext.startActivity(intent);
                          }
                        });
            // snackbar.setActionTextColor(Color.MAGENTA);
            View snackbarView = snackbar.getView();
            TextView textView =
                (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
            textView.setMaxLines(5);
            snackbar.show();
          }
        }
コード例 #10
0
  private boolean initValue(Bundle savedInstanceState) {
    if (mUserInfo == null) {
      mUserInfo = mUserDataProvider.getLoginUserInfo();
    }
    if (savedInstanceState != null) {
      int photoMode = savedInstanceState.getInt("photoStatus");
      mPhotoStatus = PhotoStatus.values()[photoMode];

      if (mUserInfo == null) {
        mUserInfo = (User) savedInstanceState.getSerializable(User.TAG);
      }
      if (BuildConfig.DEBUG) {
        Log.e(TAG, "mPhotoStatus restore:" + mPhotoStatus);
      }
    }
    mInvalidChecker = new InvalidChecker(mPopup);
    createUser();
    if (mUserInfo == null) {
      return false;
    }
    mPinSwitch = mLayout.getPinSwitchView();
    setView();
    return true;
  }
コード例 #11
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (super.onOptionsItemSelected(item)) {
      return true;
    }
    switch (item.getItemId()) {
      case R.id.action_save:
        if (mInvalidChecker.isEmptyString(
            getString(R.string.info), getString(R.string.user_create_empty), mLayout.getUserID())) {
          return true;
        }

        if (mLayout.isOperator()) {
          if (mInvalidChecker.isEmptyString(
              getString(R.string.info),
              getString(R.string.user_create_empty_idpassword),
              mLayout.getUserLoginID())) {
            return true;
          }
          if (!mUserInfo.password_exist) {
            if (mPasswordData == null) {
              mPopup.show(
                  PopupType.ALERT,
                  getString(R.string.info),
                  getString(R.string.user_create_empty_idpassword),
                  null,
                  null,
                  null);
              return true;
            }
          }
        }

        if (mInvalidChecker.isInvalidEmail(
            getString(R.string.info), getString(R.string.invalid_email), mLayout.getEmail())) {
          return true;
        }

        if (mPinData != null && mPinData.length() > 0 && mPinData.length() < 4) {
          mPopup.show(
              PopupType.ALERT,
              getString(R.string.info),
              getString(R.string.pincount),
              null,
              null,
              null);
          return true;
        }

        UpdateClone();
        mPopup.showWait(true);
        User user = null;
        try {
          user = mUserInfo.clone();
        } catch (CloneNotSupportedException e) {
          e.printStackTrace();
          return true;
        }
        user.setMyProfile();
        mUserDataProvider.modifyMyProfile(
            TAG, user, mModifyUserListener, mModifyUserErrorListener, null);
        return true;
      default:
        break;
    }
    return false;
  }
コード例 #12
0
 @Override
 public void onPause() {
   hideIme(mLayout.getUserIDView());
   super.onPause();
 }
コード例 #13
0
 @Override
 public void editOperator() {
   hideIme(mLayout.getUserIDView());
   MyProfileFragment.this.editOperator();
 }
コード例 #14
0
 @Override
 public void editAccessGroup() {
   hideIme(mLayout.getUserIDView());
   MyProfileFragment.this.editAccessGroup();
 }
コード例 #15
0
 @Override
 public void editFingerPrint() {
   hideIme(mLayout.getUserIDView());
   MyProfileFragment.this.editFingerPrint();
 }
コード例 #16
0
  private void setView() {
    if (mUserInfo == null) {
      return;
    }
    mLayout.setUserID(mUserInfo.user_id);
    mLayout.setUserName(mUserInfo.name);

    if (mUserInfo.pin_exist) {
      mLayout.showPin(true);
    } else {
      mLayout.showPin(false);
    }
    mLayout.setUserID(mUserInfo.user_id);
    mLayout.setUserName(mUserInfo.name);
    mLayout.setEmail(mUserInfo.email);
    mLayout.setTelephone(mUserInfo.phone_number);
    mLayout.setLoginID(mUserInfo.login_id);
    setPermission();

    if (mUserInfo.password_exist || (mPasswordData != null && !mPasswordData.isEmpty())) {
      mLayout.setPassword(getString(R.string.password_display));
    } else {
      mLayout.setPassword("");
    }

    if (mUserInfo.user_group != null) {
      mLayout.setUserGroup(mUserInfo.user_group.name);
      mLayout.setUserGroupID(mUserInfo.user_group.id);
    } else {
      //   mLayout.setUserGroup(getString(R.string.all_users));
      mLayout.setUserGroupID(String.valueOf(1));
    }

    if (mUserInfo.isActive()) {
      mLayout.setStatus(getString(R.string.status) + " " + getString(R.string.active));
    } else {
      mLayout.setStatus(getString(R.string.status) + " " + getString(R.string.inactive));
    }
    mLayout.setStatusSwitch(mUserInfo.isActive());
    mLayout.setDateStart(
        mUserInfo.getTimeFormmat(
            mTimeConvertProvider,
            User.UserTimeType.start_datetime,
            TimeConvertProvider.DATE_TYPE.FORMAT_DATE));
    mLayout.setDateEnd(
        mUserInfo.getTimeFormmat(
            mTimeConvertProvider,
            User.UserTimeType.expiry_datetime,
            TimeConvertProvider.DATE_TYPE.FORMAT_DATE));
    setAccessGroupCount();
    setFingerCount();
    setCardCount();

    if (mUserInfo.pin_exist || (mPinData != null && !mPinData.isEmpty())) {
      mLayout.setPin(getString(R.string.password_display));
    } else {
      mLayout.setPin("");
    }
    mPinSwitch.init(
        getActivity(),
        new OnChangeListener() {
          @Override
          public void onChange(boolean on) {
            if (BuildConfig.DEBUG) {
              Log.e(TAG, "pin :" + on);
            }
            if (on) {
              showPinPasswodPopup();
            } else {
              mLayout.setPin("");
              mPinData = null;
            }
          }
        },
        (mUserInfo.pin_exist || (mPinData != null && !mPinData.isEmpty())));
    mPinSwitch.setSwitch((mUserInfo.pin_exist || (mPinData != null && !mPinData.isEmpty())));
    mLayout.setUserPhotoDefault();
    if (mRbmp != null) {
      mLayout.setUserPhoto(mRbmp);
    } else if (bmp != null) {
      mRbmp = ImageUtil.getRoundedBitmap(bmp, false);
      mLayout.setUserPhoto(mRbmp);
    } else {
      if (mUserInfo.photo != null && !mUserInfo.photo.isEmpty()) {
        byte[] photoByte = Base64.decode(mUserInfo.photo, 0);
        bmp = ImageUtil.byteArrayToBitmap(photoByte);
        if (bmp != null) {
          mBlurBmp = ImageUtil.fastBlur(bmp, 32);
          mLayout.setBlurBackGroud(mBlurBmp);
          mRbmp = ImageUtil.getRoundedBitmap(bmp, false);
          mLayout.setUserPhoto(mRbmp);
        }
      }
    }
    isExistImageCheck();
  }
コード例 #17
0
 @Override
 public void showPasswodPopup() {
   hideIme(mLayout.getUserIDView());
   MyProfileFragment.this.showPasswodPopup();
 }