Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_highgold
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_highgold
Commits
6d6902f1
Commit
6d6902f1
authored
Jun 30, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加阅读赚钱
parent
3555a778
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1244 additions
and
6 deletions
+1244
-6
build.gradle
highgold/app/build.gradle
+5
-0
AndroidManifest.xml
highgold/app/src/main/AndroidManifest.xml
+1
-0
MintsApplication.java
...pp/src/main/java/com/mints/highgold/MintsApplication.java
+25
-0
WxLoginPresenter.java
...a/com/mints/highgold/mvp/presenters/WxLoginPresenter.java
+61
-1
LoanService.java
...app/src/main/java/com/mints/highgold/net/LoanService.java
+8
-0
AdWebActivity.java
...n/java/com/mints/highgold/ui/activitys/AdWebActivity.java
+1068
-0
WxLoginActivity.java
...java/com/mints/highgold/ui/activitys/WxLoginActivity.java
+1
-4
MainFragment.java
...ain/java/com/mints/highgold/ui/fragment/MainFragment.java
+3
-1
SystemUtils.java
...p/src/main/java/com/mints/highgold/utils/SystemUtils.java
+29
-0
activity_adweb.xml
highgold/app/src/main/res/layout/activity_adweb.xml
+43
-0
No files found.
highgold/app/build.gradle
View file @
6d6902f1
...
...
@@ -242,6 +242,7 @@ dependencies {
implementation
(
name:
'x5fit-1.2.2'
,
ext:
'aar'
)
implementation
(
name:
'gdtfit-1.2.2'
,
ext:
'aar'
)
implementation
files
(
"libs/qq_x5.jar"
)
// 鱼丸盒子
implementation
(
name:
'xzzq_ywsdk_1.0.6'
,
ext:
'aar'
)
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41"
...
...
@@ -305,6 +306,10 @@ dependencies {
// 多盟
implementation
(
name:
'domob_rvads_1.0.0'
,
ext:
'aar'
)
implementation
'com.google.protobuf:protobuf-lite:3.0.0'
// 酷问新闻
// implementation 'com.tencent.tbs.tbssdk:sdk:43903'
implementation
'com.liulishuo.filedownloader:library:1.7.4'
testImplementation
'junit:junit:4.12'
...
...
highgold/app/src/main/AndroidManifest.xml
View file @
6d6902f1
...
...
@@ -151,6 +151,7 @@
<activity
android:name=
".ui.activitys.SettingActivity"
/>
<activity
android:name=
".ui.activitys.PhoneActivity"
/>
<activity
android:name=
".ui.activitys.EraseActivity"
/>
<activity
android:name=
".ui.activitys.AdWebActivity"
/>
<activity
android:name=
".ui.activitys.WebActivity"
android:windowSoftInputMode=
"adjustResize"
/>
...
...
highgold/app/src/main/java/com/mints/highgold/MintsApplication.java
View file @
6d6902f1
...
...
@@ -18,6 +18,7 @@ import com.component.dly.xzzq_ywsdk.YwSDK;
import
com.downloader.PRDownloader
;
import
com.downloader.PRDownloaderConfig
;
import
com.lechuan.midunovel.view.FoxSDK
;
import
com.liulishuo.filedownloader.FileDownloader
;
import
com.mintegral.msdk.MIntegralSDK
;
import
com.mintegral.msdk.out.MIntegralSDKFactory
;
import
com.mints.highgold.common.AppConfig
;
...
...
@@ -43,6 +44,7 @@ import com.orhanobut.logger.FormatStrategy;
import
com.orhanobut.logger.Logger
;
import
com.orhanobut.logger.PrettyFormatStrategy
;
import
com.tencent.ep.shanhuad.adpublic.ShanHuAD
;
import
com.tencent.smtt.sdk.QbSdk
;
import
com.tendcloud.tenddata.TCAgent
;
import
com.tmsdk.module.coin.AbsTMSConfig
;
import
com.tmsdk.module.coin.TMSDKContext
;
...
...
@@ -159,6 +161,9 @@ public class MintsApplication extends MultiDexApplication {
//移动安装联盟 获取OAID等设备标识符
initMiitHelper
();
// 酷问新闻
initPipi
();
// 机型适配
initRudenessScreen
();
...
...
@@ -236,6 +241,7 @@ public class MintsApplication extends MultiDexApplication {
// 极光一键登录
initJLogin
();
}
/**
...
...
@@ -479,6 +485,25 @@ public class MintsApplication extends MultiDexApplication {
});
}
/**
* 酷问新闻
*/
private
void
initPipi
()
{
FileDownloader
.
setup
(
this
);
QbSdk
.
PreInitCallback
cb
=
new
QbSdk
.
PreInitCallback
()
{
@Override
public
void
onViewInitFinished
(
boolean
arg0
)
{
LogUtil
.
d
(
TAG
,
"onViewInitFinished is "
+
arg0
);
}
@Override
public
void
onCoreInitFinished
()
{
}
};
//x5内核初始化接口
QbSdk
.
initX5Environment
(
this
,
cb
);
}
/**
* app退出
*/
...
...
highgold/app/src/main/java/com/mints/highgold/mvp/presenters/WxLoginPresenter.java
View file @
6d6902f1
...
...
@@ -30,7 +30,7 @@ public class WxLoginPresenter extends BasePresenter<WxLoginView> {
private
UserBean
.
ConsumerBean
consumer
;
/**
* 登录
*
微信
登录
*/
public
void
login
(
Context
context
,
String
wxInfo
)
{
view
.
showLoading
(
"加载中..."
);
...
...
@@ -89,6 +89,66 @@ public class WxLoginPresenter extends BasePresenter<WxLoginView> {
});
}
/**
* 极光一键登录
*/
public
void
jPushlogin
(
Context
context
,
String
token
)
{
view
.
showLoading
(
"加载中..."
);
HashMap
<
String
,
Object
>
vo
=
new
HashMap
<>();
try
{
vo
.
put
(
"shumeiId"
,
ShumeiManager
.
getInstance
().
getShumeiDeviceId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
vo
.
put
(
"device"
,
new
DeviceUuidFactory
(
context
).
getDeviceUuid
().
toString
());
vo
.
put
(
"loginToken"
,
token
);
AppHttpManager
.
getInstance
(
loanApplication
)
.
call
(
loanService
.
jPushlogin
(
vo
),
new
BaseSubscriber
<
BaseResponse
<
UserBean
>>()
{
@Override
public
void
onCompleted
()
{
if
(
isLinkView
())
return
;
view
.
hideLoading
();
}
@Override
public
void
onError
(
Throwable
e
)
{
if
(
isLinkView
())
return
;
view
.
hideLoading
();
view
.
showToast
(
e
.
getMessage
());
}
@Override
public
void
onNext
(
BaseResponse
<
UserBean
>
baseResponse
)
{
if
(
isLinkView
())
return
;
int
code
=
baseResponse
.
getStatus
();
String
message
=
baseResponse
.
getMessage
();
UserBean
data
=
baseResponse
.
getData
();
switch
(
code
)
{
case
200
:
//成功
if
(
data
!=
null
)
{
UserManager
.
getInstance
().
saveUserInfo
(
data
);
consumer
=
data
.
getConsumer
();
if
(
consumer
!=
null
)
{
saveTerminalInfo
(
context
);
}
view
.
loginSuc
();
}
break
;
default
:
view
.
showToast
(
message
);
break
;
}
}
});
}
/**
* 提交设备信息
*
...
...
highgold/app/src/main/java/com/mints/highgold/net/LoanService.java
View file @
6d6902f1
...
...
@@ -91,6 +91,14 @@ public interface LoanService {
@POST
(
"api/v125/wechatlogin"
)
Observable
<
BaseResponse
<
UserBean
>>
wechatlogin
(
@Body
Map
<
String
,
Object
>
vo
);
/**
* 极光一键登录
*
* @return
*/
@POST
(
"api/v125/JPushlogin"
)
Observable
<
BaseResponse
<
UserBean
>>
jPushlogin
(
@Body
Map
<
String
,
Object
>
vo
);
/**
* 注册极光设备
...
...
highgold/app/src/main/java/com/mints/highgold/ui/activitys/AdWebActivity.java
0 → 100755
View file @
6d6902f1
package
com
.
mints
.
highgold
.
ui
.
activitys
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.ActivityNotFoundException
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.provider.Settings
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.RequiresApi
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.FileProvider
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.app.AppCompatActivity
;
import
android.telephony.TelephonyManager
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.webkit.JavascriptInterface
;
import
android.webkit.JsResult
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.target.SimpleTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.liulishuo.filedownloader.BaseDownloadTask
;
import
com.liulishuo.filedownloader.FileDownloadSampleListener
;
import
com.liulishuo.filedownloader.FileDownloader
;
import
com.mints.highgold.MintsApplication
;
import
com.mints.highgold.R
;
import
com.mints.highgold.common.Constant
;
import
com.mints.highgold.common.DeviceInfo
;
import
com.mints.highgold.manager.UserManager
;
import
com.mints.highgold.utils.LogUtil
;
import
com.mints.highgold.utils.SystemUtils
;
import
com.tencent.smtt.sdk.WebChromeClient
;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebViewClient
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URISyntaxException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
AdWebActivity
extends
AppCompatActivity
{
private
static
final
String
TAG
=
AdWebActivity
.
class
.
getSimpleName
();
private
static
final
int
REQUEST_CODE
=
0
;
//请求码
//配置需要动态申请的权限
private
static
final
String
[]
permissions
=
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
READ_PHONE_STATE
,
Manifest
.
permission
.
INTERNET
};
private
AlertDialog
mPermissionDialog
;
private
String
imei
;
private
String
meid
=
""
;
private
String
oaid
=
""
;
private
String
androidid
=
""
;
private
String
downUrlLocal
=
""
;
private
String
packagenameLocal
=
""
;
private
WebView
webView
;
private
SwipeRefreshLayout
swipeLayout
;
private
TextView
tv_start_download
;
private
Button
btn
;
private
List
<
String
>
mPermissionList
=
new
ArrayList
<>();
public
static
final
String
AUTHORITY
=
Constant
.
MINTS_PKG_NAME
+
".fileprovider"
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_adweb
);
webView
=
findViewById
(
R
.
id
.
webview
);
btn
=
findViewById
(
R
.
id
.
btn
);
swipeLayout
=
findViewById
(
R
.
id
.
swipe_container
);
tv_start_download
=
findViewById
(
R
.
id
.
tv_start_download
);
swipeLayout
.
setEnabled
(
false
);
//set webView
initWebView
();
//返回键
showBackBtn
();
//Android6.0需要动态获取权限
initPermission
();
//下拉刷新
swipeLayout
.
setColorScheme
(
R
.
color
.
main_mints
,
R
.
color
.
main_mints
,
R
.
color
.
main_mints
,
R
.
color
.
main_mints
);
swipeLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
@Override
public
void
onRefresh
()
{
//重新刷新页面
webView
.
loadUrl
(
webView
.
getUrl
());
}
});
btn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
openBrowser
(
webView
.
getUrl
());
}
});
//下载按钮触发事件
tv_start_download
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
//异常判断
if
(
TextUtils
.
isEmpty
(
downUrlLocal
))
{
Toast
.
makeText
(
AdWebActivity
.
this
,
"下载连接异常"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
//存在立即打开
final
boolean
isInstalled
=
SystemUtils
.
isAppInstalled
(
AdWebActivity
.
this
,
packagenameLocal
);
if
(
isInstalled
)
{
doStartApplicationWithPackageName
(
packagenameLocal
);
return
;
}
//执行下载
int
last
=
downUrlLocal
.
lastIndexOf
(
"/"
)
+
1
;
String
apkName
=
downUrlLocal
.
substring
(
last
);
if
(!
apkName
.
contains
(
".apk"
))
{
if
(
apkName
.
length
()
>
10
)
{
apkName
=
apkName
.
substring
(
apkName
.
length
()
-
10
);
}
apkName
+=
".apk"
;
}
String
downloadPath
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
File
.
separator
+
"kuwanzhuan"
+
File
.
separator
+
apkName
;
downLoadApp
(
apkName
,
downloadPath
,
downUrlLocal
,
tv_start_download
);
//下载通知后台,js交互
webView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
loadUrl
(
"javascript:startDownApp()"
);
}
});
}
});
}
@SuppressLint
(
"JavascriptInterface"
)
private
void
initWebView
()
{
//声明WebSettings子类
WebSettings
webSettings
=
webView
.
getSettings
();
//如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
webSettings
.
setJavaScriptEnabled
(
true
);
//设置自适应屏幕,两者合用
webSettings
.
setUseWideViewPort
(
true
);
//将图片调整到适合webview的大小
webSettings
.
setLoadWithOverviewMode
(
true
);
// 缩放至屏幕的大小
//其他细节操作
webSettings
.
setCacheMode
(
WebSettings
.
LOAD_NORMAL
);
//关闭webview中缓存
webSettings
.
setAllowFileAccess
(
true
);
//设置可以访问文件
webSettings
.
setJavaScriptCanOpenWindowsAutomatically
(
true
);
//支持通过JS打开新窗口
webSettings
.
setLoadsImagesAutomatically
(
true
);
//支持自动加载图片
webSettings
.
setDefaultTextEncodingName
(
"utf-8"
);
//设置编码格式
webView
.
addJavascriptInterface
(
AdWebActivity
.
this
,
"test"
);
webSettings
.
setAllowFileAccess
(
true
);
// 允许访问文件
webSettings
.
setSupportZoom
(
true
);
// 支持缩放
webSettings
.
setLoadWithOverviewMode
(
true
);
webView
.
setScrollBarStyle
(
View
.
SCROLLBARS_INSIDE_OVERLAY
);
webSettings
.
setRenderPriority
(
WebSettings
.
RenderPriority
.
HIGH
);
webSettings
.
setLayoutAlgorithm
(
WebSettings
.
LayoutAlgorithm
.
SINGLE_COLUMN
);
webSettings
.
setAppCacheEnabled
(
true
);
webSettings
.
setSaveFormData
(
false
);
webSettings
.
setDomStorageEnabled
(
true
);
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
webSettings
.
setLoadsImagesAutomatically
(
true
);
}
else
{
webSettings
.
setLoadsImagesAutomatically
(
false
);
}
webSettings
.
setUseWideViewPort
(
true
);
// 关键点
webSettings
.
setAllowFileAccessFromFileURLs
(
false
);
webSettings
.
setAllowUniversalAccessFromFileURLs
(
false
);
webSettings
.
setJavaScriptCanOpenWindowsAutomatically
(
true
);
}
private
void
showBackBtn
()
{
android
.
support
.
v7
.
app
.
ActionBar
actionBar
=
getSupportActionBar
();
if
(
actionBar
!=
null
)
{
actionBar
.
setHomeButtonEnabled
(
true
);
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
}
}
/**
* 权限判断和申请
*/
private
void
initPermission
()
{
mPermissionList
.
clear
();
//清空已经允许的没有通过的权限
//逐个判断是否还有未通过的权限
for
(
int
i
=
0
;
i
<
permissions
.
length
;
i
++)
{
if
(
ContextCompat
.
checkSelfPermission
(
this
,
permissions
[
i
])
!=
PackageManager
.
PERMISSION_GRANTED
)
{
mPermissionList
.
add
(
permissions
[
i
]);
//添加还未授予的权限到mPermissionList中
}
}
//申请权限
if
(
mPermissionList
.
size
()
>
0
)
{
//有权限没有通过,需要申请
ActivityCompat
.
requestPermissions
(
this
,
permissions
,
REQUEST_CODE
);
}
else
{
//权限已经都通过了,可以将程序继续打开了
TelephonyManager
TelephonyMgr
=
(
TelephonyManager
)
getSystemService
(
TELEPHONY_SERVICE
);
imei
=
TelephonyMgr
.
getDeviceId
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
try
{
meid
=
TelephonyMgr
.
getMeid
();
}
catch
(
Exception
e
)
{
}
}
openUrl
();
}
}
private
boolean
shouldOverrideUrlLoadingByApp
(
WebView
view
,
String
url
)
{
if
(
url
.
startsWith
(
"http"
)
||
url
.
startsWith
(
"https"
)
||
url
.
startsWith
(
"ftp"
))
{
//不处理http, https, ftp的请求
return
false
;
}
if
(
isSupportedDeepLink
(
url
))
{
boolean
ret
=
openDeepLink
(
webView
.
getView
().
getContext
(),
url
);
return
true
;
//是直达广告,拦截
}
Intent
intent
;
try
{
intent
=
Intent
.
parseUri
(
url
,
Intent
.
URI_INTENT_SCHEME
);
}
catch
(
URISyntaxException
e
)
{
return
false
;
}
intent
.
setComponent
(
null
);
try
{
startActivity
(
intent
);
}
catch
(
ActivityNotFoundException
e
)
{
return
true
;
}
return
true
;
}
private
static
String
[]
deepLinkPrex
=
{
"weixin://"
,
"pinduoduo://"
,
"openapp.jdmobile://"
,
"market://"
,
"taobao://"
,
"alipay://"
,
"market://"
};
public
boolean
isSupportedDeepLink
(
String
url
)
{
for
(
int
i
=
0
;
i
<
deepLinkPrex
.
length
;
i
++)
{
if
(
url
.
startsWith
(
deepLinkPrex
[
i
]))
{
return
true
;
}
}
return
false
;
}
public
boolean
openDeepLink
(
Context
ctx
,
String
url
)
{
try
{
Intent
intent1
=
new
Intent
();
intent1
.
setAction
(
"android.intent.action.VIEW"
);
Uri
uri
=
Uri
.
parse
(
url
);
intent1
.
setData
(
uri
);
intent1
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
ctx
.
startActivity
(
intent1
);
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
private
boolean
isCanLoadFiJs
=
false
;
private
boolean
hadLoade15
=
false
;
private
boolean
hadLoade45
=
false
;
private
boolean
hadLoade75
=
false
;
private
String
js
=
""
;
private
void
openUrl
()
{
WebChromeClient
webchromeclient
=
new
WebChromeClient
()
{
@Override
public
void
onProgressChanged
(
WebView
view
,
int
newProgress
)
{
if
(
newProgress
>=
15
&&
isCanLoadFiJs
&&
!
hadLoade15
)
{
webView
.
loadUrl
(
"javascript:"
+
js
);
hadLoade15
=
true
;
}
if
(
newProgress
>=
45
&&
isCanLoadFiJs
&&
!
hadLoade45
)
{
webView
.
loadUrl
(
"javascript:"
+
js
);
hadLoade45
=
true
;
}
if
(
newProgress
>=
75
&&
isCanLoadFiJs
&&
!
hadLoade75
)
{
webView
.
loadUrl
(
"javascript:"
+
js
);
hadLoade75
=
true
;
}
if
(
newProgress
==
100
)
{
//隐藏进度条
swipeLayout
.
setRefreshing
(
false
);
}
else
{
if
(!
swipeLayout
.
isRefreshing
())
swipeLayout
.
setRefreshing
(
true
);
}
super
.
onProgressChanged
(
view
,
newProgress
);
}
public
boolean
onJsAlert
(
WebView
view
,
String
url
,
String
message
,
JsResult
result
)
{
Toast
.
makeText
(
AdWebActivity
.
this
,
message
,
Toast
.
LENGTH_LONG
).
show
();
result
.
confirm
();
return
true
;
}
};
webView
.
setWebChromeClient
(
webchromeclient
);
webView
.
setWebViewClient
(
new
WebViewClient
()
{
@Override
public
void
onPageFinished
(
WebView
webView
,
String
s
)
{
super
.
onPageFinished
(
webView
,
s
);
if
(
isCanLoadFiJs
)
{
webView
.
loadUrl
(
"javascript:"
+
js
);
isCanLoadFiJs
=
false
;
}
}
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
if
(
isCanLoadFiJs
)
{
if
(!
LyCheckClickUrlIsCanJump
(
url
))
{
return
true
;
}
}
if
(
url
.
contains
(
"51gzdhh.xyz"
))
{
swipeLayout
.
setEnabled
(
false
);
}
else
{
swipeLayout
.
setEnabled
(
false
);
}
if
(
shouldOverrideUrlLoadingByApp
(
view
,
url
))
{
return
true
;
}
return
super
.
shouldOverrideUrlLoading
(
view
,
url
);
}
});
String
userid
=
UserManager
.
getInstance
().
getUserID
();
oaid
=
MintsApplication
.
getOaid
();
androidid
=
DeviceInfo
.
getDeviceInfo
(
this
).
getAndroidId
(
this
);
//sign =md5(pid+imei+meid+oaid+androidid+gtype+userid+key).ToLower()
String
keycode
=
"10107"
+
imei
+
meid
+
oaid
+
androidid
+
"1"
+
userid
+
"P6eYtFaq2go7QUsVthWlh2O7VHpjwyNh"
;
keycode
=
string2MD5
(
keycode
).
toLowerCase
();
webView
.
loadUrl
(
"https://www.51gzdhh.xyz/pipi/newList?userid="
+
userid
+
"&imei="
+
imei
+
">ype=1&pid=10107&sign="
+
keycode
+
"&meid="
+
meid
+
"&oaid="
+
oaid
+
"&androidid="
+
androidid
);
LogUtil
.
d
(
TAG
,
"https://www.51gzdhh.xyz/pipi/newList?userid="
+
userid
+
"&imei="
+
imei
+
">ype=1&pid=10107&sign="
+
keycode
+
"&meid="
+
meid
+
"&oaid="
+
oaid
+
"&androidid="
+
androidid
);
// String userid = "123456";
// imei= "";
// meid = "";
// oaid = "";
// androidid = "";
// //pid+imei+gtype+userid+key 测试数据
// String keycode = "3" + imei+meid + "1" + userid + "adhefoiqijefijewfowef";
// keycode = string2MD5(keycode).toLowerCase();
// //加载链接 仅仅作为测试,实际对接请加oaid 和 androidid
// webView.loadUrl("https://www.51gzdhh.xyz/pipi/newList?userid=" + userid + "&imei=" + imei + ">ype=1&pid=3&sign=" + keycode+"&meid="+meid+ "&style=2"+"&oaid="+"&androidid=");
// Log.i("url:", "https://www.51gzdhh.xyz/pipi/newList?userid=" + userid + "&imei=" + imei + ">ype=1&pid=3&sign=" + keycode+"&meid="+meid+"&oaid="+"&androidid=");
}
private
String
LyTempUrl
=
""
;
// 临时记录 点击热词跳转的Url
private
long
LyTempStarTime
=
0
;
// 临时记录 点击热词的时间
/**
* 检查点击热词的Url,在一定条件内是否可跳转
*
* @param url 热词跳转Url
* @return true:可跳转,false:不可跳转
*/
private
boolean
LyCheckClickUrlIsCanJump
(
String
url
)
{
if
(!
LyTempUrl
.
contains
(
url
))
{
LyTempUrl
=
url
;
LyTempStarTime
=
System
.
currentTimeMillis
();
return
true
;
}
if
(
System
.
currentTimeMillis
()
-
LyTempStarTime
>
600
)
{
// 此处必须为600ms
LyTempStarTime
=
System
.
currentTimeMillis
();
return
true
;
}
return
false
;
}
/**
* 打开app
*/
private
void
doStartApplicationWithPackageName
(
String
packagename
)
{
PackageManager
packageManager
=
getPackageManager
();
Intent
intent1
=
new
Intent
();
intent1
=
packageManager
.
getLaunchIntentForPackage
(
packagename
);
if
(
intent1
==
null
)
{
Toast
.
makeText
(
AdWebActivity
.
this
,
"未安装"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
startActivity
(
intent1
);
}
return
;
}
/**
* 下载逻辑
*/
public
void
downLoadApp
(
final
String
apkName
,
final
String
path
,
final
String
url
,
final
TextView
tv
)
{
BaseDownloadTask
baseDownloadTask
=
FileDownloader
.
getImpl
().
create
(
url
)
.
setPath
(
path
)
.
setCallbackProgressTimes
(
100
)
.
setMinIntervalUpdateSpeed
(
100
)
.
setListener
(
new
FileDownloadSampleListener
()
{
@Override
protected
void
pending
(
BaseDownloadTask
task
,
int
soFarBytes
,
int
totalBytes
)
{
super
.
pending
(
task
,
soFarBytes
,
totalBytes
);
}
@Override
protected
void
progress
(
BaseDownloadTask
task
,
int
soFarBytes
,
int
totalBytes
)
{
super
.
progress
(
task
,
soFarBytes
,
totalBytes
);
if
(
totalBytes
==
-
1
)
{
tv
.
setText
(
"正在下载"
);
}
else
{
int
progress
=
(
int
)
((
Long
.
valueOf
(
soFarBytes
)
*
100
)
/
Long
.
valueOf
(
totalBytes
));
tv
.
setText
(
"正在下载"
+
"("
+
progress
+
"%)"
);
}
tv
.
setEnabled
(
false
);
}
@Override
protected
void
completed
(
BaseDownloadTask
task
)
{
super
.
completed
(
task
);
tv
.
setText
(
"立即试玩"
);
installAPK
(
new
File
(
path
),
apkName
);
tv
.
setEnabled
(
true
);
}
@Override
protected
void
paused
(
BaseDownloadTask
task
,
int
soFarBytes
,
int
totalBytes
)
{
super
.
paused
(
task
,
soFarBytes
,
totalBytes
);
}
@Override
protected
void
error
(
BaseDownloadTask
task
,
Throwable
e
)
{
super
.
error
(
task
,
e
);
}
@Override
protected
void
warn
(
BaseDownloadTask
task
)
{
super
.
warn
(
task
);
}
@Override
protected
void
connected
(
BaseDownloadTask
task
,
String
etag
,
boolean
isContinue
,
int
soFarBytes
,
int
totalBytes
)
{
super
.
connected
(
task
,
etag
,
isContinue
,
soFarBytes
,
totalBytes
);
}
});
baseDownloadTask
.
start
();
}
/**
* 下载到本地后执行安装
*/
protected
void
installAPK
(
File
file
,
String
apkName
)
{
if
(!
file
.
exists
())
return
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
boolean
hasInstallPermission
=
isHasInstallPermissionWithO
(
this
);
if
(!
hasInstallPermission
)
{
Toast
.
makeText
(
this
,
"请开启安装应用权限"
,
Toast
.
LENGTH_SHORT
).
show
();
startInstallPermissionSettingActivity
(
this
);
return
;
}
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
//判读版本是否在7.0以上
Uri
apkUri
=
FileProvider
.
getUriForFile
(
this
,
AUTHORITY
,
file
);
//在AndroidManifest中的android:authorities值
Intent
install
=
new
Intent
(
Intent
.
ACTION_VIEW
);
install
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
install
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
install
.
setDataAndType
(
apkUri
,
"application/vnd.android.package-archive"
);
startActivity
(
install
);
}
else
{
Intent
install
=
new
Intent
(
Intent
.
ACTION_VIEW
);
install
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
);
install
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
install
);
}
}
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
private
boolean
isHasInstallPermissionWithO
(
Context
context
)
{
if
(
context
==
null
)
{
return
false
;
}
return
context
.
getPackageManager
().
canRequestPackageInstalls
();
}
int
REQUEST_CODE_APP_INSTALL
=
9
;
/**
* 开启设置安装未知来源应用权限界面
*
* @param context
*/
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
private
void
startInstallPermissionSettingActivity
(
Context
context
)
{
if
(
context
==
null
)
{
return
;
}
Intent
intent
=
new
Intent
(
Settings
.
ACTION_MANAGE_UNKNOWN_APP_SOURCES
);
((
Activity
)
context
).
startActivityForResult
(
intent
,
REQUEST_CODE_APP_INSTALL
);
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
REQUEST_CODE_APP_INSTALL
)
{
}
}
}
/**
* md5加密
*
* @param string
* @return
*/
public
String
string2MD5
(
String
string
)
{
if
(
TextUtils
.
isEmpty
(
string
))
{
return
""
;
}
MessageDigest
md5
=
null
;
try
{
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
byte
[]
bytes
=
md5
.
digest
(
string
.
getBytes
());
String
result
=
""
;
for
(
byte
b
:
bytes
)
{
String
temp
=
Integer
.
toHexString
(
b
&
0xff
);
if
(
temp
.
length
()
==
1
)
{
temp
=
"0"
+
temp
;
}
result
+=
temp
;
}
return
result
;
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 复制单个文件
*/
public
void
copyFile
(
String
oldPath
,
String
newPath
)
{
try
{
int
bytesum
=
0
;
int
byteread
=
0
;
File
oldfile
=
new
File
(
oldPath
);
if
(
oldfile
.
exists
())
{
//文件存在时
InputStream
inStream
=
new
FileInputStream
(
oldPath
);
//读入原文件
FileOutputStream
fs
=
new
FileOutputStream
(
newPath
);
byte
[]
buffer
=
new
byte
[
1444
];
int
length
;
while
((
byteread
=
inStream
.
read
(
buffer
))
!=
-
1
)
{
bytesum
+=
byteread
;
//字节数 文件大小
System
.
out
.
println
(
bytesum
);
fs
.
write
(
buffer
,
0
,
byteread
);
}
inStream
.
close
();
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"复制单个文件操作出错"
);
e
.
printStackTrace
();
}
}
/**
* 重写返回键
*
* @param keyCode
* @param event
* @return
*/
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
&&
webView
.
canGoBack
())
{
webView
.
goBack
();
if
(!
webView
.
canGoBack
()
&&
webView
.
getUrl
().
contains
(
"51gzdhh.xyz"
))
{
swipeLayout
.
setEnabled
(
true
);
}
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
android
.
R
.
id
.
home
:
if
(
webView
.
canGoBack
())
{
webView
.
goBack
();
}
else
{
finish
();
}
return
true
;
}
return
super
.
onOptionsItemSelected
(
item
);
}
@JavascriptInterface
public
void
setJs
(
String
js
)
{
this
.
isCanLoadFiJs
=
true
;
this
.
hadLoade15
=
false
;
this
.
hadLoade45
=
false
;
this
.
hadLoade75
=
false
;
this
.
js
=
js
;
LogUtil
.
d
(
TAG
,
"setJs..."
+
js
);
}
@JavascriptInterface
public
void
closeJs
(
String
js
)
{
this
.
isCanLoadFiJs
=
false
;
this
.
js
=
""
;
LogUtil
.
d
(
TAG
,
"closeJs ..."
);
}
@JavascriptInterface
public
void
test
()
{
LogUtil
.
d
(
TAG
,
"CheckInstall ..."
);
}
/**
* 判断指定包名的app是否已经安装,并且把结果返回给H5
*
* @param packageName
*/
@JavascriptInterface
public
void
CheckInstall
(
final
String
packageName
)
{
LogUtil
.
d
(
TAG
,
packageName
+
"..."
);
packagenameLocal
=
packageName
;
final
boolean
isInstalled
=
SystemUtils
.
isAppInstalled
(
AdWebActivity
.
this
,
packageName
);
if
(
isInstalled
)
{
webView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
loadUrl
(
"javascript:CheckInstall_Return(1)"
);
LogUtil
.
d
(
TAG
,
packageName
+
"...1"
);
}
});
}
else
{
webView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
loadUrl
(
"javascript:CheckInstall_Return(0)"
);
LogUtil
.
d
(
TAG
,
packageName
+
"...2"
);
}
});
}
}
/**
* 判断原生下载安装状态
*
* @param showType
* @param buttonType
* @param buttonName
* @param downUlr
*/
@JavascriptInterface
public
void
initPceggsData
(
final
String
showType
,
final
String
buttonType
,
final
String
buttonName
,
String
downUlr
)
{
LogUtil
.
d
(
TAG
,
showType
+
"...."
+
buttonType
+
"..."
+
buttonName
+
"..."
+
downUlr
);
downUrlLocal
=
downUlr
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
"0"
.
equals
(
showType
))
{
tv_start_download
.
setVisibility
(
View
.
GONE
);
}
else
{
tv_start_download
.
setVisibility
(
View
.
VISIBLE
);
}
tv_start_download
.
setText
(
buttonName
);
if
(
"0"
.
equals
(
buttonType
))
{
tv_start_download
.
setEnabled
(
false
);
}
else
{
tv_start_download
.
setEnabled
(
true
);
}
}
});
}
/**
* 打开指定包名App
*
* @param packageName
*/
@JavascriptInterface
public
void
AwallOpen
(
String
packageName
)
{
doStartApplicationWithPackageName
(
packageName
);
}
@JavascriptInterface
public
boolean
joinQQGroup
(
String
key
)
{
Intent
intent
=
new
Intent
();
intent
.
setData
(
Uri
.
parse
(
"mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D"
+
key
));
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try
{
startActivity
(
intent
);
return
true
;
}
catch
(
Exception
e
)
{
// 未安装手Q或安装的版本不支持
return
false
;
}
}
/**
* Toast信息提示
*
* @param message
*/
@JavascriptInterface
public
void
popout
(
String
message
)
{
if
(!
TextUtils
.
isEmpty
(
message
))
{
Toast
.
makeText
(
this
,
message
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
@JavascriptInterface
public
void
gameBegin
()
{
//异常判断
if
(
TextUtils
.
isEmpty
(
downUrlLocal
))
{
Toast
.
makeText
(
AdWebActivity
.
this
,
"下载连接异常"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
//存在立即打开
final
boolean
isInstalled
=
SystemUtils
.
isAppInstalled
(
AdWebActivity
.
this
,
packagenameLocal
);
if
(
isInstalled
)
{
doStartApplicationWithPackageName
(
packagenameLocal
);
return
;
}
//执行下载
int
last
=
downUrlLocal
.
lastIndexOf
(
"/"
)
+
1
;
String
apkName
=
downUrlLocal
.
substring
(
last
);
if
(!
apkName
.
contains
(
".apk"
))
{
if
(
apkName
.
length
()
>
10
)
{
apkName
=
apkName
.
substring
(
apkName
.
length
()
-
10
);
}
apkName
+=
".apk"
;
}
String
downloadPath
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
File
.
separator
+
"kuwanzhuan"
+
File
.
separator
+
apkName
;
downLoadApp
(
apkName
,
downloadPath
,
downUrlLocal
,
tv_start_download
);
//下载通知后台,js交互
webView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
loadUrl
(
"javascript:startDownApp()"
);
}
});
}
public
static
class
ShareToolUtil
{
private
static
String
sharePicName
=
"share_pic.jpg"
;
private
static
String
sharePicPath
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
File
.
separator
+
"kuwanzhuan"
+
File
.
separator
+
"sharepic"
+
File
.
separator
;
/**
* 保存图片,并返回一个File类型的文件
* 如今Android版本已经高达28了,但在使用该方法时,涉及到权限问题,本人在创建文件夹时遇到文件夹创建失败问题,遂将原因及解决方法记录如下:
* 问题:Android6.0以后,文件夹创建失败。也就是使用file.mkdirs方法.
* 解决方法:1.读写sdcard需要权限,但仅在manifest.xml里面添加是不够的,需要动态申请权限。2.可以将targetSdkVersion改为21或22或以下。
* 否则在分享过程中获取不到图片就会弹出“获取资源失败”这样的提示。
*/
public
static
File
saveSharePic
(
Context
context
,
Bitmap
bitmap
)
{
File
file
=
new
File
(
sharePicPath
);
if
(!
file
.
exists
())
{
file
.
mkdirs
();
}
File
filePic
=
new
File
(
sharePicPath
,
sharePicName
);
if
(
filePic
.
exists
())
{
filePic
.
delete
();
}
try
{
FileOutputStream
out
=
new
FileOutputStream
(
filePic
);
if
(
bitmap
==
null
)
{
bitmap
=
BitmapFactory
.
decodeResource
(
context
.
getResources
(),
R
.
drawable
.
ic_launcher_background
);
}
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
90
,
out
);
try
{
out
.
flush
();
out
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
filePic
;
}
}
/**
* 刷新
*/
@JavascriptInterface
public
void
refresh
()
{
if
(
null
!=
webView
)
{
webView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
reload
();
}
});
}
}
public
static
class
PlatformUtil
{
public
static
final
String
PACKAGE_WECHAT
=
"com.tencent.mm"
;
public
static
final
String
PACKAGE_MOBILE_QQ
=
"com.tencent.mobileqq"
;
public
static
final
String
PACKAGE_QZONE
=
"com.qzone"
;
public
static
final
String
PACKAGE_SINA
=
"com.sina.weibo"
;
// 判断是否安装指定app
public
static
boolean
isInstallApp
(
Context
context
,
String
app_package
)
{
final
PackageManager
packageManager
=
context
.
getPackageManager
();
List
<
PackageInfo
>
pInfo
=
packageManager
.
getInstalledPackages
(
0
);
if
(
pInfo
!=
null
)
{
for
(
int
i
=
0
;
i
<
pInfo
.
size
();
i
++)
{
String
pn
=
pInfo
.
get
(
i
).
packageName
;
if
(
app_package
.
equals
(
pn
))
{
return
true
;
}
}
}
return
false
;
}
}
/**
* 直接分享文本到微信好友
*/
@JavascriptInterface
public
void
shareWechatFriend
(
String
content
)
{
if
(
PlatformUtil
.
isInstallApp
(
AdWebActivity
.
this
,
PlatformUtil
.
PACKAGE_WECHAT
))
{
Intent
intent
=
new
Intent
();
ComponentName
cop
=
new
ComponentName
(
"com.tencent.mm"
,
"com.tencent.mm.ui.tools.ShareImgUI"
);
intent
.
setComponent
(
cop
);
intent
.
setAction
(
Intent
.
ACTION_SEND
);
intent
.
putExtra
(
"android.intent.extra.TEXT"
,
content
);
// intent.putExtra("sms_body", content);
intent
.
putExtra
(
"Kdescription"
,
!
TextUtils
.
isEmpty
(
content
)
?
content
:
""
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
intent
);
}
else
{
Toast
.
makeText
(
AdWebActivity
.
this
,
"您需要安装微信客户端"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
@JavascriptInterface
public
void
jsShareWechatMoment
(
final
String
url
,
final
String
contents
)
{
new
Handler
(
AdWebActivity
.
this
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
// 在这里执行你要想的操作 比如直接在这里更新ui或者调用回调在 在回调中更新ui
Glide
.
with
(
AdWebActivity
.
this
).
asBitmap
().
load
(
url
).
into
(
new
SimpleTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
resource
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
File
file
=
ShareToolUtil
.
saveSharePic
(
AdWebActivity
.
this
,
resource
);
shareWechatMoment
(
AdWebActivity
.
this
,
contents
,
file
);
}
});
}
});
}
/**
* 直接分享文本和图片到微信朋友圈
*
* @param context
* @param content
*/
public
static
void
shareWechatMoment
(
Context
context
,
String
content
,
File
picFile
)
{
if
(
PlatformUtil
.
isInstallApp
(
context
,
PlatformUtil
.
PACKAGE_WECHAT
))
{
Intent
intent
=
new
Intent
();
//分享精确到微信的页面,朋友圈页面,或者选择好友分享页面
ComponentName
comp
=
new
ComponentName
(
"com.tencent.mm"
,
"com.tencent.mm.ui.tools.ShareToTimeLineUI"
);
intent
.
setComponent
(
comp
);
// intent.setAction(Intent.ACTION_SEND_MULTIPLE);// 分享多张图片时使用
intent
.
setAction
(
Intent
.
ACTION_SEND
);
intent
.
setType
(
"image/*"
);
//添加Uri图片地址--用于添加多张图片
//ArrayList<Uri> imageUris = new ArrayList<>();
//intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
if
(
picFile
!=
null
)
{
if
(
picFile
.
isFile
()
&&
picFile
.
exists
())
{
Uri
uri
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
uri
=
FileProvider
.
getUriForFile
(
context
,
AUTHORITY
,
picFile
);
}
else
{
uri
=
Uri
.
fromFile
(
picFile
);
}
intent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
uri
);
}
}
// 微信现不能进行标题同时分享
intent
.
putExtra
(
"Kdescription"
,
!
TextUtils
.
isEmpty
(
content
)
?
content
:
""
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
context
.
startActivity
(
intent
);
}
else
{
Toast
.
makeText
(
context
,
"您需要安装微信客户端"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
/**
* 打开浏览器试玩
*
* @param url
*/
@JavascriptInterface
public
void
openBrowser
(
String
url
)
{
Intent
intent
=
new
Intent
();
intent
.
setAction
(
"android.intent.action.VIEW"
);
Uri
content_url
=
Uri
.
parse
(
url
);
intent
.
setData
(
content_url
);
startActivity
(
intent
);
}
/**
* 请求权限后回调的方法
*/
@SuppressLint
(
"MissingPermission"
)
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
boolean
hasPermissionDismiss
=
false
;
//有权限没有通过
if
(
REQUEST_CODE
==
requestCode
)
{
for
(
int
i
=
0
;
i
<
grantResults
.
length
;
i
++)
{
if
(
grantResults
[
i
]
==
-
1
)
{
hasPermissionDismiss
=
true
;
break
;
}
}
}
if
(
hasPermissionDismiss
)
{
//如果有没有被允许的权限
showPermissionDialog
();
}
else
{
//权限已经都通过了,可以将程序继续打开了
TelephonyManager
TelephonyMgr
=
(
TelephonyManager
)
getSystemService
(
TELEPHONY_SERVICE
);
imei
=
TelephonyMgr
.
getDeviceId
();
openUrl
();
}
}
/**
* 设置权限弹框
*/
private
void
showPermissionDialog
()
{
if
(
mPermissionDialog
==
null
)
{
mPermissionDialog
=
new
AlertDialog
.
Builder
(
this
)
.
setMessage
(
"已禁用权限,请手动授予"
)
.
setPositiveButton
(
"设置"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
cancelPermissionDialog
();
Uri
packageURI
=
Uri
.
parse
(
"package:"
+
getPackageName
(
AdWebActivity
.
this
));
Intent
intent
=
new
Intent
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
,
packageURI
);
startActivity
(
intent
);
}
})
.
setNegativeButton
(
"取消"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
//关闭页面或者做其他操作
cancelPermissionDialog
();
finish
();
}
})
.
create
();
}
mPermissionDialog
.
show
();
}
/**
* 取消弹框
*/
private
void
cancelPermissionDialog
()
{
mPermissionDialog
.
cancel
();
}
/**
* [获取应用程序版本名称信息]
*
* @param context
* @return 当前应用的版本名称
*/
public
static
synchronized
String
getPackageName
(
Context
context
)
{
try
{
PackageManager
packageManager
=
context
.
getPackageManager
();
PackageInfo
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
getPackageName
(),
0
);
return
packageInfo
.
packageName
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
highgold/app/src/main/java/com/mints/highgold/ui/activitys/WxLoginActivity.java
View file @
6d6902f1
...
...
@@ -239,10 +239,7 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
if
(
code
==
6000
)
{
//登录成功
// toSuccessActivity(5,token);
showToast
(
"登录成功"
);
readyGo
(
MainActivity
.
class
);
wxLoginPresenter
.
jPushlogin
(
getContext
(),
token
);
}
else
if
(
code
!=
6002
)
{
showToast
(
operator
);
}
...
...
highgold/app/src/main/java/com/mints/highgold/ui/fragment/MainFragment.java
View file @
6d6902f1
...
...
@@ -44,6 +44,7 @@ import com.mints.highgold.mvp.model.UserTaskMsgBean;
import
com.mints.highgold.mvp.model.VedioAdingBean
;
import
com.mints.highgold.mvp.presenters.LoanPresenter
;
import
com.mints.highgold.mvp.views.LoanView
;
import
com.mints.highgold.ui.activitys.AdWebActivity
;
import
com.mints.highgold.ui.activitys.AwardActivity
;
import
com.mints.highgold.ui.activitys.FriendsNewActivity
;
import
com.mints.highgold.ui.activitys.MainActivity
;
...
...
@@ -357,7 +358,8 @@ public class MainFragment extends BaseFragment
Bundle
bundle
;
switch
(
view
.
getId
())
{
case
R
.
id
.
tv_fragment_main_whatgold
:
// 如何赚金币
readyGo
(
WhatGoldActivity
.
class
);
// readyGo(WhatGoldActivity.class);
readyGo
(
AdWebActivity
.
class
);
break
;
case
R
.
id
.
rl_fragment_main_redbox
:
// 红包
readyGo
(
RedboxActivity
.
class
);
...
...
highgold/app/src/main/java/com/mints/highgold/utils/SystemUtils.java
0 → 100755
View file @
6d6902f1
package
com
.
mints
.
highgold
.
utils
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
public
class
SystemUtils
{
/**
* @param context
* @param packagename
* @return
*/
public
static
boolean
isAppInstalled
(
Context
context
,
String
packagename
)
{
PackageInfo
packageInfo
;
try
{
packageInfo
=
context
.
getPackageManager
().
getPackageInfo
(
packagename
,
PackageManager
.
GET_UNINSTALLED_PACKAGES
);
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
packageInfo
=
null
;
e
.
printStackTrace
();
}
if
(
packageInfo
==
null
)
{
//System.out.println("没有安装");
return
false
;
}
else
{
//System.out.println("已经安装");
return
true
;
}
}
}
highgold/app/src/main/res/layout/activity_adweb.xml
0 → 100755
View file @
6d6902f1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<Button
android:visibility=
"gone"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"跳转"
android:id=
"@+id/btn"
/>
<android.support.v4.widget.SwipeRefreshLayout
android:id=
"@+id/swipe_container"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
>
<com.tencent.smtt.sdk.WebView
android:id=
"@+id/webview"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
tools:context=
"com.ns.pipidemo.AdWebActivity"
>
</com.tencent.smtt.sdk.WebView>
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id=
"@+id/tv_start_download"
android:layout_width=
"match_parent"
android:layout_height=
"44dp"
android:background=
"#f29445"
android:gravity=
"center"
android:text=
"立即下载"
android:textColor=
"#ffffff"
android:textSize=
"15sp"
android:visibility=
"gone"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment