From ce2c6bed0adc742416152c2ae696e2c739e91724 Mon Sep 17 00:00:00 2001 From: leafwai Date: Mon, 23 Aug 2021 15:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=85=89=E7=8E=AF=E5=8A=A9=E6=89=8BV5?= =?UTF-8?q?.2.0=E3=80=91=E5=B0=8F=E7=B1=B3=E7=AD=89=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=AE=89=E8=A3=85=E5=BC=95=E5=AF=BC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD-=E5=AE=A2=E6=88=B7=E7=AB=AF=20https://git.gh?= =?UTF-8?q?zs.com/pm/halo-app-issues/-/issues/1410?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gh/common/constant/Config.java | 32 ++++++++++ .../com/gh/common/constant/Constants.java | 6 ++ .../gamecenter/entity/GameGuidePopupEntity.kt | 28 +++++++++ .../gamedetail/GameDetailFragment.kt | 55 ++++++++++++++++-- .../retrofit/service/ApiService.java | 11 ++++ .../drawable-xxxhdpi/ic_install_arrow.webp | Bin 0 -> 166 bytes .../drawable-xxxhdpi/ic_install_close.webp | Bin 0 -> 224 bytes .../res/drawable-xxxhdpi/ic_install_hint.webp | Bin 0 -> 2862 bytes app/src/main/res/drawable/bg_install_hint.xml | 13 +++++ .../main/res/layout/detail_download_item.xml | 55 ++++++++++++++++++ app/src/main/res/values/colors.xml | 2 + 11 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/gh/gamecenter/entity/GameGuidePopupEntity.kt create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_install_arrow.webp create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_install_close.webp create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_install_hint.webp create mode 100644 app/src/main/res/drawable/bg_install_hint.xml diff --git a/app/src/main/java/com/gh/common/constant/Config.java b/app/src/main/java/com/gh/common/constant/Config.java index 39b990b3f5..911525d2f9 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -1,5 +1,6 @@ package com.gh.common.constant; +import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; @@ -12,6 +13,7 @@ import com.gh.common.util.PackageUtils; import com.gh.common.util.SPUtils; import com.gh.gamecenter.BuildConfig; import com.gh.gamecenter.SuggestionActivity; +import com.gh.gamecenter.entity.GameGuidePopupEntity; import com.gh.gamecenter.entity.NewSettingsEntity; import com.gh.gamecenter.entity.NewsEntity; import com.gh.gamecenter.entity.SettingsEntity; @@ -27,6 +29,7 @@ import org.greenrobot.eventbus.EventBus; import java.util.List; import androidx.annotation.Nullable; + import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; @@ -68,6 +71,7 @@ public class Config { private static SettingsEntity mSettingsEntity; private static NewSettingsEntity mNewSettingsEntity; + private static GameGuidePopupEntity mGameGuidePopupEntity; public static final String FIX_DOWNLOAD_KEY = "isFixDownload"; public static final String FIX_PLUGIN_KEY = "isFixPlugin"; @@ -225,6 +229,21 @@ public class Config { return mNewSettingsEntity; } + @Nullable + public static GameGuidePopupEntity getGameGuidePopupEntityEntity() { + if (mGameGuidePopupEntity == null) { + try { + String json = SPUtils.getString(Constants.SP_GAME_DETAIL_INSTALL_GUIDE_CONTENT); + if (!TextUtils.isEmpty(json)) { + mGameGuidePopupEntity = GsonUtils.fromJson(json, GameGuidePopupEntity.class); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return mGameGuidePopupEntity; + } + private static boolean isExistDownloadFilter() { if (getSettings() == null || getSettings().getDownload() == null || getSettings().getDownload().size() == 0) { return false; @@ -277,6 +296,7 @@ public class Config { editor.apply(); } + @SuppressLint("CheckResult") public static void getGhzsSettings() { String channel = HaloApp.getInstance().getChannel(); RetrofitManager.getInstance(HaloApp.getInstance().getApplication()) @@ -312,5 +332,17 @@ public class Config { SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data)); } }); + + RetrofitManager.getInstance(HaloApp.getInstance().getApplication()) + .getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, Constants.API_VERSION) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BiResponse() { + @Override + public void onSuccess(GameGuidePopupEntity data) { + mGameGuidePopupEntity = data; + SPUtils.setString(Constants.SP_GAME_DETAIL_INSTALL_GUIDE_CONTENT, GsonUtils.toJson(data)); + } + }); } } diff --git a/app/src/main/java/com/gh/common/constant/Constants.java b/app/src/main/java/com/gh/common/constant/Constants.java index fe82cf3855..a4915e1450 100644 --- a/app/src/main/java/com/gh/common/constant/Constants.java +++ b/app/src/main/java/com/gh/common/constant/Constants.java @@ -6,6 +6,8 @@ import com.halo.assistant.HaloApp; public class Constants { + public static final String API_VERSION = "v5d2d0"; + public static final int SEND_NEWS_FEEDBACK = 0x126; public static final int SEND_COMMENT_FEEDBACK = 0x127; @@ -217,6 +219,10 @@ public class Constants { public static final String SP_COMMUNITY_HOME_VIDEO_GUIDE = "community_home_video_guide"; // 论坛详情申请版主引导 public static final String SP_FORUM_DETAIL_MODERATOR_GUIDE = "forum_detail_moderator_guide"; + // 游戏详情安装引导 + public static final String SP_GAME_DETAIL_INSTALL_GUIDE = "game_detail_install_guide"; + // 游戏详情安装引导内容 + public static final String SP_GAME_DETAIL_INSTALL_GUIDE_CONTENT = "game_detail_install_guide_content"; //手机号码匹配规则 public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"; diff --git a/app/src/main/java/com/gh/gamecenter/entity/GameGuidePopupEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/GameGuidePopupEntity.kt new file mode 100644 index 0000000000..e3e64c94ea --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/GameGuidePopupEntity.kt @@ -0,0 +1,28 @@ +package com.gh.gamecenter.entity + +import com.google.gson.annotations.SerializedName + +data class GameGuidePopupEntity( + @SerializedName("_id") + var id: String = "", + var content: String = "", + var jump: Jump +) { + data class Jump( + var type: String = "", + var title: String = "", + var link: String = "", + @SerializedName("link_text") + var linkText: String = "", + var text: String = "", + @SerializedName("link_community") + var linkCommunity: CommunityEntity? = null, + var display: Display? = Display(), + ) { + data class Display( + var slide: Boolean = false, + var recommend: Boolean = false, + var refresh: Boolean = false + ) + } +} diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt index db3d49a4b9..94263e6aec 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt @@ -25,6 +25,7 @@ import com.ethanhua.skeleton.Skeleton import com.ethanhua.skeleton.ViewSkeletonScreen import com.gh.base.adapter.FragmentAdapter import com.gh.base.fragment.BaseFragment_TabLayout +import com.gh.common.constant.Config import com.gh.common.constant.Constants import com.gh.common.databind.BindingAdapters import com.gh.common.dialog.ReserveDialogFragment @@ -41,10 +42,7 @@ import com.gh.common.xapk.XapkInstaller import com.gh.common.xapk.XapkUnzipStatus import com.gh.download.DownloadManager import com.gh.download.server.BrowserInstallHelper -import com.gh.gamecenter.DownloadManagerActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.SearchActivity -import com.gh.gamecenter.ShellActivity +import com.gh.gamecenter.* import com.gh.gamecenter.adapter.viewholder.DetailViewHolder import com.gh.gamecenter.entity.* import com.gh.gamecenter.eventbus.* @@ -195,6 +193,15 @@ class GameDetailFragment : NormalFragment() { @BindView(R.id.browser_install_hint_tv) lateinit var mBrowserInstallHintTv: TextView + @BindView(R.id.install_hint_container) + lateinit var mInstallContainer: View + + @BindView(R.id.install_hint_close_iv) + lateinit var mInstallCloseIv: View + + @BindView(R.id.install_hint_tv) + lateinit var mInstallHintTv: TextView + @BindView(R.id.recommendView) lateinit var mRecommendView: View @@ -272,6 +279,7 @@ class GameDetailFragment : NormalFragment() { mRecommendPopupEntity?.popupDetail?.link?.text, downloadEntity.gameId, downloadEntity.name) } } else if (downloadEntity.status == DownloadStatus.done) { + showInstallHint() if (downloadEntity.gameId == mViewModel.game?.id) { hideRecommendView() } @@ -281,6 +289,8 @@ class GameDetailFragment : NormalFragment() { ?: "", mRecommendPopupEntity?.popupDetail?.link?.type, mRecommendPopupEntity?.popupDetail?.link?.text, downloadEntity.gameId, downloadEntity.name) } + } else if (downloadEntity.status == DownloadStatus.downloading) { + showInstallHint() } } } @@ -492,6 +502,18 @@ class GameDetailFragment : NormalFragment() { if (gameResource.status == Status.SUCCESS) { mViewModel.logHistory(gameResource.data!!) mGameEntity = gameResource.data + val isInstalled = PackageUtils.isInstalledFromAllPackage( + requireContext(), + mGameEntity?.simulator?.apk?.packageName + ) + val status = GameUtils.getDownloadBtnText( + requireContext(), + mGameEntity, + PluginLocation.only_game + ) + if (status == getString(R.string.install) && !isInstalled) { + showInstallHint() + } // 添加启动弹窗的相关信息 if (mEntrance.contains(EntranceUtils.ENTRANCE_WELCOME) && mEntrance.countOccurrences("+") <= 1) { @@ -1226,6 +1248,31 @@ class GameDetailFragment : NormalFragment() { } } + private fun showInstallHint() { + val gameGuidePopupEntity = Config.getGameGuidePopupEntityEntity() + if (SPUtils.getBoolean(Constants.SP_GAME_DETAIL_INSTALL_GUIDE, true) && gameGuidePopupEntity != null) { + showReserveGuide(false) + SPUtils.setBoolean(Constants.SP_GAME_DETAIL_RESERVE_GUIDE, false) + mInstallHintTv.text = gameGuidePopupEntity.content + mInstallContainer.visibility = View.VISIBLE + mInstallContainer.setDebouncedClickListener { + requireContext().startActivity( + WebActivity.getIntent( + requireContext(), + gameGuidePopupEntity.jump.link, + gameGuidePopupEntity.jump.title, + false, + 1 + ) + ) + } + mInstallCloseIv.setDebouncedClickListener { + mInstallContainer.visibility = View.GONE + SPUtils.setBoolean(Constants.SP_GAME_DETAIL_INSTALL_GUIDE, false) + } + } + } + private fun initRecommendUI() { val recommendPopupList = mViewModel.recommendPopupLiveData.value mRecommendPopupEntity = RecommendPopupHelper.getRecommendPopup(mViewModel.game, recommendPopupList) diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 2084ee2f37..1e2ff3f26c 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -34,6 +34,7 @@ import com.gh.gamecenter.entity.GameColumnCollection; import com.gh.gamecenter.entity.GameDetailEntity; import com.gh.gamecenter.entity.GameDigestEntity; import com.gh.gamecenter.entity.GameEntity; +import com.gh.gamecenter.entity.GameGuidePopupEntity; import com.gh.gamecenter.entity.ServerPublishEntity; import com.gh.gamecenter.entity.GameVideoInfo; import com.gh.gamecenter.entity.HelpCategoryEntity; @@ -3272,4 +3273,14 @@ public interface ApiService { @POST("bbses/activities/explore/tasks/explore:finish") Single postExplorerFinish(); + /** + * 获取引导浮窗 + */ + @GET("api_go/games_guide_popup") + Single getGameGuidePopup( + @Query("manufacture") String manufacture, + @Query("android_version") String systemVersion, + @Query("model") String model, + @Query("channel") String channel, + @Query("api_version") String apiVersion); } \ No newline at end of file diff --git a/app/src/main/res/drawable-xxxhdpi/ic_install_arrow.webp b/app/src/main/res/drawable-xxxhdpi/ic_install_arrow.webp new file mode 100644 index 0000000000000000000000000000000000000000..34e1bf6cea01c8265abcff7a8e8e7ced795508d0 GIT binary patch literal 166 zcmV;X09pT1Nk&GV00012MM6+kP&iDH0000lAHW9?H$V^wlED5r8?CSgnSjNjt$z>& z{19Z@Z2nO5xXcx@kp%6hu>`Af{vbyX0JWs!;(afe`(P8i8AH)m(3H~D@0EI0000lAHW9?M_`a`q#nTesCKCXy)@Z{3 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_install_hint.webp b/app/src/main/res/drawable-xxxhdpi/ic_install_hint.webp new file mode 100644 index 0000000000000000000000000000000000000000..a76536b295c277e050f9b6c917c292fe2ae2fc4e GIT binary patch literal 2862 zcmWNRdpwg11IM2|HfCFFvoT7ZG1`O>x*r>}9+xz03gu*T7v-pjH%86ze z)j@6@af}e%6JC)nZ&z>Vu0t+we|^9Iem}p@=g0HqaO|)Eu*=7byOX;Y(W;Tf64c_h_Z8ZK>dDB>s_D_+;u z8U_A+Zob^B-HU)xdnkAagPe@`wmcEiJ;|n@W%fO|iaD}q5F2Z7CosD-0}T{0*>0B; z2qq8Dw)F6`!Te8WW8!o;LhvO9RJ-SsF5&sieo?kyd?!G`j5Z5|i*<*c+1$5ncy^E8BIMpy|r}7?C2|(v^#dIi9H`9x!~vGP9cUx=!-u7;ldW5x3W&n?y=^p zNyYEe9zF|Kms9VS>neJC~QdCg5l{yMzDz7-@LEl?Z)S;_x1Oi#(4+mW3eeTUm5Mp>kkP5 zVO9aXNJz9~LeQD~vc0Xhq5sB(3$e|U3k557w(sF*lq5v0eq`6A+z9U*c%xYrA8M|+ z(4Vyu<6rL`w9S|QWScL~^?u7hN#!8PX>MTZS=En>`Q(3=wru?NVPvn&bA~zl^64ey z;DXckSz7DY$Lr=So$ZG1H~N~a4yPcQhkWr`fixG%_~|5s*a#m^)O112p>w-#x27EW z<>oI7Z$GW>m{2@AZ@GOiN!br^>vQU8_9|HI4`6IewJf5~13I%Dh!f=bE$b?>mKiDD zDM%N7Z+e-E&P^+;jZ%oI-m)Nj90=MY7-&6M4tGL;8VxT8lrVuI0!ZPbMIkwMUyc}m z^QpUgecjSKx2q>!eSP=jVdf(V2BRm;@?f*Iuz(3Qo?@5DNW*YbN?5C=xh-v?L$JFf z1KNB%g_tTf4>7-ku90AZ-LX4$5FJJKa|g+kD7Kem(%t@t<<@%z*HV`{GR~AFxJ4nE zdbCOjlhFhbTzGUmJqSxA*r3dX?6_>gre6MkEzd4mwWdCwX7>VRfUZmA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z}a3fyAMEYF`#@gdWT67&f z8g)bJ{PXen`53j-!kt%Swr}W$+CZKl=9fp%@vJKq6<`^O5n)Po7BnFuh!jEv6CFdk zd!uRHn(&pXVKsFV+^C`Ea3ndhU|p1qbc(CwYo*efZMIA*gku3=sb?mkD?YV*fBZf& z`o$^s!&|pWl?uaWihFfsR_Dto5e%6*s*CS~aF&JPM4fSLaD=e@$HBR@j+k2NwO6us zOK%cY8Yfm^vVxLM!qs(r9>JEM$!06_@q#?qo5a}Um^^o`9XBL11j@Xv~dabYl~(;ZB^t9G>?Q0Gz0xIxzQ-f`#rMr0ct^fhyxlrEqqEDkQ%6>LtHfFFObKqV8iedm zVMJOfY(@YM71xKx7!bQ>CLWB(TP@7p*8lfULfhhG)l}f-Zx2dBzKmj)Mc<@eH6at- zV4I3As0+{aWw60MSBvFXq;FE}jdkN8a}N%DD9!f#%qaCS+p@Il%%26bg2Wb@M1U;E zi#Tk47S*1C8z_pr1=96bSdLGI%+DV9ejwX((O0qN`XSuN`$l!rI6`P1of8yBBnKIi zI2HAU=1twA&P@3a)AY|{O-=Mn&sCDDfO|e?bNXBzHh{pviB4hz3QFs! z``Ykq`f}Rj{NMli7|Z!MI<>~a>Sw~WaMhh#Zrv1Gv~VRgC%?<)%Hrp)&aI2-Gj{W{ zgtpX|?{jaK9*<}}7i+RQM-?(uAon~p`bl@V*3-vw-iOeZ{v(@{t2B1X-D|w`?||80 HrxoV^3E{FL literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/bg_install_hint.xml b/app/src/main/res/drawable/bg_install_hint.xml new file mode 100644 index 0000000000..6284917b29 --- /dev/null +++ b/app/src/main/res/drawable/bg_install_hint.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/detail_download_item.xml b/app/src/main/res/layout/detail_download_item.xml index 1d8c7af8df..a6c0a7641d 100644 --- a/app/src/main/res/layout/detail_download_item.xml +++ b/app/src/main/res/layout/detail_download_item.xml @@ -74,6 +74,61 @@ android:layout_marginRight="8dp" /> + + + + + + + + + + + + + + #74FFFF #60D5FF #EDF5FC + #EBFAF7 #b2b2b2 #9a9a9a #3a3a3a @@ -268,6 +269,7 @@ #17C2A1 #0089D1 #00DBA4 + #07B896 #99666666 #6621282E