Files
assistant-android/app/src/main/java/com/gh/gamecenter/SkipActivity.java
2024-04-19 17:32:51 +08:00

513 lines
29 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.gh.gamecenter;
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_BROWSER;
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_PUSH;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ANSWER;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARCHIVE_LOGIN;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARTICLE;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_CATEGORY;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COLUMN;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COLUMN_COLLECTION;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COMMUNITY;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COMMUNITY_COLUMN;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_CREATE_SHORTCUT;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_DOWNLOAD;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_GAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_GAME_COLLECTION_DETAIL;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_GAME_COLLECTION_SQUARE;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_INVOKE_ONLY;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_LIBAO;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_GAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_GROUP;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_QUN;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QUESTION;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_RESTART_GAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_SUGGESTION;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_TOOLBOX;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_UPLOAD_VIDEO;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_USERHOME;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_VIDEO;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_VIDEO_COLLECTION;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_VIDEO_MORE;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_VIDEO_SINGLE;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_VIDEO_STREAMING_DESC;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_VIDEO_STREAMING_HOME;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_WEB;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_DATA;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_GAME_NAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_NAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_PACKAGENAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_PLATFORM;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_PLATFORM_VERSION;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_TO;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_TYPE;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_VERSION;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import androidx.annotation.Nullable;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DirectUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.common.base.activity.BaseActivity;
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.entity.SimpleGameEntity;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.ToastUtils;
import com.gh.gamecenter.entity.SubjectRecommendEntity;
import com.gh.gamecenter.entity.VideoLinkEntity;
import com.gh.gamecenter.feature.utils.PlatformUtils;
import com.gh.gamecenter.login.view.LoginActivity;
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
import com.gh.gamecenter.video.videomanager.VideoManagerActivity;
import com.gh.vspace.VHelper;
import com.gh.vspace.shortcut.OnCreateShortcutResult;
import com.gh.vspace.shortcut.ShortcutManager;
import com.gh.vspace.shortcut.ShortcutPermissionTipsDialog;
import com.lightgame.config.CommonDebug;
import com.lightgame.utils.Utils;
import com.muugi.shortcut.core.Executor;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by LGT on 2016/11/16.
* 链接跳转用
*/
public class SkipActivity extends BaseActivity {
@Override
protected int getLayoutId() {
return R.layout.activity_shell;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri uri = getIntent().getData();
Bundle bundle;
if (uri != null) {
if ("ghzhushou".equals(uri.getScheme())) {
if (CommonDebug.IS_DEBUG) {
Utils.log("SkipActivity:: Uri=>" + uri.toString());
}
String host = uri.getHost();
String path = uri.getPath();
String to = uri.getQueryParameter("to");
String type = uri.getQueryParameter("type");
String name = uri.getQueryParameter("name");
String referer = uri.getQueryParameter("referer");
String id = uri.getQueryParameter("id");
if (!TextUtils.isEmpty(path)) {
path = path.substring(1);
}
String platform = uri.getQueryParameter(KEY_PLATFORM);
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
String gameId = uri.getQueryParameter(EntranceConsts.KEY_GAMEID);
String packageMd5 = uri.getQueryParameter(EntranceConsts.KEY_PACKAGE_MD5);
String isQaFeedbackString = uri.getQueryParameter(EntranceConsts.KEY_IS_QA_FEEDBACK);
String suggestionType = uri.getQueryParameter(KEY_TYPE);
boolean isQaFeedback = !TextUtils.isEmpty(isQaFeedbackString) && isQaFeedbackString.equals("true");
String content = (TextUtils.isEmpty(gameId) || TextUtils.isEmpty(packageMd5)) ?
String.format("%s—V%s—%sV%s",
uri.getQueryParameter(KEY_GAME_NAME),
uri.getQueryParameter(KEY_VERSION),
TextUtils.isEmpty(platformName) ? platform : platformName,
uri.getQueryParameter(KEY_PLATFORM_VERSION)) :
String.format("%s-%s-V%s\n游戏ID%s\n游戏包MD5%s\n",
uri.getQueryParameter(KEY_GAME_NAME),
TextUtils.isEmpty(platformName) ? platform : platformName,
uri.getQueryParameter(KEY_VERSION), gameId, packageMd5);
String qaId = uri.getQueryParameter("qa_id");
String qaContentId = uri.getQueryParameter(EntranceConsts.KEY_QA_CONTENT_ID);
String qaTitle = uri.getQueryParameter(EntranceConsts.KEY_QA_TITLE);
String isFromPushString = uri.getQueryParameter(EntranceConsts.KEY_IS_FROM_PUSH);
boolean isFromPush = !TextUtils.isEmpty(isFromPushString) && isFromPushString.equals("true");
String entrance = isFromPush ? ENTRANCE_PUSH : ENTRANCE_BROWSER;
String pathName = isFromPush ? ENTRANCE_PUSH : "浏览器";
if (host != null) {
Intent intent;
switch (host) {
case HOST_INVOKE_ONLY:
// 仅唤起光环助手,不进入光环页面。用于类似 ContentProvider 的用途
break;
case HOST_CREATE_SHORTCUT:
// 创建桌面快捷方式
createShortcut(uri);
return;
case HOST_ARTICLE:
DirectUtils.directToArticle(this, path, entrance);
break;
case HOST_GAME:
DirectUtils.directToGameDetail(this, path, "", entrance, "true".equals(uri.getQueryParameter("auto_download")), to, null);
break;
case HOST_COLUMN:
DirectUtils.directToSubject(this, path, uri.getQueryParameter(KEY_NAME), entrance, null, false);
break;
case HOST_SUGGESTION:
if (!TextUtils.isEmpty(qaId)) {
DirectUtils.directToQa(this, qaTitle, qaId);
} else {
// 插件反馈跳转到意见反馈分类页
DirectUtils.directToFeedback(this, content, isQaFeedback, qaContentId, true, false, entrance);
}
break;
case HOST_DOWNLOAD:
DirectUtils.directToDownloadManagerAndStartUpdate(this, path, uri.getQueryParameter(KEY_PACKAGENAME), entrance);
break;
case HOST_ANSWER:
DirectUtils.directToAnswerDetail(this, path, entrance, pathName);
break;
case HOST_QUESTION:
DirectUtils.directToQuestionDetail(this, path, entrance, pathName, "");
break;
case HOST_TOOLBOX:
DirectUtils.directToToolbox(this, uri.getQueryParameter("gameId"), uri.getQueryParameter("toolboxUrl"), entrance);
break;
case HOST_COMMUNITY:
DirectUtils.directToHomeCommunityTab(this);
break;
// 社区文章格式一
case "community.article":
DirectUtils.directToCommunityArticle(this, uri.getQueryParameter("articleId"), uri.getQueryParameter("communityId"), entrance, pathName, "");
break;
// 社区文章格式二
case "communities":
String communityId = "";
String typeId = "";
String[] split = path.split("/");
for (String text : split) {
if (TextUtils.isEmpty(communityId)) {
communityId = text;
continue;
}
if (TextUtils.isEmpty(type)) {
type = text;
continue;
}
if (TextUtils.isEmpty(typeId)) {
typeId = text;
}
}
if ("articles".equals(type)) {
DirectUtils.directToCommunityArticle(this, typeId, communityId, entrance, pathName, "");
break;
}
break;
case HOST_VIDEO:
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.HOTTEST_GAME_VIDEO.getValue(),
false, id, entrance, pathName, TextUtils.isEmpty(referer) ? "" : referer, "");
break;
case HOST_UPLOAD_VIDEO://跳转上传视频
String titleParameter = uri.getQueryParameter("title");
String title = TextUtils.isEmpty(titleParameter) ? "" : "#" + titleParameter + "#";
String categoryId = uri.getQueryParameter("category_id");
String link = uri.getQueryParameter("link");
gameId = uri.getQueryParameter("gameId");
String gameName = uri.getQueryParameter("gameName");
String tagActivityId = uri.getQueryParameter("tagActivityId");
String tagActivityName = uri.getQueryParameter("tagActivityName");
VideoLinkEntity linkEntity = new VideoLinkEntity(title, categoryId, link, tagActivityId, tagActivityName);
SimpleGameEntity simpleGameEntity = new SimpleGameEntity(gameId != null ? gameId : "", gameName != null ? gameName : "", "", "");
Bundle nextToBundle = VideoManagerActivity.getVideoManagerBundle(linkEntity, simpleGameEntity, entrance, "");
CheckLoginUtils.checkLogin(this, nextToBundle, true, entrance, () ->
DirectUtils.directToVideoManager(SkipActivity.this, linkEntity, simpleGameEntity, entrance, pathName));
break;
case HOST_VIDEO_SINGLE:
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.getValue(),
false, "", entrance, pathName, TextUtils.isEmpty(referer) ? "" : referer, "");
break;
case HOST_VIDEO_MORE:
gameId = uri.getQueryParameter("gameId");
String act = uri.getQueryParameter("act");
String fieldId = uri.getQueryParameter("fieldId");
String sectionName = uri.getQueryParameter("sectionName");
String paginationType = uri.getQueryParameter("paginationType");//活动分页方式 page filter
String location;
if (!TextUtils.isEmpty(act)) {
location = VideoDetailContainerViewModel.Location.VIDEO_ACTIVITY.getValue();
} else if (!TextUtils.isEmpty(fieldId)) {
location = VideoDetailContainerViewModel.Location.GAME_ZONE.getValue();
} else {
location = path;
}
DirectUtils.directToLegacyVideoDetail(this, path, location,
false, TextUtils.isEmpty(gameId) ? "" : gameId, entrance, pathName, TextUtils.isEmpty(referer) ? "" : referer,
TextUtils.isEmpty(type) ? "" : type, TextUtils.isEmpty(act) ? "" : act, TextUtils.isEmpty(paginationType) ? "page" : paginationType, TextUtils.isEmpty(fieldId) ? "" : fieldId,
TextUtils.isEmpty(sectionName) ? "" : sectionName, false, "");
break;
case HOST_VIDEO_STREAMING_HOME:
DirectUtils.directToHomeVideoTab(this);
break;
case HOST_VIDEO_STREAMING_DESC:
DirectUtils.directToGameDetailVideoStreaming(this, path, entrance);
break;
case HOST_VIDEO_COLLECTION:
DirectUtils.directToGameVideo(this, path, entrance, pathName);
break;
case HOST_QQ:
bundle = new Bundle();
bundle.putString(KEY_TO, HOST_QQ);
bundle.putString(KEY_DATA, path);
EntranceUtils.jumpActivity(this, bundle);
break;
case HOST_QQ_GROUP:
bundle = new Bundle();
bundle.putString(KEY_TO, HOST_QQ_GROUP);
bundle.putString(KEY_DATA, path);
EntranceUtils.jumpActivity(this, bundle);
break;
case HOST_QQ_QUN:
String key = uri.getQueryParameter("key");
bundle = new Bundle();
bundle.putString(KEY_TO, HOST_QQ_GROUP);
bundle.putString(KEY_DATA, key);
EntranceUtils.jumpActivity(this, bundle);
break;
case HOST_WEB:
bundle = new Bundle();
bundle.putString(KEY_TO, HOST_WEB);
bundle.putString(KEY_DATA, to);
bundle.putString(KEY_TYPE, type);
EntranceUtils.jumpActivityCompat(this, bundle);
break;
case EntranceConsts.HOST_VIDEO_DETAIL:
DirectUtils.directToVideoDetail(this, path, entrance, "", "");
break;
case HOST_LIBAO:
DirectUtils.directToGiftDetail(this, path, entrance);
break;
case HOST_USERHOME:
String position = uri.getQueryParameter("position");
String subTypeString = uri.getQueryParameter("sub_type");
String subGameType = uri.getQueryParameter("sub_game_type");
DirectUtils.directToHomeActivity(this, path, subTypeString, subGameType, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), entrance, pathName);
break;
case HOST_COMMUNITY_COLUMN:
CommunityEntity community = new CommunityEntity();
community.setId(uri.getQueryParameter("community_id"));
community.setName(uri.getQueryParameter("community_name"));
String columnId = uri.getQueryParameter("column_id");
DirectUtils.directToCommunityColumn(this, community, columnId, entrance, "");
break;
case HOST_CATEGORY:
title = uri.getQueryParameter("title");
DirectUtils.directCategoryDirectory(this, path, title, entrance, pathName);
break;
case HOST_COLUMN_COLLECTION:
DirectUtils.directToColumnCollection(this, path, -1, entrance, "", "", "", "", null,false);
break;
case EntranceConsts.HOST_BLOCK:
name = uri.getQueryParameter("name");
SubjectRecommendEntity entity = new SubjectRecommendEntity();
entity.setLink(path);
entity.setName(name);
entity.setText(name);
DirectUtils.directToBlock(this, entity, mEntrance, null);
break;
case EntranceConsts.HOST_SERVER_BLOCK:
DirectUtils.directToGameServers(this, entrance, pathName, null);
break;
case EntranceConsts.HOST_AMWAY_BLOCK:
DirectUtils.directToAmway(this, null, entrance, pathName);
break;
case EntranceConsts.HOST_HELP:
name = uri.getQueryParameter("name");
DirectUtils.directToQa(this, name, path);
break;
case EntranceConsts.HOST_HELP_COLLECTION:
name = uri.getQueryParameter("name");
DirectUtils.directToQaCollection(this, name, path);
break;
case EntranceConsts.HOST_GAME_UPLOAD:
DirectUtils.directGameUpload(this, entrance, pathName);
break;
case EntranceConsts.HOST_GAME_ZONE:
String zoneUrl = uri.getQueryParameter("url");
DirectUtils.directGameZone(this, path, zoneUrl, entrance);
break;
case EntranceConsts.HOST_LINK:
try {
String dataString = uri.getQueryParameter("data");
if (!TextUtils.isEmpty(dataString)) {
byte[] linkData = Base64.decode(dataString, Base64.DEFAULT);
String linkDataString = new String(linkData, "UTF-8");
LinkEntity le = GsonUtils.INSTANCE.getGson().fromJson(linkDataString, LinkEntity.class);
DirectUtils.directToLinkPage(this, le, entrance, "", "");
}
} catch (Exception e) {
e.printStackTrace();
toast(e.getMessage());
}
break;
case EntranceConsts.HOST_REAL_NAME:
DirectUtils.directToRealName(this);
break;
case EntranceConsts.HOST_GAME_NEWS:
DirectUtils.directToGameNews(
this,
uri.getQueryParameter(EntranceConsts.KEY_GAME_ID),
uri.getQueryParameter(EntranceConsts.KEY_GAME_NAME),
entrance);
break;
case EntranceConsts.HOST_GAME_CALENDAR:
DirectUtils.directToGameServerCalendar(this, uri.getQueryParameter(EntranceConsts.KEY_GAME_ID), 0);
break;
case EntranceConsts.HOST_HISTORY_APK:
DirectUtils.directToHistoryApk(this, uri.getQueryParameter(EntranceConsts.KEY_GAME_ID));
break;
case EntranceConsts.HOST_FORUM_DETAIL:
String sectionId = uri.getQueryParameter("section_id");
DirectUtils.directForumDetailSection(this, id, sectionId, entrance);
break;
case EntranceConsts.HOST_GAME_RATING_DETAIL:
DirectUtils.directToGameRatingDetail(this, uri.getQueryParameter(EntranceConsts.KEY_GAME_ID), uri.getQueryParameter(EntranceConsts.KEY_COMMENT_ID), entrance);
break;
case EntranceConsts.HOST_FORUM:
DirectUtils.directToHomeCommunityTab(this);
break;
case EntranceConsts.HOST_HELP_AND_FEEDBACK:
if ("vgame".equals(suggestionType)) {
DirectUtils.directToHelpAndFeedback(this, content, isQaFeedback, qaContentId, false, true, entrance);
} else {
DirectUtils.directToHelpAndFeedback(this, content, isQaFeedback, qaContentId, true, false, entrance);
}
break;
case HOST_GAME_COLLECTION_DETAIL:
DirectUtils.directToGameCollectionDetail(this, path, entrance, "", null);
break;
case HOST_GAME_COLLECTION_SQUARE:
DirectUtils.directToGameCollectionSquare(this, entrance, "", "", "", "", "", null);
break;
case HOST_QQ_GAME:
String extJson = uri.getQueryParameter("ext");
try {
JSONObject extJsonObject = new JSONObject(extJson);
String qqGameId = extJsonObject.optString("aid");
DirectUtils.directToQGameById(this, qqGameId);
} catch (JSONException ignored) {
}
break;
case HOST_ARCHIVE_LOGIN:
String gamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
if(CheckLoginUtils.isLogin()) {
VHelper.INSTANCE.updateAuthorizeInfo(true);
} else {
Bundle newBundle = new Bundle();
newBundle.putString(EntranceConsts.KEY_TO, LoginActivity.class.getName());
EntranceUtils.jumpActivity(this, null, newBundle, (resultCode, data) -> {
if(CheckLoginUtils.isLogin()) {
VHelper.INSTANCE.updateAuthorizeInfo(true);
}
VHelper.launch(this, gamePkg, false, false);
finish();
});
return;
}
break;
case HOST_RESTART_GAME:
String restartGamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
VHelper.launch(this, restartGamePkg, false, true);
break;
default:
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
return;
}
}
} else if ("market".equals(uri.getScheme())) {
String host = uri.getHost();
String id = "";
try {
id = uri.getQueryParameter("id");
} catch (UnsupportedOperationException e) {
e.printStackTrace();
}
if (host != null) {
if ("details".equals(host)) {
bundle = new Bundle();
bundle.putString(KEY_TO, EntranceConsts.KEY_MARKET_DETAILS);
bundle.putString(KEY_DATA, id);
EntranceUtils.jumpActivity(this, bundle);
} else {
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
}
}
}
}
finish();
}
/**
* 畅玩助手调用创建游戏桌面图标
*/
private void createShortcut(Uri uri) {
String shortcutGameId = uri.getQueryParameter(EntranceConsts.KEY_GAME_ID);
String shortcutGamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
OnCreateShortcutResult onCreateShortcutResult = new OnCreateShortcutResult() {
@Override
public void showPermissionDialog(@Nullable Executor executor) {
ShortcutPermissionTipsDialog dialog =
new ShortcutPermissionTipsDialog(SkipActivity.this, shortcutGameId, executor);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
finish();
}
});
if (SkipActivity.this.isFinishing()) {
ToastUtils.toast("创建桌面图标失败,请重试");
return;
}
dialog.show();
}
@Override
public void exist() {
Utils.toast(SkipActivity.this, getString(R.string.shortcut_exist));
finish();
}
@Override
public void success() {
Utils.toast(SkipActivity.this, getString(R.string.shortcut_create_success));
finish();
}
@Override
public void failed() {
Utils.toast(SkipActivity.this, getString(R.string.shortcut_create_failed));
finish();
}
};
ShortcutManager.Companion.getInstance().tryCreateShortCut(
this,
shortcutGameId,
shortcutGamePkg,
onCreateShortcutResult);
}
}