|
@@ -4,6 +4,7 @@ import android.Manifest
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
import android.app.Activity
|
|
import android.app.Activity
|
|
import android.content.ComponentName
|
|
import android.content.ComponentName
|
|
|
|
+import android.content.ContentResolver
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
@@ -27,17 +28,20 @@ import com.qmuiteam.qmui.widget.QMUIRadiusImageView
|
|
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog
|
|
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog
|
|
import com.qmuiteam.qmui.widget.popup.QMUIPopup
|
|
import com.qmuiteam.qmui.widget.popup.QMUIPopup
|
|
import com.qmuiteam.qmui.widget.popup.QMUIPopups
|
|
import com.qmuiteam.qmui.widget.popup.QMUIPopups
|
|
-import com.zswc.creativity.R
|
|
|
|
import com.yanzhenjie.permission.Action
|
|
import com.yanzhenjie.permission.Action
|
|
import com.yanzhenjie.permission.AndPermission
|
|
import com.yanzhenjie.permission.AndPermission
|
|
|
|
+import com.yanzhenjie.permission.FileProvider
|
|
import com.ysnows.base.utils.UiUtils
|
|
import com.ysnows.base.utils.UiUtils
|
|
import com.zhy.http.okhttp.OkHttpUtils
|
|
import com.zhy.http.okhttp.OkHttpUtils
|
|
import com.zhy.http.okhttp.callback.FileCallBack
|
|
import com.zhy.http.okhttp.callback.FileCallBack
|
|
|
|
+import com.zswc.creativity.BuildConfig
|
|
|
|
+import com.zswc.creativity.R
|
|
import okhttp3.Call
|
|
import okhttp3.Call
|
|
import java.io.File
|
|
import java.io.File
|
|
import java.io.FileNotFoundException
|
|
import java.io.FileNotFoundException
|
|
import java.util.*
|
|
import java.util.*
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 分享
|
|
* 分享
|
|
*Created by shihuiyun
|
|
*Created by shihuiyun
|
|
@@ -50,8 +54,9 @@ object PopuShareWxUtils {
|
|
var tipDialog: QMUITipDialog? = null
|
|
var tipDialog: QMUITipDialog? = null
|
|
private var downimg: String? = null
|
|
private var downimg: String? = null
|
|
private val uriArrayList = ArrayList<Uri>() //下载到本地的图片的集合
|
|
private val uriArrayList = ArrayList<Uri>() //下载到本地的图片的集合
|
|
- fun show(context: Context, url: String, view: View){
|
|
|
|
-
|
|
|
|
|
|
+ var cr:ContentResolver?=null
|
|
|
|
+ fun show(context: Context, url: String, view: View, contentResolver: ContentResolver){
|
|
|
|
+ cr=contentResolver
|
|
var mNormalPopup = QMUIPopups.fullScreenPopup(context)
|
|
var mNormalPopup = QMUIPopups.fullScreenPopup(context)
|
|
val builder: QMUISkinValueBuilder = QMUISkinValueBuilder.acquire()
|
|
val builder: QMUISkinValueBuilder = QMUISkinValueBuilder.acquire()
|
|
val frameLayout = QMUIFrameLayout(context)
|
|
val frameLayout = QMUIFrameLayout(context)
|
|
@@ -62,6 +67,7 @@ object PopuShareWxUtils {
|
|
val img: QMUIRadiusImageView =layout.findViewById(R.id.img)
|
|
val img: QMUIRadiusImageView =layout.findViewById(R.id.img)
|
|
val ivShareOne:ImageView=layout.findViewById(R.id.iv_share_one)
|
|
val ivShareOne:ImageView=layout.findViewById(R.id.iv_share_one)
|
|
val ivShareTwo:ImageView=layout.findViewById(R.id.iv_share_two)
|
|
val ivShareTwo:ImageView=layout.findViewById(R.id.iv_share_two)
|
|
|
|
+ val ivShareThree:ImageView=layout.findViewById(R.id.iv_share_three)
|
|
val ivSave:ImageView=layout.findViewById(R.id.iv_save)
|
|
val ivSave:ImageView=layout.findViewById(R.id.iv_save)
|
|
val ivClose:ImageView=layout.findViewById(R.id.iv_close)
|
|
val ivClose:ImageView=layout.findViewById(R.id.iv_close)
|
|
|
|
|
|
@@ -70,8 +76,8 @@ object PopuShareWxUtils {
|
|
val display = (context as Activity).windowManager.defaultDisplay
|
|
val display = (context as Activity).windowManager.defaultDisplay
|
|
val screenWidth = display.width
|
|
val screenWidth = display.width
|
|
params.width = screenWidth - UiUtils.dp2Px(context, 60f)
|
|
params.width = screenWidth - UiUtils.dp2Px(context, 60f)
|
|
- // params.height = (((screenWidth - UiUtils.dp2Px(context, 60f)) * 1.6).toInt())
|
|
|
|
- params.height=screenWidth - UiUtils.dp2Px(context, 60f)
|
|
|
|
|
|
+ params.height = (((screenWidth - UiUtils.dp2Px(context, 60f)) * 1.6).toInt())
|
|
|
|
+ // params.height=screenWidth - UiUtils.dp2Px(context, 60f)
|
|
|
|
|
|
img.layoutParams = params
|
|
img.layoutParams = params
|
|
|
|
|
|
@@ -93,6 +99,13 @@ object PopuShareWxUtils {
|
|
mNormalPopup.dismiss()
|
|
mNormalPopup.dismiss()
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ ivShareThree.onClick {
|
|
|
|
+ //分享到QQ
|
|
|
|
+ // toShareQQ(context,url)
|
|
|
|
+ chose = 3
|
|
|
|
+ setShareImages(context, url)
|
|
|
|
+ mNormalPopup.dismiss()
|
|
|
|
+ }
|
|
|
|
|
|
ivClose.onClick {
|
|
ivClose.onClick {
|
|
mNormalPopup.dismiss()
|
|
mNormalPopup.dismiss()
|
|
@@ -307,10 +320,75 @@ object PopuShareWxUtils {
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ if(chose==3){//qq好友
|
|
|
|
+ //todo:分享失败
|
|
|
|
+ try {
|
|
|
|
+// var fileUri: Uri? =null
|
|
|
|
+// if (Build.VERSION.SDK_INT >= 24) {
|
|
|
|
+// fileUri = getUriForFile24(context, downimg)
|
|
|
|
+// } else {
|
|
|
|
+// fileUri = Uri.fromFile(File(downimg))
|
|
|
|
+// }
|
|
|
|
+ var fileUri: Uri? =null
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
|
|
+
|
|
|
|
+ fileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", File(downimg))
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ fileUri=Uri.fromFile(File(downimg))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val intent = Intent()
|
|
|
|
+ val comp = ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity")
|
|
|
|
+ intent.component = comp
|
|
|
|
+
|
|
|
|
+ intent.action = Intent.ACTION_SEND
|
|
|
|
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
|
+ intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
|
|
|
+ intent.putExtra(Intent.EXTRA_STREAM, fileUri)
|
|
|
|
+ intent.type = "image/*" //分享文件
|
|
|
|
+ context.startActivity(Intent.createChooser(intent, "分享"))
|
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
|
+ Log.e("-shy-", "e=: $e")
|
|
|
|
+ Toast.makeText(context,"分享图片到QQ失败",Toast.LENGTH_SHORT).show()
|
|
|
|
+// ContextUtil.getInstance().showToastMsg("分享图片到**失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fun toShareQQ(context:Context,url:String){
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ val bitmap: Bitmap = SaveLocalUtils.returnBitMap(url)
|
|
|
|
+ val intent = Intent()
|
|
|
|
+ val comp = ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity")
|
|
|
|
+ intent.component = comp
|
|
|
|
+
|
|
|
|
+ intent.action = Intent.ACTION_SEND
|
|
|
|
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
|
+ // intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(File(path)))
|
|
|
|
+ intent.type = "image/*" //分享文件
|
|
|
|
+
|
|
|
|
+ context.startActivity(Intent.createChooser(intent, "分享"))
|
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
|
+ Toast.makeText(context,"分享图片到QQ失败",Toast.LENGTH_SHORT).show()
|
|
|
|
+// ContextUtil.getInstance().showToastMsg("分享图片到**失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
private fun insertImageToSystem(context: Context, imagePath: String): String? {
|
|
private fun insertImageToSystem(context: Context, imagePath: String): String? {
|
|
var url: String? = ""
|
|
var url: String? = ""
|
|
try {
|
|
try {
|