Merge branch 'feature-GHZS-802' into 'dev'
feat:春节活动—集“萌兔福签”,得新年好礼—客户端 https://jira.shanqu.cc/browse/GHZS-802 See merge request halo/android/assistant-android!587
This commit is contained in:
@ -55,8 +55,6 @@ import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
class DefaultJsApi(var context: Context, val entrance: String = "", private var mFragment: Fragment? = null) {
|
||||
|
||||
@ -592,6 +590,15 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
DownloadManager.getInstance().pause(url)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun shareText(event: Any) {
|
||||
val textShareEvent = event.toString().toObject() ?: TextShareEvent()
|
||||
if (textShareEvent.text.isNotEmpty() && textShareEvent.type.isNotEmpty()) {
|
||||
val activity = CurrentActivityHolder.getCurrentActivity()
|
||||
MessageShareUtils.getInstance(activity).shareTextFromWeb(activity, textShareEvent.text, textShareEvent.type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun autoUnregisterDownloadObserverIfNeeded(fragment: Fragment?) {
|
||||
fragment?.parentFragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
@ -635,6 +642,9 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
@Keep
|
||||
internal data class ImageShareEvent(var image: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal data class TextShareEvent(var text: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal data class InviteFriendsEvent(
|
||||
var type: String = "",
|
||||
|
||||
@ -15,25 +15,26 @@ import com.gh.common.util.DirectUtils.directToGameVideo
|
||||
import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.DirectUtils.directToQa
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.core.utils.GsonUtils.gson
|
||||
import com.gh.gamecenter.LibaoDetailActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.NewsDetailActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.EnvHelper
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
import com.lightgame.utils.Utils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.nio.charset.Charset
|
||||
|
||||
object DefaultUrlHandler {
|
||||
@ -492,6 +493,18 @@ object DefaultUrlHandler {
|
||||
)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_LIBRARY -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault()
|
||||
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||||
EventBus.getDefault().post(EBReuse(host))
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (bringAppToFront) {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
|
||||
@ -43,6 +43,7 @@ import com.tencent.connect.share.QQShare;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.open.TDialog;
|
||||
@ -311,6 +312,51 @@ public class MessageShareUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void shareTextFromWeb(Activity activity, String text, String type) {
|
||||
switch (type) {
|
||||
case "qq":
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
if (ShareUtils.isQQClientAvailable(activity)) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, text);
|
||||
intent.setType("text/plain");
|
||||
intent.setPackage("com.tencent.mobileqq");
|
||||
intent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
|
||||
try {
|
||||
activity.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Utils.toast(mContext, "分享失败");
|
||||
}
|
||||
} else {
|
||||
Utils.toast(mContext, "请安装QQ客户端");
|
||||
}
|
||||
break;
|
||||
case "wechat":
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
|
||||
if (!mIWXAPI.isWXAppInstalled() && !PermissionHelper.isGetInstalledListPermissionDisabled(mContext)) {
|
||||
Utils.toast(mContext, mContext.getString(R.string.share_no_wechat_hint));
|
||||
return;
|
||||
}
|
||||
|
||||
WXTextObject textObj = new WXTextObject();
|
||||
textObj.text = text;
|
||||
|
||||
WXMediaMessage msg = new WXMediaMessage();
|
||||
msg.mediaObject = textObj;
|
||||
msg.description = text;
|
||||
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.transaction = buildTransaction("text");
|
||||
req.message = msg;
|
||||
req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
|
||||
mIWXAPI.sendReq(req);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//QQ分享
|
||||
private void qqShare() {
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
|
||||
@ -21,6 +21,7 @@ import com.gh.gamecenter.category.CategoryDirectoryFragment
|
||||
import com.gh.gamecenter.category2.CategoryV2Fragment
|
||||
import com.gh.gamecenter.common.base.adapter.FragmentAdapter
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.databinding.FragmentMainHomeWrapperBinding
|
||||
@ -38,6 +39,8 @@ import com.gh.gamecenter.servers.GameServersTestFragment
|
||||
import com.gh.gamecenter.subject.SubjectFragment
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.halo.assistant.fragment.WebFragment
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import kotlin.math.abs
|
||||
|
||||
class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
@ -576,6 +579,18 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
override fun onEventMainThread(reuse: EBReuse) {
|
||||
super.onEventMainThread(reuse)
|
||||
if (reuse.type == EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE) {
|
||||
mFragmentList.forEachIndexed { index, fragment ->
|
||||
if (fragment is GameCollectionSquareFragment) {
|
||||
mBinding?.viewPager?.currentItem = index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
getCurrentTab()?.isTopViewShow = true
|
||||
|
||||
@ -72,6 +72,8 @@ public class EntranceConsts {
|
||||
public static final String HOST_GAME_COLLECTION_DETAIL = "game_collection_detail";
|
||||
public static final String HOST_GAME_COLLECTION_SQUARE = "game_collection_square";
|
||||
public static final String HOST_GAME_COLLECTION_EDIT = "game_collection_edit";
|
||||
public static final String HOST_GAME_LIBRARY = "game_library";
|
||||
public static final String HOST_HOME_GAME_COLLECTION_SQUARE = "home_game_collection_square";
|
||||
public static final String KEY_DATA = "data";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_MESSAGE_ID = "message_id";
|
||||
|
||||
Reference in New Issue
Block a user