-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wumeng1
authored and
wumeng1
committed
Aug 17, 2021
1 parent
ae186e5
commit 282a0cc
Showing
13 changed files
with
269 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.mirkowu.mvm; | ||
|
||
public class Constant { | ||
public static final String FILE_SAVE_DIR = "Mirko"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
lib_util/src/main/java/com/mirkowu/lib_util/SystemShareUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.mirkowu.lib_util; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* 使用的系统 分享 和自己的账号没关系 | ||
*/ | ||
public class SystemShareUtil { | ||
|
||
|
||
/** | ||
* 分享到微信朋友圈 带文字和图片 | ||
* | ||
* @param context | ||
* @param content | ||
* @param file | ||
*/ | ||
|
||
public static boolean shareToWxCircle(@NonNull Context context, String content, @NonNull File file) { | ||
try { | ||
Uri uri = FileUtil.createUri(context, file); | ||
Intent intent = new Intent(); | ||
intent.setAction(Intent.ACTION_SEND); | ||
intent.putExtra(Intent.EXTRA_STREAM, uri); | ||
intent.putExtra("Kdescription", content); | ||
intent.setType("image/*"); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | ||
context.startActivity(Intent.createChooser(intent, "选择要分享的应用")); | ||
return true; | ||
} catch (Throwable e) { | ||
LogUtil.e("分享失败", e); | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean shareText(@NonNull Context context, @NonNull String text) { | ||
try { | ||
Intent intent = new Intent(); | ||
intent.setAction(Intent.ACTION_SEND); | ||
intent.putExtra(Intent.EXTRA_TEXT, text); | ||
intent.setType("text/*"); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | ||
context.startActivity(Intent.createChooser(intent, "选择要分享的应用")); | ||
return true; | ||
} catch (Throwable e) { | ||
LogUtil.e("分享失败", e); | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean shareImage(@NonNull Context context, @NonNull File file) { | ||
try { | ||
Uri uri = FileUtil.createUri(context, file); | ||
Intent intent = new Intent(); | ||
intent.setAction(Intent.ACTION_SEND); | ||
intent.putExtra(Intent.EXTRA_STREAM, uri); | ||
intent.setType("image/*"); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | ||
context.startActivity(Intent.createChooser(intent, "选择要分享的应用")); | ||
return true; | ||
} catch (Throwable e) { | ||
LogUtil.e("分享失败", e); | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean shareImage(@NonNull Context context, @NonNull List<File> files) { | ||
try { | ||
Intent intent = new Intent(); | ||
intent.setAction(Intent.ACTION_SEND_MULTIPLE); | ||
ArrayList<Uri> imageUris = new ArrayList<Uri>(); | ||
for (File file : files) { | ||
Uri uri = FileUtil.createUri(context, file); | ||
imageUris.add(uri); | ||
} | ||
intent.setType("image/*"); | ||
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | ||
context.startActivity(Intent.createChooser(intent, "选择要分享的应用")); | ||
return true; | ||
} catch (Throwable e) { | ||
LogUtil.e("分享失败", e); | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.