Commit 324693cab8d6622d3339da95b29582059bd545ba
1 parent
d3e82c2efd
Exists in
master
版本升级
Showing
2 changed files
with
77 additions
and
46 deletions
Show diff stats
app/build.gradle
... | ... | @@ -25,8 +25,8 @@ android { |
25 | 25 | applicationId "com.hjx.parent" |
26 | 26 | minSdk 24 |
27 | 27 | targetSdk 32 |
28 | - versionCode 1001 | |
29 | - versionName "1.0.0.1" | |
28 | + versionCode 1002 | |
29 | + versionName "1.0.0.2" | |
30 | 30 | |
31 | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
32 | 32 | } | ... | ... |
app/src/main/java/com/hjx/parent/ErrorBookActivity.java
... | ... | @@ -12,6 +12,7 @@ import android.view.LayoutInflater; |
12 | 12 | import android.view.View; |
13 | 13 | import android.view.ViewGroup; |
14 | 14 | import android.widget.LinearLayout; |
15 | +import android.widget.Toast; | |
15 | 16 | |
16 | 17 | import androidx.annotation.NonNull; |
17 | 18 | import androidx.annotation.Nullable; |
... | ... | @@ -22,6 +23,9 @@ import androidx.recyclerview.widget.RecyclerView; |
22 | 23 | import com.chad.library.adapter.base.BaseQuickAdapter; |
23 | 24 | import com.chad.library.adapter.base.BaseViewHolder; |
24 | 25 | import com.google.gson.Gson; |
26 | +import com.hjq.permissions.OnPermissionCallback; | |
27 | +import com.hjq.permissions.Permission; | |
28 | +import com.hjq.permissions.XXPermissions; | |
25 | 29 | import com.hjx.parent.adapter.ErrorAdapter; |
26 | 30 | import com.hjx.parent.bean.StudentBean; |
27 | 31 | import com.hjx.parent.databinding.ActivityErrorBookBinding; |
... | ... | @@ -86,51 +90,30 @@ public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { |
86 | 90 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { |
87 | 91 | @Override |
88 | 92 | public void onClick(View v) { |
89 | - MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | |
90 | - View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | |
91 | - dialog.setContentView(bottomView); | |
92 | - bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | |
93 | - @Override | |
94 | - public void onClick(View view) { | |
95 | - dialog.dismiss(); | |
96 | - Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
97 | - //确保有相机来处理Intent | |
98 | - filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | |
99 | - File photoFile = new File(filePath); | |
100 | - if (photoFile != null) { | |
101 | - //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | |
102 | - Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | |
103 | - takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | |
104 | - takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | |
105 | - activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | |
106 | - } | |
107 | - } | |
108 | - }); | |
109 | - bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | |
110 | - @Override | |
111 | - public void onClick(View view) { | |
112 | - dialog.dismiss(); | |
113 | - ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | |
114 | - .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | |
115 | - .multiSelect(true) //是否多选 | |
116 | - .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | |
117 | - .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | |
118 | - .maxImageSelectable(9) //图片可选择数 | |
119 | - .maxHeight(1920) //图片最大高度 | |
120 | - .maxWidth(1920) //图片最大宽度 | |
121 | - .maxImageSize(10) //图片最大大小Mb | |
122 | - .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | |
123 | - ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); | |
93 | + if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | |
94 | + XXPermissions.with(context) | |
95 | + // 申请多个权限 | |
96 | + .permission(Permission.CAMERA) | |
97 | + .request(new OnPermissionCallback() { | |
98 | + @Override | |
99 | + public void onGranted(List<String> permissions, boolean all) { | |
100 | + if (all) { | |
101 | + //开启扫码界面 | |
102 | + showButtonDialog(); | |
103 | + } else { | |
104 | + Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | |
105 | + } | |
106 | + } | |
107 | + | |
108 | + @Override | |
109 | + public void onDenied(List<String> permissions, boolean never) { | |
110 | + XXPermissions.startPermissionActivity(context, permissions); | |
111 | + } | |
112 | + }); | |
113 | + } else { | |
114 | + showButtonDialog(); | |
115 | + } | |
124 | 116 | |
125 | - } | |
126 | - }); | |
127 | - bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | |
128 | - @Override | |
129 | - public void onClick(View view) { | |
130 | - dialog.dismiss(); | |
131 | - } | |
132 | - }); | |
133 | - dialog.show(); | |
134 | 117 | } |
135 | 118 | }); |
136 | 119 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
... | ... | @@ -191,6 +174,54 @@ public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { |
191 | 174 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); |
192 | 175 | } |
193 | 176 | |
177 | + private void showButtonDialog() { | |
178 | + MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | |
179 | + View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | |
180 | + dialog.setContentView(bottomView); | |
181 | + bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | |
182 | + @Override | |
183 | + public void onClick(View view) { | |
184 | + dialog.dismiss(); | |
185 | + Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
186 | + //确保有相机来处理Intent | |
187 | + filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | |
188 | + File photoFile = new File(filePath); | |
189 | + if (photoFile != null) { | |
190 | + //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | |
191 | + Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | |
192 | + takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | |
193 | + takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | |
194 | + activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | |
195 | + } | |
196 | + } | |
197 | + }); | |
198 | + bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | |
199 | + @Override | |
200 | + public void onClick(View view) { | |
201 | + dialog.dismiss(); | |
202 | + ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | |
203 | + .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | |
204 | + .multiSelect(true) //是否多选 | |
205 | + .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | |
206 | + .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | |
207 | + .maxImageSelectable(9) //图片可选择数 | |
208 | + .maxHeight(1920) //图片最大高度 | |
209 | + .maxWidth(1920) //图片最大宽度 | |
210 | + .maxImageSize(10) //图片最大大小Mb | |
211 | + .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | |
212 | + ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); | |
213 | + | |
214 | + } | |
215 | + }); | |
216 | + bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | |
217 | + @Override | |
218 | + public void onClick(View view) { | |
219 | + dialog.dismiss(); | |
220 | + } | |
221 | + }); | |
222 | + dialog.show(); | |
223 | + } | |
224 | + | |
194 | 225 | private void getError(String subject) { |
195 | 226 | if (studentBean != null) { |
196 | 227 | Map map = new HashMap(); | ... | ... |