|
@@ -19,16 +19,6 @@ import java.io.File
|
|
|
object IntentUtil {
|
|
|
|
|
|
|
|
|
- fun addPicture(activity: Activity, intent: Intent, requestCode: Int) {
|
|
|
- try {
|
|
|
- activity.startActivityForResult(intent, requestCode)
|
|
|
- } catch (e: Exception) {
|
|
|
- e.printStackTrace()
|
|
|
- ToastUtil.Companion.showToast(activity, R.string.activity_not_found)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* @description 打开浏览器
|
|
|
* @param context 上下文
|
|
@@ -68,13 +58,32 @@ object IntentUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param :[context, packageName]
|
|
|
+ * @return : void
|
|
|
+ * @methodName :readyToAppOrMarket created by luozhipeng on 5/12/17 13:28.
|
|
|
+ * @description :传入包名,如果应该已安装就打开应用 如果没有安装就进入应用市场
|
|
|
+ */
|
|
|
+ fun readyToAppOrMarket(context: Context, packageName: String) {
|
|
|
+ if (PackageUtil.isInstallSoftware(context, packageName)) {
|
|
|
+ var intent: Intent? = context.packageManager.getLaunchIntentForPackage(packageName)
|
|
|
+ if (intent != null) {
|
|
|
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
|
+ context.applicationContext.startActivity(intent)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ openMarket(context, packageName, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 邮件反馈
|
|
|
+ * 发送邮件
|
|
|
* @param email 收件人邮箱
|
|
|
+ * @param content 邮件内容
|
|
|
*/
|
|
|
- fun reportUs(context: Context, email: String, content : String) {
|
|
|
+ fun sendEmail(context: Context, email: String, content : String) {
|
|
|
try {
|
|
|
context.startActivity(Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:${email}")).apply {
|
|
|
putExtra(Intent.EXTRA_SUBJECT, content)
|
|
@@ -92,10 +101,8 @@ object IntentUtil {
|
|
|
* @param title 主题
|
|
|
* @param content 邮件正文
|
|
|
* @param file 附件
|
|
|
- * @param errorToastMsg 错误的提示
|
|
|
*/
|
|
|
- fun reportUs(context: Context, addressee: String, title: String?, content: String?, file: File?, chooserTitle: String = "") {
|
|
|
-
|
|
|
+ fun sendEmailWithFile(context: Context, addressee: String, title: String?, content: String?, file: File?, chooserTitle: String = "") {
|
|
|
try {
|
|
|
val intent = Intent(Intent.ACTION_SEND).apply {
|
|
|
type = "plain/text"
|
|
@@ -120,7 +127,7 @@ object IntentUtil {
|
|
|
* @param file 分享的文件
|
|
|
*
|
|
|
*/
|
|
|
- fun share(context: Context, title: String, type: String, file: File?) {
|
|
|
+ fun shareFile(context: Context, title: String, type: String, file: File?) {
|
|
|
try {
|
|
|
val intent = Intent(Intent.ACTION_SEND)
|
|
|
intent.type = type
|
|
@@ -134,32 +141,7 @@ object IntentUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param :[context, packageName]
|
|
|
- * @return : void
|
|
|
- * @methodName :readyToAppOrMarket created by luozhipeng on 5/12/17 13:28.
|
|
|
- * @description :传入包名,如果应该已安装就打开应用 如果没有安装就进入应用市场
|
|
|
- */
|
|
|
- fun readyToAppOrMarket(context: Context, packageName: String) {
|
|
|
- if (PackageUtil.isInstallSoftware(context, packageName)) {
|
|
|
- var intent: Intent? = context.packageManager.getLaunchIntentForPackage(packageName)
|
|
|
- if (intent != null) {
|
|
|
- intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
|
- context.applicationContext.startActivity(intent)
|
|
|
- }
|
|
|
- } else {
|
|
|
- try {
|
|
|
- val intent = Intent(Intent.ACTION_VIEW).apply {
|
|
|
- flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
- data = Uri.parse("market://details?id=${packageName}")
|
|
|
- }
|
|
|
- context.applicationContext.startActivity(intent)
|
|
|
- } catch (e: ActivityNotFoundException) {
|
|
|
- e.printStackTrace()
|
|
|
- ToastUtil.Companion.showToast(context, R.string.activity_not_found)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|