Merge branch 'dev_share'

# Conflicts:
#	main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java
This commit is contained in:
zlzw 2023-04-01 11:15:18 +08:00
commit e301e7bfce
66 changed files with 1887 additions and 95 deletions

1
Share/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

73
Share/build.gradle Normal file
View File

@ -0,0 +1,73 @@
apply plugin: 'com.android.library'
apply plugin: 'img-optimizer'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
packagingOptions {
pickFirst "lib/armeabi/libyuvutils.so"
pickFirst "lib/arm64-v8a/libyuvutils.so"
pickFirst "lib/armeabi-v7a/libyuvutils.so"
pickFirst "lib/armeabi/libyuvtools.so"
pickFirst "lib/arm64-v8a/libyuvtools.so"
pickFirst "lib/armeabi-v7a/libyuvtools.so"
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
exclude "lib/arm64-v8a/libmmcv_api_express.so"
exclude "lib/arm64-v8a/libMediaEncoder.so"
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
exclude "lib/arm64-v8a/libmediadecoder.so"
exclude "lib/arm64-v8a/libMediaMuxer.so"
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
exclude "lib/arm64-v8a/libMediaUtils.so"
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
}
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs 'libs', '../libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies["appcompat-androidx"]
implementation rootProject.ext.dependencies["recyclerview-androidx"]
//common
implementation project(path: ':common')
//Twitter
implementation 'com.twitter.sdk.android:twitter:3.1.1'
//facebook & Messenger
implementation 'com.facebook.android:facebook-share:15.2.0'
}

0
Share/consumer-rules.pro Normal file
View File

21
Share/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,26 @@
package com.yunbao.share;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.yunbao.share.test", appContext.getPackageName());
}
}

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.pdlive.shayu">
<queries>
<package android:name="com.pdlive.shayu"/>
<package android:name="com.facebook.orca"/>
<package
android:name="com.facebook.composer" />
<package
android:name="com.facebook.katana" />
<package
android:name="com.facebook.messenger" />
<provider
android:authorities="com.facebook.katana.provider.PlatformProvider"
tools:ignore="ExportedContentProvider" />
</queries>
<application android:allowBackup="true">
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:screenOrientation="portrait" />
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider2011402032399020"
android:exported="true" />
<receiver
android:name="com.yunbao.share.receiver.TwitterResultReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_SUCCESS" />
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_FAILURE" />
<action android:name="com.twitter.sdk.android.tweetcomposer.TWEET_COMPOSE_CANCEL" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -0,0 +1,34 @@
package com.yunbao.share;
import android.content.Context;
import android.content.IntentFilter;
import android.net.Uri;
import androidx.core.content.FileProvider;
import com.twitter.sdk.android.tweetcomposer.TweetUploadService;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.receiver.TwitterResultReceiver;
import java.io.File;
public abstract class AbsShareInterface {
protected final Context mContext;
public AbsShareInterface(Context context) {
this.mContext = context;
IntentFilter filter = new IntentFilter(TweetUploadService.UPLOAD_SUCCESS);
filter.addAction(TweetUploadService.UPLOAD_FAILURE);
filter.addAction(TweetUploadService.TWEET_COMPOSE_CANCEL);
context.registerReceiver(new TwitterResultReceiver(), filter);
}
public abstract void share(ShareBuilder builder, ICallback callback);
public Uri fileToUri(File file){
return FileProvider.getUriForFile(mContext,
mContext.getPackageName() + ".fileprovider",
file
);
}
}

View File

@ -0,0 +1,6 @@
package com.yunbao.share;
public interface ICallback {
void onSuccess();
void onFailure();
}

View File

@ -0,0 +1,67 @@
package com.yunbao.share.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.pdlive.shayu.R;
import com.yunbao.share.bean.InviteRewardBean;
import java.util.List;
public class InviteRewardListAdapter extends RecyclerView.Adapter<InviteRewardListAdapter.RewardViewHolder> {
private Context mContext;
private List<InviteRewardBean> list;
public InviteRewardListAdapter(Context mContext) {
this.mContext = mContext;
}
public void setList(List<InviteRewardBean> list) {
this.list = list;
}
@NonNull
@Override
public RewardViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new RewardViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_invite_reward,parent,false));
}
@Override
public void onBindViewHolder(@NonNull RewardViewHolder holder, int position) {
holder.setData(list.get(position),position);
}
@Override
public int getItemCount() {
return list.size();
}
public static class RewardViewHolder extends RecyclerView.ViewHolder {
private final TextView item1;
private final TextView item2;
private final TextView item3;
private final TextView item4;
public RewardViewHolder(@NonNull View itemView) {
super(itemView);
item1 = itemView.findViewById(R.id.item1);
item2 = itemView.findViewById(R.id.item2);
item3 = itemView.findViewById(R.id.item3);
item4 = itemView.findViewById(R.id.item4);
}
void setData(InviteRewardBean bean, int position) {
item1.setText(bean.getUsername());
item2.setText(bean.getInviteTime());
item3.setText(bean.getType());
item4.setText(bean.getReward());
}
}
}

View File

@ -0,0 +1,130 @@
package com.yunbao.share.adapters;
import android.content.Context;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.recyclerview.widget.RecyclerView;
import com.pdlive.shayu.R;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.platform.FacebookShare;
import com.yunbao.share.platform.Instagram;
import com.yunbao.share.platform.Line;
import com.yunbao.share.platform.MessengerShare;
import com.yunbao.share.platform.TwitterShare;
import com.yunbao.share.platform.WhatsApp;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class ShareAppAdapter extends RecyclerView.Adapter<ShareAppAdapter.AppViewHolder> {
private Context mContext;
private List<ShareBuilder> list;
public ShareAppAdapter(Context mContext) {
list = new ArrayList<>();
this.mContext = mContext;
}
public void setList(List<ShareBuilder> list) {
this.list = list;
notifyDataSetChanged();
}
@NonNull
@Override
public AppViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new AppViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_share_app, parent, false));
}
@Override
public void onBindViewHolder(@NonNull AppViewHolder holder, int position) {
ShareBuilder builder = list.get(position);
switch (builder.getType()) {
case ShareBuilder.APP_FACEBOOK:
holder.setData(builder, R.mipmap.icon_share_facebook, R.string.dialog_share_app_facebook);
break;
case ShareBuilder.APP_LINE:
holder.setData(builder, R.mipmap.icon_share_line, R.string.dialog_share_app_line);
break;
case ShareBuilder.APP_TWITTER:
holder.setData(builder, R.mipmap.icon_share_twitter, R.string.dialog_share_app_twitter);
break;
case ShareBuilder.APP_WHATSAPP:
holder.setData(builder, R.mipmap.icon_share_whatsapp, R.string.dialog_share_app_whatsapp);
break;
case ShareBuilder.APP_MESSENGER:
holder.setData(builder, R.mipmap.icon_share_messenger, R.string.dialog_share_app_messenger);
break;
case ShareBuilder.APP_INSTAGRAM:
holder.setData(builder, R.mipmap.icon_share_instagram, R.string.dialog_share_app_instagram);
break;
}
}
@Override
public int getItemCount() {
return list.size();
}
public static class AppViewHolder extends RecyclerView.ViewHolder {
ImageView icon;
TextView title;
public AppViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(R.id.share_app_icon);
title = itemView.findViewById(R.id.share_app_name);
}
public void setData(ShareBuilder bean, @DrawableRes int iconId, @StringRes int appName) {
icon.setImageResource(iconId);
title.setText(appName);
itemView.setOnClickListener(v -> {
switch (bean.getType()) {
case ShareBuilder.APP_FACEBOOK:
new FacebookShare(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_LINE:
new Line(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_TWITTER:
new TwitterShare(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_WHATSAPP:
new WhatsApp(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_MESSENGER:
new MessengerShare(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_INSTAGRAM:
new Instagram(itemView.getContext()).share(bean, new ShareCallback());
break;
}
});
}
private static class ShareCallback implements ICallback {
@Override
public void onSuccess() {
}
@Override
public void onFailure() {
}
}
}
}

View File

@ -0,0 +1,63 @@
package com.yunbao.share.bean;
import androidx.annotation.NonNull;
public class InviteRewardBean{
private String username;
private String inviteTime;
private String type;
private String reward;
public InviteRewardBean() {
}
public InviteRewardBean(String username, String inviteTime, String type, String reward) {
this.username = username;
this.inviteTime = inviteTime;
this.type = type;
this.reward = reward;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getInviteTime() {
return inviteTime;
}
public void setInviteTime(String inviteTime) {
this.inviteTime = inviteTime;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getReward() {
return reward;
}
public void setReward(String reward) {
this.reward = reward;
}
@NonNull
@Override
public String toString() {
return "InviteRewardBean{" +
"username='" + username + '\'' +
", inviteTime='" + inviteTime + '\'' +
", type='" + type + '\'' +
", reward='" + reward + '\'' +
'}';
}
}

View File

@ -0,0 +1,136 @@
package com.yunbao.share.bean;
import androidx.annotation.NonNull;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.utils.StringUtil;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class ShareBuilder {
public static final int APP_FACEBOOK = 0;
public static final int APP_LINE = 1;
public static final int APP_TWITTER = 2;
public static final int APP_WHATSAPP = 3;
public static final int APP_MESSENGER = 4;
public static final int APP_INSTAGRAM = 5;
private String text;
private String link;
private File file;
private int type;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
public static String createLiveShareLink(String shareUid, String anchorId, String anchorName, String anchorAvatar) {
try {
return String.format(CommonAppConfig.HOST +
"/h5/activity/FriendInvitation/liveShare.html?user_id=%s&anchor_id=%s&anchor_name=%s&anchor_avatar=%s&isGoogle=%s",
shareUid,
anchorId,
URLEncoder.encode(anchorName, "UTF-8"),
URLEncoder.encode(anchorAvatar, "UTF-8"),
CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"
);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public static String createInviteLink(String shareUid){
return String.format("https://www.pdlive.com/public/app/download/index.html?user_id=%s&isGoogle=%s",
shareUid,
CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"
);
}
public static ShareBuilder builder(int type) {
return new ShareBuilder(type);
}
private ShareBuilder(int type) {
this.type = type;
}
public int getType() {
return type;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getAnchorId() {
return anchorId;
}
public void setAnchorId(String anchorId) {
this.anchorId = anchorId;
}
public String getAnchorName() {
return anchorName;
}
public void setAnchorName(String anchorName) {
this.anchorName = anchorName;
}
public String getAnchorAvatar() {
return anchorAvatar;
}
public void setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
}
public ShareBuilder setText(String text) {
this.text = text;
return this;
}
public ShareBuilder setLink(String link) {
this.link = link;
return this;
}
public ShareBuilder setFile(File file) {
this.file = file;
return this;
}
public String getText() {
if (StringUtil.isEmpty(text)) {
return getLink();
}
return text + "\n" + getLink();
}
public String getLink() {
if (StringUtil.isEmpty(link)) {
link = createLiveShareLink(uid, anchorId, anchorName, anchorAvatar);
}
return link;
}
public File getFile() {
return file;
}
@NonNull
@Override
public String toString() {
return "ShareBuilder{" +
"text='" + text + '\'' +
", link='" + link + '\'' +
", file=" + file +
'}';
}
}

View File

@ -0,0 +1,51 @@
package com.yunbao.share.platform;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.share.Sharer;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.ShareDialog;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class FacebookShare extends AbsShareInterface {
public static CallbackManager callbackManager;
public FacebookShare(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
callbackManager= CallbackManager.Factory.create();
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(builder.getLink()))
.build();
ShareDialog dialog=new ShareDialog((Activity) mContext);
dialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
ToastUtil.show("Facebook分享成功");
}
@Override
public void onCancel() {
ToastUtil.show("Facebook分享取消");
}
@Override
public void onError(@NonNull FacebookException e) {
ToastUtil.show("Facebook分享失败:"+e.toString());
}
});
dialog.show(content);
}
}

View File

@ -0,0 +1,27 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class Instagram extends AbsShareInterface {
public Instagram(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
String type = "image/*";
Intent share = new Intent(Intent.ACTION_SEND);
Uri uri = fileToUri(builder.getFile());
share.setType(type);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("com.instagram.android");
mContext.startActivity(Intent.createChooser(share, "Share to"));
callback.onSuccess();
}
}

View File

@ -0,0 +1,31 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
import java.net.URLEncoder;
public class Line extends AbsShareInterface {
public Line(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
try {
Intent share = new Intent(Intent.ACTION_VIEW, Uri.parse("https://line.me/R/share?text=" + URLEncoder.encode(builder.getText(), "UTF-8")));
mContext.startActivity(share);
callback.onSuccess();
} catch (Exception e) {
callback.onFailure();
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,60 @@
package com.yunbao.share.platform;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.share.Sharer;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.MessageDialog;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class MessengerShare extends AbsShareInterface {
public static CallbackManager callbackManager;
public MessengerShare(Context context) {
super(context);
FacebookSdk.setIsDebugEnabled(true);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
callbackManager = CallbackManager.Factory.create();
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(builder.getLink()))
.build();
MessageDialog dialog = new MessageDialog((Activity) mContext);
dialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
ToastUtil.show("Messenger分享成功:"+result.getPostId());
callback.onSuccess();
}
@Override
public void onCancel() {
ToastUtil.show("Messenger分享取消");
}
@Override
public void onError(@NonNull FacebookException e) {
ToastUtil.show("Messenger分享失败:" + e.toString());
e.printStackTrace();
}
});
if(dialog.canShow(content)) {
dialog.show(content);
}else{
callback.onFailure();
}
}
}

View File

@ -0,0 +1,73 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.twitter.sdk.android.core.Twitter;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
import java.net.URLEncoder;
public class TwitterShare extends AbsShareInterface {
public TwitterShare(Context context) {
super(context);
Twitter.initialize(context);
}
@Override
public void share(ShareBuilder date, ICallback callback) {
/*
new TwitterAuthClient().authorize((Activity) mContext, new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
//获取以下登录成功返回信息进行登录验证
//获取登录用户信息
final TwitterSession activeSession=TwitterCore.getInstance().getSessionManager().getActiveSession();
Intent intent = new ComposerActivity.Builder(mContext)
.session(activeSession)
.image(fileToUri(date.getFile()))
.text(date.getText())
.hashtags("#twitter")
.createIntent();
mContext.startActivity(intent);
}
@Override
public void failure(TwitterException e) {
}
});*/
/* TweetComposer.Builder builder;
if (date.getFile() == null) {
try {
builder=new TweetComposer.Builder(mContext)
.text(date.getText())
.url(new URL(date.getLink()));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
} else {
builder = new TweetComposer.Builder(mContext)
.text(date.getText())
.image(fileToUri(date.getFile()));
}
builder.show();*/
try {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_VIEW);
sendIntent.putExtra(Intent.EXTRA_TEXT, date.getLink());
// sendIntent.setType("text/plain");
//sendIntent.setPackage("com.twitter.composer.ComposerShareActivity");
sendIntent.setData(Uri.parse("https://twitter.com/intent/tweet?text=" +URLEncoder.encode(date.getText(),"UTF-8")));
mContext.startActivity(sendIntent);
callback.onSuccess();
} catch (Exception e) {
callback.onFailure();
}
}
}

View File

@ -0,0 +1,30 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class WhatsApp extends AbsShareInterface {
public WhatsApp(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
try {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, builder.getText());
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
mContext.startActivity(sendIntent);
callback.onSuccess();
} catch (Exception e) {
callback.onFailure();
}
}
}

View File

@ -0,0 +1,28 @@
package com.yunbao.share.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.twitter.sdk.android.tweetcomposer.TweetUploadService;
import com.yunbao.common.utils.ToastUtil;
public class TwitterResultReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("分享log", "onReceive: "+intent.getAction());
if (TweetUploadService.UPLOAD_SUCCESS.equals(intent.getAction())) {
ToastUtil.show("推特分享成功");
// success
final Long tweetId = intent.getExtras().getLong(TweetUploadService.EXTRA_TWEET_ID);
} else if (TweetUploadService.UPLOAD_FAILURE.equals(intent.getAction())) {
// failure
ToastUtil.show("推特分享失败");
final Intent retryIntent = intent.getExtras().getParcelable(TweetUploadService.EXTRA_RETRY_INTENT);
} else if (TweetUploadService.TWEET_COMPOSE_CANCEL.equals(intent.getAction())) {
// cancel
ToastUtil.show("推特分享取消");
}
}
}

View File

@ -0,0 +1,131 @@
package com.yunbao.share.ui;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.pdlive.shayu.R;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.adapters.ShareAppAdapter;
import java.util.ArrayList;
import java.util.List;
public class InvitePopDialog extends AbsDialogPopupWindow {
private ShareAppAdapter adapter;
private RecyclerView list;
private RoundedImageView avatar;
private TextView info;
private TextView link;
private List<ShareBuilder> data;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
public InvitePopDialog(@NonNull Context context) {
super(context);
}
public InvitePopDialog setUid(String uid) {
this.uid = uid;
return this;
}
public InvitePopDialog setAnchorId(String anchorId) {
this.anchorId = anchorId;
return this;
}
public InvitePopDialog setAnchorName(String anchorName) {
this.anchorName = anchorName;
return this;
}
public InvitePopDialog setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
return this;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_share;
}
@Override
protected void onCreate() {
super.onCreate();
findViewById(R.id.close).setOnClickListener(v -> dismiss());
findViewById(R.id.share_copy).setOnClickListener(v -> copyLink());
findViewById(R.id.share_title).setOnClickListener(v -> copyLink());
findViewById(R.id.share_preview).setVisibility(GONE);
findViewById(R.id.share_dialog).setBackgroundResource(R.mipmap.bg_dialog_inviet);
((TextView) findViewById(R.id.share_title)).setText(R.string.dialog_invite_title);
((TextView) findViewById(R.id.share_title)).setTextColor(R.drawable.bg_invite_title);
list = findViewById(R.id.share_apps_list);
avatar = findViewById(R.id.share_avatar);
info = findViewById(R.id.share_info);
link = findViewById(R.id.share_link);
adapter = new ShareAppAdapter(getContext());
list.setLayoutManager(new GridLayoutManager(getContext(), 3));
list.setAdapter(adapter);
initData();
}
private void initData() {
data = new ArrayList<>();
data.add(builder(ShareBuilder.APP_FACEBOOK));
data.add(builder(ShareBuilder.APP_LINE));
data.add(builder(ShareBuilder.APP_TWITTER));
data.add(builder(ShareBuilder.APP_WHATSAPP));
data.add(builder(ShareBuilder.APP_MESSENGER));
// data.add(builder(ShareBuilder.APP_INSTAGRAM));
adapter.setList(data);
}
private ShareBuilder builder(int type) {
ShareBuilder builder = ShareBuilder.builder(type);
//builder.setText(WordUtil.getString(R.string.dialog_share_info));
builder.setLink(ShareBuilder.createInviteLink(uid));
builder.setUid(uid);
builder.setAnchorId(anchorId);
builder.setAnchorName(anchorName);
builder.setAnchorAvatar(anchorAvatar);
return builder;
}
private void copyLink() {
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text", link.getText().toString());
cm.setPrimaryClip(clipData);
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
DialogUitl.showSimpleDialog(getContext(), ShareBuilder.createInviteLink(uid), new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
dialog.dismiss();
}
});
}
}

View File

@ -0,0 +1,131 @@
package com.yunbao.share.ui;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.pdlive.shayu.R;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.adapters.ShareAppAdapter;
import java.util.ArrayList;
import java.util.List;
public class InviteRewardPopDialog extends AbsDialogPopupWindow {
private ShareAppAdapter adapter;
private RecyclerView list;
private RoundedImageView avatar;
private TextView info;
private TextView link;
private List<ShareBuilder> data;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
public InviteRewardPopDialog(@NonNull Context context) {
super(context);
}
public InviteRewardPopDialog setUid(String uid) {
this.uid = uid;
return this;
}
public InviteRewardPopDialog setAnchorId(String anchorId) {
this.anchorId = anchorId;
return this;
}
public InviteRewardPopDialog setAnchorName(String anchorName) {
this.anchorName = anchorName;
return this;
}
public InviteRewardPopDialog setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
return this;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_share;
}
@Override
protected void onCreate() {
super.onCreate();
findViewById(R.id.close).setOnClickListener(v -> dismiss());
findViewById(R.id.share_copy).setOnClickListener(v -> copyLink());
findViewById(R.id.share_title).setOnClickListener(v -> copyLink());
findViewById(R.id.share_preview).setVisibility(GONE);
findViewById(R.id.share_dialog).setBackgroundResource(R.mipmap.bg_dialog_inviet);
((TextView) findViewById(R.id.share_title)).setText(R.string.dialog_invite_title);
((TextView) findViewById(R.id.share_title)).setTextColor(R.drawable.bg_invite_title);
list = findViewById(R.id.share_apps_list);
avatar = findViewById(R.id.share_avatar);
info = findViewById(R.id.share_info);
link = findViewById(R.id.share_link);
adapter = new ShareAppAdapter(getContext());
list.setLayoutManager(new LinearLayoutManager(getContext(),RecyclerView.VERTICAL,false));
list.setAdapter(adapter);
initData();
}
private void initData() {
data = new ArrayList<>();
data.add(builder(ShareBuilder.APP_FACEBOOK));
data.add(builder(ShareBuilder.APP_LINE));
data.add(builder(ShareBuilder.APP_TWITTER));
data.add(builder(ShareBuilder.APP_WHATSAPP));
data.add(builder(ShareBuilder.APP_MESSENGER));
// data.add(builder(ShareBuilder.APP_INSTAGRAM));
adapter.setList(data);
}
private ShareBuilder builder(int type) {
ShareBuilder builder = ShareBuilder.builder(type);
//builder.setText(WordUtil.getString(R.string.dialog_share_info));
builder.setLink(ShareBuilder.createInviteLink(uid));
builder.setUid(uid);
builder.setAnchorId(anchorId);
builder.setAnchorName(anchorName);
builder.setAnchorAvatar(anchorAvatar);
return builder;
}
private void copyLink() {
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text", link.getText().toString());
cm.setPrimaryClip(clipData);
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
DialogUitl.showSimpleDialog(getContext(), ShareBuilder.createInviteLink(uid), new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
dialog.dismiss();
}
});
}
}

View File

@ -0,0 +1,146 @@
package com.yunbao.share.ui;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.pdlive.shayu.R;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.adapters.ShareAppAdapter;
import java.util.ArrayList;
import java.util.List;
public class SharePopDialog extends AbsDialogPopupWindow {
private ShareAppAdapter adapter;
private RecyclerView list;
private RoundedImageView avatar;
private TextView info;
private TextView link;
private List<ShareBuilder> data;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
private String shareLink;
public SharePopDialog(@NonNull Context context) {
super(context);
}
public SharePopDialog setUid(String uid) {
this.uid = uid;
return this;
}
public SharePopDialog setAnchorId(String anchorId) {
this.anchorId = anchorId;
return this;
}
public SharePopDialog setAnchorName(String anchorName) {
this.anchorName = anchorName;
return this;
}
public SharePopDialog setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
return this;
}
public SharePopDialog setShareLink(String link) {
this.shareLink = link;
return this;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_share;
}
@Override
protected void onCreate() {
super.onCreate();
findViewById(R.id.close).setOnClickListener(v -> dismiss());
findViewById(R.id.share_copy).setOnClickListener(v -> copyLink());
list = findViewById(R.id.share_apps_list);
avatar = findViewById(R.id.share_avatar);
info = findViewById(R.id.share_info);
link = findViewById(R.id.share_link);
adapter = new ShareAppAdapter(getContext());
list.setLayoutManager(new GridLayoutManager(getContext(), 3));
list.setAdapter(adapter);
initData();
}
private void initData() {
data = new ArrayList<>();
data.add(builder(ShareBuilder.APP_FACEBOOK));
data.add(builder(ShareBuilder.APP_LINE));
data.add(builder(ShareBuilder.APP_TWITTER));
data.add(builder(ShareBuilder.APP_WHATSAPP));
data.add(builder(ShareBuilder.APP_MESSENGER));
//data.add(builder(ShareBuilder.APP_INSTAGRAM));
adapter.setList(data);
String url;
if (shareLink == null) {
url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar).substring(0, 40) + "...";
} else {
if (shareLink.length() > 40) {
url = shareLink.substring(0, 40) + "...";
} else {
url = shareLink;
}
}
link.setText(url);
info.setText(String.format(WordUtil.getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName));
ImgLoader.display(getContext(), anchorAvatar, avatar);
}
private ShareBuilder builder(int type) {
ShareBuilder builder = ShareBuilder.builder(type);
builder.setText(String.format(WordUtil.getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName));
builder.setUid(uid);
builder.setAnchorId(anchorId);
builder.setAnchorName(anchorName);
builder.setAnchorAvatar(anchorAvatar);
if (shareLink != null) {
builder.setLink(shareLink);
}
return builder;
}
private void copyLink() {
String url;
if (shareLink != null) {
url = shareLink;
} else {
url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar);
}
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text", url);
cm.setPrimaryClip(clipData);
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="15dp" />
<solid android:color="#ffffff" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="189dp" android:height="42dp">
<shape android:shape="rectangle">
<gradient android:type="linear" android:useLevel="true" android:startColor="#ffffc621" android:endColor="#ffffae05" android:angle="135" />
<corners android:radius="21dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="112dp" android:height="42dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffffff" />
<gradient android:type="linear" android:useLevel="true" android:startColor="#3377FF" android:endColor="#7F66FF" android:angle="90" />
<corners android:topLeftRadius="22dp" android:topRightRadius="22dp" android:bottomLeftRadius="22dp" android:bottomRightRadius="22dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/share_dialog"
android:layout_height="wrap_content"
android:background="@mipmap/bg_dialog_share">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/share_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="@string/dialog_invite_title"
android:textColor="@drawable/bg_invite_title"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/close"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="16dp"
app:srcCompat="@mipmap/icon_dialog_charge_close" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_apps_list"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
tools:itemCount="6"
tools:layoutManager="GridLayoutManager"
tools:listitem="@layout/item_share_app"
tools:spanCount="3" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/share_dialog"
android:layout_height="wrap_content"
android:background="@mipmap/bg_dialog_share">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/share_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="@string/dialog_share_title"
android:textColor="#333333"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/close"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="16dp"
app:srcCompat="@mipmap/icon_dialog_charge_close" />
</LinearLayout>
<include
android:id="@+id/share_preview"
layout="@layout/view_share_preview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_apps_list"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/share_preview"
tools:itemCount="6"
tools:layoutManager="GridLayoutManager"
tools:listitem="@layout/item_share_app"
tools:spanCount="3" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/item1"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="@+id/item2"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="@+id/item3"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="@+id/item4"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/share_app_icon"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginStart="35dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="35dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars" />
<TextView
android:id="@+id/share_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="12dp"
android:text="TextView"
android:textColor="#666666"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/share_app_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_fff"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/share_avatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="centerCrop"
android:src="@drawable/m_chu_xia"
app:riv_oval="true" />
<TextView
android:id="@+id/share_info"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="12dp"
android:text="@string/dialog_share_info"
android:layout_weight="1"
android:textColor="#333333"
android:textSize="12sp"
/>
<Button
android:id="@+id/share_copy"
android:layout_width="70dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginEnd="16dp"
android:layout_weight="0.01"
android:background="@drawable/bg_btn"
android:text="复制"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/share_layout_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginBottom="12dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="12dp"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@mipmap/icon_share_url" />
<TextView
android:id="@+id/share_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="TextView"
android:textColor="#999999"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -0,0 +1,15 @@
<resources>
<string name="com.twitter.sdk.android.CONSUMER_KEY" translatable="false">ZWRrZnRUNlBlcHVxMXpsMzVmb2k6MTpjaQ</string>
<string name="com.twitter.sdk.android.CONSUMER_SECRET" translatable="false">aq0eV4R1pqMK_AAeKRWnjPr7ErGMGgTPGgZJdm73WeRY-Kluws</string>
<string name="dialog_share_title">分享</string>
<string name="dialog_share_info">快來 PDLIVE觀看%s直播認識更多有趣的朋友吧</string>
<string name="dialog_share_app_facebook" translatable="false">Facebook</string>
<string name="dialog_share_app_line" translatable="false">Line</string>
<string name="dialog_share_app_twitter" translatable="false">Twitter</string>
<string name="dialog_share_app_whatsapp" translatable="false">WhatsApp</string>
<string name="dialog_share_app_messenger" translatable="false">Messenger</string>
<string name="dialog_share_app_instagram" translatable="false">Instagram</string>
<string name="dialog_invite_title">邀請好友</string>
</resources>

View File

@ -0,0 +1,17 @@
package com.yunbao.share;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -162,8 +162,8 @@ dependencies {
api 'cn.rongcloud.sdk:im_kit:5.2.5.4' // UI api 'cn.rongcloud.sdk:im_kit:5.2.5.4' // UI
// //
api 'cn.rongcloud.sdk:sight:5.2.5.4' api 'cn.rongcloud.sdk:sight:5.2.5.4'
api 'com.facebook.android:facebook-android-sdk:15.0.1' api 'com.facebook.android:facebook-android-sdk:15.2.0'
implementation 'com.facebook.android:facebook-android-sdk:15.0.1' implementation 'com.facebook.android:facebook-android-sdk:15.2.0'
api('com.twitter.sdk.android:twitter-core:3.1.1@aar') { api('com.twitter.sdk.android:twitter-core:3.1.1@aar') {
transitive = true transitive = true

View File

@ -21,6 +21,8 @@ public class CustomDrawerPopupEvent extends BaseModel {
private boolean reportLayout = false; private boolean reportLayout = false;
//刷新 //刷新
private boolean refresh = false; private boolean refresh = false;
//特效設置
private boolean effects = false;
public boolean isRefresh() { public boolean isRefresh() {
return refresh; return refresh;
@ -102,4 +104,13 @@ public class CustomDrawerPopupEvent extends BaseModel {
isDisMiss = disMiss; isDisMiss = disMiss;
return this; return this;
} }
public boolean isEffects() {
return effects;
}
public CustomDrawerPopupEvent setEffects(boolean effects) {
this.effects = effects;
return this;
}
} }

View File

@ -0,0 +1,20 @@
package com.yunbao.common.server;
import static android.content.Intent.EXTRA_CHOSEN_COMPONENT;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class ShareBroadcastReceiver extends BroadcastReceiver {
public static final int REQUEST_CODE = 888;
private static final String TAG = "分享log";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "onReceive");
Log.i(TAG, intent.getAction() + " | " + intent.getParcelableExtra(EXTRA_CHOSEN_COMPONENT));
}
}

View File

@ -497,4 +497,13 @@ public class JavascriptInterfaceUtils {
mWebView.setVisibility(View.VISIBLE); mWebView.setVisibility(View.VISIBLE);
}); });
} }
@JavascriptInterface
public void androidCommunityShare(String avatar,String link){
JSONObject json=new JSONObject();
json.put("avatar",avatar);
json.put("link",link);
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidCommunityShare")
.setData(json.toJSONString()));
}
} }

View File

@ -0,0 +1,53 @@
package com.yunbao.common.utils;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static android.content.Intent.EXTRA_CHOSEN_COMPONENT;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.net.Uri;
import com.yunbao.common.server.ShareBroadcastReceiver;
import java.io.File;
/**
* 分享工具
*/
public class ShareUtil {
public static void share(Context context, String content) {
share(context, content, null);
}
public static void share(Context context, File image) {
share(context, null, image);
}
public static void share(Context context, String content, File image) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
if (image != null) {
Uri uri = Uri.fromFile(image);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/*");
//当用户选择短信时使用sms_body取得文字
shareIntent.putExtra("sms_body", content);
} else {
shareIntent.setType("text/plain");
}
shareIntent.putExtra(Intent.EXTRA_TEXT, content);
//自定义选择框的标题
PendingIntent pi = PendingIntent.getBroadcast(context, ShareBroadcastReceiver.REQUEST_CODE,
new Intent(context, ShareBroadcastReceiver.class), PendingIntent.FLAG_MUTABLE);
context.registerReceiver(new ShareBroadcastReceiver(),new IntentFilter(EXTRA_CHOSEN_COMPONENT));
shareIntent = Intent.createChooser(shareIntent, null, pi.getIntentSender());
context.startActivity(Intent.createChooser(shareIntent, "Share"));
//系统默认标题
}
}

View File

@ -93,13 +93,13 @@ public class CustomDrawerPopupView extends DrawerPopupView {
} }
} }
}); });
//特效设置 //分享
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.effects_settings_layout), new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.share_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
dismiss(); dismiss();
if (callBack != null) { if (callBack != null) {
callBack.effectsSetting(); callBack.share();
} }
} }
}); });
@ -203,6 +203,8 @@ public class CustomDrawerPopupView extends DrawerPopupView {
void online(); void online();
void reportLayout(); void reportLayout();
void share();
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
@ -233,6 +235,10 @@ public class CustomDrawerPopupView extends DrawerPopupView {
dismiss(); dismiss();
callBack.reportLayout(); callBack.reportLayout();
} }
if(event.isEffects()){
dismiss();
callBack.effectsSetting();
}
} }
if (event.isRefresh()) { if (event.isRefresh()) {

View File

@ -22,6 +22,15 @@ public class MoreMenuPopupView extends AttachPopupView {
@Override @Override
protected void onCreate() { protected void onCreate() {
//特效设置
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.effects_settings_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dismiss();
Bus.get().post(new CustomDrawerPopupEvent()
.setDisMiss(true).setEffects(true));
}
});
//系统通知 //系统通知
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.system_notice), new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.system_notice), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override

View File

@ -41,27 +41,6 @@
android:textSize="10sp" /> android:textSize="10sp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/effects_settings_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="26dp"
android:layout_height="26dp"
android:src="@mipmap/live_more_icon_special_new" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/effects_settings"
android:textColor="#FF9A9A9A"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/slide_settings_layout" android:id="@+id/slide_settings_layout"
@ -85,6 +64,28 @@
android:textSize="10sp" /> android:textSize="10sp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/share_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="26dp"
android:layout_height="26dp"
android:src="@mipmap/ic_custom_share" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="分享設置"
android:textColor="#FF9A9A9A"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/float_settings_layout" android:id="@+id/float_settings_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="176dp" android:layout_width="220dp"
android:layout_height="62dp" android:layout_height="62dp"
app:cardBackgroundColor="#0F0B14" app:cardBackgroundColor="#0F0B14"
app:cardCornerRadius="4dp" app:cardCornerRadius="4dp"
@ -11,6 +11,27 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical"> android:gravity="center_vertical">
<LinearLayout
android:id="@+id/effects_settings_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="26dp"
android:layout_height="26dp"
android:src="@mipmap/live_more_icon_special_new" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="@string/effects_settings"
android:textColor="#FF9A9A9A"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/system_notice" android:id="@+id/system_notice"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -25,6 +25,6 @@ ext {
// true表示谷歌支付 false // true表示谷歌支付 false
isGooglePlay : false, isGooglePlay : false,
// //
isUploadLog : true isUploadLog : false
] ]
} }

View File

@ -1 +1 @@
apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" //ExoPlayer,腾讯的播放器不支持无缝切换 implementation 'com.google.android.exoplayer:exoplayer:2.18.2' implementation 'com.google.android.exoplayer:exoplayer-core:2.18.2@aar' } apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 api project(':Share')//分享 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" //ExoPlayer,腾讯的播放器不支持无缝切换 implementation 'com.google.android.exoplayer:exoplayer:2.18.2' implementation 'com.google.android.exoplayer:exoplayer-core:2.18.2@aar' }

View File

@ -101,6 +101,7 @@ import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import com.yunbao.live.views.LiveRoomPlayViewHolder; import com.yunbao.live.views.LiveRoomPlayViewHolder;
import com.yunbao.live.views.PortraitLiveManager; import com.yunbao.live.views.PortraitLiveManager;
import com.yunbao.share.ui.SharePopDialog;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -909,6 +910,13 @@ public class LiveAudienceActivity extends LiveActivity {
.setBean(mLiveBean) .setBean(mLiveBean)
.setType(LiveAudienceEvent.LiveAudienceType.REPORT)); .setType(LiveAudienceEvent.LiveAudienceType.REPORT));
} }
@Override
public void share() {
Bus.get().post(new LiveAudienceEvent()
.setBean(mLiveBean)
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_SHARE));
}
}); });
new XPopup.Builder(mContext) new XPopup.Builder(mContext)
.hasShadowBg(false) .hasShadowBg(false)
@ -1280,6 +1288,14 @@ public class LiveAudienceActivity extends LiveActivity {
case LIVE_HIDE_MSG_RED: case LIVE_HIDE_MSG_RED:
showMsgRed(-1); showMsgRed(-1);
break; break;
case LIVE_SHARE:
new SharePopDialog(mContext)
.setUid(CommonAppConfig.getInstance().getUid())
.setAnchorId(event.getBean().getUid())
.setAnchorName(event.getBean().getUserNiceName())
.setAnchorAvatar(event.getBean().getAvatar())
.showDialog();
break;
} }

View File

@ -76,7 +76,7 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSa
} }
public void setData(String text, int position) { public void setData(String text, int position) {
textView.setText("已输入的\n内容已输\n入的内容\n入的内容"); textView.setText("已输入的内容\n已输入的内容\n已输入的");
ImgLoader.display(mContext, text, icon); ImgLoader.display(mContext, text, icon);
if (position == click) { if (position == click) {
itemView.setBackgroundResource(R.drawable.bg_anchor_say_select); itemView.setBackgroundResource(R.drawable.bg_anchor_say_select);

View File

@ -121,20 +121,7 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
sayModel.getLivePreview().setContent(s.toString()); sayModel.getLivePreview().setContent(s.toString());
StringBuilder sb = new StringBuilder(); sayText.setText(getText(s.toString()));
int len=6;
int n = (s.length() + 3) / len;
for (int i = 0; i < n; i++) {
if (i < (n - 1)) {
sb.append(s.toString().substring(i * len, (i + 1) * len)).append("\n");
} else {
sb.append(s.toString().substring(i * len));
}
}
if (sb.length() == 0) {
sb.append("默认字符\n默认字符\n默认字符");
}
sayText.setText(sb.toString());
} }
@Override @Override
@ -142,6 +129,21 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
} }
public String getText(String content) {
int t = 6;
float len = (float) content.length() / t;
StringBuilder sb = new StringBuilder();
sb.append("\n");
for (int i = 0; i < len; i++) {
if (len - i < 1) {
sb.append(content.substring(i * t));
} else {
sb.append(content.substring(i * t, i * t + t)).append("\n");
}
}
return sb.toString();
}
}); });
close.setOnClickListener(v -> { close.setOnClickListener(v -> {
dismiss(); dismiss();

View File

@ -300,7 +300,8 @@ public class LiveAudienceEvent extends BaseModel {
LIVE_VIDEO(54, "画质选择"), LIVE_VIDEO(54, "画质选择"),
LUCKY_100_CHECK(55, "幸运百分百"), LUCKY_100_CHECK(55, "幸运百分百"),
LIVE_END(56, "主播下播"), LIVE_END(56, "主播下播"),
LIVE_HIDE_MSG_RED(57,"隐藏红点"); LIVE_HIDE_MSG_RED(57,"隐藏红点"),
LIVE_SHARE(58,"直播間分享");
private int type; private int type;
private String name; private String name;

View File

@ -9,7 +9,7 @@
android:id="@+id/anchor_say" android:id="@+id/anchor_say"
layout="@layout/sim_live_room_anchor_say" layout="@layout/sim_live_room_anchor_say"
android:layout_width="77dp" android:layout_width="77dp"
android:layout_height="88dp" android:layout_height="110dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="106dp" android:layout_width="106dp"
android:layout_height="128dp" android:layout_height="128dp"
android:layout_marginStart="5dp" android:layout_marginStart="2dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="@drawable/bg_anchor_say" android:background="@drawable/bg_anchor_say"
android:layout_marginTop="10dp"> android:layout_marginTop="10dp">
@ -11,8 +11,8 @@
<include <include
layout="@layout/sim_live_room_anchor_say" layout="@layout/sim_live_room_anchor_say"
android:layout_width="67dp" android:layout_width="83dp"
android:layout_height="88dp" android:layout_height="110dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -2,20 +2,21 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="67dp" android:layout_width="77dp"
android:layout_height="88dp"> android:layout_height="110dp">
<ImageView <ImageView
android:id="@+id/anchor_say_icon" android:id="@+id/anchor_say_icon"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:scaleType="fitXY"
android:src="@color/main_color_79CDF9" android:src="@color/main_color_79CDF9"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@color/main_color_79CDF9" /> tools:srcCompat="@mipmap/tmp" />
<TextView <TextView
android:id="@+id/anchor_say_text" android:id="@+id/anchor_say_text"
@ -28,14 +29,14 @@
android:gravity="center" android:gravity="center"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:maxEms="6" android:maxEms="6"
android:text="中文测试\n中文测试\n中文测试\n中文测试" android:text="已输入的内容\n已输入的内容\n已输入的"
android:textColor="#333333" android:textColor="#333333"
android:textSize="10sp" android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/anchor_say_icon" app:layout_constraintTop_toTopOf="@+id/anchor_say_icon"
tools:text="中文测试\n中文测试\n中文测试\n中文测试" /> tools:text="已输入的内容\n已输入的内容\n已输入的" />
<ImageView <ImageView
android:id="@+id/anchor_say_hide" android:id="@+id/anchor_say_hide"

View File

@ -1295,7 +1295,7 @@
android:id="@+id/anchor_say_layout" android:id="@+id/anchor_say_layout"
layout="@layout/sim_live_room_anchor_say" layout="@layout/sim_live_room_anchor_say"
android:layout_width="77dp" android:layout_width="77dp"
android:layout_height="88dp" android:layout_height="110dp"
android:layout_alignBottom="@+id/live_video" android:layout_alignBottom="@+id/live_video"
android:layout_marginStart="14dp" android:layout_marginStart="14dp"
android:visibility="invisible" android:visibility="invisible"

View File

@ -73,6 +73,7 @@ dependencies {
api project(':video') api project(':video')
api project(':common') api project(':common')
api project(':FaceUnity')// api project(':FaceUnity')//
api project(':Share')//
implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0' implementation 'com.google.android.material:material:1.4.0'
annotationProcessor rootProject.ext.dependencies["arouter-compiler"] annotationProcessor rootProject.ext.dependencies["arouter-compiler"]

View File

@ -2,23 +2,14 @@ package com.yunbao.main.activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.text.SpannableStringBuilder;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.share.platform.FacebookShare;
import com.yunbao.live.dialog.LiveDataInfoDialog; import com.yunbao.share.platform.MessengerShare;
import com.yunbao.live.dialog.LiveTaskDialog;
import java.io.File;
public class TestActivity extends AppCompatActivity { public class TestActivity extends AppCompatActivity {
@ -30,31 +21,16 @@ public class TestActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
listView = new ListView(this); listView = new ListView(this);
setContentView(listView); setContentView(listView);
String[] strs = new String[]{
"弹出主播任务",
"直播數據"
};
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, strs));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
new LiveTaskDialog(TestActivity.this).showDialog();
break;
case 1:
new LiveDataInfoDialog(TestActivity.this).showDialog();
break;
}
}
});
} }
@Override @Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
Log.i("分享log", "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data.getAction() + "]");
if (FacebookShare.callbackManager != null) {
FacebookShare.callbackManager.onActivityResult(requestCode, resultCode, data);
} else if (MessengerShare.callbackManager != null) {
MessengerShare.callbackManager.onActivityResult(requestCode, resultCode, data);
}
} }
} }

View File

@ -28,6 +28,7 @@ import android.widget.TextView;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.HtmlConfig; import com.yunbao.common.HtmlConfig;
@ -50,6 +51,7 @@ import com.yunbao.main.R;
import com.yunbao.main.activity.MainActivity; import com.yunbao.main.activity.MainActivity;
import com.yunbao.main.dialog.EncourageDialog; import com.yunbao.main.dialog.EncourageDialog;
import com.yunbao.main.utils.BottomBarUtil; import com.yunbao.main.utils.BottomBarUtil;
import com.yunbao.share.ui.SharePopDialog;
import com.yunbao.video.activity.VideoPlayActivity; import com.yunbao.video.activity.VideoPlayActivity;
import com.yunbao.video.utils.VideoStorge; import com.yunbao.video.utils.VideoStorge;
@ -238,7 +240,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override @Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
} }
@Override @Override
@ -248,9 +250,9 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
}); });
} else { } else {
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0); RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
}
} }
}
}); });
@ -345,10 +347,16 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) { } else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
//看直播 //看直播
gotoLive(event.getLiveId()); gotoLive(event.getLiveId());
}else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")){ } else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")) {
if(nowMainActivity!=null) { if (nowMainActivity != null) {
nowMainActivity.isClose(event.getIsClose()); nowMainActivity.isClose(event.getIsClose());
} }
} else if (TextUtils.equals(event.getMethod(), "androidCommunityShare")) {
JSONObject json = JSONObject.parseObject(event.getData());
new SharePopDialog(mContext)
.setShareLink(CommonAppConfig.HOST+json.getString("link"))
.setAnchorAvatar(json.getString("avatar"))
.showDialog();
} }
} }
} }

View File

@ -3,7 +3,10 @@ package com.yunbao.main.views;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Outline; import android.graphics.Outline;
import android.net.Uri;
import android.os.Environment;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -11,6 +14,7 @@ import android.view.ViewGroup;
import android.view.ViewOutlineProvider; import android.view.ViewOutlineProvider;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -36,6 +40,7 @@ import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ShareUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.CustomViewHolder; import com.yunbao.common.views.CustomViewHolder;
import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.event.LiveRoomChangeEvent;
@ -54,6 +59,7 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -330,7 +336,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override @Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
} }
@Override @Override
@ -361,6 +367,11 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
.setOnBannerClickListener(new OnBannerClickListener() { .setOnBannerClickListener(new OnBannerClickListener() {
@Override @Override
public void onBannerClick(List datas, int p) { public void onBannerClick(List datas, int p) {
if (false) {
throw new NullPointerException("空指针测试异常");
// mContext.startActivity(new Intent(mContext, TestActivity.class));
//return;
}
if (mBannerList != null) { if (mBannerList != null) {
if (p >= 0 && p < mBannerList.size()) { if (p >= 0 && p < mBannerList.size()) {
BannerBean bean = mBannerList.get(p); BannerBean bean = mBannerList.get(p);
@ -423,7 +434,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
} }
if (!"".endsWith(Constants.mStream)) { if (!"".endsWith(Constants.mStream)) {
if(MicStatusManager.getInstance().isMic(liveUid)){ if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -1,4 +1,5 @@
include ':app', ':video', ':common', ':main', ':baidu', ':live', ':lib_country_code' include ':app', ':video', ':common', ':main', ':baidu', ':live', ':lib_country_code'
include ':FaceUnity' include ':FaceUnity'
//include ':baidu' //include ':baidu'
//include ':recognizer'// //include ':recognizer'//
include ':Share'