Compare commits

...

8 Commits

10 changed files with 125 additions and 112 deletions

View File

@ -50,6 +50,7 @@ android {
GH_104 {} GH_104 {}
GH_106 {} GH_106 {}
GH_107 {} GH_107 {}
GH_108 {}
GH_109 {} GH_109 {}
GH_110 {} GH_110 {}
GH_111 {} GH_111 {}
@ -57,6 +58,7 @@ android {
GH_114 {} GH_114 {}
GH_115 {} GH_115 {}
GH_116 {} GH_116 {}
GH_117 {}
GH_118 {} GH_118 {}
GH_119 {} GH_119 {}
GH_120 {} GH_120 {}

View File

@ -61,7 +61,7 @@
android:value="81DB144D555386A38A70B833537EC256" /> android:value="81DB144D555386A38A70B833537EC256" />
<meta-data <meta-data
android:name="TD_CHANNEL_ID" android:name="TD_CHANNEL_ID"
android:value="GH_TEST"/> android:value="${CHANNEL_VALUE}"/>
<!--android:value="${CHANNEL_VALUE}"--> <!--android:value="${CHANNEL_VALUE}"-->
<!-- MTA --> <!-- MTA -->
@ -70,7 +70,7 @@
android:value="APV567FTBS7J"/> android:value="APV567FTBS7J"/>
<meta-data <meta-data
android:name="InstallChannel" android:name="InstallChannel"
android:value="GH_TEST"/> android:value="${CHANNEL_VALUE}"/>
<!--android:value="${CHANNEL_VALUE}"--> <!--android:value="${CHANNEL_VALUE}"-->
<activity <activity

View File

@ -17,6 +17,7 @@ import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils; import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils; import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils; import com.gh.common.util.FileUtils;
import com.gh.common.util.GameUtils;
import com.gh.common.util.NetworkUtils; import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils; import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils; import com.gh.common.util.PlatformUtils;
@ -229,49 +230,12 @@ public abstract class BaseDetailActivity extends BaseActivity implements View.On
} }
} }
} else { } else {
int doneCount = 0; // 下载完成数量 String status = GameUtils.getDownloadBtnText(this, gameEntity);
int pluginCount = 0; // 可插件化数量 if ("插件化".equals(status)) {
int updateCount = 0; // 可更新数量
int installCount = 0; // 已安装数量
DownloadEntity downloadEntity;
for (ApkEntity apkEntity : gameEntity.getApk()) {
downloadEntity = DownloadManager.getInstance(this).get(apkEntity.getUrl());
if (downloadEntity != null) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
} else if (downloadEntity.isPluggable()) {
pluginCount++;
} else if (downloadEntity.isUpdate()) {
updateCount++;
}
}
if (PackageManager.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
updateCount++;
}
if (PackageManager.isInstalled(apkEntity.getPackageName())) {
if (!PackageUtils.isSignature(this, apkEntity.getPackageName())) {
pluginCount++;
} else {
installCount++;
}
}
}
String status;
if (doneCount != 0) {
status = "安装";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (pluginCount != 0) {
status = "插件化";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_plugin_style); detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if (updateCount != 0) { } else if ("打开".equals(status)) {
status = "更新";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (installCount != 0) {
status = "打开";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_launch_style); detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else { } else {
status = "下载";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style); detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style);
} }

View File

@ -169,58 +169,9 @@ public class DownloadItemUtils {
GameEntity gameEntity, GameEntity gameEntity,
boolean isShowPlatform) { boolean isShowPlatform) {
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn);
ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap(); ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
// 更新下载按钮状态
int doneCount = 0; // 下载完成数量
int pluginCount = 0; // 可插件化数量
int updateCount = 0; // 可更新数量
int installCount = 0; // 已安装数量
if (entryMap != null && !entryMap.isEmpty()) {
DownloadEntity downloadEntity;
for (String key : entryMap.keySet()) {
downloadEntity = entryMap.get(key);
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
} else if (downloadEntity.isPluggable()) {
pluginCount++;
} else if (downloadEntity.isUpdate()) {
updateCount++;
}
}
}
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (PackageManager.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
updateCount++;
}
if (PackageManager.isInstalled(apkEntity.getPackageName())) {
if (!PackageUtils.isSignature(context, apkEntity.getPackageName())) {
pluginCount++;
} else {
installCount++;
}
}
}
downloadBtn.setTextColor(Color.WHITE);
if (doneCount != 0) {
downloadBtn.setText("安装");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (pluginCount != 0) {
downloadBtn.setText("插件化");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if (updateCount != 0) {
downloadBtn.setText("更新");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (installCount != 0) {
downloadBtn.setText("打开");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else {
downloadBtn.setText("下载");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
if (entryMap != null && !entryMap.isEmpty()) { if (entryMap != null && !entryMap.isEmpty()) {
DownloadEntity downloadEntity; DownloadEntity downloadEntity;

View File

@ -2,10 +2,19 @@ package com.gh.common.util;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;
import com.gh.base.AppController; import com.gh.base.AppController;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
import com.gh.gamecenter.GameDetailActivity; import com.gh.gamecenter.GameDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.manager.PackageManager;
/** /**
* Created by LGT on 2016/9/29. * Created by LGT on 2016/9/29.
@ -34,4 +43,66 @@ public class GameUtils {
context.startActivity(intent); context.startActivity(intent);
} }
/**
* 设置下载按钮状态
*/
public static void setDownloadBtnStatus(Context context, GameEntity gameEntity, TextView downloadBtn) {
String status = getDownloadBtnText(context, gameEntity);
downloadBtn.setTextColor(Color.WHITE);
downloadBtn.setText(status);
if ("插件化".equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if ("打开".equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
}
/**
* 获取下载按钮文案
*/
public static String getDownloadBtnText(Context context, GameEntity gameEntity) {
int doneCount = 0; // 下载完成数量
int pluginCount = 0; // 可插件化数量
int updateCount = 0; // 可更新数量
int installCount = 0; // 已安装数量
DownloadEntity downloadEntity;
Object gh_id;
for (ApkEntity apkEntity : gameEntity.getApk()) {
downloadEntity = DownloadManager.getInstance(context).get(apkEntity.getUrl());
if (downloadEntity != null) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
} else if (downloadEntity.isPluggable()) {
pluginCount++;
} else if (downloadEntity.isUpdate()) {
updateCount++;
}
}
if (PackageManager.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
updateCount++;
}
if (PackageManager.isInstalled(apkEntity.getPackageName())) {
gh_id = PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_id");
if (!PackageUtils.isSignature(context, apkEntity.getPackageName())) {
pluginCount++;
} else if (gh_id == null || gh_id.equals(gameEntity.getId())) {
installCount++;
}
}
}
if (doneCount != 0) {
return "安装";
} else if (pluginCount != 0) {
return "插件化";
} else if (updateCount != 0) {
return "更新";
} else if (installCount != 0) {
return "打开";
} else {
return "下载";
}
}
} }

View File

@ -78,8 +78,8 @@ public class HttpsUtils {
} }
mSSLSocketFactory = sslContext.getSocketFactory(); mSSLSocketFactory = sslContext.getSocketFactory();
HttpsURLConnection.setDefaultSSLSocketFactory(mSSLSocketFactory); // HttpsURLConnection.setDefaultSSLSocketFactory(mSSLSocketFactory);
HttpsURLConnection.setDefaultHostnameVerifier(mHostnameVerifier); // HttpsURLConnection.setDefaultHostnameVerifier(mHostnameVerifier);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -113,24 +113,25 @@ public class HttpsUtils {
} }
public static HttpsURLConnection getHttpsURLConnection(URL url) throws Exception { public static HttpsURLConnection getHttpsURLConnection(URL url) throws Exception {
if (mSSLSocketFactory == null || mHostnameVerifier == null) { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
if ("apk2.ghzhushou.com".equals(url.getHost())
|| "download.ghzhushou.com".equals(url.getHost())) {
if (mSSLSocketFactory == null || mHostnameVerifier == null) {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, TRUST_MANAGERS, null);
mSSLSocketFactory = sslContext.getSocketFactory();
mHostnameVerifier = HOSTNAME_VERIFIER;
}
httpsURLConnection.setSSLSocketFactory(mSSLSocketFactory);
httpsURLConnection.setHostnameVerifier(mHostnameVerifier);
} else {
SSLContext sslContext = SSLContext.getInstance("TLS"); SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, TRUST_MANAGERS, null); sslContext.init(null, TRUST_MANAGERS, null);
mSSLSocketFactory = sslContext.getSocketFactory(); httpsURLConnection.setSSLSocketFactory(sslContext.getSocketFactory());
httpsURLConnection.setHostnameVerifier(HOSTNAME_VERIFIER);
mHostnameVerifier = HOSTNAME_VERIFIER;
HttpsURLConnection.setDefaultSSLSocketFactory(mSSLSocketFactory);
HttpsURLConnection.setDefaultHostnameVerifier(mHostnameVerifier);
} else {
if (HttpsURLConnection.getDefaultSSLSocketFactory() != mSSLSocketFactory) {
HttpsURLConnection.setDefaultSSLSocketFactory(mSSLSocketFactory);
}
if (HttpsURLConnection.getDefaultHostnameVerifier() != mHostnameVerifier) {
HttpsURLConnection.setDefaultHostnameVerifier(mHostnameVerifier);
}
} }
return (HttpsURLConnection) url.openConnection(); return httpsURLConnection;
} }
} }

View File

@ -371,7 +371,13 @@ public class ShareUtils {
Intent sendIntent = new Intent(Intent.ACTION_VIEW, Uri.parse( "smsto:" )); Intent sendIntent = new Intent(Intent.ACTION_VIEW, Uri.parse( "smsto:" ));
sendIntent.putExtra( "sms_body", smsBody); sendIntent.putExtra( "sms_body", smsBody);
sendIntent.setType( "vnd.android-dir/mms-sms" ); sendIntent.setType( "vnd.android-dir/mms-sms" );
context.startActivity(sendIntent);
try {
context.startActivity(sendIntent);
} catch (Exception e) {
Utils.toast(context, "系统异常,分享失败");
e.printStackTrace();
}
popupWindow.dismiss(); popupWindow.dismiss();
} }

View File

@ -41,7 +41,11 @@ public class SkipActivity extends BaseActivity {
intent.putExtra("id", id); intent.putExtra("id", id);
intent.putExtra("name", getIntent().getData().getQueryParameter("name")); intent.putExtra("name", getIntent().getData().getQueryParameter("name"));
} else if ("suggestion".equals(host)) { } else if ("suggestion".equals(host)) {
intent.putExtra("content", getIntent().getData().getQueryParameter("content")); Uri uri = getIntent().getData();
String content = "" + uri.getQueryParameter("game_name")
+ "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform"))
+ "-V" + uri.getQueryParameter("version") + "";
intent.putExtra("content", content);
intent.setClass(this, SuggestionActivity.class); intent.setClass(this, SuggestionActivity.class);
} }
} else { } else {

View File

@ -18,13 +18,19 @@ import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils; import com.gh.common.util.DisplayUtils;
import com.gh.common.util.GameUtils; import com.gh.common.util.GameUtils;
import com.gh.common.util.GameViewUtils; import com.gh.common.util.GameViewUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.view.CardLinearLayout; import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.DownloadDialog; import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
import com.gh.gamecenter.R; import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder; import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.listener.OnCallBackListener; import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.DataCollectionManager; import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest; import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -168,6 +174,7 @@ public class SearchGameDetailFragmentAdapter extends RecyclerView.Adapter<GameNo
viewHolder.downloadBtn.setText("暂无"); viewHolder.downloadBtn.setText("暂无");
viewHolder.downloadBtn.setClickable(false); viewHolder.downloadBtn.setClickable(false);
} else { } else {
GameUtils.setDownloadBtnStatus(context, gameEntity, viewHolder.downloadBtn);
viewHolder.downloadBtn.setVisibility(View.VISIBLE); viewHolder.downloadBtn.setVisibility(View.VISIBLE);
viewHolder.downloadBtn.setOnClickListener(new OnClickListener() { viewHolder.downloadBtn.setOnClickListener(new OnClickListener() {
@Override @Override

View File

@ -18,13 +18,19 @@ import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils; import com.gh.common.util.DisplayUtils;
import com.gh.common.util.GameUtils; import com.gh.common.util.GameUtils;
import com.gh.common.util.GameViewUtils; import com.gh.common.util.GameViewUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.view.CardLinearLayout; import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.DownloadDialog; import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
import com.gh.gamecenter.R; import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder; import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.listener.OnCallBackListener; import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.DataCollectionManager; import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest; import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -161,6 +167,7 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
viewHolder.downloadBtn.setText("暂无"); viewHolder.downloadBtn.setText("暂无");
viewHolder.downloadBtn.setClickable(false); viewHolder.downloadBtn.setClickable(false);
} else { } else {
GameUtils.setDownloadBtnStatus(context, gameEntity, viewHolder.downloadBtn);
viewHolder.downloadBtn.setVisibility(View.VISIBLE); viewHolder.downloadBtn.setVisibility(View.VISIBLE);
viewHolder.downloadBtn.setOnClickListener(new View.OnClickListener() { viewHolder.downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override