| | |
| | | import android.app.Activity; |
| | | import android.app.ActivityManager; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.PackageInfo; |
| | |
| | | import com.alibaba.baichuan.android.trade.callback.AlibcTradeInitCallback; |
| | | import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; |
| | | import com.google.gson.Gson; |
| | | import com.huawei.android.hms.agent.HMSAgent; |
| | | import com.huawei.android.hms.agent.common.handler.ConnectHandler; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.qq.e.ads.splash.SplashAD; |
| | | import com.qq.e.ads.splash.SplashADListener; |
| | | import com.qq.e.comm.managers.GDTADManager; |
| | | import com.qq.e.comm.managers.GDTAdSdk; |
| | | import com.qq.e.comm.managers.setting.GlobalSetting; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.tejia.lijin.app.ShoppingApplication; |
| | | import com.tejia.lijin.app.ui.dialog.PermissionAuthNotifyDialog; |
| | | import com.tejia.lijin.app.ui.dialog.UserGuideDialog; |
| | | import com.tejia.lijin.app.ui.dialog.UserProtocolDialog; |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.wpc.library.okhttp.OkHttpUtils; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import androidx.core.app.ActivityCompat; |
| | | import androidx.core.content.ContextCompat; |
| | | import okhttp3.Call; |
| | | |
| | | import static android.content.pm.PackageManager.PERMISSION_DENIED; |
| | | import static android.content.pm.PackageManager.PERMISSION_GRANTED; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2017/2/20. |
| | | */ |
| | | public class SplashActivity extends BaseActivity implements SplashADListener { |
| | | public class SplashActivity extends Activity implements SplashADListener { |
| | | // 所需的全部权限 |
| | | static final String[] PERMISSIONS = new String[]{ |
| | | Manifest.permission.READ_PHONE_STATE};//, Manifest.permission.READ_EXTERNAL_STORAGE, |
| | |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_splash); |
| | | initView(); |
| | | setShowRecommend(false); |
| | | // TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); |
| | | ActivityManager.RunningTaskInfo info = manager.getRunningTasks(1).get(0); |
| | | int acitivitynum = info.numActivities; |
| | | if (acitivitynum > 1) { |
| | | finish(); |
| | | } |
| | | |
| | | /*同化顶部状态栏*/ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.TRANSPARENT); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(getWindow().getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | if (UserUtil.isAgreeUserProtocol(getApplicationContext())) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.TRANSPARENT); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(getWindow().getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | if (!AlibcTradeSDK.initState.isInitialized() && !AlibcTradeSDK.initState.isInitializing()) |
| | | taobaoInit(); |
| | | |
| | | mPermissionsChecker = new PermissionsChecker(this); |
| | | iv_splash = findViewById(R.id.iv_splash); |
| | | |
| | | /** |
| | | * SDK连接HMS |
| | | */ |
| | | if (MobileUtil.getDeviceBrand().equalsIgnoreCase("HUAWEI") |
| | | || MobileUtil.getDeviceBrand().equalsIgnoreCase("HONOR")) { |
| | | HMSAgent.connect(this, new ConnectHandler() { |
| | | @Override |
| | | public void onConnect(int rst) { |
| | | // Toast.makeText(SplashActivity.this, "HMS connect end:" + rst, Toast.LENGTH_LONG).show(); |
| | | Log.e("mResult", "HMS connect end:" + rst); |
| | | // getToken(); |
| | | } |
| | | }); |
| | | if (UserUtil.isAgreeUserProtocol(this)) { |
| | | nextStep(); |
| | | } else { |
| | | String data = "尊敬的用户:<br>感谢您对" + getResources().getString(R.string.app_name) + "一直以来的信任!<br>"; |
| | | data += "我们非常尊重并保护您的个人信息、隐私。为了更好的保障您的权利,在您使用我们的产品之前,请您务必审慎阅读"; |
| | | data += String.format("<a href='%s'>《隐私政策》</a>和", "http://h5.tejia.yeshitv.com/privacy.html"); |
| | | data += String.format("<a href='%s'>《用户协议》</a>", "http://h5.tejia.yeshitv.com/user-protocol.html"); |
| | | data += "内的所有条款,<b>尤其是:<br>" + |
| | | "1、我们对您的个人信息(包括但不限于<font color='#FF0000'>设备MAC地址、IMEI/AndroidID/OAID/IMSI/ICCID/GAID/MEID</font>等信息)的收集/保存/使用/对外提供/保护等规则条款,以及您的用户权利等条款;<br>" + |
| | | "2、约定我们的限制责任、免责条款;<br>" + |
| | | "3、其他以加粗或斜体字进行标识的重要条款。</b><br>" + |
| | | "如您对协议有任何疑虑,可通过电子邮箱: tjapp@qq.com 向我们询问,我们将为您竭诚解答。您点击“同意”的行为代表您已阅读完毕并接受以上协议全部条款。如您同意以上协议内容,请您点击“同意”,开始使用您的产品。"; |
| | | showUserProtocolAndGuide(data); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void myRequetPermission() { |
| | | if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PERMISSION_GRANTED) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("permission", Context.MODE_PRIVATE); |
| | | //是否需要再次请求权限 |
| | | if (sharedPreferences.getBoolean("show", true)) |
| | | ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | else { |
| | | nextStep(); |
| | | } |
| | | } else { |
| | | nextStep(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 显示用户协议与弹窗 |
| | | */ |
| | | private void showUserProtocolAndGuide(String protocol) { |
| | | |
| | | final UserProtocolDialog.Builder dialogBuilder = new UserProtocolDialog.Builder(this).setData(protocol).setNegativeButton(null, new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | finish(); |
| | | } |
| | | }).setPositiveButton(null, new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | UserUtil.agreeUserProtocol(getApplicationContext()); |
| | | dialog.dismiss(); |
| | | //展示弹框 |
| | | new PermissionAuthNotifyDialog.Builder(SplashActivity.this).setPositiveButton(null, new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | myRequetPermission(); |
| | | } |
| | | }).create().show(); |
| | | //请求权限 |
| | | } |
| | | }); |
| | | dialogBuilder.create().show(); |
| | | |
| | | } |
| | | |
| | | |
| | | private void nextStep() { |
| | | ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); |
| | | ActivityManager.RunningTaskInfo info = manager.getRunningTasks(1).get(0); |
| | | int acitivitynum = info.numActivities; |
| | | if (acitivitynum > 1) { |
| | | finish(); |
| | | } |
| | | if (!ShoppingApplication.init) { |
| | | ShoppingApplication.init(ShoppingApplication.application); |
| | | } |
| | | |
| | | if (!AlibcTradeSDK.initState.isInitialized() && !AlibcTradeSDK.initState.isInitializing()) |
| | | taobaoInit(); |
| | | getSystemParams(); |
| | | setGoodsIndex(); |
| | | getHomeNavbar(); |
| | | jumpActivitry();//跳转主页 |
| | | } |
| | | |
| | | |
| | | private void initView() { |
| | | ll_ad = findViewById(R.id.ll_ad); |
| | |
| | | @Override |
| | | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { |
| | | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| | | if (requestCode == 1024 && hasAllPermissionsGranted(grantResults)) { |
| | | GDTAdInfo adInfo = AdUtil.getGDTADInfo(getApplicationContext()); |
| | | if(adInfo==null) |
| | | return; |
| | | fetchSplashAD(this, container, skipView, adInfo.getSplashPid(), this, 0); |
| | | } else { |
| | | // 如果用户没有授权,那么应该说明意图,引导用户去设置里面授权。 |
| | | Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show(); |
| | | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | intent.setData(Uri.parse("package:" + getPackageName())); |
| | | startActivity(intent); |
| | | finish(); |
| | | if (requestCode == REQUEST_CODE) { |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PERMISSION_GRANTED) {//选择了“始终允许” |
| | | myRequetPermission(); |
| | | } else { |
| | | //拒绝了授权 |
| | | if (grantResults[i] == PERMISSION_DENIED) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("permission", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putBoolean("show", false); |
| | | editor.commit(); |
| | | } |
| | | nextStep(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | // isHomeJump = false; |
| | | // startPermissionsActivity(); |
| | | // } else { |
| | | jumpActivitry();//跳转主页 |
| | | // } |
| | | |
| | | if (canJump) { |
| | |
| | | GDTAdInfo info = new Gson().fromJson(ad.toString(), GDTAdInfo.class); |
| | | if (info != null) { |
| | | AdUtil.saveGDTADInfo(getApplicationContext(), info); |
| | | GDTADManager.getInstance().initWith(SplashActivity.this, info.getAppId()); |
| | | GlobalSetting.setEnableCollectAppInstallStatus(false); |
| | | GDTAdSdk.init(SplashActivity.this, info.getAppId()); |
| | | loadAD(); |
| | | iv_splash.postDelayed(new Runnable() { |
| | | @Override |
| | |
| | | OkHttpUtils.getInstance().cancelTag(tag2); |
| | | OkHttpUtils.getInstance().cancelTag(tag3); |
| | | handler.removeCallbacksAndMessages(null); |
| | | } |
| | | |
| | | private void startPermissionsActivity() { |
| | | PermissionsActivity.startActivityForResult(this, REQUEST_CODE, true, PERMISSIONS); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onADClicked() { |
| | | Log.i("AD_DEMO", "SplashADClicked clickUrl: " |
| | | + (splashAD.getExt() != null ? splashAD.getExt().get("clickUrl") : "")); |
| | | |
| | | } |
| | | |
| | | /** |