| | |
| | | package com.hdl.photovoltaic.ui.me; |
| | | |
| | | |
| | | import android.Manifest; |
| | | import android.content.Intent; |
| | | import android.os.Build; |
| | |
| | | |
| | | |
| | | import androidx.activity.result.ActivityResultLauncher; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | |
| | |
| | | import com.hdl.photovoltaic.utils.GlideUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationInputDialog; |
| | | import com.hdl.photovoltaic.widget.PermissionExplanationDialog; |
| | | import com.hdl.photovoltaic.widget.popupview.CameraAlbumPopWindow; |
| | | |
| | | import java.io.File; |
| | | import java.util.Objects; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setNotificationBarBackgroundColor(CustomColor.white); |
| | | setStatusBarTextColor(); |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | mMemberHeadIconUrl = UserConfigManage.getInstance().getUserImageUrl(); |
| | | //初始化 |
| | | initView(); |
| | |
| | | } |
| | | |
| | | private void initData() { |
| | | |
| | | // generalPermission = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() { |
| | | // @Override |
| | | // public void onActivityResult(Map<String, Boolean> result) { |
| | |
| | | |
| | | private void initEvent() { |
| | | |
| | | viewBinding.toolbarTopFragmentMeRl.topBackLl.setOnClickListener(new View.OnClickListener() { |
| | | viewBinding.toolbarTopRl.topBackLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // backPressedData(); |
| | | finish(); |
| | | } |
| | | }); |
| | | |
| | | viewBinding.personalDataUserPortraitIl.getRoot().setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | //Manifest.permission.WRITE_EXTERNAL_STORAGE 读写设备上的照片以及文件 |
| | | //generalPermission.launch(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}); |
| | | |
| | | PermissionUtils.requestPermissionsResultCallback(_mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionUtils.PermissionState() { |
| | | @Override |
| | | public void Success(int value) { |
| | | if (value == PermissionUtils.STATUS_REFUSE_PERMANENT) { |
| | | // generalPermission.launch(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}); |
| | | // Android 13以上用别的权限 |
| | | if (Build.VERSION.SDK_INT >= 33) { |
| | | // PermissionUtils.requestPermissionsResultCallback(_mActivity, Manifest.permission.READ_MEDIA_IMAGES, new PermissionUtils.PermissionState() { |
| | | // @Override |
| | | // public void Success(int value) { |
| | | // if (value == PermissionUtils.STATUS_REFUSE_PERMANENT) { |
| | | // HdlThreadLogic.toast(_mActivity, R.string.permission_open); |
| | | return; |
| | | // return; |
| | | // } |
| | | changedUserAvatar(); |
| | | // } |
| | | // }, true); |
| | | } else { |
| | | // 未授权 如果应用程序没有所需的权限,则显示解释说明 |
| | | PermissionExplanationDialog.getInstance().showPortConflictPdDialog(_mActivity, getString(R.string.camera_storage_instructions), getString(R.string.camera_storage_purpose)); |
| | | PermissionUtils.requestPermissionsResultCallback(_mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionUtils.PermissionState() { |
| | | @Override |
| | | public void Success(int value) { |
| | | PermissionExplanationDialog.getInstance().dismiss(); |
| | | if (value == PermissionUtils.STATUS_REFUSE_PERMANENT | value == PermissionUtils.STATUS_REFUSE) { |
| | | // HdlThreadLogic.toast(_mActivity, R.string.permission_open); |
| | | return; |
| | | } |
| | | changedUserAvatar(); |
| | | } |
| | | changedUserAvatar(); |
| | | } |
| | | }, true); |
| | | |
| | | }, true); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | changedNickname(); |
| | | } |
| | | }); |
| | | viewBinding.personalDataPhoneIl.getRoot().setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | Intent intent = new Intent(); |
| | | intent.setClass(_mActivity, BindPhoneActivity.class); |
| | | startActivityForResult(intent, 20); |
| | | } |
| | | }); |
| | | viewBinding.personalDataMailIl.getRoot().setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | Intent intent = new Intent(); |
| | | intent.setClass(_mActivity, BindMailActivity.class); |
| | | startActivityForResult(intent, 20); |
| | | } |
| | | }); |
| | | viewBinding.personalDataQrCodeIl.getRoot().setOnClickListener(new View.OnClickListener() { |
| | |
| | | } |
| | | |
| | | private void initView() { |
| | | viewBinding.toolbarTopFragmentMeRl.topTitleTv.setText(R.string.me_personal_data); |
| | | viewBinding.toolbarTopFragmentMeRl.topBackLl.setVisibility(View.VISIBLE); |
| | | viewBinding.toolbarTopFragmentMeRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null)); |
| | | viewBinding.toolbarTopFragmentMeRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | viewBinding.toolbarTopRl.topTitleTv.setText(R.string.me_personal_data); |
| | | viewBinding.toolbarTopRl.topBackLl.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataUserPortraitIl.sllLlRlNameTv.setText(R.string.me_personal_data_portrait); |
| | | viewBinding.personalDataUserNameIl.sllLlRlNameTv.setText(R.string.me_personal_data_user_name); |
| | | viewBinding.personalDataMailIl.sllLlRlNameTv.setText(R.string.home_login_email); |
| | | viewBinding.personalDataPhoneIl.sllLlRlNameTv.setText(R.string.home_login_phone); |
| | | viewBinding.personalDataQrCodeIl.sllLlRlNameTv.setText(R.string.qr_code_business_card); |
| | | viewBinding.personalDataUserPortraitIl.sllLlRlRightContentIv.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataUserPortraitIl.lineV.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataUserNameIl.sllLlRlRightContentTv.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataUserNameIl.lineV.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataMailIl.sllLlRlRightContentTv.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataMailIl.lineV.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataPhoneIl.sllLlRlRightContentTv.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataPhoneIl.lineV.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataQrCodeIl.sllLlRlRightContentIv.setVisibility(View.VISIBLE); |
| | | viewBinding.personalDataUserNameIl.sllLlRlRightContentTv.setText(UserConfigManage.getInstance().getUserName()); |
| | | viewBinding.personalDataQrCodeIl.sllLlRlRightContentIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.qr_code)); |
| | | setMemberHeadIcon(); |
| | | updateStyle(); |
| | | } |
| | | |
| | | |
| | |
| | | private void changedUserAvatar() { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //todo B端不支持更改昵称 |
| | | HdlThreadLogic.toast(_mActivity, R.string.loading_not_supported); |
| | | // HdlThreadLogic.toast(_mActivity, R.string.loading_not_supported); |
| | | |
| | | |
| | | } else { |
| | | cameraAlbumPopWindow = new CameraAlbumPopWindow(_mActivity, new CameraAlbumPopWindow.CameraAlbumListener() { |
| | | @Override |
| | |
| | | default: |
| | | break; |
| | | } |
| | | } else if (requestCode == 20 && resultCode == 20) { |
| | | updateStyle(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 刷新绑定手机号和邮箱 |
| | | */ |
| | | private void updateStyle() { |
| | | String phoneStr = TextUtils.isEmpty(UserConfigManage.getInstance().getBingPhone()) ? getString(R.string.set_not_bind) : UserConfigManage.getInstance().getBingPhone(); |
| | | String emailStr = TextUtils.isEmpty(UserConfigManage.getInstance().getBingEmail()) ? getString(R.string.set_not_bind) : UserConfigManage.getInstance().getBingEmail(); |
| | | viewBinding.personalDataPhoneIl.sllLlRlRightContentTv.setText(phoneStr); |
| | | viewBinding.personalDataMailIl.sllLlRlRightContentTv.setText(emailStr); |
| | | |
| | | } |
| | | |
| | | |
| | | } |