| | |
| | | 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 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 (UserUtil.isAgreeUserProtocol(getApplicationContext())) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | cache = DiskLruCache.open( |
| | | new File(StorageUtils.getCacheDirectory(this) |
| | |
| | | iv_splash = findViewById(R.id.iv_splash); |
| | | |
| | | if (UserUtil.isAgreeUserProtocol(this)) { |
| | | init(); |
| | | nextStep(); |
| | | } else { |
| | | String data = "感谢您对特价一直以来的信任!<br> 我们依照新的监管要求条例更新了<a href=\"http://h5.tejia.yeshitv.com/privacy.html\" style=\"text-decoration: none;\">《隐私政策》</a> 和<a href=\"http://h5.tejia.yeshitv.com/user-protocol.html\" style=\"text-decoration: none;\">《用户协议》</a>,为采取相应安全保护措施,尽力保护您的个人信息安全可控,特向你说明如下:\n" + |
| | | "\t\t<br> 1、您在使用特价各项产品或服务时,将会提供与具体功能相关的个人信息(可能涉及帐号、位置、交易等信息)。\n" + |
| | | "\t\t<br> 2、您可以随时查询、更正、删除您的个人信息,我们也提供账户注销的渠道。\n" + |
| | | "\t\t<br> 3、未经您的再次同意,我们不会将上述信息用于您未授权的其他用途或目的。\n" + |
| | | "\t\t<br> 4、未经监护人同意,我们不会收集使用14周岁以下(含14周岁)未成年人个人信息,且不会利用其信息推送新闻、时政信息、广告等定向推送活动。"; |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | UserUtil.agreeUserProtocol(getApplicationContext()); |
| | | dialog.dismiss(); |
| | | ShoppingApplication.init(ShoppingApplication.application); |
| | | init(); |
| | | //展示弹框 |
| | | 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 init() { |
| | | |
| | | 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(); |
| | |
| | | @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); |
| | | if (requestCode == REQUEST_CODE) { |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PERMISSION_GRANTED) {//选择了“始终允许” |
| | | myRequetPermission(); |
| | | } 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 (grantResults[i] == PERMISSION_DENIED) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("permission", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putBoolean("show", false); |
| | | editor.commit(); |
| | | } |
| | | nextStep(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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") : "")); |
| | | |
| | | } |
| | | |
| | | /** |