Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
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_goodmoney
Commits
712b7968
Commit
712b7968
authored
Jan 07, 2021
by
jyx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_ad' of
http://39.97.65.143:81/android/android_goodmoney
into dev_ad
parents
73721273
b67cc834
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
332 additions
and
16 deletions
+332
-16
build.gradle
GoodMoney/app/build.gradle
+2
-2
DownloadApkManager.kt
...in/java/com/mints/goodmoney/manager/DownloadApkManager.kt
+160
-0
WebActivity.kt
...main/java/com/mints/goodmoney/ui/activitys/WebActivity.kt
+21
-7
MyFragment.kt
...c/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
+2
-5
DownloadProgressDialog.kt
.../com/mints/goodmoney/ui/widgets/DownloadProgressDialog.kt
+73
-0
ForegroundOrBackground.java
...ava/com/mints/goodmoney/utils/ForegroundOrBackground.java
+3
-2
dialog_download_progress.xml
...oney/app/src/main/res/layout/dialog_download_progress.xml
+71
-0
No files found.
GoodMoney/app/build.gradle
View file @
712b7968
...
...
@@ -9,8 +9,8 @@ android {
applicationId
"com.mints.goodmoney"
minSdkVersion
rootProject
.
ext
.
androidMinSdkVersion
targetSdkVersion
rootProject
.
ext
.
androidTargetSdkVersion
versionCode
1
1
versionName
"1.1.
0
"
versionCode
1
2
versionName
"1.1.
1
"
flavorDimensions
"default"
// dex突破65535的限制
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/DownloadApkManager.kt
0 → 100644
View file @
712b7968
package
com.mints.goodmoney.manager
import
android.app.AlertDialog
import
android.content.Context
import
android.content.DialogInterface
import
android.content.Intent
import
android.net.Uri
import
android.os.Build
import
android.provider.Settings
import
androidx.annotation.RequiresApi
import
androidx.core.content.FileProvider
import
com.downloader.Error
import
com.downloader.OnDownloadListener
import
com.downloader.PRDownloader
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ui.widgets.DownloadProgressDialog
import
com.mints.goodmoney.utils.CacheUtil
import
com.mints.goodmoney.utils.ForegroundOrBackground
import
com.mints.goodmoney.utils.MD5
import
java.io.File
/**
* apk下载管理
*/
object
DownloadApkManager
{
private
var
downloadProgressDialog
:
DownloadProgressDialog
?
=
null
private
var
apkName
=
""
private
var
cachePath
=
""
private
var
canOnceInstallApk
=
false
//8.0以上系统 防止首次授权时 未安装apk调用
fun
downloadApk
(
url
:
String
)
{
apkName
=
MD5
.
GetMD5Code
(
System
.
currentTimeMillis
().
toString
()
+
UserManager
.
getInstance
().
userID
)
+
".apk"
this
.
download
(
url
)
}
fun
downloadApk
(
url
:
String
,
name
:
String
)
{
this
.
apkName
=
apkName
this
.
download
(
url
)
}
/**
* 防止首次授权未知来源权限时 未安装apk调用
*/
fun
tryOnceInstallApk
()
{
try
{
if
(
canOnceInstallApk
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
context
=
MintsApplication
.
getContext
()
val
haveInstallPermission
=
context
.
getPackageManager
().
canRequestPackageInstalls
()
if
(
haveInstallPermission
)
{
installApk
()
canOnceInstallApk
=
false
}
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
private
fun
download
(
url
:
String
)
{
downloadProgressDialog
=
DownloadProgressDialog
(
ForegroundOrBackground
.
getApp_activity
())
downloadProgressDialog
!!
.
show
()
val
context
=
MintsApplication
.
getContext
()
cachePath
=
context
.
cacheDir
.
path
+
"/"
PRDownloader
.
download
(
url
,
cachePath
,
apkName
)
.
build
()
.
setOnProgressListener
{
progress
->
downloadProgressDialog
?.
setProgress
(
progress
)
}
.
start
(
object
:
OnDownloadListener
{
override
fun
onDownloadComplete
()
{
downloadProgressDialog
?.
dismiss
()
try
{
preInstallApk
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
override
fun
onError
(
error
:
Error
)
{
downloadProgressDialog
?.
dismiss
()
try
{
CacheUtil
.
clearAllCache
(
context
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
})
}
/**
* 预安装,授权校验
*/
private
fun
preInstallApk
()
{
val
context
=
MintsApplication
.
getContext
()
// 8.0以上系统设置安装未知来源权限
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
haveInstallPermission
=
context
.
getPackageManager
().
canRequestPackageInstalls
()
if
(!
haveInstallPermission
)
{
showAlert
(
ForegroundOrBackground
.
getApp_activity
(),
"安装权限"
,
"需要打开允许来自此来源,请去设置中开启此权限"
,
DialogInterface
.
OnClickListener
{
dialog
,
which
->
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
//此方法需要API>=26才能使用
toInstallPermissionSettingIntent
()
}
})
return
}
}
installApk
()
}
/**
* 授权提示框
*/
private
fun
showAlert
(
context
:
Context
,
title
:
String
,
message
:
String
,
listener
:
DialogInterface
.
OnClickListener
?)
{
val
builder
=
AlertDialog
.
Builder
(
context
)
builder
.
setTitle
(
title
)
builder
.
setMessage
(
message
)
builder
.
setPositiveButton
(
"确定"
,
listener
)
builder
.
setCancelable
(
false
)
builder
.
setIcon
(
R
.
mipmap
.
ic_launcher_main
)
val
dialog
=
builder
.
create
()
dialog
.
show
()
}
/**
* 跳转安装未知来源权限页面
*/
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
private
fun
toInstallPermissionSettingIntent
()
{
canOnceInstallApk
=
true
val
context
=
ForegroundOrBackground
.
getApp_activity
()
val
packageURI
=
Uri
.
parse
(
"package:"
+
context
.
getPackageName
())
val
intent
=
Intent
(
Settings
.
ACTION_MANAGE_UNKNOWN_APP_SOURCES
,
packageURI
)
context
.
startActivity
(
intent
)
}
/**
* 安装apk包
*/
private
fun
installApk
()
{
val
context
=
ForegroundOrBackground
.
getApp_activity
()
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
val
file
=
File
(
cachePath
+
apkName
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
val
apkUri
:
Uri
=
FileProvider
.
getUriForFile
(
context
,
context
.
packageName
+
".fileprovider"
,
file
)
intent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
intent
.
setDataAndType
(
apkUri
,
"application/vnd.android.package-archive"
)
}
else
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
)
}
context
.
startActivity
(
intent
)
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/WebActivity.kt
View file @
712b7968
...
...
@@ -9,6 +9,7 @@ import android.view.View
import
android.webkit.WebView
import
android.webkit.WebViewClient
import
com.mints.goodmoney.R
import
com.mints.goodmoney.manager.DownloadApkManager
import
com.mints.goodmoney.ui.activitys.base.BaseActivity
import
kotlinx.android.synthetic.main.activity_web.*
...
...
@@ -36,8 +37,13 @@ class WebActivity : BaseActivity(), View.OnClickListener {
}
if
(!
TextUtils
.
isEmpty
(
url
)
&&
(
url
!!
.
contains
(
".apk"
)
||
url
!!
.
contains
(
"pgyer"
))
)
{
&&
url
!!
.
contains
(
".apk"
))
{
DownloadApkManager
.
downloadApk
(
url
!!
)
return
}
if
(!
TextUtils
.
isEmpty
(
url
)
&&
url
!!
.
contains
(
"pgyer"
))
{
val
uri
=
Uri
.
parse
(
url
)
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
uri
)
startActivity
(
intent
)
...
...
@@ -51,10 +57,13 @@ class WebActivity : BaseActivity(), View.OnClickListener {
view
:
WebView
,
url
:
String
):
Boolean
{
if
(
url
.
contains
(
".apk"
)
||
url
.
contains
(
"pgyer"
)
||
url
.
contains
(
"weixin://wap/pay"
)
||
url
.
contains
(
"alipays://platformapi/startApp"
)
)
{
if
(
url
.
contains
(
".apk"
))
{
DownloadApkManager
.
downloadApk
(
url
!!
)
return
true
}
if
(
url
.
contains
(
"pgyer"
)
||
url
.
contains
(
"weixin://wap/pay"
)
||
url
.
contains
(
"alipays://platformapi/startApp"
))
{
val
uri
=
Uri
.
parse
(
url
)
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
uri
)
startActivity
(
intent
)
...
...
@@ -83,6 +92,11 @@ class WebActivity : BaseActivity(), View.OnClickListener {
}
override
fun
onResume
()
{
super
.
onResume
()
DownloadApkManager
.
tryOnceInstallApk
()
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
if
(
browser_layout
!=
null
)
{
...
...
@@ -100,7 +114,7 @@ class WebActivity : BaseActivity(), View.OnClickListener {
return
super
.
onKeyDown
(
keyCode
,
event
)
}
override
fun
isApplyKitKatTranslucency
()
=
false
override
fun
isApplyKitKatTranslucency
()
=
false
companion
object
{
const
val
WEB_TITLE
=
"web_title"
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
View file @
712b7968
...
...
@@ -48,7 +48,6 @@ import com.tbruyelle.rxpermissions.RxPermissions
import
com.xiangzi.articlesdk.callback.IXzArticleSdkInitCallback
import
com.xiangzi.articlesdk.core.XzArticleCoreImpl
import
com.xiangzi.articlesdk.exception.XzSdkException
import
io.reactivex.disposables.Disposable
import
kotlinx.android.synthetic.main.fragment_main_my.*
import
kotlinx.android.synthetic.main.header_layout.*
import
kotlinx.android.synthetic.main.item_fragment_main_my_clock.*
...
...
@@ -60,8 +59,6 @@ import net.grandcentrix.tray.AppPreferences
import
java.math.BigDecimal
import
java.util.*
private
val
TAG
=
MyFragment
::
class
.
java
.
simpleName
/**
* 描述:我
* 作者:孟崔广
...
...
@@ -70,6 +67,8 @@ private val TAG = MyFragment::class.java.simpleName
@SuppressLint
(
"SetTextI18n"
)
class
MyFragment
:
BaseFragment
(),
MyView
,
OnItemChildClickListener
,
OnRefreshListener
,
View
.
OnClickListener
,
AdapterView
.
OnItemClickListener
{
private
val
TAG
=
MyFragment
::
class
.
java
.
simpleName
private
val
ps
by
lazy
{
AppPreferences
(
context
)
}
private
val
myPresenter
by
lazy
{
MyPresenter
()
}
private
val
userManager
by
lazy
{
UserManager
.
getInstance
()
}
...
...
@@ -94,7 +93,6 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
private
var
bannerFlag
=
false
// 高额任务
private
var
disposable
:
Disposable
?
=
null
private
var
mCurrentPkg
:
String
?
=
null
private
var
mCarrierType
:
String
?
=
null
...
...
@@ -171,7 +169,6 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
BxmManager
.
onDestory
()
BannerManager
.
onDestroy
()
myPresenter
.
detachView
()
disposable
?.
dispose
()
mContext
.
unregisterReceiver
(
this
.
mReceiverBroadcastReceiver
)
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/widgets/DownloadProgressDialog.kt
0 → 100644
View file @
712b7968
package
com.mints.goodmoney.ui.widgets
import
android.app.Activity
import
android.app.Dialog
import
android.content.Intent
import
android.os.Bundle
import
android.view.Gravity
import
android.view.KeyEvent
import
android.view.View
import
android.view.WindowManager
import
android.widget.ImageView
import
android.widget.TextView
import
cn.sharesdk.framework.ShareSDK
import
cn.sharesdk.wechat.friends.Wechat
import
com.downloader.Progress
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.R
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.login.LoginApi
import
com.mints.goodmoney.login.OnLoginListener
import
com.mints.goodmoney.mvp.model.DrawcashBean
import
com.mints.goodmoney.mvp.model.WXInfo
import
com.mints.goodmoney.mvp.presenters.SettingsPresenter
import
com.mints.goodmoney.mvp.views.SettingsView
import
com.mints.goodmoney.ui.activitys.AccountMergeActivity
import
com.mints.goodmoney.ui.activitys.AwardActivity
import
com.mints.goodmoney.utils.ToastUtil
import
com.mints.goodmoney.utils.Utils
import
com.mints.library.utils.json.JsonUtil
import
com.mints.library.utils.nodoubleclick.AntiShake
import
java.util.*
/**
* 下载进度弹窗
*/
class
DownloadProgressDialog
(
context
:
Activity
)
:
Dialog
(
context
,
R
.
style
.
dialog
),
View
.
OnClickListener
{
private
var
tvDownloadProgress
:
TextView
?
=
null
init
{
setContentView
(
R
.
layout
.
dialog_download_progress
)
// 设置window属性
val
lp
=
window
!!
.
attributes
lp
.
gravity
=
Gravity
.
CENTER
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
lp
.
windowAnimations
=
R
.
style
.
DialogAnimBottom
window
!!
.
attributes
=
lp
// 设置外部不可关闭
setCancelable
(
false
)
setCanceledOnTouchOutside
(
false
)
setOnKeyListener
{
_
,
i
,
_
->
i
==
KeyEvent
.
KEYCODE_BACK
}
findViewById
<
ImageView
>(
R
.
id
.
iv_download_quit
).
setOnClickListener
(
this
)
tvDownloadProgress
=
findViewById
<
TextView
>(
R
.
id
.
tv_download_progress
)
}
override
fun
onClick
(
v
:
View
)
{
if
(
AntiShake
.
check
(
v
?.
id
))
return
when
(
v
.
id
)
{
R
.
id
.
iv_download_quit
->
{
dismiss
()
}
}
}
fun
setProgress
(
progress
:
Progress
)
{
tvDownloadProgress
?.
text
=
"正在下载 "
+
Utils
.
getProgressDisplayLine
(
progress
.
currentBytes
,
progress
.
totalBytes
)
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/ForegroundOrBackground.java
View file @
712b7968
...
...
@@ -64,8 +64,9 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
// if (activity == null)
// return;
if
(
activity
==
null
)
return
;
app_activity
=
new
WeakReference
<>(
activity
);
// String simpleName = activity.getClass().getSimpleName();
// if (TextUtils.equals(simpleName, "MainActivity")) {
// // 版本更新
...
...
GoodMoney/app/src/main/res/layout/dialog_download_progress.xml
0 → 100644
View file @
712b7968
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"420dp"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:layout_marginLeft=
"40dp"
android:layout_marginRight=
"40dp"
android:background=
"@drawable/shape_bg_write"
android:orientation=
"vertical"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:text=
"温馨提示"
android:textColor=
"@color/black"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
<ImageView
android:id=
"@+id/iv_download_quit"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:layout_alignParentRight=
"true"
android:layout_marginRight=
"10dp"
android:src=
"@mipmap/ic_activity_quit"
/>
</RelativeLayout>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1px"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"10dp"
android:background=
"#E1E1E1"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:gravity=
"center_horizontal"
android:text=
"应用下载中,请等待..."
android:textColor=
"@color/black"
android:textSize=
"14sp"
/>
<TextView
android:id=
"@+id/tv_download_progress"
android:layout_width=
"match_parent"
android:layout_height=
"46dp"
android:layout_marginLeft=
"30dp"
android:layout_marginTop=
"20dp"
android:layout_marginRight=
"30dp"
android:layout_marginBottom=
"20dp"
android:background=
"@drawable/shape_main"
android:gravity=
"center"
android:textColor=
"@color/white"
android:textSize=
"14sp"
/>
</LinearLayout>
</RelativeLayout>
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