v418
This commit is contained in:
@@ -843,32 +843,22 @@ public class AddCaseRecordActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(AddCaseRecordActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(AddCaseRecordActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
EasyWindow.with(AddCaseRecordActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
|
||||
.setContentView(R.layout.float_top_dialog_new).show();
|
||||
PermissionsUtil.requestPermission(AddCaseRecordActivity.this, new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
//用户拒绝了访问读写的申请
|
||||
EasyWindow.cancelAll(); return;
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(AddCaseRecordActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(AddCaseRecordActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();
|
||||
} else {
|
||||
@@ -888,7 +878,7 @@ public class AddCaseRecordActivity extends BaseActivity implements
|
||||
EasyWindow.cancelAll();
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -903,11 +893,17 @@ public class AddCaseRecordActivity extends BaseActivity implements
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(AddCaseRecordActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
// Android 6.0 ~ 12 使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(AddCaseRecordActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
mActivity.startActivityForResult(intent,
|
||||
SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -920,7 +916,7 @@ public class AddCaseRecordActivity extends BaseActivity implements
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
mActivity.startActivityForResult(intent,
|
||||
SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -932,15 +928,9 @@ public class AddCaseRecordActivity extends BaseActivity implements
|
||||
EasyWindow.cancelAll();
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
mActivity.startActivityForResult(intent,
|
||||
SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+1325
-1217
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,460 @@
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Images.Thumbnails;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.FrameLayout.LayoutParams;
|
||||
import android.widget.GridView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.adapter.PhotoAdappter2;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.PhotoAibum;
|
||||
import cn.shangyu.gdxzExpert.bean.PhotoItem;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferenceSettings;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferences;
|
||||
import cn.shangyu.gdxzExpert.photo.AlbumPreviewActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
|
||||
/******************************************
|
||||
* 类描述: 直接显示全部照片的相册选择页面 类名称:AllPhotosActivity
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author: Auto
|
||||
* @time: 2024
|
||||
*****************************************/
|
||||
public class AllPhotosActivity extends BaseActivity {
|
||||
private GridView photosGV;
|
||||
private PhotoAdappter2 adapter;
|
||||
private View view;
|
||||
private Intent getIntent;
|
||||
private String haveNums;
|
||||
private String istopc;
|
||||
private boolean isTopc = false;
|
||||
private boolean isTalke = false;
|
||||
private ArrayList<PhotoItem> gl_arr = new ArrayList<PhotoItem>();
|
||||
private int PhotoNum = 8;
|
||||
int maxnumber, issendgroup;
|
||||
|
||||
// 设置获取图片的字段信息
|
||||
private static final String[] STORE_IMAGES = {
|
||||
MediaStore.Images.Media.DISPLAY_NAME, // 显示的名称
|
||||
MediaStore.Images.Media.DATA,//路径
|
||||
MediaStore.Images.Media.LONGITUDE, // 经度
|
||||
MediaStore.Images.Media._ID, // id
|
||||
MediaStore.Images.Media.BUCKET_ID, // dir id 目录
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME // dir name 目录名字
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("选择图片");
|
||||
}
|
||||
|
||||
private PhotoAibum allPhotosAibum;
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
LogUtil.d("AllPhotosActivity", "onCreateSuccessedView: 开始创建视图");
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
view = UIUtils.inflate(R.layout.activity_photoalbum);
|
||||
photosGV = (GridView) view.findViewById(R.id.album_gridview);
|
||||
|
||||
if (photosGV == null) {
|
||||
LogUtil.e("AllPhotosActivity", "onCreateSuccessedView: photosGV 为 null");
|
||||
}
|
||||
|
||||
// 直接加载所有照片
|
||||
allPhotosAibum = getAllPhotos();
|
||||
|
||||
LogUtil.d("AllPhotosActivity", "onCreateSuccessedView: 照片加载完成, allPhotosAibum.bitList.size=" +
|
||||
(allPhotosAibum != null && allPhotosAibum.bitList != null ? allPhotosAibum.bitList.size() : 0));
|
||||
|
||||
if (allPhotosAibum == null || allPhotosAibum.bitList == null || allPhotosAibum.bitList.isEmpty()) {
|
||||
LogUtil.w("AllPhotosActivity", "onCreateSuccessedView: 照片列表为空,无法显示照片");
|
||||
}
|
||||
|
||||
initIntent();
|
||||
initPhotosView();
|
||||
LogUtil.d("AllPhotosActivity", "onCreateSuccessedView: 视图创建完成");
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化照片视图
|
||||
*/
|
||||
private void initPhotosView() {
|
||||
top_right_text.setVisibility(View.VISIBLE);
|
||||
if (isTopc) {
|
||||
maxnumber = 3;
|
||||
PhotoNum = 3;
|
||||
top_right_text.setText("确认" + haveNums + "/3");
|
||||
} else {
|
||||
maxnumber = PhotoNum;
|
||||
top_right_text.setText("确认" + haveNums + "/" + PhotoNum);
|
||||
}
|
||||
|
||||
top_right_text.setTextColor(AllPhotosActivity.this.getResources()
|
||||
.getColor(R.color.white));
|
||||
top_right_text.setTextSize(14);
|
||||
top_right_text.setBackgroundResource(R.drawable.selector_btn);
|
||||
LayoutParams paras = (LayoutParams) top_right_text
|
||||
.getLayoutParams();
|
||||
paras.setMargins(0, 0, dip2px(AllPhotosActivity.this, 10), 0);
|
||||
paras.height = dip2px(AllPhotosActivity.this, 30);
|
||||
top_right_text.setLayoutParams(paras);
|
||||
|
||||
top_right_text.setOnClickListener(this);
|
||||
adapter = new PhotoAdappter2(this, allPhotosAibum);
|
||||
photosGV.setNumColumns(3);
|
||||
photosGV.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener(new PhotoAdappter2.ViewItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position) {
|
||||
if (potisions.contains(position + "")) {
|
||||
potisions.remove(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) - 1) + "";
|
||||
} else {
|
||||
if (isTopc) {
|
||||
if (Integer.parseInt(haveNums) < 3) {
|
||||
potisions.add(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
maxnumber = 3;
|
||||
} else {
|
||||
ToastUtil.showMessage("最多添加" + PhotoNum + "张");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Integer.parseInt(haveNums) < PhotoNum) {
|
||||
potisions.add(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
maxnumber = PhotoNum;
|
||||
} else {
|
||||
ToastUtil.showMessage("最多添加" + PhotoNum + "张");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isTopc) {
|
||||
maxnumber = 3;
|
||||
top_right_text.setText("确认" + haveNums + "/3");
|
||||
} else {
|
||||
maxnumber = PhotoNum;
|
||||
top_right_text.setText("确认" + haveNums + "/" + PhotoNum);
|
||||
}
|
||||
|
||||
adapter.getPosition(potisions);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
photosGV.setOnItemClickListener(gvItemClickListener);
|
||||
}
|
||||
|
||||
private ArrayList<String> potisions = new ArrayList<String>();
|
||||
|
||||
private OnItemClickListener gvItemClickListener = new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Intent intent = new Intent(AllPhotosActivity.this, AlbumPreviewActivity.class);
|
||||
intent.putExtra(AlbumPreviewActivity.ARG_BUCKET_INDEX, 0);
|
||||
intent.putExtra(AlbumPreviewActivity.ARG_INDEX, position);
|
||||
intent.putExtra(AlbumPreviewActivity.MAX_NUMBER, maxnumber);
|
||||
intent.putExtra("aibum", allPhotosAibum);
|
||||
intent.putExtra("haveNums", Integer.parseInt(haveNums));
|
||||
intent.putStringArrayListExtra("potisions", potisions);
|
||||
startActivityForResult(intent, 500);
|
||||
}
|
||||
};
|
||||
|
||||
ContentResolver cr;
|
||||
|
||||
public void getpath() {
|
||||
LogUtil.d("AllPhotosActivity", "getpath: potisions=" + (potisions != null ? "not null, size=" + potisions.size() : "null") +
|
||||
", allPhotosAibum=" + (allPhotosAibum != null ? "not null" : "null") +
|
||||
", allPhotosAibum.bitList=" + (allPhotosAibum != null && allPhotosAibum.bitList != null ? "not null, size=" + allPhotosAibum.bitList.size() : "null"));
|
||||
gl_arr.clear();
|
||||
if (potisions == null || potisions.isEmpty()) {
|
||||
LogUtil.w("AllPhotosActivity", "getpath: potisions 为空,没有选中的照片");
|
||||
return;
|
||||
}
|
||||
if (allPhotosAibum == null || allPhotosAibum.bitList == null || allPhotosAibum.bitList.isEmpty()) {
|
||||
LogUtil.w("AllPhotosActivity", "getpath: allPhotosAibum 或 bitList 为空,无法获取照片");
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < potisions.size(); i++) {
|
||||
try {
|
||||
int position = Integer.parseInt(potisions.get(i));
|
||||
if (position >= 0 && position < allPhotosAibum.bitList.size()) {
|
||||
PhotoItem item = allPhotosAibum.bitList.get(position);
|
||||
if (item != null) {
|
||||
gl_arr.add(item);
|
||||
LogUtil.d("AllPhotosActivity", "getpath: 添加 PhotoItem[" + i + "], position=" + position + ", path=" + item.getPath());
|
||||
} else {
|
||||
LogUtil.e("AllPhotosActivity", "getpath: PhotoItem[" + position + "] 为 null");
|
||||
}
|
||||
} else {
|
||||
LogUtil.e("AllPhotosActivity", "getpath: 索引越界, position=" + position + ", bitList.size=" + allPhotosAibum.bitList.size());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtil.e("AllPhotosActivity", "getpath: 无法解析位置索引[" + i + "]=" + potisions.get(i) + ", error: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("AllPhotosActivity", "getpath: 处理位置[" + i + "]时发生异常, error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
LogUtil.d("AllPhotosActivity", "getpath: 最终 gl_arr.size=" + gl_arr.size());
|
||||
}
|
||||
|
||||
private void getThumbnail() {
|
||||
LogUtil.d("AllPhotosActivity", "getThumbnail: 开始加载缩略图");
|
||||
cr = AllPhotosActivity.this.getContentResolver();
|
||||
String[] projection = { Thumbnails._ID, Thumbnails.IMAGE_ID,
|
||||
Thumbnails.DATA };
|
||||
try {
|
||||
Cursor cursor = cr.query(Thumbnails.EXTERNAL_CONTENT_URI, projection,
|
||||
null, null, null);
|
||||
if (cursor == null) {
|
||||
LogUtil.w("AllPhotosActivity", "getThumbnail: cursor 为 null");
|
||||
} else {
|
||||
LogUtil.d("AllPhotosActivity", "getThumbnail: cursor.count=" + cursor.getCount());
|
||||
getThumbnailColumnData(cursor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("AllPhotosActivity", "getThumbnail: 查询缩略图时发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> thumbnailList = new HashMap<String, String>();
|
||||
|
||||
private void getThumbnailColumnData(Cursor cur) {
|
||||
if (cur.moveToFirst()) {
|
||||
int _id;
|
||||
int image_id;
|
||||
String image_path;
|
||||
int _idColumn = cur.getColumnIndex(Thumbnails._ID);
|
||||
int image_idColumn = cur.getColumnIndex(Thumbnails.IMAGE_ID);
|
||||
int dataColumn = cur.getColumnIndex(Thumbnails.DATA);
|
||||
|
||||
do {
|
||||
_id = cur.getInt(_idColumn);
|
||||
image_id = cur.getInt(image_idColumn);
|
||||
image_path = cur.getString(dataColumn);
|
||||
thumbnailList.put("" + image_id, image_path);
|
||||
} while (cur.moveToNext());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法描述:获取所有照片(不分类)
|
||||
*
|
||||
* @author: Auto
|
||||
* @time: 2024
|
||||
*/
|
||||
private PhotoAibum getAllPhotos() {
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: 开始加载所有照片, SDK_INT=" + Build.VERSION.SDK_INT);
|
||||
getThumbnail();
|
||||
PhotoAibum allPhotos = new PhotoAibum();
|
||||
allPhotos.setName("全部图片");
|
||||
|
||||
// 检查权限
|
||||
boolean hasPermission = false;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 需要 READ_MEDIA_IMAGES 权限
|
||||
hasPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: Android 13+, READ_MEDIA_IMAGES permission=" + hasPermission);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// Android 6.0-12 需要 READ_EXTERNAL_STORAGE 权限
|
||||
hasPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: Android 6.0-12, READ_EXTERNAL_STORAGE permission=" + hasPermission);
|
||||
} else {
|
||||
// Android 6.0 以下不需要运行时权限
|
||||
hasPermission = true;
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: Android < 6.0, 不需要运行时权限");
|
||||
}
|
||||
|
||||
if (!hasPermission) {
|
||||
LogUtil.e("AllPhotosActivity", "getAllPhotos: 没有读取照片的权限,无法查询照片");
|
||||
ToastUtil.showMessage("需要照片访问权限才能查看相册");
|
||||
return allPhotos;
|
||||
}
|
||||
|
||||
try {
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: 查询 MediaStore.Images.Media.EXTERNAL_CONTENT_URI=" + MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = getContentResolver().query(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
STORE_IMAGES,
|
||||
null,
|
||||
null,
|
||||
MediaStore.Images.Media.DATE_ADDED + " ASC");
|
||||
} catch (SecurityException e) {
|
||||
LogUtil.e("AllPhotosActivity", "getAllPhotos: SecurityException - 权限被拒绝, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
ToastUtil.showMessage("无法访问照片,请检查权限设置");
|
||||
return allPhotos;
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("AllPhotosActivity", "getAllPhotos: 查询时发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return allPhotos;
|
||||
}
|
||||
|
||||
if (cursor == null) {
|
||||
LogUtil.e("AllPhotosActivity", "getAllPhotos: cursor 为 null,无法查询照片");
|
||||
return allPhotos;
|
||||
}
|
||||
|
||||
int cursorCount = cursor.getCount();
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: cursor.count=" + cursorCount);
|
||||
|
||||
if (cursorCount == 0) {
|
||||
LogUtil.w("AllPhotosActivity", "getAllPhotos: cursor 为空,没有找到照片。可能原因:1)设备上没有照片 2)权限问题 3)Android 10+分区存储限制");
|
||||
cursor.close();
|
||||
return allPhotos;
|
||||
}
|
||||
|
||||
List<PhotoItem> photoList = allPhotos.getBitList();
|
||||
int processedCount = 0;
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
try {
|
||||
String path = cursor.getString(1) + "";
|
||||
String id = cursor.getString(3) + "";
|
||||
|
||||
if (path == null || path.isEmpty() || "null".equals(path)) {
|
||||
LogUtil.w("AllPhotosActivity", "getAllPhotos: 跳过无效路径的照片, id=" + id);
|
||||
continue;
|
||||
}
|
||||
|
||||
processedCount++;
|
||||
if (processedCount <= 5) {
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: 处理照片[" + processedCount + "], id=" + id + ", path=" + path);
|
||||
}
|
||||
|
||||
photoList.add(new PhotoItem(Integer.valueOf(id), path));
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("AllPhotosActivity", "getAllPhotos: 处理照片时发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
allPhotos.setCount(photoList.size());
|
||||
LogUtil.d("AllPhotosActivity", "getAllPhotos: 处理完成, processedCount=" + processedCount + ", total=" + photoList.size());
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("AllPhotosActivity", "getAllPhotos: 发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return allPhotos;
|
||||
}
|
||||
|
||||
private void initIntent() {
|
||||
getIntent = getIntent();
|
||||
haveNums = getIntent.getStringExtra("photonum");
|
||||
PhotoNum = getIntent.getIntExtra("maxphotonum", 8);
|
||||
issendgroup = getIntent.getIntExtra("issendgroup", 0);
|
||||
if (haveNums.equals("-1")) {
|
||||
PhotoNum = 5;
|
||||
haveNums = "0";
|
||||
isTalke = true;
|
||||
} else if ("1".equals(issendgroup + "")) {
|
||||
isTalke = true;
|
||||
}
|
||||
istopc = getIntent.getStringExtra("isTopic");
|
||||
if (istopc != null && istopc.equals("isTopic")) {
|
||||
isTopc = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultState onLoad() {
|
||||
return ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.top_right_text:
|
||||
LogUtil.d("AllPhotosActivity", "确认按钮点击,开始返回照片数据");
|
||||
getpath();
|
||||
LogUtil.d("AllPhotosActivity", "确认按钮: gl_arr.size=" + gl_arr.size() + ", isTalke=" + isTalke);
|
||||
if (gl_arr.size() > 0) {
|
||||
try {
|
||||
ECPreferences.savePreference(
|
||||
ECPreferenceSettings.SETTINGS_PREVIEW_SELECTED,
|
||||
Boolean.TRUE, true);
|
||||
} catch (InvalidClassException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (int i = 0; i < gl_arr.size(); i++) {
|
||||
PhotoItem item = gl_arr.get(i);
|
||||
LogUtil.d("AllPhotosActivity", "返回 PhotoItem[" + i + "]: path=" + (item != null ? item.getPath() : "null"));
|
||||
}
|
||||
} else {
|
||||
LogUtil.w("AllPhotosActivity", "确认按钮: gl_arr 为空,没有选择照片");
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("photos", (Serializable) gl_arr);
|
||||
if (isTalke) {
|
||||
setResult(RESULT_OK, intent);
|
||||
LogUtil.d("AllPhotosActivity", "设置返回结果: RESULT_OK, photos count=" + gl_arr.size());
|
||||
} else {
|
||||
setResult(102, intent);
|
||||
LogUtil.d("AllPhotosActivity", "设置返回结果: 102, photos count=" + gl_arr.size());
|
||||
}
|
||||
|
||||
this.finish();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// dp到像素的转换
|
||||
public static int dip2px(Context context, double d) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (d * scale + 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 500) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
potisions = data.getExtras().getStringArrayList("potisions");
|
||||
haveNums = data.getExtras().getInt("haveNums") + "";
|
||||
adapter.getPosition(potisions);
|
||||
adapter.notifyDataSetChanged();
|
||||
top_right_text.setText("确认" + haveNums + "/" + maxnumber + "张");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,8 +470,21 @@ public class BiochemistryActivity extends BaseActivity implements AdapterView.On
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(BiochemistryActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(BiochemistryActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(BiochemistryActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -492,7 +505,7 @@ public class BiochemistryActivity extends BaseActivity implements AdapterView.On
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -508,11 +521,17 @@ public class BiochemistryActivity extends BaseActivity implements AdapterView.On
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(BiochemistryActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
// Android 6.0 ~ 12 使用旧的存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(BiochemistryActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -525,7 +544,7 @@ public class BiochemistryActivity extends BaseActivity implements AdapterView.On
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(BiochemistryActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(BiochemistryActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -539,15 +558,10 @@ public class BiochemistryActivity extends BaseActivity implements AdapterView.On
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(BiochemistryActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -682,30 +682,39 @@ public class BookDetailActivity extends BaseActivity implements
|
||||
public void run() {
|
||||
// TODO
|
||||
// CanDownYK();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(BookDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
CanDownWF();
|
||||
} else {
|
||||
EasyWindow.with(BookDetailActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
|
||||
if (PermissionsUtil.hasPermission(BookDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
CanDownWF();
|
||||
} else {
|
||||
EasyWindow.with(BookDetailActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
.setContentView(R.layout.float_top_dialog_download).show();
|
||||
PermissionsUtil.requestPermission(BookDetailActivity.this, new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
CanDownWF();
|
||||
|
||||
.setContentView(R.layout.float_top_dialog_download).show();
|
||||
PermissionsUtil.requestPermission(BookDetailActivity.this, new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
CanDownWF();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}
|
||||
|
||||
}else {
|
||||
CanDownWF();
|
||||
@@ -841,8 +850,18 @@ public class BookDetailActivity extends BaseActivity implements
|
||||
if (result.contains("Waiting")) {
|
||||
ToastUtil.showMessage("暂无全文");
|
||||
} else {
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(BookDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(BookDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
downloadBook(urls);
|
||||
} else {
|
||||
PermissionsUtil.requestPermission(BookDetailActivity.this, new PermissionListener() {
|
||||
|
||||
@@ -295,8 +295,18 @@ public class CourseDetailOrderActivity extends BaseActivity implements
|
||||
|
||||
}
|
||||
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(CourseDetailOrderActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(CourseDetailOrderActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
getDownLoadResult();
|
||||
} else {
|
||||
EasyWindow.with(CourseDetailOrderActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
|
||||
@@ -465,8 +465,21 @@ public class CtActivity extends BaseActivity implements AdapterView.OnItemClickL
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(CtActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(CtActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(CtActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -487,7 +500,7 @@ public class CtActivity extends BaseActivity implements AdapterView.OnItemClickL
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -503,11 +516,17 @@ public class CtActivity extends BaseActivity implements AdapterView.OnItemClickL
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(CtActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
// Android 6.0 ~ 12 使用旧的存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(CtActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -520,7 +539,7 @@ public class CtActivity extends BaseActivity implements AdapterView.OnItemClickL
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(CtActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(CtActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -529,20 +548,14 @@ public class CtActivity extends BaseActivity implements AdapterView.OnItemClickL
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(CtActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -421,8 +421,21 @@ public class FibroActivity extends BaseActivity implements AdapterView.OnItemCli
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(FibroActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(FibroActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(FibroActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -443,7 +456,7 @@ public class FibroActivity extends BaseActivity implements AdapterView.OnItemCli
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -459,11 +472,17 @@ public class FibroActivity extends BaseActivity implements AdapterView.OnItemCli
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(FibroActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
// Android 6.0 ~ 12 使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(FibroActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -476,7 +495,7 @@ public class FibroActivity extends BaseActivity implements AdapterView.OnItemCli
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(FibroActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(FibroActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -485,20 +504,15 @@ public class FibroActivity extends BaseActivity implements AdapterView.OnItemCli
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(FibroActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,18 @@ public class FindHelpActivity extends BaseActivity {
|
||||
im_we.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
// 保存图片到 MediaStore,Android 13+ 可能需要权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(FindHelpActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
||||
hasPermission = PermissionsUtil.hasPermission(FindHelpActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到 MediaStore 可能需要 READ_MEDIA_IMAGES,但通常不需要
|
||||
|
||||
if (hasPermission) {
|
||||
savePhoto();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -68,9 +68,22 @@ public class GandanMeetingActivity extends BaseActivity{
|
||||
// intent.putExtra("title",getResources().getString(R.string.gandanhuifang));
|
||||
// startActivity(intent);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
//
|
||||
if (PermissionsUtil.hasPermission(GandanMeetingActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(GandanMeetingActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(GandanMeetingActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
startToCapture();
|
||||
} else {
|
||||
EasyWindow.with(GandanMeetingActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -80,16 +93,16 @@ public class GandanMeetingActivity extends BaseActivity{
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问读取短信的权限
|
||||
//用户授予了访问摄像头的权限
|
||||
startToCapture();
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
//用户拒绝了访问读取短信的申请
|
||||
//用户拒绝了访问摄像头的申请
|
||||
EasyWindow.cancelAll();
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
@@ -536,8 +536,21 @@ public class HbvdnaActivity extends BaseActivity implements AdapterView.OnItemCl
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -558,7 +571,7 @@ public class HbvdnaActivity extends BaseActivity implements AdapterView.OnItemCl
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -574,11 +587,17 @@ public class HbvdnaActivity extends BaseActivity implements AdapterView.OnItemCl
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
// Android 6.0 ~ 12 使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -591,7 +610,7 @@ public class HbvdnaActivity extends BaseActivity implements AdapterView.OnItemCl
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(HbvdnaActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(HbvdnaActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -600,20 +619,15 @@ public class HbvdnaActivity extends BaseActivity implements AdapterView.OnItemCl
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(HbvdnaActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -738,8 +738,21 @@ public class InfomationActivity extends BaseActivity implements AdapterView.OnIt
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -760,7 +773,7 @@ public class InfomationActivity extends BaseActivity implements AdapterView.OnIt
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -776,11 +789,18 @@ public class InfomationActivity extends BaseActivity implements AdapterView.OnIt
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
|
||||
// Android 6.0 ~ 12 使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -793,7 +813,7 @@ public class InfomationActivity extends BaseActivity implements AdapterView.OnIt
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(InfomationActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(InfomationActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -802,20 +822,15 @@ public class InfomationActivity extends BaseActivity implements AdapterView.OnIt
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(InfomationActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import static cn.shangyu.gdxzExpert.utils.Url.getAccessToken;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.getShowMagazine;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.scanurl;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.umVerifyLogin;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.url_path;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.urlmyLan;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.yxrefresh;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.yxregist;
|
||||
@@ -177,6 +178,7 @@ import cn.shangyu.gdxzExpert.netease.DemoCache;
|
||||
import cn.shangyu.gdxzExpert.netease.bagder.Badger;
|
||||
import cn.shangyu.gdxzExpert.netease.config.preference.Preferences;
|
||||
import cn.shangyu.gdxzExpert.netease.config.preference.UserPreferences;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty;
|
||||
import cn.shangyu.gdxzExpert.service.UpdateService;
|
||||
import cn.shangyu.gdxzExpert.splash.UniappSplashView;
|
||||
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
||||
@@ -188,6 +190,7 @@ import cn.shangyu.gdxzExpert.utils.DataCleanManager;
|
||||
import cn.shangyu.gdxzExpert.utils.GrayManager;
|
||||
import cn.shangyu.gdxzExpert.utils.HmacSha256ApiVerify;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.MyUserIconUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StaUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StreamTool;
|
||||
@@ -200,10 +203,8 @@ import cn.shangyu.gdxzExpert.view.viewbadger.BadgeView;
|
||||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
import io.dcloud.feature.sdk.DCUniMPSDK;
|
||||
import io.dcloud.feature.sdk.Interface.IOnUniMPEventCallBack;
|
||||
import io.dcloud.feature.sdk.Interface.IUniMP;
|
||||
import io.dcloud.feature.sdk.Interface.IUniMPOnCloseCallBack;
|
||||
import io.dcloud.feature.unimp.DCUniMPJSCallback;
|
||||
import io.dcloud.feature.unimp.config.UniMPOpenConfiguration;
|
||||
import me.leolin.shortcutbadger.ShortcutBadger;
|
||||
import me.majiajie.pagerbottomtabstrip.NavigationController;
|
||||
@@ -470,7 +471,9 @@ public class MainActivity extends BaseActivity implements
|
||||
tab_rbn_published.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(ct,PatientVideoActivity.class));
|
||||
|
||||
MyUserIconUtil.showUniMp(MainActivity.this, "/pages_app/patientVideo/patientVideo");
|
||||
// startActivity(new Intent(ct,PatientVideoActivity.class));
|
||||
}
|
||||
});
|
||||
main_radiogroup.setOnCheckedChangeListener(this);
|
||||
@@ -486,242 +489,6 @@ public class MainActivity extends BaseActivity implements
|
||||
} else {
|
||||
changeHome();
|
||||
}
|
||||
|
||||
|
||||
DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(new IUniMPOnCloseCallBack() {
|
||||
@Override
|
||||
public void onClose(String appid) {
|
||||
auto_show_unimp = false;
|
||||
LogUtil.i("setUniMPOnCloseCallBack: ", appid);
|
||||
if(BaseApplication.getUniMPCaches().containsKey(appid)){
|
||||
BaseApplication.getUniMPCaches().remove(appid);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
DCUniMPSDK.getInstance().setOnUniMPEventCallBack(new IOnUniMPEventCallBack() {
|
||||
@Override
|
||||
public void onUniMPEventReceive(String appid, String event, Object data, DCUniMPJSCallback callback) {
|
||||
|
||||
|
||||
LogUtil.i("onUniMPEventReceive appid="+appid);
|
||||
LogUtil.i("onUniMPEventReceive event="+event);
|
||||
LogUtil.i("onUniMPEventReceive data="+data);
|
||||
|
||||
try {
|
||||
if(event.equals("goTabbarPage")){
|
||||
|
||||
auto_show_unimp = false;
|
||||
// BaseApplication.getUniMPCaches().get(appid).hideUniMP();
|
||||
// BaseApplication.getUniMPCaches().get(appid).showUniMP();
|
||||
// BaseApplication.getUniMPCaches().get(appid).closeUniMP();
|
||||
// data 可能是 JSONObject 或 String,需要判断类型
|
||||
String msg = null;
|
||||
if (data instanceof com.alibaba.fastjson.JSONObject) {
|
||||
// 如果是 fastjson 的 JSONObject,直接使用
|
||||
com.alibaba.fastjson.JSONObject fastJsonObj = (com.alibaba.fastjson.JSONObject) data;
|
||||
msg = fastJsonObj.getString("msg");
|
||||
} else if (data instanceof String) {
|
||||
// 如果是 String,解析为 JSONObject
|
||||
JSONObject jsonObject = new JSONObject((String) data);
|
||||
msg = jsonObject.getString("msg");
|
||||
} else {
|
||||
// 尝试转换为字符串再解析
|
||||
JSONObject jsonObject = new JSONObject(data.toString());
|
||||
msg = jsonObject.getString("msg");
|
||||
}
|
||||
LogUtil.i("goTabbarPage msg=" + msg);
|
||||
if(msg.equals("home")){//首页
|
||||
LogUtil.i("准备切换到首页");
|
||||
// 使用主线程 Handler 确保在主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LogUtil.i("开始执行首页切换逻辑");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
// 直接执行首页切换逻辑,不依赖事件触发
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_home);
|
||||
main_radiogroup.setOnCheckedChangeListener(MainActivity.this);
|
||||
|
||||
// 执行首页相关的UI更新和逻辑
|
||||
if (mToolbar != null) {
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
}
|
||||
if (mRg_kepu != null) {
|
||||
mRg_kepu.setVisibility(View.GONE);
|
||||
}
|
||||
if (mV_kp != null) {
|
||||
mV_kp.setVisibility(View.GONE);
|
||||
}
|
||||
MobclickAgent.onEvent(MainActivity.this, EXPERT_TAB_HOME);
|
||||
changeHome();
|
||||
LogUtil.i("首页切换逻辑执行完成");
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("执行首页切换时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if(msg.equals("patientClass")){//患教
|
||||
LogUtil.i("准备切换到患教页");
|
||||
// 使用主线程 Handler 确保在主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LogUtil.i("开始执行患教页切换逻辑");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
// 直接执行患教页切换逻辑,不依赖事件触发
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_kepu);
|
||||
main_radiogroup.setOnCheckedChangeListener(MainActivity.this);
|
||||
|
||||
// 执行患教页相关的UI更新和逻辑
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
mToolbar.getBackground().setAlpha(255);
|
||||
mRg_kepu.setVisibility(View.VISIBLE);
|
||||
mV_kp.setVisibility(View.VISIBLE);
|
||||
mRb_published.setChecked(true);
|
||||
top_sgin.setVisibility(View.GONE);
|
||||
MobclickAgent.onEvent(MainActivity.this, EXPERT_TAB_TEACH);
|
||||
changePatientZhongxin();
|
||||
LogUtil.i("患教页切换逻辑执行完成");
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("执行患教页切换时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if(msg.equals("education")){//继续教育
|
||||
LogUtil.i("准备切换到继续教育页");
|
||||
// 使用主线程 Handler 确保在主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LogUtil.i("开始执行继续教育页切换逻辑");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
// 直接执行继续教育页切换逻辑,不依赖事件触发
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_news);
|
||||
main_radiogroup.setOnCheckedChangeListener(MainActivity.this);
|
||||
|
||||
// 执行继续教育页相关的UI更新和逻辑
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
mRg_kepu.setVisibility(View.GONE);
|
||||
mV_kp.setVisibility(View.GONE);
|
||||
top_sgin.setVisibility(View.GONE);
|
||||
mToolbar.getBackground().setAlpha(255);
|
||||
MobclickAgent.onEvent(MainActivity.this, EXPERT_TAB_EDUCATION);
|
||||
changeNews();
|
||||
LogUtil.i("继续教育页切换逻辑执行完成");
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("执行继续教育页切换时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if(msg.equals("mine")){//我的
|
||||
LogUtil.i("准备切换到我的页");
|
||||
// 使用主线程 Handler 确保在主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LogUtil.i("开始执行我的页切换逻辑");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
// 直接执行我的页切换逻辑,不依赖事件触发
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_my);
|
||||
main_radiogroup.setOnCheckedChangeListener(MainActivity.this);
|
||||
|
||||
// 执行我的页相关的UI更新和逻辑
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
mToolbar.getBackground().setAlpha(255);
|
||||
top_sgin.setVisibility(View.GONE);
|
||||
mRg_kepu.setVisibility(View.GONE);
|
||||
mV_kp.setVisibility(View.GONE);
|
||||
MobclickAgent.onEvent(MainActivity.this, EXPERT_TAB_MY);
|
||||
changeMy();
|
||||
LogUtil.i("我的页切换逻辑执行完成");
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("执行我的页切换时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
||||
}
|
||||
} else if (event.equals("getScanCodeAuth")){
|
||||
JSONObject ScanCodeAuthData = new JSONObject();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
ScanCodeAuthData.put("code", 200);
|
||||
callback.invoke(ScanCodeAuthData);//给uniapp 回传消息
|
||||
} else {
|
||||
EasyWindow.with(MainActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000).setContentView(R.layout.float_top_dialog).show();
|
||||
PermissionsUtil.requestPermission(MainActivity.this, new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问读取短信的权限
|
||||
try {
|
||||
ScanCodeAuthData.put("code", 200);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
callback.invoke(ScanCodeAuthData);//给uniapp 回传消息
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
//用户拒绝了访问读取短信的申请
|
||||
EasyWindow.cancelAll();
|
||||
try {
|
||||
ScanCodeAuthData.put("code", 0);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
callback.invoke(ScanCodeAuthData);//给uniapp 回传消息
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}
|
||||
}else {
|
||||
ScanCodeAuthData.put("code", 0);
|
||||
callback.invoke(ScanCodeAuthData);//给uniapp 回传消息
|
||||
}
|
||||
}else if(event.equals("checkToken")){
|
||||
JSONObject checkToken = new JSONObject();
|
||||
checkToken.put("code", 200);
|
||||
String access_token = SharePrefUtil.getString(MainActivity.this, "access_token", "");
|
||||
if(StringUtil.isEmpty(access_token)){
|
||||
checkToken.put("code", 0);
|
||||
}
|
||||
callback.invoke(checkToken);//给uniapp 回传消息
|
||||
}
|
||||
}catch (Exception e){
|
||||
LogUtil.e("处理uniapp事件时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
private OldPageNavigationView tab;
|
||||
@@ -1639,7 +1406,7 @@ public class MainActivity extends BaseActivity implements
|
||||
};
|
||||
|
||||
//展示uniapp mp
|
||||
private void showUniMp(boolean showLoading){
|
||||
public void showUniMp(boolean showLoading){
|
||||
if(showLoading){
|
||||
showFullScreenLoading();
|
||||
}
|
||||
@@ -1653,25 +1420,9 @@ public class MainActivity extends BaseActivity implements
|
||||
if(StringUtil.isEmpty(access_token)){
|
||||
Map<String, String> param = new HashMap<>();
|
||||
sendJsonPostParamtoNetSignMD5(getAccessToken, param, ACCESS_TOKEN,this);
|
||||
access_token = SharePrefUtil.getString(MainActivity.this, "access_token", "");
|
||||
}
|
||||
|
||||
JSONObject userInfo = new JSONObject();
|
||||
userInfo.put("uuid", SharePrefUtil.getString(MainActivity.this, Constant.uuid, ""));
|
||||
userInfo.put("realName", SharePrefUtil.getString(MainActivity.this, Constant.realName, ""));
|
||||
userInfo.put("mobile", SharePrefUtil.getString(MainActivity.this, "mobile", ""));
|
||||
userInfo.put("photo", SharePrefUtil.getString(MainActivity.this, Constant.photo, ""));
|
||||
|
||||
UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration();
|
||||
uniMPOpenConfiguration.splashClass = UniappSplashView.class;
|
||||
// uniMPOpenConfiguration.path= "pages/live/live";
|
||||
uniMPOpenConfiguration.extraData.put("darkmode", "light");
|
||||
uniMPOpenConfiguration.extraData.put("apiHost", urlmyLan);
|
||||
uniMPOpenConfiguration.extraData.put("token", access_token);
|
||||
uniMPOpenConfiguration.extraData.put("userInfo", userInfo);
|
||||
uniMPOpenConfiguration.extraData.put("targetPath", "/pages/live/live");
|
||||
IUniMP uniapp_MP = DCUniMPSDK.getInstance().openUniMP(mContext, uniapp_mp_appid, uniMPOpenConfiguration);
|
||||
BaseApplication.getUniMPCaches().put(uniapp_MP.getAppid(), uniapp_MP);
|
||||
MyUserIconUtil.showUniMp(MainActivity.this, "/pages/live/live");
|
||||
|
||||
if(showLoading) {
|
||||
hideFullScreenLoading();
|
||||
@@ -1757,9 +1508,22 @@ public class MainActivity extends BaseActivity implements
|
||||
// intent.putExtra("title",getResources().getString(R.string.gandanhuifang));
|
||||
// startActivity(intent);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
//
|
||||
if (PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
// 扫码功能主要需要 CAMERA 权限,Android 13+ 不需要存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 只需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
startToCapture();
|
||||
} else {
|
||||
EasyWindow.with(MainActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -1769,16 +1533,16 @@ public class MainActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问读取短信的权限
|
||||
//用户授予了访问摄像头的权限
|
||||
startToCapture();
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
//用户拒绝了访问读取短信的申请
|
||||
//用户拒绝了访问摄像头的申请
|
||||
EasyWindow.cancelAll();
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -2238,7 +2002,8 @@ public class MainActivity extends BaseActivity implements
|
||||
|
||||
// registerReceiver(internalReceiver, intentfilter);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
// Android 13 (API 33) 及以上版本需要指定 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
registerReceiver(internalReceiver, intentfilter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
registerReceiver(internalReceiver, intentfilter);
|
||||
@@ -2420,8 +2185,18 @@ public class MainActivity extends BaseActivity implements
|
||||
if (resultCode == RESULT_OK && requestCode == 10086){
|
||||
SharePrefUtil.saveString(MainActivity.this, "newVersion",
|
||||
newVewsion);
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
intent = new Intent(MainActivity.this, UpdateService.class);
|
||||
intent.putExtra("newVersion", newVewsion);
|
||||
@@ -2451,7 +2226,7 @@ public class MainActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -2593,8 +2368,18 @@ public class MainActivity extends BaseActivity implements
|
||||
if (b){
|
||||
SharePrefUtil.saveString(MainActivity.this, "newVersion",
|
||||
newVersion);
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
intent = new Intent(MainActivity.this, UpdateService.class);
|
||||
intent.putExtra("newVersion", newVewsion);
|
||||
@@ -2658,8 +2443,18 @@ public class MainActivity extends BaseActivity implements
|
||||
}else {
|
||||
SharePrefUtil.saveString(MainActivity.this, "newVersion",
|
||||
newVersion);
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
intent = new Intent(MainActivity.this, UpdateService.class);
|
||||
intent.putExtra("newVersion", newVewsion);
|
||||
|
||||
@@ -11,6 +11,7 @@ import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||||
import cn.shangyu.gdxzExpert.utils.MyUserIconUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
@@ -112,7 +113,7 @@ public class MyDownLoadsActivity extends BaseActivity{
|
||||
mRl_1.setVisibility(View.VISIBLE);
|
||||
mRl_2.setVisibility(View.VISIBLE);
|
||||
mRl_3.setVisibility(View.VISIBLE);
|
||||
mRl_4.setVisibility(View.GONE);
|
||||
mRl_4.setVisibility(View.VISIBLE);
|
||||
mV_line1.setVisibility(View.VISIBLE);
|
||||
mV_line2.setVisibility(View.VISIBLE);
|
||||
mV_line3.setVisibility(View.VISIBLE);
|
||||
@@ -120,6 +121,7 @@ public class MyDownLoadsActivity extends BaseActivity{
|
||||
mTv_title1.setText("诊疗指南");
|
||||
mTv_title2.setText("期刊杂志");
|
||||
mTv_title3.setText("课件文档");
|
||||
mTv_title4.setText("诊疗指南(新)");
|
||||
if(SharePrefUtil.getBoolean(this, Constant.ShowMagazine,true))
|
||||
{
|
||||
}
|
||||
@@ -207,7 +209,8 @@ public class MyDownLoadsActivity extends BaseActivity{
|
||||
}
|
||||
} else if (id == R.id.rl_4) {
|
||||
if (isDownLoad) {
|
||||
|
||||
//跳到uniapp 的缓存页面
|
||||
MyUserIconUtil.showUniMp(MyDownLoadsActivity.this, "/pages_app/zhinanDownload/zhinanDownload");
|
||||
} else {
|
||||
startActivity(new Intent(mActivity, CoollectVideoActivity.class).putExtra("name",mTv_title4.getText().toString()));
|
||||
}
|
||||
|
||||
@@ -632,8 +632,21 @@ public class MyIdeaActivity extends BaseActivity implements AdapterView.OnItemC
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(MyIdeaActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MyIdeaActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(MyIdeaActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -655,7 +668,7 @@ public class MyIdeaActivity extends BaseActivity implements AdapterView.OnItemC
|
||||
isFirst = true;
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -671,11 +684,18 @@ public class MyIdeaActivity extends BaseActivity implements AdapterView.OnItemC
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(MyIdeaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
|
||||
// Android 6.0 ~ 12 继续使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(MyIdeaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",6);
|
||||
startActivityForResult(intent,
|
||||
@@ -688,7 +708,7 @@ public class MyIdeaActivity extends BaseActivity implements AdapterView.OnItemC
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(MyIdeaActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(MyIdeaActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",6);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -697,20 +717,14 @@ public class MyIdeaActivity extends BaseActivity implements AdapterView.OnItemC
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
isFirst = true;
|
||||
//
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(MyIdeaActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",6);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -144,13 +144,19 @@ public class MyQrCodeActivity extends BaseActivity {
|
||||
btn_code.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// saveAsImg() 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
// 但需要保存到 MediaStore,可能需要权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(MyQrCodeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// WebView.HitTestResult result = ((WebView) web).getHitTestResult();
|
||||
// final String imgurl = result.getExtra();
|
||||
// new DownLoadUrlImage(web.getUrl(), getApplicationContext());
|
||||
// //有访问录音
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
||||
hasPermission = PermissionsUtil.hasPermission(MyQrCodeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限,但保存到 MediaStore 可能需要 READ_MEDIA_IMAGES
|
||||
|
||||
if (hasPermission) {
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -172,7 +178,6 @@ public class MyQrCodeActivity extends BaseActivity {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问录音的权限
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -190,11 +195,11 @@ public class MyQrCodeActivity extends BaseActivity {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问录音的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
// finish();
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
@@ -1028,8 +1028,18 @@ public class NewsDetailActivity extends BaseActivity implements
|
||||
// 下载
|
||||
itemLongClickedPopWindow.dismiss();
|
||||
// 点击图片后将图片保存到SD卡跟目录下的Test文件夹内
|
||||
// DownLoadUrlImage 使用应用私有目录,Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(NewsDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
||||
hasPermission = PermissionsUtil.hasPermission(NewsDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
new DownLoadUrlImage(imgurl, ctx);
|
||||
Toast.makeText(getBaseContext(), "图片保存",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -1,415 +1,582 @@
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Images.Thumbnails;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.FrameLayout.LayoutParams;
|
||||
import android.widget.GridView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.adapter.PhotoAdappter2;
|
||||
import cn.shangyu.gdxzExpert.adapter.PhotoAibumAdapter;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.PhotoAibum;
|
||||
import cn.shangyu.gdxzExpert.bean.PhotoItem;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferenceSettings;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferences;
|
||||
import cn.shangyu.gdxzExpert.photo.AlbumPreviewActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
|
||||
/******************************************
|
||||
* 类描述: 相册管理类 类名称:PhotoAlbumActivity
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author: zhaodewei
|
||||
* @time: 2013-10-18 下午2:10:46
|
||||
*****************************************/
|
||||
public class PhotoAlbumActivity extends BaseActivity {
|
||||
private GridView aibumGV;
|
||||
private List<PhotoAibum> aibumList;
|
||||
private PhotoAdappter2 adapter;
|
||||
private View view;
|
||||
private Intent getIntent;
|
||||
private String haveNums;
|
||||
// private AlbumHelper helper;
|
||||
private String istopc;
|
||||
private boolean isTopc = false;
|
||||
private boolean isTalke = false;
|
||||
private ArrayList<PhotoItem> gl_arr = new ArrayList<PhotoItem>();
|
||||
private int PhotoNum=8;
|
||||
int maxnumber,issendgroup;
|
||||
// 设置获取图片的字段信�?
|
||||
private static final String[] STORE_IMAGES = {
|
||||
MediaStore.Images.Media.DISPLAY_NAME, // 显示的名称
|
||||
MediaStore.Images.Media.DATA,//路径
|
||||
MediaStore.Images.Media.LONGITUDE, // 经度
|
||||
MediaStore.Images.Media._ID, // id
|
||||
MediaStore.Images.Media.BUCKET_ID, // dir id 目录
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME // dir name 目录名字
|
||||
|
||||
};
|
||||
/**
|
||||
* 相册点击事件
|
||||
*/
|
||||
OnItemClickListener aibumClickListener = new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
// Intent intent = new Intent(PhotoAlbumActivity.this,
|
||||
// PhotoActivity.class);
|
||||
// intent.putExtra("aibum", aibumList.get(position));
|
||||
// startActivity(intent);
|
||||
aibum = aibumList.get(position);
|
||||
changePhotos(aibumList.get(position));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
// TODO Auto-generated method stub
|
||||
top_title.setText("全部图片");
|
||||
|
||||
}
|
||||
|
||||
private PhotoAibum aibum;
|
||||
|
||||
public void changePhotos(PhotoAibum aibum) {
|
||||
top_right_text.setVisibility(View.VISIBLE);
|
||||
top_title.setText("选择图片");
|
||||
if (isTopc) {
|
||||
maxnumber=3;
|
||||
PhotoNum=3;
|
||||
top_right_text.setText("确认" + haveNums + "/3");
|
||||
} else {
|
||||
maxnumber=PhotoNum;
|
||||
top_right_text.setText("确认" + haveNums + "/"+PhotoNum);
|
||||
}
|
||||
|
||||
top_right_text.setTextColor(PhotoAlbumActivity.this.getResources()
|
||||
.getColor(R.color.white));
|
||||
top_right_text.setTextSize(14);
|
||||
top_right_text.setBackgroundResource(R.drawable.selector_btn);
|
||||
LayoutParams paras = (LayoutParams) top_right_text
|
||||
.getLayoutParams();
|
||||
paras.setMargins(0, 0, dip2px(PhotoAlbumActivity.this, 10), 0);
|
||||
paras.height = dip2px(PhotoAlbumActivity.this, 30);
|
||||
top_right_text.setLayoutParams(paras);
|
||||
|
||||
top_right_text.setOnClickListener(this);
|
||||
adapter = new PhotoAdappter2(this, aibum);
|
||||
aibumGV.setNumColumns(3);
|
||||
aibumGV.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener(new PhotoAdappter2.ViewItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position) {
|
||||
if (potisions.contains(position + "")) {
|
||||
potisions.remove(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) - 1) + "";
|
||||
} else {
|
||||
if (isTopc) {
|
||||
if (Integer.parseInt(haveNums) < 3) {
|
||||
potisions.add(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
maxnumber=3;
|
||||
} else {
|
||||
ToastUtil.showMessage("最多添加"+PhotoNum+"张");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Integer.parseInt(haveNums) < PhotoNum) {
|
||||
potisions.add(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
maxnumber=PhotoNum;
|
||||
} else {
|
||||
ToastUtil.showMessage("最多添加"+PhotoNum+"张");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (isTopc) {
|
||||
maxnumber=3;
|
||||
top_right_text.setText("确认" + haveNums + "/3");
|
||||
} else {
|
||||
maxnumber=PhotoNum;
|
||||
top_right_text.setText("确认" + haveNums + "/"+PhotoNum);
|
||||
}
|
||||
|
||||
// getpath();
|
||||
adapter.getPosition(potisions);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
aibumGV.setOnItemClickListener(gvItemClickListener);
|
||||
}
|
||||
|
||||
private ArrayList<String> potisions = new ArrayList<String>();
|
||||
// private ArrayList<String> paths;
|
||||
private OnItemClickListener gvItemClickListener = new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Intent intent = new Intent(PhotoAlbumActivity.this, AlbumPreviewActivity.class);
|
||||
intent.putExtra(AlbumPreviewActivity.ARG_BUCKET_INDEX, 0);
|
||||
intent.putExtra(AlbumPreviewActivity.ARG_INDEX, position);
|
||||
intent.putExtra(AlbumPreviewActivity.MAX_NUMBER, maxnumber);
|
||||
intent.putExtra("aibum",aibum);
|
||||
intent.putExtra("haveNums",Integer.parseInt(haveNums));
|
||||
intent.putStringArrayListExtra("potisions",potisions);
|
||||
startActivityForResult(intent, 500);
|
||||
|
||||
|
||||
|
||||
// if (potisions.contains(position + "")) {
|
||||
// potisions.remove(position + "");
|
||||
// haveNums = (Integer.parseInt(haveNums) - 1) + "";
|
||||
// } else {
|
||||
// if (isTopc) {
|
||||
// if (Integer.parseInt(haveNums) < 3) {
|
||||
// potisions.add(position + "");
|
||||
// haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
//
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// if (Integer.parseInt(haveNums) < PhotoNum) {
|
||||
// potisions.add(position + "");
|
||||
// haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
//
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (isTopc) {
|
||||
// top_right_text.setText("确认" + haveNums + "/3");
|
||||
// } else {
|
||||
// top_right_text.setText("确认" + haveNums + "/"+PhotoNum);
|
||||
// }
|
||||
//
|
||||
// // getpath();
|
||||
// adapter.getPosition(potisions);
|
||||
// adapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
ContentResolver cr;
|
||||
|
||||
public void getpath() {
|
||||
// paths = new ArrayList<String>();
|
||||
for (int i = 0; i < potisions.size(); i++) {
|
||||
int position = Integer.parseInt(potisions.get(i));
|
||||
// paths.add(aibum.bitList.get(i).getPath());
|
||||
gl_arr.add(aibum.bitList.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
private void getThumbnail() {
|
||||
cr = PhotoAlbumActivity.this.getContentResolver();
|
||||
String[] projection = { Thumbnails._ID, Thumbnails.IMAGE_ID,
|
||||
Thumbnails.DATA };
|
||||
Cursor cursor = cr.query(Thumbnails.EXTERNAL_CONTENT_URI, projection,
|
||||
null, null, null);
|
||||
getThumbnailColumnData(cursor);
|
||||
}
|
||||
|
||||
HashMap<String, String> thumbnailList = new HashMap<String, String>();
|
||||
|
||||
private void getThumbnailColumnData(Cursor cur) {
|
||||
if (cur.moveToFirst()) {
|
||||
int _id;
|
||||
int image_id;
|
||||
String image_path;
|
||||
int _idColumn = cur.getColumnIndex(Thumbnails._ID);
|
||||
int image_idColumn = cur.getColumnIndex(Thumbnails.IMAGE_ID);
|
||||
int dataColumn = cur.getColumnIndex(Thumbnails.DATA);
|
||||
|
||||
do {
|
||||
// Get the field values
|
||||
_id = cur.getInt(_idColumn);
|
||||
image_id = cur.getInt(image_idColumn);
|
||||
image_path = cur.getString(dataColumn);
|
||||
|
||||
// Do something with the values.
|
||||
// Log.i(TAG, _id + " image_id:" + image_id + " path:"
|
||||
// + image_path + "---");
|
||||
// HashMap<String, String> hash = new HashMap<String, String>();
|
||||
// hash.put("image_id", image_id + "");
|
||||
// hash.put("path", image_path);
|
||||
// thumbnailList.add(hash);
|
||||
thumbnailList.put("" + image_id, image_path);
|
||||
} while (cur.moveToNext());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法描述:按相册获取图片信息
|
||||
*
|
||||
* @author: why
|
||||
* @time: 2013-10-18 下午1:35:24
|
||||
*/
|
||||
private List<PhotoAibum> getPhotoAlbum() {
|
||||
getThumbnail();
|
||||
List<PhotoAibum> aibumList = new ArrayList<PhotoAibum>();
|
||||
Cursor cursor = MediaStore.Images.Media.query(getContentResolver(),
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, STORE_IMAGES);
|
||||
Map<String, PhotoAibum> countMap = new HashMap<String, PhotoAibum>();
|
||||
PhotoAibum pa = null;
|
||||
while (cursor.moveToNext()) {
|
||||
String path = cursor.getString(1)+"";
|
||||
String id = cursor.getString(3)+"";
|
||||
String dir_id = cursor.getString(4)+"";
|
||||
String dir = cursor.getString(5)+"";
|
||||
// Log.e("info", "id===" + id + "==dir_id==" + dir_id + "==dir=="+ dir + "==path=" + path);
|
||||
if (!countMap.containsKey(dir_id)) {
|
||||
pa = new PhotoAibum();
|
||||
pa.setName(dir);
|
||||
pa.setBitmapPath(path);
|
||||
|
||||
|
||||
// pa.thumbnailPath = thumbnailList.get(Integer.parseInt(id));
|
||||
pa.setBitmap(Integer.parseInt(id));
|
||||
pa.setCount(1);
|
||||
List<PhotoItem> list= pa.getBitList();
|
||||
list.add(new PhotoItem(Integer.valueOf(id), path));
|
||||
countMap.put(dir_id, pa);
|
||||
} else {
|
||||
pa = countMap.get(dir_id);
|
||||
pa.setCount(pa.getCount() + 1);
|
||||
List<PhotoItem> list= pa.getBitList();
|
||||
list.add(new PhotoItem(Integer.valueOf(id), path));
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
Iterable<String> it = countMap.keySet();
|
||||
for (String key : it) {
|
||||
aibumList.add(countMap.get(key));
|
||||
}
|
||||
|
||||
return aibumList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
// TODO Auto-generated method stub
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
view = UIUtils.inflate(R.layout.activity_photoalbum);
|
||||
aibumGV = (GridView) view.findViewById(R.id.album_gridview);
|
||||
// helper = AlbumHelper.getHelper();
|
||||
// helper.init(getApplicationContext());
|
||||
// aibumList = helper.getImagesBucketList(false);
|
||||
aibumList = getPhotoAlbum();
|
||||
aibumGV.setAdapter(new PhotoAibumAdapter(aibumList, this));
|
||||
aibumGV.setOnItemClickListener(aibumClickListener);
|
||||
initIntent();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initIntent() {
|
||||
// TODO Auto-generated method stub
|
||||
getIntent = getIntent();
|
||||
haveNums = getIntent.getStringExtra("photonum");
|
||||
PhotoNum =getIntent.getIntExtra("maxphotonum",8);
|
||||
issendgroup=getIntent.getIntExtra("issendgroup",0);
|
||||
if (haveNums.equals("-1")) {
|
||||
PhotoNum=5;
|
||||
haveNums = "0";
|
||||
isTalke = true;
|
||||
}
|
||||
else if ("1".equals(issendgroup+"")) {
|
||||
// PhotoNum=1;
|
||||
// haveNums = "0";
|
||||
isTalke = true;
|
||||
}
|
||||
// }
|
||||
// else if ("1".equals(haveNums)){
|
||||
// PhotoNum=1;
|
||||
// haveNums = "0";
|
||||
// isTalke = true;
|
||||
// }
|
||||
istopc = getIntent.getStringExtra("isTopic");
|
||||
if (istopc != null && istopc.equals("isTopic")) {
|
||||
isTopc = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultState onLoad() {
|
||||
// TODO Auto-generated method stub
|
||||
return ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (v.getId()) {
|
||||
case R.id.top_right_text:
|
||||
getpath();
|
||||
if (gl_arr.size() > 0) {
|
||||
try {
|
||||
ECPreferences.savePreference(
|
||||
ECPreferenceSettings.SETTINGS_PREVIEW_SELECTED,
|
||||
Boolean.TRUE, true);
|
||||
} catch (InvalidClassException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("photos", (Serializable) gl_arr);
|
||||
if (isTalke) {
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(102, intent);
|
||||
}
|
||||
|
||||
this.finish();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// dp到像素的转换
|
||||
public static int dip2px(Context context, double d) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (d * scale + 0.5f);
|
||||
}
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 500) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
potisions= data.getExtras().getStringArrayList("potisions");
|
||||
haveNums=data.getExtras().getInt("haveNums")+"";
|
||||
adapter.getPosition(potisions);
|
||||
adapter.notifyDataSetChanged();
|
||||
top_right_text.setText("确认" + haveNums + "/"+maxnumber+"张");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Images.Thumbnails;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.FrameLayout.LayoutParams;
|
||||
import android.widget.GridView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.adapter.PhotoAdappter2;
|
||||
import cn.shangyu.gdxzExpert.adapter.PhotoAibumAdapter;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.PhotoAibum;
|
||||
import cn.shangyu.gdxzExpert.bean.PhotoItem;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferenceSettings;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferences;
|
||||
import cn.shangyu.gdxzExpert.photo.AlbumPreviewActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
|
||||
/******************************************
|
||||
* 类描述: 相册管理类 类名称:PhotoAlbumActivity
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author: zhaodewei
|
||||
* @time: 2013-10-18 下午2:10:46
|
||||
*****************************************/
|
||||
public class PhotoAlbumActivity extends BaseActivity {
|
||||
private GridView aibumGV;
|
||||
private List<PhotoAibum> aibumList;
|
||||
private PhotoAdappter2 adapter;
|
||||
private View view;
|
||||
private Intent getIntent;
|
||||
private String haveNums;
|
||||
// private AlbumHelper helper;
|
||||
private String istopc;
|
||||
private boolean isTopc = false;
|
||||
private boolean isTalke = false;
|
||||
private ArrayList<PhotoItem> gl_arr = new ArrayList<PhotoItem>();
|
||||
private int PhotoNum=8;
|
||||
int maxnumber,issendgroup;
|
||||
// 设置获取图片的字段信�?
|
||||
private static final String[] STORE_IMAGES = {
|
||||
MediaStore.Images.Media.DISPLAY_NAME, // 显示的名称
|
||||
MediaStore.Images.Media.DATA,//路径
|
||||
MediaStore.Images.Media.LONGITUDE, // 经度
|
||||
MediaStore.Images.Media._ID, // id
|
||||
MediaStore.Images.Media.BUCKET_ID, // dir id 目录
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME // dir name 目录名字
|
||||
|
||||
};
|
||||
/**
|
||||
* 相册点击事件
|
||||
*/
|
||||
OnItemClickListener aibumClickListener = new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
// Intent intent = new Intent(PhotoAlbumActivity.this,
|
||||
// PhotoActivity.class);
|
||||
// intent.putExtra("aibum", aibumList.get(position));
|
||||
// startActivity(intent);
|
||||
aibum = aibumList.get(position);
|
||||
changePhotos(aibumList.get(position));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
// TODO Auto-generated method stub
|
||||
top_title.setText("全部图片");
|
||||
|
||||
}
|
||||
|
||||
private PhotoAibum aibum;
|
||||
|
||||
public void changePhotos(PhotoAibum aibum) {
|
||||
top_right_text.setVisibility(View.VISIBLE);
|
||||
top_title.setText("选择图片");
|
||||
if (isTopc) {
|
||||
maxnumber=3;
|
||||
PhotoNum=3;
|
||||
top_right_text.setText("确认" + haveNums + "/3");
|
||||
} else {
|
||||
maxnumber=PhotoNum;
|
||||
top_right_text.setText("确认" + haveNums + "/"+PhotoNum);
|
||||
}
|
||||
|
||||
top_right_text.setTextColor(PhotoAlbumActivity.this.getResources()
|
||||
.getColor(R.color.white));
|
||||
top_right_text.setTextSize(14);
|
||||
top_right_text.setBackgroundResource(R.drawable.selector_btn);
|
||||
LayoutParams paras = (LayoutParams) top_right_text
|
||||
.getLayoutParams();
|
||||
paras.setMargins(0, 0, dip2px(PhotoAlbumActivity.this, 10), 0);
|
||||
paras.height = dip2px(PhotoAlbumActivity.this, 30);
|
||||
top_right_text.setLayoutParams(paras);
|
||||
|
||||
top_right_text.setOnClickListener(this);
|
||||
adapter = new PhotoAdappter2(this, aibum);
|
||||
aibumGV.setNumColumns(3);
|
||||
aibumGV.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener(new PhotoAdappter2.ViewItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position) {
|
||||
if (potisions.contains(position + "")) {
|
||||
potisions.remove(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) - 1) + "";
|
||||
} else {
|
||||
if (isTopc) {
|
||||
if (Integer.parseInt(haveNums) < 3) {
|
||||
potisions.add(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
maxnumber=3;
|
||||
} else {
|
||||
ToastUtil.showMessage("最多添加"+PhotoNum+"张");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Integer.parseInt(haveNums) < PhotoNum) {
|
||||
potisions.add(position + "");
|
||||
haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
maxnumber=PhotoNum;
|
||||
} else {
|
||||
ToastUtil.showMessage("最多添加"+PhotoNum+"张");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (isTopc) {
|
||||
maxnumber=3;
|
||||
top_right_text.setText("确认" + haveNums + "/3");
|
||||
} else {
|
||||
maxnumber=PhotoNum;
|
||||
top_right_text.setText("确认" + haveNums + "/"+PhotoNum);
|
||||
}
|
||||
|
||||
// getpath();
|
||||
adapter.getPosition(potisions);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
aibumGV.setOnItemClickListener(gvItemClickListener);
|
||||
}
|
||||
|
||||
private ArrayList<String> potisions = new ArrayList<String>();
|
||||
// private ArrayList<String> paths;
|
||||
private OnItemClickListener gvItemClickListener = new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Intent intent = new Intent(PhotoAlbumActivity.this, AlbumPreviewActivity.class);
|
||||
intent.putExtra(AlbumPreviewActivity.ARG_BUCKET_INDEX, 0);
|
||||
intent.putExtra(AlbumPreviewActivity.ARG_INDEX, position);
|
||||
intent.putExtra(AlbumPreviewActivity.MAX_NUMBER, maxnumber);
|
||||
intent.putExtra("aibum",aibum);
|
||||
intent.putExtra("haveNums",Integer.parseInt(haveNums));
|
||||
intent.putStringArrayListExtra("potisions",potisions);
|
||||
startActivityForResult(intent, 500);
|
||||
|
||||
|
||||
|
||||
// if (potisions.contains(position + "")) {
|
||||
// potisions.remove(position + "");
|
||||
// haveNums = (Integer.parseInt(haveNums) - 1) + "";
|
||||
// } else {
|
||||
// if (isTopc) {
|
||||
// if (Integer.parseInt(haveNums) < 3) {
|
||||
// potisions.add(position + "");
|
||||
// haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
//
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// if (Integer.parseInt(haveNums) < PhotoNum) {
|
||||
// potisions.add(position + "");
|
||||
// haveNums = (Integer.parseInt(haveNums) + 1) + "";
|
||||
//
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (isTopc) {
|
||||
// top_right_text.setText("确认" + haveNums + "/3");
|
||||
// } else {
|
||||
// top_right_text.setText("确认" + haveNums + "/"+PhotoNum);
|
||||
// }
|
||||
//
|
||||
// // getpath();
|
||||
// adapter.getPosition(potisions);
|
||||
// adapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
ContentResolver cr;
|
||||
|
||||
public void getpath() {
|
||||
// paths = new ArrayList<String>();
|
||||
LogUtil.d("PhotoAlbumActivity", "getpath: potisions=" + (potisions != null ? "not null, size=" + potisions.size() : "null") + ", aibum=" + (aibum != null ? "not null" : "null") + ", aibum.bitList=" + (aibum != null && aibum.bitList != null ? "not null, size=" + aibum.bitList.size() : "null"));
|
||||
gl_arr.clear();
|
||||
if (potisions == null || potisions.isEmpty()) {
|
||||
LogUtil.w("PhotoAlbumActivity", "getpath: potisions 为空,没有选中的照片");
|
||||
return;
|
||||
}
|
||||
if (aibum == null || aibum.bitList == null || aibum.bitList.isEmpty()) {
|
||||
LogUtil.w("PhotoAlbumActivity", "getpath: aibum 或 bitList 为空,无法获取照片");
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < potisions.size(); i++) {
|
||||
try {
|
||||
int position = Integer.parseInt(potisions.get(i));
|
||||
// paths.add(aibum.bitList.get(i).getPath());
|
||||
if (position >= 0 && position < aibum.bitList.size()) {
|
||||
PhotoItem item = aibum.bitList.get(position);
|
||||
if (item != null) {
|
||||
gl_arr.add(item);
|
||||
LogUtil.d("PhotoAlbumActivity", "getpath: 添加 PhotoItem[" + i + "], position=" + position + ", path=" + item.getPath());
|
||||
} else {
|
||||
LogUtil.e("PhotoAlbumActivity", "getpath: PhotoItem[" + position + "] 为 null");
|
||||
}
|
||||
} else {
|
||||
LogUtil.e("PhotoAlbumActivity", "getpath: 索引越界, position=" + position + ", bitList.size=" + aibum.bitList.size());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getpath: 无法解析位置索引[" + i + "]=" + potisions.get(i) + ", error: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getpath: 处理位置[" + i + "]时发生异常, error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
LogUtil.d("PhotoAlbumActivity", "getpath: 最终 gl_arr.size=" + gl_arr.size());
|
||||
}
|
||||
|
||||
private void getThumbnail() {
|
||||
LogUtil.d("PhotoAlbumActivity", "getThumbnail: 开始加载缩略图");
|
||||
cr = PhotoAlbumActivity.this.getContentResolver();
|
||||
String[] projection = { Thumbnails._ID, Thumbnails.IMAGE_ID,
|
||||
Thumbnails.DATA };
|
||||
try {
|
||||
Cursor cursor = cr.query(Thumbnails.EXTERNAL_CONTENT_URI, projection,
|
||||
null, null, null);
|
||||
if (cursor == null) {
|
||||
LogUtil.w("PhotoAlbumActivity", "getThumbnail: cursor 为 null");
|
||||
} else {
|
||||
LogUtil.d("PhotoAlbumActivity", "getThumbnail: cursor.count=" + cursor.getCount());
|
||||
getThumbnailColumnData(cursor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getThumbnail: 查询缩略图时发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> thumbnailList = new HashMap<String, String>();
|
||||
|
||||
private void getThumbnailColumnData(Cursor cur) {
|
||||
if (cur.moveToFirst()) {
|
||||
int _id;
|
||||
int image_id;
|
||||
String image_path;
|
||||
int _idColumn = cur.getColumnIndex(Thumbnails._ID);
|
||||
int image_idColumn = cur.getColumnIndex(Thumbnails.IMAGE_ID);
|
||||
int dataColumn = cur.getColumnIndex(Thumbnails.DATA);
|
||||
|
||||
do {
|
||||
// Get the field values
|
||||
_id = cur.getInt(_idColumn);
|
||||
image_id = cur.getInt(image_idColumn);
|
||||
image_path = cur.getString(dataColumn);
|
||||
|
||||
// Do something with the values.
|
||||
// Log.i(TAG, _id + " image_id:" + image_id + " path:"
|
||||
// + image_path + "---");
|
||||
// HashMap<String, String> hash = new HashMap<String, String>();
|
||||
// hash.put("image_id", image_id + "");
|
||||
// hash.put("path", image_path);
|
||||
// thumbnailList.add(hash);
|
||||
thumbnailList.put("" + image_id, image_path);
|
||||
} while (cur.moveToNext());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法描述:按相册获取图片信息
|
||||
*
|
||||
* @author: why
|
||||
* @time: 2013-10-18 下午1:35:24
|
||||
*/
|
||||
private List<PhotoAibum> getPhotoAlbum() {
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: 开始加载相册列表, SDK_INT=" + Build.VERSION.SDK_INT);
|
||||
getThumbnail();
|
||||
List<PhotoAibum> aibumList = new ArrayList<PhotoAibum>();
|
||||
|
||||
// 检查权限
|
||||
boolean hasPermission = false;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 需要 READ_MEDIA_IMAGES 权限
|
||||
hasPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: Android 13+, READ_MEDIA_IMAGES permission=" + hasPermission);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// Android 6.0-12 需要 READ_EXTERNAL_STORAGE 权限
|
||||
hasPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: Android 6.0-12, READ_EXTERNAL_STORAGE permission=" + hasPermission);
|
||||
} else {
|
||||
// Android 6.0 以下不需要运行时权限
|
||||
hasPermission = true;
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: Android < 6.0, 不需要运行时权限");
|
||||
}
|
||||
|
||||
if (!hasPermission) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: 没有读取照片的权限,无法查询照片");
|
||||
ToastUtil.showMessage("需要照片访问权限才能查看相册");
|
||||
return aibumList;
|
||||
}
|
||||
|
||||
try {
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: 查询 MediaStore.Images.Media.EXTERNAL_CONTENT_URI=" + MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
// 使用 ContentResolver.query() 代替 MediaStore.Images.Media.query() 以提高兼容性
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = getContentResolver().query(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
STORE_IMAGES,
|
||||
null,
|
||||
null,
|
||||
MediaStore.Images.Media.DATE_ADDED + " DESC");
|
||||
} catch (SecurityException e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: SecurityException - 权限被拒绝, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
ToastUtil.showMessage("无法访问照片,请检查权限设置");
|
||||
return aibumList;
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: 查询时发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return aibumList;
|
||||
}
|
||||
|
||||
if (cursor == null) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: cursor 为 null,无法查询照片");
|
||||
return aibumList;
|
||||
}
|
||||
|
||||
int cursorCount = cursor.getCount();
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: cursor.count=" + cursorCount);
|
||||
|
||||
if (cursorCount == 0) {
|
||||
LogUtil.w("PhotoAlbumActivity", "getPhotoAlbum: cursor 为空,没有找到照片。可能原因:1)设备上没有照片 2)权限问题 3)Android 10+分区存储限制");
|
||||
// 尝试查询内部存储
|
||||
try {
|
||||
Cursor internalCursor = getContentResolver().query(
|
||||
MediaStore.Images.Media.INTERNAL_CONTENT_URI,
|
||||
STORE_IMAGES,
|
||||
null,
|
||||
null,
|
||||
MediaStore.Images.Media.DATE_ADDED + " DESC");
|
||||
if (internalCursor != null) {
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: INTERNAL_CONTENT_URI count=" + internalCursor.getCount());
|
||||
internalCursor.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: 查询内部存储时异常, error: " + e.getMessage());
|
||||
}
|
||||
cursor.close();
|
||||
return aibumList;
|
||||
}
|
||||
|
||||
Map<String, PhotoAibum> countMap = new HashMap<String, PhotoAibum>();
|
||||
PhotoAibum pa = null;
|
||||
int processedCount = 0;
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
try {
|
||||
String path = cursor.getString(1) + "";
|
||||
String id = cursor.getString(3) + "";
|
||||
String dir_id = cursor.getString(4) + "";
|
||||
String dir = cursor.getString(5) + "";
|
||||
|
||||
if (path == null || path.isEmpty() || "null".equals(path)) {
|
||||
LogUtil.w("PhotoAlbumActivity", "getPhotoAlbum: 跳过无效路径的照片, id=" + id);
|
||||
continue;
|
||||
}
|
||||
|
||||
processedCount++;
|
||||
if (processedCount <= 5) {
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: 处理照片[" + processedCount + "], id=" + id + ", path=" + path + ", dir=" + dir);
|
||||
}
|
||||
|
||||
if (!countMap.containsKey(dir_id)) {
|
||||
pa = new PhotoAibum();
|
||||
pa.setName(dir);
|
||||
pa.setBitmapPath(path);
|
||||
|
||||
// pa.thumbnailPath = thumbnailList.get(Integer.parseInt(id));
|
||||
pa.setBitmap(Integer.parseInt(id));
|
||||
pa.setCount(1);
|
||||
List<PhotoItem> list = pa.getBitList();
|
||||
list.add(new PhotoItem(Integer.valueOf(id), path));
|
||||
countMap.put(dir_id, pa);
|
||||
} else {
|
||||
pa = countMap.get(dir_id);
|
||||
pa.setCount(pa.getCount() + 1);
|
||||
List<PhotoItem> list = pa.getBitList();
|
||||
list.add(new PhotoItem(Integer.valueOf(id), path));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: 处理照片时发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: 处理完成, processedCount=" + processedCount + ", countMap.size=" + countMap.size());
|
||||
|
||||
Iterable<String> it = countMap.keySet();
|
||||
for (String key : it) {
|
||||
PhotoAibum album = countMap.get(key);
|
||||
aibumList.add(album);
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: 添加相册 - " + album.getName() + ", 照片数=" + album.getCount());
|
||||
}
|
||||
|
||||
LogUtil.d("PhotoAlbumActivity", "getPhotoAlbum: 返回相册列表, size=" + aibumList.size());
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("PhotoAlbumActivity", "getPhotoAlbum: 发生异常, error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return aibumList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
// TODO Auto-generated method stub
|
||||
LogUtil.d("PhotoAlbumActivity", "onCreateSuccessedView: 开始创建视图");
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
view = UIUtils.inflate(R.layout.activity_photoalbum);
|
||||
aibumGV = (GridView) view.findViewById(R.id.album_gridview);
|
||||
|
||||
if (aibumGV == null) {
|
||||
LogUtil.e("PhotoAlbumActivity", "onCreateSuccessedView: aibumGV 为 null");
|
||||
}
|
||||
|
||||
// helper = AlbumHelper.getHelper();
|
||||
// helper.init(getApplicationContext());
|
||||
// aibumList = helper.getImagesBucketList(false);
|
||||
aibumList = getPhotoAlbum();
|
||||
|
||||
LogUtil.d("PhotoAlbumActivity", "onCreateSuccessedView: 相册列表加载完成, aibumList.size=" + (aibumList != null ? aibumList.size() : 0));
|
||||
|
||||
if (aibumList == null || aibumList.isEmpty()) {
|
||||
LogUtil.w("PhotoAlbumActivity", "onCreateSuccessedView: 相册列表为空,无法显示照片");
|
||||
}
|
||||
|
||||
aibumGV.setAdapter(new PhotoAibumAdapter(aibumList, this));
|
||||
aibumGV.setOnItemClickListener(aibumClickListener);
|
||||
initIntent();
|
||||
LogUtil.d("PhotoAlbumActivity", "onCreateSuccessedView: 视图创建完成");
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initIntent() {
|
||||
// TODO Auto-generated method stub
|
||||
getIntent = getIntent();
|
||||
haveNums = getIntent.getStringExtra("photonum");
|
||||
PhotoNum =getIntent.getIntExtra("maxphotonum",8);
|
||||
issendgroup=getIntent.getIntExtra("issendgroup",0);
|
||||
if (haveNums.equals("-1")) {
|
||||
PhotoNum=5;
|
||||
haveNums = "0";
|
||||
isTalke = true;
|
||||
}
|
||||
else if ("1".equals(issendgroup+"")) {
|
||||
// PhotoNum=1;
|
||||
// haveNums = "0";
|
||||
isTalke = true;
|
||||
}
|
||||
// }
|
||||
// else if ("1".equals(haveNums)){
|
||||
// PhotoNum=1;
|
||||
// haveNums = "0";
|
||||
// isTalke = true;
|
||||
// }
|
||||
istopc = getIntent.getStringExtra("isTopic");
|
||||
if (istopc != null && istopc.equals("isTopic")) {
|
||||
isTopc = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultState onLoad() {
|
||||
// TODO Auto-generated method stub
|
||||
return ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (v.getId()) {
|
||||
case R.id.top_right_text:
|
||||
LogUtil.d("PhotoAlbumActivity", "确认按钮点击,开始返回照片数据");
|
||||
getpath();
|
||||
LogUtil.d("PhotoAlbumActivity", "确认按钮: gl_arr.size=" + gl_arr.size() + ", isTalke=" + isTalke);
|
||||
if (gl_arr.size() > 0) {
|
||||
try {
|
||||
ECPreferences.savePreference(
|
||||
ECPreferenceSettings.SETTINGS_PREVIEW_SELECTED,
|
||||
Boolean.TRUE, true);
|
||||
} catch (InvalidClassException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (int i = 0; i < gl_arr.size(); i++) {
|
||||
PhotoItem item = gl_arr.get(i);
|
||||
LogUtil.d("PhotoAlbumActivity", "返回 PhotoItem[" + i + "]: path=" + (item != null ? item.getPath() : "null"));
|
||||
}
|
||||
} else {
|
||||
LogUtil.w("PhotoAlbumActivity", "确认按钮: gl_arr 为空,没有选择照片");
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("photos", (Serializable) gl_arr);
|
||||
if (isTalke) {
|
||||
setResult(RESULT_OK, intent);
|
||||
LogUtil.d("PhotoAlbumActivity", "设置返回结果: RESULT_OK, photos count=" + gl_arr.size());
|
||||
} else {
|
||||
setResult(102, intent);
|
||||
LogUtil.d("PhotoAlbumActivity", "设置返回结果: 102, photos count=" + gl_arr.size());
|
||||
}
|
||||
|
||||
this.finish();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// dp到像素的转换
|
||||
public static int dip2px(Context context, double d) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (d * scale + 0.5f);
|
||||
}
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 500) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
potisions= data.getExtras().getStringArrayList("potisions");
|
||||
haveNums=data.getExtras().getInt("haveNums")+"";
|
||||
adapter.getPosition(potisions);
|
||||
adapter.notifyDataSetChanged();
|
||||
top_right_text.setText("确认" + haveNums + "/"+maxnumber+"张");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -31,8 +32,11 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
@@ -69,6 +73,9 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
private static final String CROP_IMAGE_FILE_NAME = "gdxz_crop.jpg";
|
||||
private String mExtStorDir;
|
||||
private Uri mUriPath;
|
||||
private Uri mCropOutputUri;
|
||||
|
||||
private static final String TAG = "SelectedPhotoActivity";
|
||||
/**
|
||||
* 拍照获取图片
|
||||
*/
|
||||
@@ -126,18 +133,28 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
* 从相册中取图片
|
||||
*/
|
||||
private void pickPhoto() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(SelectedPhotoActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
|
||||
|
||||
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
// Android 12及以下使用旧的存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(SelectedPhotoActivity.this,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
// 有访问相册的权限
|
||||
Log.d(TAG, "pickPhoto: has legacy storage permission, opening ACTION_PICK");
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
// intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
|
||||
} else {
|
||||
Log.d(TAG, "pickPhoto: request legacy storage permission");
|
||||
EasyWindow.with(SelectedPhotoActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
|
||||
.setContentView(R.layout.float_top_dialog_photo).show();
|
||||
PermissionsUtil.requestPermission(SelectedPhotoActivity.this, new PermissionListener() {
|
||||
@Override
|
||||
@@ -145,30 +162,21 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
// intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//
|
||||
// 用户拒绝了访问相册的申请
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
// intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -177,9 +185,9 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
*/
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
|
||||
Log.d(TAG, "onActivityResult: RESULT_OK, dispatching to doPhoto");
|
||||
doPhoto(requestCode, data);
|
||||
}
|
||||
|
||||
@@ -193,20 +201,36 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
try {
|
||||
if (requestCode == SELECT_PIC_BY_PICK_PHOTO) // 从相册取图片,有些手机有异常情况,请注意
|
||||
{
|
||||
Log.d(TAG, "doPhoto: SELECT_PIC_BY_PICK_PHOTO, data=" + data);
|
||||
if (data == null) {
|
||||
Toast.makeText(this, "选择图片文件出错", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
photoUri = data.getData();
|
||||
Log.d(TAG, "doPhoto: SELECT_PIC_BY_PICK_PHOTO, photoUri=" + photoUri);
|
||||
if (photoUri == null) {
|
||||
Toast.makeText(this, "选择图片文件出错", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
cropImage(photoUri);
|
||||
|
||||
// 用户希望自行裁剪图片:统一走系统裁剪 UI(ACTION_CROP),但先把图片复制到应用可控的文件再传给裁剪应用
|
||||
try {
|
||||
Uri copyUri = copyToAppFile(photoUri);
|
||||
if (copyUri == null) {
|
||||
Toast.makeText(this, "图片处理失败,请重新选择", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "doPhoto: SELECT_PIC_BY_PICK_PHOTO, start cropImage with uri=" + copyUri);
|
||||
cropImage(copyUri);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, "图片处理失败,请重新选择", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
if (requestCode == SELECT_PIC_BY_TACK_PHOTO) {
|
||||
|
||||
photoUri = Uri.parse(sp.getString("photoUri", ""));
|
||||
Log.d(TAG, "doPhoto: SELECT_PIC_BY_TACK_PHOTO, photoUri(sp)=" + photoUri);
|
||||
if (photoUri == null) {
|
||||
Toast.makeText(this, "选择图片文件出错", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
@@ -214,50 +238,76 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
cropImage(photoUri);
|
||||
}
|
||||
if (requestCode == PHOTO_RESOULT) {
|
||||
if (data != null) {
|
||||
Bitmap bm;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
bm = BitmapFactory.decodeStream(getContentResolver()
|
||||
.openInputStream(FileUtils.uri));
|
||||
// 裁剪结果优先从我们指定的输出 Uri 读取,失败则回退尝试 data 中的 Uri 或缩略图
|
||||
Bitmap bm = null;
|
||||
Uri resultUri = null;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bm = BitmapFactory.decodeStream(getContentResolver()
|
||||
.openInputStream(mUriPath));
|
||||
|
||||
}
|
||||
// Bitmap bm = BitmapFactory.decodeStream(getContentResolver()
|
||||
// .openInputStream(mUriPath));
|
||||
String userimg = Base64Util.BitmaptoBase64Xiongpai(bm);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MMddhhmmss");
|
||||
Date dt = new Date();
|
||||
String picN = "cy" + sdf.format(dt) + ".jpg";
|
||||
File temp = new File(this.getCacheDir(), picN);// 放到
|
||||
if (temp.exists())
|
||||
temp.delete();
|
||||
try {
|
||||
temp.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
bm.compress(CompressFormat.JPEG, 100, new FileOutputStream(
|
||||
temp));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!bm.isRecycled()) {
|
||||
bm.recycle();
|
||||
bm = null;
|
||||
}
|
||||
lastIntent.putExtra(KEY_PHOTO_PATH, temp.getAbsolutePath());
|
||||
lastIntent.putExtra(KEY_PHOTO_BASE64, userimg);
|
||||
setResult(Activity.RESULT_OK, lastIntent);
|
||||
finish();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
resultUri = mCropOutputUri;
|
||||
} else {
|
||||
resultUri = mUriPath;
|
||||
}
|
||||
Log.d(TAG, "doPhoto: PHOTO_RESOULT, resultUri=" + resultUri + ", data=" + data);
|
||||
|
||||
try {
|
||||
// 1. 优先使用我们传给裁剪页面的输出 Uri
|
||||
if (resultUri != null) {
|
||||
Log.d(TAG, "doPhoto: try decode from resultUri");
|
||||
bm = BitmapFactory.decodeStream(
|
||||
getContentResolver().openInputStream(resultUri));
|
||||
}
|
||||
|
||||
// 2. 如果上述失败,再尝试从 data 中获取(部分机型会忽略 EXTRA_OUTPUT,只返回 data)
|
||||
if (bm == null && data != null) {
|
||||
Uri dataUri = data.getData();
|
||||
if (dataUri != null) {
|
||||
Log.d(TAG, "doPhoto: try decode from dataUri=" + dataUri);
|
||||
bm = BitmapFactory.decodeStream(
|
||||
getContentResolver().openInputStream(dataUri));
|
||||
}
|
||||
if (bm == null && data.getExtras() != null) {
|
||||
Log.d(TAG, "doPhoto: try get bitmap from extras");
|
||||
bm = data.getExtras().getParcelable("data");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (bm == null) {
|
||||
Log.w(TAG, "doPhoto: PHOTO_RESOULT bitmap is null after all attempts");
|
||||
Toast.makeText(this, "图片处理失败,请重新选择", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String userimg = Base64Util.BitmaptoBase64Xiongpai(bm);
|
||||
Log.d(TAG, "doPhoto: PHOTO_RESOULT base64 length=" + (userimg != null ? userimg.length() : 0));
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MMddhhmmss");
|
||||
Date dt = new Date();
|
||||
String picN = "cy" + sdf.format(dt) + ".jpg";
|
||||
File temp = new File(this.getCacheDir(), picN);// 放到
|
||||
if (temp.exists())
|
||||
temp.delete();
|
||||
try {
|
||||
temp.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
bm.compress(CompressFormat.JPEG, 100, new FileOutputStream(
|
||||
temp));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!bm.isRecycled()) {
|
||||
bm.recycle();
|
||||
}
|
||||
lastIntent.putExtra(KEY_PHOTO_PATH, temp.getAbsolutePath());
|
||||
lastIntent.putExtra(KEY_PHOTO_BASE64, userimg);
|
||||
setResult(Activity.RESULT_OK, lastIntent);
|
||||
finish();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
@@ -267,13 +317,8 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
}
|
||||
private void cropImage(Uri uri) {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
{
|
||||
FileUtils.createImageFile(this, true);
|
||||
}
|
||||
|
||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
intent.setDataAndType(uri, "image/*");
|
||||
intent.putExtra("crop", "true");
|
||||
if (!isConstraint) {
|
||||
@@ -290,22 +335,126 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
intent.putExtra("outputY", 300);
|
||||
}
|
||||
|
||||
Uri outputUri;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, FileUtils.uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Android 11+:将裁剪结果保存到应用私有目录,通过 FileProvider 暴露给裁剪应用,避免访问公共媒体库被限制
|
||||
String fileName = System.currentTimeMillis() + "_" + CROP_IMAGE_FILE_NAME;
|
||||
File outputFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), fileName);
|
||||
mCropOutputUri = FileProvider.getUriForFile(this,
|
||||
getApplicationContext().getPackageName() + ".fileprovider",
|
||||
outputFile);
|
||||
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
outputUri = mCropOutputUri;
|
||||
} else {
|
||||
String mLinshi = System.currentTimeMillis() + CROP_IMAGE_FILE_NAME;
|
||||
File mFile = new File(mExtStorDir, mLinshi);
|
||||
mUriPath = Uri.parse("file://" + mFile.getAbsolutePath());
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT,mUriPath);
|
||||
outputUri = mUriPath;
|
||||
}
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
|
||||
|
||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||
intent.putExtra("return-data", false);
|
||||
|
||||
// 显式授予裁剪目标应用对输入 uri 和输出 uri 的读写权限,避免 SecurityException
|
||||
try {
|
||||
List<android.content.pm.ResolveInfo> resInfoList =
|
||||
getPackageManager().queryIntentActivities(intent, android.content.pm.PackageManager.MATCH_DEFAULT_ONLY);
|
||||
for (android.content.pm.ResolveInfo resolveInfo : resInfoList) {
|
||||
String packageName = resolveInfo.activityInfo.packageName;
|
||||
grantUriPermission(packageName, uri,
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
if (outputUri != null) {
|
||||
grantUriPermission(packageName, outputUri,
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
startActivityForResult(intent, PHOTO_RESOULT);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 在应用内部对 Bitmap 做中心裁剪
|
||||
*
|
||||
* @param src 原图
|
||||
* @param ratioWtoH 宽:高 比例,例如 1f 表示 1:1,3f/2f 表示 3:2
|
||||
* @return 裁剪后的 Bitmap
|
||||
*/
|
||||
private Bitmap cropCenter(Bitmap src, float ratioWtoH) {
|
||||
if (src == null || src.isRecycled()) {
|
||||
return null;
|
||||
}
|
||||
int srcW = src.getWidth();
|
||||
int srcH = src.getHeight();
|
||||
if (srcW <= 0 || srcH <= 0) {
|
||||
return null;
|
||||
}
|
||||
if (ratioWtoH <= 0f) {
|
||||
ratioWtoH = 1f;
|
||||
}
|
||||
|
||||
int targetW;
|
||||
int targetH;
|
||||
|
||||
// 目标宽高满足 targetW / targetH = ratioWtoH,且不超出原图
|
||||
float targetHFromW = srcW / ratioWtoH;
|
||||
if (targetHFromW <= srcH) {
|
||||
targetW = srcW;
|
||||
targetH = (int) targetHFromW;
|
||||
} else {
|
||||
targetH = srcH;
|
||||
targetW = (int) (srcH * ratioWtoH);
|
||||
}
|
||||
|
||||
int left = (srcW - targetW) / 2;
|
||||
int top = (srcH - targetH) / 2;
|
||||
|
||||
try {
|
||||
return Bitmap.createBitmap(src, left, top, targetW, targetH);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将来源 Uri 指向的图片复制到应用私有目录,并返回对应的 FileProvider Uri,
|
||||
* 以便安全地传给系统裁剪应用(避免 Photo Picker Uri 权限问题)。
|
||||
*/
|
||||
private Uri copyToAppFile(Uri srcUri) throws IOException {
|
||||
if (srcUri == null) return null;
|
||||
File dir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||
if (dir == null) {
|
||||
dir = getFilesDir();
|
||||
}
|
||||
String fileName = "pick_" + System.currentTimeMillis() + ".jpg";
|
||||
File outFile = new File(dir, fileName);
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
in = getContentResolver().openInputStream(srcUri);
|
||||
if (in == null) return null;
|
||||
out = new FileOutputStream(outFile);
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
int len;
|
||||
while ((len = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
out.flush();
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ignored) {}
|
||||
if (out != null) try { out.close(); } catch (IOException ignored) {}
|
||||
}
|
||||
|
||||
return FileProvider.getUriForFile(this,
|
||||
getApplicationContext().getPackageName() + ".fileprovider",
|
||||
outFile);
|
||||
}
|
||||
/**
|
||||
* 剪切图片
|
||||
*/
|
||||
@@ -398,8 +547,21 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
// break;
|
||||
case R.id.btn_camera://拍照
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();
|
||||
} else {
|
||||
@@ -420,7 +582,7 @@ public class SelectedPhotoActivity extends BaseActivity implements
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.umeng.PushHelper.addUMToken;
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.uniapp_mp_appid;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.checkVersion;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -52,6 +53,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
||||
import cn.shangyu.gdxzExpert.base.AppManager;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferenceSettings;
|
||||
@@ -75,6 +77,9 @@ import cn.shangyu.gdxzExpert.utils.UpdateVersionUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
import io.dcloud.feature.sdk.DCSDKInitConfig;
|
||||
import io.dcloud.feature.sdk.DCUniMPSDK;
|
||||
import io.dcloud.feature.sdk.Interface.IUniMP;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -665,8 +670,11 @@ public class SettingAndHelpActivity extends BaseActivity implements OnCallBackFr
|
||||
|
||||
handleLogout();
|
||||
|
||||
|
||||
|
||||
IUniMP uniapp_MP = BaseApplication.getUniMPCaches().get(uniapp_mp_appid);
|
||||
if(uniapp_MP != null && uniapp_MP.isRunning()){
|
||||
uniapp_MP.closeUniMP();
|
||||
BaseApplication.getUniMPCaches().remove(uniapp_mp_appid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,8 +145,18 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
if (Build.VERSION.SDK_INT>26){
|
||||
boolean b = getPackageManager().canRequestPackageInstalls();
|
||||
if(b){
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
Intent intent = new Intent(SettingVersionActivity.this,
|
||||
UpdateService.class);
|
||||
@@ -176,7 +186,7 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -210,8 +220,18 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
}
|
||||
else
|
||||
{
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
Intent intent = new Intent(SettingVersionActivity.this,
|
||||
UpdateService.class);
|
||||
@@ -241,7 +261,7 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -506,8 +526,18 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
if (b){
|
||||
SharePrefUtil.saveString(SettingVersionActivity.this,
|
||||
"newVersion", newVersion);
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
Intent intent = new Intent(SettingVersionActivity.this,
|
||||
UpdateService.class);
|
||||
intent.putExtra("titleId", R.string.app_name);
|
||||
@@ -537,7 +567,7 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -567,8 +597,18 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
LogUtil.i("SDK_INT = "+25);
|
||||
SharePrefUtil.saveString(SettingVersionActivity.this,
|
||||
"newVersion", newVersion);
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
Intent intent = new Intent(SettingVersionActivity.this,
|
||||
UpdateService.class);
|
||||
intent.putExtra("titleId", R.string.app_name);
|
||||
@@ -598,7 +638,7 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -647,8 +687,18 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
//返回权限后,执行自己的逻辑;
|
||||
SharePrefUtil.saveString(SettingVersionActivity.this,
|
||||
"newVersion", newVersion);
|
||||
// UpdateService 使用应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(SettingVersionActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
Intent intent = new Intent(SettingVersionActivity.this,
|
||||
UpdateService.class);
|
||||
intent.putExtra("titleId", R.string.app_name);
|
||||
@@ -678,7 +728,7 @@ public class SettingVersionActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -968,8 +968,21 @@ public class TerminationActivity extends BaseActivity implements AdapterView.OnI
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(TerminationActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(TerminationActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(TerminationActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -990,7 +1003,7 @@ public class TerminationActivity extends BaseActivity implements AdapterView.OnI
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -1006,11 +1019,18 @@ public class TerminationActivity extends BaseActivity implements AdapterView.OnI
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(TerminationActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
|
||||
// Android 6.0 ~ 12 使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(TerminationActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -1023,7 +1043,7 @@ public class TerminationActivity extends BaseActivity implements AdapterView.OnI
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(TerminationActivity.this, PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(TerminationActivity.this, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -1032,20 +1052,15 @@ public class TerminationActivity extends BaseActivity implements AdapterView.OnI
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(TerminationActivity.this, PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -294,8 +294,18 @@ public class TicketDetailActivity extends BaseActivity implements OnCallBackFrom
|
||||
}
|
||||
else
|
||||
{
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(TicketDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(TicketDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
downloadPdf(ticketDetailBean.getData().getDown_url(),ticketDetailBean.getData().getId());
|
||||
} else {
|
||||
EasyWindow.with(TicketDetailActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -312,7 +322,7 @@ public class TicketDetailActivity extends BaseActivity implements OnCallBackFrom
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -698,8 +698,21 @@ public class WriteTopicActivity extends BaseActivity implements OnClickListener,
|
||||
// 拍照获取照片
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(WriteTopicActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(WriteTopicActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(WriteTopicActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();
|
||||
} else {
|
||||
@@ -720,7 +733,7 @@ public class WriteTopicActivity extends BaseActivity implements OnClickListener,
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -819,11 +832,20 @@ public class WriteTopicActivity extends BaseActivity implements OnClickListener,
|
||||
private ArrayList<PhotoItem> paths;
|
||||
|
||||
private void pickPhoto() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(WriteTopicActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
|
||||
|
||||
|
||||
// Android 6.0 ~ 12 使用旧的存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(WriteTopicActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
isTopic = 1;
|
||||
Intent intent = new Intent(WriteTopicActivity.this,
|
||||
PhotoAlbumActivity.class);
|
||||
AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("isTopic", "isTopic");
|
||||
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -837,7 +859,7 @@ public class WriteTopicActivity extends BaseActivity implements OnClickListener,
|
||||
EasyWindow.cancelAll();
|
||||
isTopic = 1;
|
||||
Intent intent = new Intent(WriteTopicActivity.this,
|
||||
PhotoAlbumActivity.class);
|
||||
AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("isTopic", "isTopic");
|
||||
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -846,21 +868,13 @@ public class WriteTopicActivity extends BaseActivity implements OnClickListener,
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//
|
||||
//用户拒绝了访问相册的申请
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
isTopic = 1;
|
||||
Intent intent = new Intent(WriteTopicActivity.this,
|
||||
PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("isTopic", "isTopic");
|
||||
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -261,8 +261,18 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
return;
|
||||
}
|
||||
if (CommonUtil.isNetworkAvailable(mContext) == 1) {
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadPdf(Url.urlHtml + data.getPath(), data.getTitle(),
|
||||
position, holder);
|
||||
@@ -283,7 +293,7 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -322,8 +332,18 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
try {
|
||||
// TODO Auto-generated method stub
|
||||
// 下载
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadPdf(Url.urlHtml + data.getPath(), data.getTitle(),
|
||||
position, holder);
|
||||
@@ -344,7 +364,7 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -435,8 +455,18 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
ToastUtil.showToast("文件不存在,请重新下载");
|
||||
}
|
||||
} else {
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml + data.filepath,
|
||||
@@ -461,7 +491,7 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
@@ -547,8 +577,18 @@ public class BookshelfListAdapter extends BaseAdapter {
|
||||
ToastUtil.showToast("文件不存在,请重新下载");
|
||||
}
|
||||
} else {
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml + data.filepath,
|
||||
|
||||
@@ -169,8 +169,18 @@ public class KejianAdapter extends RecyclerView.Adapter<KejianAdapter.ViewHolder
|
||||
}
|
||||
else
|
||||
{
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml +datas.get(position).getPath(),
|
||||
@@ -203,8 +213,7 @@ public class KejianAdapter extends RecyclerView.Adapter<KejianAdapter.ViewHolder
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// 下载
|
||||
// Android 6.0以下直接下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml +datas.get(position).getPath(),
|
||||
datas.get(position).getTitle(), position,
|
||||
|
||||
@@ -47,6 +47,8 @@ import com.umeng.commonsdk.UMConfigure;
|
||||
import com.umeng.socialize.PlatformConfig;
|
||||
import com.zhy.http.okhttp.OkHttpUtils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InvalidClassException;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -59,8 +61,17 @@ import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.dcloud.feature.sdk.Interface.IUniMP;
|
||||
import io.dcloud.feature.sdk.DCSDKInitConfig;
|
||||
import io.dcloud.feature.sdk.DCUniMPSDK;
|
||||
import io.dcloud.feature.sdk.Interface.IOnUniMPEventCallBack;
|
||||
import io.dcloud.feature.sdk.Interface.IUniMPOnCloseCallBack;
|
||||
import io.dcloud.feature.unimp.DCUniMPJSCallback;
|
||||
|
||||
import cn.shangyu.gdxzExpert.activity.LoginNewActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.PublicSearchActivity;
|
||||
import cn.shangyu.gdxzExpert.base.AppManager;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty;
|
||||
import cn.shangyu.gdxzExpert.cast.PolyvScreencastManager;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.CCPAppManager;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferenceSettings;
|
||||
@@ -280,6 +291,106 @@ public class BaseApplication extends Application {
|
||||
{
|
||||
initYinsi();
|
||||
}
|
||||
|
||||
//uniapp
|
||||
DCSDKInitConfig config = new DCSDKInitConfig.Builder()
|
||||
.setCapsule(false)
|
||||
.setMenuDefFontSize("16px")
|
||||
.setMenuDefFontColor("#ff00ff")
|
||||
.setMenuDefFontWeight("normal")
|
||||
.setEnableBackground(true)
|
||||
.build();
|
||||
DCUniMPSDK.getInstance().initialize(this, config);
|
||||
|
||||
DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(new IUniMPOnCloseCallBack() {
|
||||
@Override
|
||||
public void onClose(String appid) {
|
||||
LogUtil.i("unimp", appid+" 被关闭了");
|
||||
getUniMPCaches().clear();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 设置 UniMP 事件回调
|
||||
DCUniMPSDK.getInstance().setOnUniMPEventCallBack(new IOnUniMPEventCallBack() {
|
||||
@Override
|
||||
public void onUniMPEventReceive(String appid, String event, Object data, DCUniMPJSCallback callback) {
|
||||
LogUtil.i("onUniMPEventReceive appid="+appid);
|
||||
LogUtil.i("onUniMPEventReceive event="+event);
|
||||
LogUtil.i("onUniMPEventReceive data="+data);
|
||||
|
||||
try {
|
||||
|
||||
// 解析 data
|
||||
String msgValue = null;
|
||||
if (data instanceof com.alibaba.fastjson.JSONObject) {
|
||||
com.alibaba.fastjson.JSONObject fastJsonObj = (com.alibaba.fastjson.JSONObject) data;
|
||||
msgValue = fastJsonObj.getString("msg");
|
||||
} else if (data instanceof String) {
|
||||
JSONObject jsonObject = new JSONObject((String) data);
|
||||
msgValue = jsonObject.getString("msg");
|
||||
} else {
|
||||
JSONObject jsonObject = new JSONObject(data.toString());
|
||||
msgValue = jsonObject.getString("msg");
|
||||
}
|
||||
|
||||
Activity currentActivity = null;
|
||||
try {
|
||||
AppManager appManager = AppManager.getAppManager();
|
||||
if (appManager != null) {
|
||||
currentActivity = appManager.currentActivity();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("获取当前Activity失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (currentActivity == null) {
|
||||
LogUtil.e("当前Activity为空,无法处理uniapp事件");
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.equals("goTabbarPage")){
|
||||
// MainActivity 特有的逻辑,需要检查当前 Activity 是否是 MainActivity
|
||||
if (currentActivity instanceof cn.shangyu.gdxzExpert.activity.MainActivity) {
|
||||
cn.shangyu.gdxzExpert.activity.MainActivity mainActivity = (cn.shangyu.gdxzExpert.activity.MainActivity) currentActivity;
|
||||
if (currentActivity instanceof BaseActivity) {
|
||||
((BaseActivity) currentActivity).handleMainActivityEvent(mainActivity, event, msgValue);
|
||||
}
|
||||
}
|
||||
} else if (event.equals("getScanCodeAuth")){
|
||||
if (currentActivity instanceof BaseActivity) {
|
||||
((BaseActivity) currentActivity).handleScanCodeAuth(callback);
|
||||
}
|
||||
} else if(event.equals("checkToken")){
|
||||
if (currentActivity instanceof BaseActivity) {
|
||||
((BaseActivity) currentActivity).handleCheckToken(callback);
|
||||
}
|
||||
} else if(event.equals("goHomeSearch")){
|
||||
if (currentActivity != null) {
|
||||
Intent intentv = new Intent(currentActivity, cn.shangyu.gdxzExpert.activity.PublicSearchActivity.class);
|
||||
|
||||
if (msgValue.equals("patientVideo")) {
|
||||
intentv.setType("patientVideo");
|
||||
}else if (msgValue.equals("meetVideo")) {
|
||||
intentv.setType("video");
|
||||
}else if (msgValue.equals("zhinan")) {
|
||||
intentv.setType("drug");
|
||||
}
|
||||
|
||||
currentActivity.startActivity(intentv);
|
||||
}
|
||||
} else if(event.equals("buyPointPage")) {
|
||||
if (currentActivity != null) {
|
||||
Intent intentv = new Intent(currentActivity, cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty.class);
|
||||
currentActivity.startActivity(intentv);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
LogUtil.e("处理uniapp事件时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public void initYinsi()
|
||||
{
|
||||
|
||||
@@ -9,10 +9,12 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.Manifest;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -39,6 +41,8 @@ import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -78,6 +82,7 @@ import cn.shangyu.gdxzExpert.utils.RSAUtils2;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SignUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StreamTool;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.UpdateVersionUtils;
|
||||
@@ -87,8 +92,17 @@ import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
import io.dcloud.feature.sdk.DCSDKInitConfig;
|
||||
import io.dcloud.feature.sdk.DCUniMPSDK;
|
||||
import io.dcloud.feature.sdk.Interface.IOnUniMPEventCallBack;
|
||||
import io.dcloud.feature.sdk.Interface.IUniMP;
|
||||
import io.dcloud.feature.sdk.MenuActionSheetItem;
|
||||
import io.dcloud.feature.unimp.DCUniMPJSCallback;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.github.dfqin.grantor.PermissionListener;
|
||||
import com.github.dfqin.grantor.PermissionsUtil;
|
||||
import com.hjq.window.EasyWindow;
|
||||
import android.view.Gravity;
|
||||
import io.dcloud.feature.unimp.DCUniMPJSCallback;
|
||||
|
||||
/**
|
||||
* BaseActivity.java
|
||||
@@ -212,18 +226,245 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
||||
loadView();
|
||||
|
||||
// abstracrRegist();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 MainActivity 特有的事件
|
||||
*/
|
||||
public void handleMainActivityEvent(cn.shangyu.gdxzExpert.activity.MainActivity mainActivity, String event, String msgValue) {
|
||||
try {
|
||||
if(event.equals("goTabbarPage")){
|
||||
// 设置 auto_show_unimp 为 false
|
||||
try {
|
||||
java.lang.reflect.Field field = mainActivity.getClass().getDeclaredField("auto_show_unimp");
|
||||
field.setAccessible(true);
|
||||
field.setBoolean(mainActivity, false);
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("设置 auto_show_unimp 失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//uniapp
|
||||
DCSDKInitConfig config = new DCSDKInitConfig.Builder()
|
||||
.setCapsule(false)
|
||||
.setMenuDefFontSize("16px")
|
||||
.setMenuDefFontColor("#ff00ff")
|
||||
.setMenuDefFontWeight("normal")
|
||||
.setEnableBackground(true)
|
||||
.build();
|
||||
DCUniMPSDK.getInstance().initialize(this, config);
|
||||
final String msg = msgValue;
|
||||
LogUtil.i("goTabbarPage msg=" + msg);
|
||||
|
||||
// 通过反射访问 MainActivity 的私有成员和方法
|
||||
final cn.shangyu.gdxzExpert.activity.MainActivity finalMainActivity = mainActivity;
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// 通过反射获取私有成员
|
||||
java.lang.reflect.Field mainRadiogroupField = finalMainActivity.getClass().getDeclaredField("main_radiogroup");
|
||||
mainRadiogroupField.setAccessible(true);
|
||||
android.widget.RadioGroup main_radiogroup = (android.widget.RadioGroup) mainRadiogroupField.get(finalMainActivity);
|
||||
|
||||
java.lang.reflect.Field mRgKepuField = finalMainActivity.getClass().getDeclaredField("mRg_kepu");
|
||||
mRgKepuField.setAccessible(true);
|
||||
android.widget.RadioGroup mRg_kepu = (android.widget.RadioGroup) mRgKepuField.get(finalMainActivity);
|
||||
|
||||
java.lang.reflect.Field mVKpField = finalMainActivity.getClass().getDeclaredField("mV_kp");
|
||||
mVKpField.setAccessible(true);
|
||||
View mV_kp = (View) mVKpField.get(finalMainActivity);
|
||||
|
||||
java.lang.reflect.Field mRbPublishedField = finalMainActivity.getClass().getDeclaredField("mRb_published");
|
||||
mRbPublishedField.setAccessible(true);
|
||||
android.widget.RadioButton mRb_published = (android.widget.RadioButton) mRbPublishedField.get(finalMainActivity);
|
||||
|
||||
if(msg.equals("home")){
|
||||
LogUtil.i("准备切换到首页");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_home);
|
||||
main_radiogroup.setOnCheckedChangeListener((android.widget.RadioGroup.OnCheckedChangeListener) finalMainActivity);
|
||||
|
||||
if (mToolbar != null) {
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
}
|
||||
if (mRg_kepu != null) {
|
||||
mRg_kepu.setVisibility(View.GONE);
|
||||
}
|
||||
if (mV_kp != null) {
|
||||
mV_kp.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 调用 changeHome 方法
|
||||
java.lang.reflect.Method changeHomeMethod = finalMainActivity.getClass().getDeclaredMethod("changeHome");
|
||||
changeHomeMethod.setAccessible(true);
|
||||
changeHomeMethod.invoke(finalMainActivity);
|
||||
|
||||
LogUtil.i("首页切换逻辑执行完成");
|
||||
}else if(msg.equals("patientClass")){
|
||||
LogUtil.i("准备切换到患教页");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_kepu);
|
||||
main_radiogroup.setOnCheckedChangeListener((android.widget.RadioGroup.OnCheckedChangeListener) finalMainActivity);
|
||||
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
mToolbar.getBackground().setAlpha(255);
|
||||
if (mRg_kepu != null) {
|
||||
mRg_kepu.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mV_kp != null) {
|
||||
mV_kp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mRb_published != null) {
|
||||
mRb_published.setChecked(true);
|
||||
}
|
||||
if (top_sgin != null) {
|
||||
top_sgin.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
java.lang.reflect.Method changePatientZhongxinMethod = finalMainActivity.getClass().getDeclaredMethod("changePatientZhongxin");
|
||||
changePatientZhongxinMethod.setAccessible(true);
|
||||
changePatientZhongxinMethod.invoke(finalMainActivity);
|
||||
|
||||
LogUtil.i("患教页切换逻辑执行完成");
|
||||
}else if(msg.equals("education")){
|
||||
LogUtil.i("准备切换到继续教育页");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_news);
|
||||
main_radiogroup.setOnCheckedChangeListener((android.widget.RadioGroup.OnCheckedChangeListener) finalMainActivity);
|
||||
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
if (mRg_kepu != null) {
|
||||
mRg_kepu.setVisibility(View.GONE);
|
||||
}
|
||||
if (mV_kp != null) {
|
||||
mV_kp.setVisibility(View.GONE);
|
||||
}
|
||||
if (top_sgin != null) {
|
||||
top_sgin.setVisibility(View.GONE);
|
||||
}
|
||||
mToolbar.getBackground().setAlpha(255);
|
||||
|
||||
java.lang.reflect.Method changeNewsMethod = finalMainActivity.getClass().getDeclaredMethod("changeNews");
|
||||
changeNewsMethod.setAccessible(true);
|
||||
changeNewsMethod.invoke(finalMainActivity);
|
||||
|
||||
LogUtil.i("继续教育页切换逻辑执行完成");
|
||||
}else if(msg.equals("mine")){
|
||||
LogUtil.i("准备切换到我的页");
|
||||
if (main_radiogroup == null) {
|
||||
LogUtil.e("main_radiogroup is null!");
|
||||
return;
|
||||
}
|
||||
main_radiogroup.setOnCheckedChangeListener(null);
|
||||
main_radiogroup.check(R.id.tab_rbn_my);
|
||||
main_radiogroup.setOnCheckedChangeListener((android.widget.RadioGroup.OnCheckedChangeListener) finalMainActivity);
|
||||
|
||||
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
||||
mToolbar.getBackground().setAlpha(255);
|
||||
if (top_sgin != null) {
|
||||
top_sgin.setVisibility(View.GONE);
|
||||
}
|
||||
if (mRg_kepu != null) {
|
||||
mRg_kepu.setVisibility(View.GONE);
|
||||
}
|
||||
if (mV_kp != null) {
|
||||
mV_kp.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
java.lang.reflect.Method changeMyMethod = finalMainActivity.getClass().getDeclaredMethod("changeMy");
|
||||
changeMyMethod.setAccessible(true);
|
||||
changeMyMethod.invoke(finalMainActivity);
|
||||
|
||||
LogUtil.i("我的页切换逻辑执行完成");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("执行页面切换时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("处理 MainActivity 事件时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理扫码权限请求
|
||||
*/
|
||||
public void handleScanCodeAuth(DCUniMPJSCallback callback) {
|
||||
try {
|
||||
JSONObject ScanCodeAuthData = new JSONObject();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
hasPermission = PermissionsUtil.hasPermission(this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
hasPermission = PermissionsUtil.hasPermission(this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
ScanCodeAuthData.put("code", 200);
|
||||
callback.invoke(ScanCodeAuthData);
|
||||
} else {
|
||||
EasyWindow.with(this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000).setContentView(R.layout.float_top_dialog).show();
|
||||
PermissionsUtil.requestPermission(this, new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
try {
|
||||
ScanCodeAuthData.put("code", 200);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
callback.invoke(ScanCodeAuthData);
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
try {
|
||||
ScanCodeAuthData.put("code", 0);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
callback.invoke(ScanCodeAuthData);
|
||||
}
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
} else {
|
||||
ScanCodeAuthData.put("code", 0);
|
||||
callback.invoke(ScanCodeAuthData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("处理扫码权限请求时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 Token 检查
|
||||
*/
|
||||
public void handleCheckToken(DCUniMPJSCallback callback) {
|
||||
try {
|
||||
JSONObject checkToken = new JSONObject();
|
||||
checkToken.put("code", 200);
|
||||
String access_token = SharePrefUtil.getString(this, "access_token", "");
|
||||
if(StringUtil.isEmpty(access_token)){
|
||||
checkToken.put("code", 0);
|
||||
}
|
||||
callback.invoke(checkToken);
|
||||
} catch (Exception e) {
|
||||
LogUtil.e("处理 Token 检查时出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,9 +86,22 @@ public class BigMettingActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(BigMettingActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(BigMettingActivity.this, Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(BigMettingActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
startToCapture();
|
||||
} else {
|
||||
EasyWindow.with(BigMettingActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -98,17 +111,17 @@ public class BigMettingActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问读取短信的权限
|
||||
//用户授予了访问摄像头的权限
|
||||
startToCapture();
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读取短信的申请
|
||||
//用户拒绝了访问摄像头的申请
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
@@ -147,8 +147,18 @@ public class BigKejianAdapter extends RecyclerView.Adapter<BigKejianAdapter.View
|
||||
}
|
||||
else
|
||||
{
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml +datas.get(position).getPath(),
|
||||
|
||||
+7
-1
@@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
@@ -180,7 +181,12 @@ public class PolyvScreencastSearchLayout extends FrameLayout implements View.OnC
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(WIFI_AP_STATE_CHANGED_ACTION);
|
||||
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
getContext().registerReceiver(networkReceiver, intentFilter);
|
||||
// Android 13 (API 33) 及以上版本需要指定 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
getContext().registerReceiver(networkReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
getContext().registerReceiver(networkReceiver, intentFilter);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -137,7 +138,12 @@ public abstract class CCPFragment extends Fragment {
|
||||
if (internalReceiver == null) {
|
||||
internalReceiver = new InternalReceiver();
|
||||
}
|
||||
getActivity().registerReceiver(internalReceiver, intentfilter);
|
||||
// Android 13 (API 33) 及以上版本需要指定 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
getActivity().registerReceiver(internalReceiver, intentfilter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
getActivity().registerReceiver(internalReceiver, intentfilter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
@@ -60,7 +61,12 @@ public class ChattingActivity extends ECFragmentActivity implements
|
||||
filter1.addAction("com.yuntongxun.ecdemo.removemember");
|
||||
filter1.addAction(SDKCoreHelper.ACTION_KICK_OFF);
|
||||
|
||||
registerReceiver(myReceiver, filter1);
|
||||
// Android 13 (API 33) 及以上版本需要指定 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
registerReceiver(myReceiver, filter1, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
registerReceiver(myReceiver, filter1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.AllPhotosActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.GroupChatSelectPatientActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.GroupSelectParentActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.OutofPatientNoticeActivity;
|
||||
@@ -2325,7 +2326,7 @@ public class ChattingFragment extends CCPFragment implements
|
||||
// MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
// startActivityForResult(i, REQUEST_CODE_LOAD_IMAGE);
|
||||
Intent intent = new Intent(getChattingActivity(),
|
||||
PhotoAlbumActivity.class);
|
||||
AllPhotosActivity.class);
|
||||
if (patientUuid.contains(",")){//群发消息,只能发一张图片
|
||||
// intent.putExtra("photonum", "1");
|
||||
intent.putExtra("photonum", "0");
|
||||
@@ -2394,35 +2395,48 @@ public class ChattingFragment extends CCPFragment implements
|
||||
@Override
|
||||
public void OnTakingPictureRequest() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
showTakeStyle(getActivity());
|
||||
} else {
|
||||
EasyWindow.with(getActivity()).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限
|
||||
showTakeStyle(getActivity());
|
||||
} else {
|
||||
EasyWindow.with(getActivity()).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
.setContentView(R.layout.float_top_dialog_new).show();
|
||||
PermissionsUtil.requestPermission(getActivity(), new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问摄像头的权限
|
||||
showTakeStyle(getActivity());
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问摄像头的申请
|
||||
|
||||
.setContentView(R.layout.float_top_dialog_new).show();
|
||||
PermissionsUtil.requestPermission(getActivity(), new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户授予了访问摄像头的权限
|
||||
showTakeStyle(getActivity());
|
||||
}
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问摄像头的申请
|
||||
}
|
||||
|
||||
}
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}else {
|
||||
showTakeStyle(getActivity());
|
||||
}
|
||||
|
||||
}else {
|
||||
showTakeStyle(getActivity());
|
||||
}
|
||||
|
||||
hideBottomPanel();
|
||||
}
|
||||
|
||||
@@ -2431,8 +2445,22 @@ public class ChattingFragment extends CCPFragment implements
|
||||
* */
|
||||
@Override
|
||||
public void OnSelectImageReuqest() {
|
||||
// Android 13+(含 15)使用系统 Photo Picker,不再依赖 READ_MEDIA_IMAGES,避免“限制访问”被误判为无权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
handleSelectImageIntent();
|
||||
hideBottomPanel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 6.0 ~ 12 使用旧的存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
handleSelectImageIntent();
|
||||
hideBottomPanel();
|
||||
} else {
|
||||
@@ -2451,10 +2479,9 @@ public class ChattingFragment extends CCPFragment implements
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
+12
-2
@@ -120,8 +120,18 @@ public class ImageGalleryFragment extends CCPFragment {
|
||||
dialog.setOnDialogItemClickListener(new ECListDialog.OnDialogItemClickListener() {
|
||||
@Override
|
||||
public void onDialogItemClick(Dialog d, int position) {
|
||||
// 保存图片到 MediaStore,Android 13+ 可能需要权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限,但保存到 MediaStore 可能需要
|
||||
|
||||
if (hasPermission) {
|
||||
handleDialogItemClick(position);
|
||||
} else {
|
||||
EasyWindow.with(getActivity()).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -138,7 +148,7 @@ public class ImageGalleryFragment extends CCPFragment {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -114,8 +114,18 @@ public class ImageGralleryPagerActivity extends ECSuperActivity implements
|
||||
.showMessage(R.string.save_img_waite_download);
|
||||
return;
|
||||
}
|
||||
// DemoUtils.saveImage 使用应用私有目录,但保存到 MediaStore 可能需要权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(ImageGralleryPagerActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
||||
hasPermission = PermissionsUtil.hasPermission(ImageGralleryPagerActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限,但保存到 MediaStore 可能需要
|
||||
|
||||
if (hasPermission) {
|
||||
try {
|
||||
File file;
|
||||
// // 由于不是聊天的图片查看无法下载保存
|
||||
@@ -209,7 +219,7 @@ public class ImageGralleryPagerActivity extends ECSuperActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.CoursewareActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.MainActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.MyLibraryActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.UpanExchangeActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.VideoActivity;
|
||||
@@ -33,6 +34,7 @@ import cn.shangyu.gdxzExpert.polyvplayer.QualityCourseActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.MyUserIconUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
@@ -205,7 +207,8 @@ public class GetWelfAreFragment extends BaseFragment implements View.OnClickList
|
||||
}
|
||||
else
|
||||
{
|
||||
startActivity(new Intent(getActivity(), VideoActivity.class));
|
||||
MyUserIconUtil.showUniMp(getActivity(), "/pages_app/video/video");
|
||||
// startActivity(new Intent(getActivity(), VideoActivity.class));
|
||||
}
|
||||
} else if (id == R.id.tv_kjlijilingqu) {
|
||||
if(BigModule())
|
||||
|
||||
@@ -1079,8 +1079,10 @@ public class HomeNewFragment extends BaseFragment implements OnClickListener,OnC
|
||||
startActivity(intent1);
|
||||
} else if (id == R.id.more2) {
|
||||
MobclickAgent.onEvent(mainActivity,EXPERT_HOME_PLAYBACK_MORE);
|
||||
Intent intent2 = new Intent(mActivity, VideoActivity.class);
|
||||
startActivity(intent2);
|
||||
// Intent intent2 = new Intent(mActivity, VideoActivity.class);
|
||||
// startActivity(intent2);
|
||||
|
||||
MyUserIconUtil.showUniMp(mainActivity, "/pages_app/video/video");
|
||||
} else if (id == R.id.more3) {
|
||||
if(navigationController.getSelected()==0)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ import cn.shangyu.gdxzExpert.activity.NewLessonsActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.VideoActivity;
|
||||
import cn.shangyu.gdxzExpert.base.BaseFragment;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.QualityCourseActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.MyUserIconUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
@@ -104,7 +105,8 @@ public class KeepEducationFragment extends BaseFragment implements View.OnClickL
|
||||
} else if (id == R.id.rl_video) {//经典病例
|
||||
startActivity(new Intent(mActivity, MyCicleActivity.class));
|
||||
} else if (id == R.id.rl_lczhaomu) {//肝胆视频
|
||||
startActivity(new Intent(mActivity, VideoActivity.class));
|
||||
MyUserIconUtil.showUniMp(mainActivity, "/pages_app/video/video");
|
||||
// startActivity(new Intent(mActivity, VideoActivity.class));
|
||||
} else if (id == R.id.rl_office_work) {//精品课程
|
||||
startActivity( new Intent(mActivity, QualityCourseActivity.class));
|
||||
} else if (id == R.id.rl_casediscussion) {//新手教程
|
||||
|
||||
@@ -70,6 +70,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.AllPhotosActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.PhotoAlbumActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.ResearchActivity;
|
||||
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
||||
@@ -515,8 +516,21 @@ public class YiganFragment extends BaseFragment implements AdapterView.OnItemCli
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
takePhoto11();// 拍照获取
|
||||
} else {
|
||||
@@ -537,7 +551,7 @@ public class YiganFragment extends BaseFragment implements AdapterView.OnItemCli
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
@@ -553,11 +567,18 @@ public class YiganFragment extends BaseFragment implements AdapterView.OnItemCli
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||||
|
||||
|
||||
// Android 6.0 ~ 12 使用存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问相册的权限
|
||||
Intent intent = new Intent(mActivity, AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,
|
||||
@@ -570,7 +591,7 @@ public class YiganFragment extends BaseFragment implements AdapterView.OnItemCli
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent = new Intent(getActivity(), PhotoAlbumActivity.class);
|
||||
Intent intent = new Intent(getActivity(), AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
@@ -579,20 +600,15 @@ public class YiganFragment extends BaseFragment implements AdapterView.OnItemCli
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问相册的申请
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
Intent intent = new Intent(getActivity(), PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||||
intent.putExtra("maxphotonum",9);
|
||||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
|
||||
import com.netease.nim.uikit.common.ToastHelper;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
@@ -59,7 +60,12 @@ public class NIMInitManager {
|
||||
if (register) {
|
||||
updateLocale();
|
||||
IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
|
||||
DemoCache.getContext().registerReceiver(localeReceiver, filter);
|
||||
// Android 13 (API 33) 及以上版本需要指定 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
DemoCache.getContext().registerReceiver(localeReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
DemoCache.getContext().registerReceiver(localeReceiver, filter);
|
||||
}
|
||||
} else {
|
||||
DemoCache.getContext().unregisterReceiver(localeReceiver);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.contact.ContactChangedObserver;
|
||||
@@ -176,7 +177,12 @@ public class OnlineStateEventManager {
|
||||
private static void registerNetTypeChangeObserver() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
DemoCache.getContext().registerReceiver(receiver, filter);
|
||||
// Android 13 (API 33) 及以上版本需要指定 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
DemoCache.getContext().registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
DemoCache.getContext().registerReceiver(receiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -374,10 +374,23 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
|
||||
} else if (v == sendMessageButtonInInputBar) {
|
||||
onTextMessageSendButtonPressed();
|
||||
} else if (v == switchToAudioButtonInInputBar) {
|
||||
// Android 13+ 录音只需要 RECORD_AUDIO 权限,不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(container.activity, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问录音
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 录音只需要 RECORD_AUDIO 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(container.activity, Manifest.permission.RECORD_AUDIO);
|
||||
permissionsToRequest = new String[]{Manifest.permission.RECORD_AUDIO};
|
||||
} else {
|
||||
// Android 12及以下需要 RECORD_AUDIO 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(container.activity, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问录音的权限
|
||||
switchToAudioLayout();
|
||||
} else {
|
||||
EasyWindow.with(container.activity).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -397,7 +410,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.AllPhotosActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.PhotoAlbumActivity;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.utils.DemoUtils;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.common.utils.FileAccessor;
|
||||
@@ -42,9 +43,16 @@ public class ImageAction extends BaseAction {
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
Intent intent=new Intent(getActivity(), PhotoAlbumActivity.class);
|
||||
|
||||
// Android 6.0 ~ 12 使用旧的存储权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
if (hasPermission) {
|
||||
Intent intent=new Intent(getActivity(), AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "-1");
|
||||
getActivity().startActivityForResult(intent, 0x4);
|
||||
} else {
|
||||
@@ -55,7 +63,7 @@ public class ImageAction extends BaseAction {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
Intent intent=new Intent(getActivity(), PhotoAlbumActivity.class);
|
||||
Intent intent=new Intent(getActivity(), AllPhotosActivity.class);
|
||||
intent.putExtra("photonum", "-1");
|
||||
getActivity().startActivityForResult(intent, 0x4);
|
||||
}
|
||||
@@ -63,18 +71,13 @@ public class ImageAction extends BaseAction {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//
|
||||
//用户拒绝了访问相册的申请
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
} else {
|
||||
Intent intent=new Intent(getActivity(), PhotoAlbumActivity.class);
|
||||
intent.putExtra("photonum", "-1");
|
||||
getActivity().startActivityForResult(intent, 0x4);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -51,8 +51,21 @@ public class VideoAction extends BaseAction {
|
||||
@Override
|
||||
public void onClick() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问摄像头的权限
|
||||
showDialog();
|
||||
} else {
|
||||
@@ -73,7 +86,7 @@ public class VideoAction extends BaseAction {
|
||||
|
||||
}
|
||||
|
||||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,8 +106,22 @@ public class VideoAction extends BaseAction {
|
||||
public void onDialogItemClick(Dialog d, int position) {
|
||||
|
||||
if (position == 0) {
|
||||
// Android 13+ (API 33+) 拍照主要需要 CAMERA 权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 拍照主要需要 CAMERA 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA};
|
||||
} else {
|
||||
// Android 12及以下需要 CAMERA 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
// handleTackPicture();
|
||||
takePhoto11();
|
||||
} else {
|
||||
@@ -112,11 +139,11 @@ public class VideoAction extends BaseAction {
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问摄像头的申请
|
||||
//
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -125,11 +152,23 @@ public class VideoAction extends BaseAction {
|
||||
|
||||
|
||||
} else if (position == 1) {
|
||||
|
||||
// Android 13+ 录音只需要 RECORD_AUDIO 权限,不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (PermissionsUtil.hasPermission(getActivity(), Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
//有访问录音
|
||||
boolean hasPermission;
|
||||
String[] permissionsToRequest;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13+ 录音只需要 RECORD_AUDIO 权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.RECORD_AUDIO);
|
||||
permissionsToRequest = new String[]{Manifest.permission.RECORD_AUDIO};
|
||||
} else {
|
||||
// Android 12及以下需要 RECORD_AUDIO 和存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(getActivity(), Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
permissionsToRequest = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
|
||||
if (hasPermission) {
|
||||
//有访问录音的权限
|
||||
handleVideoRecord();
|
||||
} else {
|
||||
EasyWindow.with(getActivity()).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -149,7 +188,7 @@ public class VideoAction extends BaseAction {
|
||||
// finish();
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}, permissionsToRequest);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
@@ -7,8 +7,10 @@ import android.widget.RelativeLayout;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.MyDownLoadsActivity;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.MyUserIconUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
@@ -19,7 +21,7 @@ import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
public class MyDownLoadVideoActivity extends BaseActivity {
|
||||
private View view;
|
||||
private MyDownLoadVideoActivity mActivity;
|
||||
private RelativeLayout rl_1,rl_2;
|
||||
private RelativeLayout rl_1,rl_2,rl_3;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
@@ -40,11 +42,20 @@ public class MyDownLoadVideoActivity extends BaseActivity {
|
||||
else
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.activity_my_down_loadvideo);
|
||||
rl_3 = view.findViewById(R.id.rl_3);
|
||||
}
|
||||
rl_1 = view.findViewById(R.id.rl_1);
|
||||
rl_2 = view.findViewById(R.id.rl_2);
|
||||
rl_1.setOnClickListener(this);
|
||||
rl_2.setOnClickListener(this);
|
||||
|
||||
if (rl_1 != null) {
|
||||
rl_1.setOnClickListener(this);
|
||||
}
|
||||
if (rl_2 != null) {
|
||||
rl_2.setOnClickListener(this);
|
||||
}
|
||||
if (rl_3 != null) {
|
||||
rl_3.setOnClickListener(this);
|
||||
}
|
||||
mActivity = this;
|
||||
return view;
|
||||
}
|
||||
@@ -69,6 +80,10 @@ public class MyDownLoadVideoActivity extends BaseActivity {
|
||||
case R.id.rl_2:
|
||||
startActivity(new Intent(MyDownLoadVideoActivity.this, PolyvDownloadActivity.class));
|
||||
break;
|
||||
case R.id.rl_3:
|
||||
//跳到uniapp 的视频缓存页面
|
||||
MyUserIconUtil.showUniMp(MyDownLoadVideoActivity.this, "/pages_app/downLoadVideo/downLoadVideo");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +91,9 @@ public class UpdateService extends Service {
|
||||
|
||||
this.updateNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
updateIntent = new Intent(this, SettingVersionActivity.class);
|
||||
updatePendingIntent = PendingIntent.getActivity(this, 0, updateIntent, 0);
|
||||
updateIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);//关键的一步,设置启动模式
|
||||
updateIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);//关键的一步,设置启动模式
|
||||
// Android 12+ 需要显式声明 PendingIntent 的可变性,这里通知点击行为不需要修改,使用 FLAG_IMMUTABLE
|
||||
updatePendingIntent = PendingIntent.getActivity(this, 0, updateIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
notificationUtils = new NotificationUtils(this,0,updatePendingIntent);
|
||||
notificationUtils.sendUpVersonNotification("开始下载", "当前下载进度:0%");
|
||||
|
||||
@@ -128,7 +129,8 @@ public class UpdateService extends Service {
|
||||
intent.setDataAndType(FileProvider.getUriForFile(UpdateService.this, "cn.shangyu.gdxzExpert.fileprovider", updateFile),"application/vnd.android.package-archive");
|
||||
getApplicationContext().startActivity(intent);
|
||||
// startActivity(intent);
|
||||
updatePendingIntent = PendingIntent.getActivity(UpdateService.this, 0, intent, 0);
|
||||
// 安装 APK 的 PendingIntent 同样不需要在外部被修改,使用 FLAG_IMMUTABLE
|
||||
updatePendingIntent = PendingIntent.getActivity(UpdateService.this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
NotificationUtils notificationUtils1 = new NotificationUtils(UpdateService.this,0,updatePendingIntent);
|
||||
notificationUtils1.sendUpVersonNotification("肝胆相照专家版", "下载完成,点击安装");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -652,8 +652,18 @@ public class PushCourseUrlDetailActivity extends BaseActivity implements
|
||||
// TODO Auto-generated catch block
|
||||
|
||||
}
|
||||
// 文件保存到应用私有目录(getExternalFilesDir),Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(PushCourseUrlDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限
|
||||
hasPermission = PermissionsUtil.hasPermission(PushCourseUrlDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
getDownLoadResult();
|
||||
} else {
|
||||
EasyWindow.with(PushCourseUrlDetailActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
@@ -670,7 +680,7 @@ public class PushCourseUrlDetailActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -821,8 +821,18 @@ public class PushNewsDetailActivity extends BaseActivity implements
|
||||
// 下载
|
||||
itemLongClickedPopWindow.dismiss();
|
||||
// 点击图片后将图片保存到SD卡跟目录下的Test文件夹内
|
||||
// DownLoadUrlImage 使用应用私有目录,Android 13+ 不需要存储权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(PushNewsDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
||||
hasPermission = PermissionsUtil.hasPermission(PushNewsDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到应用私有目录不需要权限
|
||||
|
||||
if (hasPermission) {
|
||||
new DownLoadUrlImage(imgurl, ctx);
|
||||
Toast.makeText(getBaseContext(), "图片保存",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
@@ -843,7 +853,7 @@ public class PushNewsDetailActivity extends BaseActivity implements
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -212,5 +212,5 @@ public class Constant {
|
||||
public static String Repotr_app_key="";
|
||||
|
||||
//uniapp小程序appid
|
||||
public static String uniapp_mp_appid="__UNI__89F511F";
|
||||
public static String uniapp_mp_appid="__UNI__89F511F";//__UNI__09BE685 __UNI__89F511F
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package cn.shangyu.gdxzExpert.utils;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.uniapp_mp_appid;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.url_path;
|
||||
import static cn.shangyu.gdxzExpert.utils.Url.weurl;
|
||||
import static com.taobao.accs.ACCSManager.mContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.activity.AccumulatePointsActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.BindWeChatActivity;
|
||||
@@ -37,11 +46,16 @@ import cn.shangyu.gdxzExpert.activity.SendMindActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.SettingVersionActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.TestingActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.VideoActivity;
|
||||
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BiggNewPatientActivity;
|
||||
import cn.shangyu.gdxzExpert.big.activity.NormNewPatientActivity;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.PointsMallActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.MyDownLoadVideoActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.QualityCourseActivity;
|
||||
import cn.shangyu.gdxzExpert.splash.UniappSplashView;
|
||||
import io.dcloud.feature.sdk.DCUniMPSDK;
|
||||
import io.dcloud.feature.sdk.Interface.IUniMP;
|
||||
import io.dcloud.feature.unimp.config.UniMPOpenConfiguration;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2020/3/10.
|
||||
@@ -95,7 +109,9 @@ public class MyUserIconUtil {
|
||||
}
|
||||
else if("肝胆视频".equals(name))
|
||||
{
|
||||
context.startActivity(new Intent(context, VideoActivity.class));
|
||||
// context.startActivity(new Intent(context, VideoActivity.class));
|
||||
// 调用公共方法打开uniapp mp
|
||||
showUniMp(context, "/pages_app/video/video");
|
||||
}
|
||||
else if("公益咨询".equals(name))
|
||||
{
|
||||
@@ -103,7 +119,9 @@ public class MyUserIconUtil {
|
||||
}
|
||||
else if("指南杂志".equals(name)||"我的图书馆".equals(name)||"指南工具".equals(name))
|
||||
{
|
||||
context.startActivity(new Intent(context, MyLibraryActivity.class));
|
||||
// context.startActivity(new Intent(context, MyLibraryActivity.class));
|
||||
// 调用公共方法打开uniapp mp
|
||||
showUniMp(context, "/pages_app/zhinan/zhinan");
|
||||
}
|
||||
else if ("专题e站".equals(name)){
|
||||
Intent intent1 = new Intent(context, NewsDetailActivity.class);
|
||||
@@ -225,4 +243,46 @@ public class MyUserIconUtil {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示uniapp mp - 公共方法
|
||||
* @param context 上下文
|
||||
* @param targetPath
|
||||
*/
|
||||
public static void showUniMp(Context context, String targetPath) {
|
||||
try {
|
||||
String uuid = SharePrefUtil.getString(context, Constant.uuid, "");
|
||||
if(StringUtil.isEmpty(uuid)){
|
||||
return;
|
||||
}
|
||||
String access_token = SharePrefUtil.getString(context, "access_token", "");
|
||||
|
||||
JSONObject userInfo = new JSONObject();
|
||||
userInfo.put("uuid", SharePrefUtil.getString(context, Constant.uuid, ""));
|
||||
userInfo.put("realName", SharePrefUtil.getString(context, Constant.realName, ""));
|
||||
userInfo.put("mobile", SharePrefUtil.getString(context, "mobile", ""));
|
||||
userInfo.put("photo", SharePrefUtil.getString(context, Constant.photo, ""));
|
||||
|
||||
UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration();
|
||||
uniMPOpenConfiguration.splashClass = UniappSplashView.class;
|
||||
uniMPOpenConfiguration.extraData.put("darkmode", "light");
|
||||
uniMPOpenConfiguration.extraData.put("apiHost", url_path);
|
||||
uniMPOpenConfiguration.extraData.put("token", access_token);
|
||||
uniMPOpenConfiguration.extraData.put("userInfo", userInfo);
|
||||
|
||||
IUniMP uniapp_MP_cash = BaseApplication.getUniMPCaches().get(uniapp_mp_appid);
|
||||
if(uniapp_MP_cash != null && uniapp_MP_cash.isRunning()){
|
||||
uniapp_MP_cash.sendUniMPEvent("goPage", targetPath);
|
||||
uniapp_MP_cash.showUniMP();
|
||||
}else{
|
||||
if(StringUtil.notEmpty(targetPath)){
|
||||
uniMPOpenConfiguration.extraData.put("targetPath", targetPath);
|
||||
}
|
||||
IUniMP uniapp_MP = DCUniMPSDK.getInstance().openUniMP(mContext, uniapp_mp_appid, uniMPOpenConfiguration);
|
||||
BaseApplication.getUniMPCaches().put(uniapp_MP.getAppid(), uniapp_MP);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.shangyu.gdxzExpert.utils;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
public class UniappFileProvider extends FileProvider {
|
||||
}
|
||||
@@ -148,8 +148,18 @@ public class UpdateVersionUtils {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// TODO Auto-generated method stub
|
||||
// downloadApp 使用 Environment.getExternalStorageDirectory(),这是公共存储,需要权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (com.github.dfqin.grantor.PermissionsUtil.hasPermission(ct, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
||||
boolean hasPermission = true;
|
||||
|
||||
if (needsPermission) {
|
||||
// Android 12及以下需要存储权限(用于保存到公共存储)
|
||||
hasPermission = com.github.dfqin.grantor.PermissionsUtil.hasPermission(ct, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
// Android 13+ 保存到公共存储仍需要权限(但通常使用应用私有目录更好)
|
||||
|
||||
if (hasPermission) {
|
||||
// 下载
|
||||
downloadApp();
|
||||
} else {
|
||||
@@ -163,7 +173,7 @@ public class UpdateVersionUtils {
|
||||
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
//用户拒绝了访问读写的申请
|
||||
//用户拒绝了访问存储的申请
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user