Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_street
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_street
Commits
aa7a8865
Commit
aa7a8865
authored
Jul 28, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加权限弹窗
parent
7d632fdd
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
364 additions
and
27 deletions
+364
-27
Constant.kt
app/src/main/java/com/mints/street/common/Constant.kt
+5
-0
SplashActivity.kt
app/src/main/java/com/mints/street/splash/SplashActivity.kt
+85
-26
PowerDialog.kt
...c/main/java/com/mints/street/widget/dialog/PowerDialog.kt
+55
-0
shape_bg_write.xml
app/src/main/res/drawable/shape_bg_write.xml
+10
-0
dialog_power.xml
app/src/main/res/layout/dialog_power.xml
+207
-0
ic_dialog_permission_bottom.png
...src/main/res/mipmap-xhdpi/ic_dialog_permission_bottom.png
+0
-0
ic_dialog_permission_top.png
app/src/main/res/mipmap-xhdpi/ic_dialog_permission_top.png
+0
-0
colors.xml
app/src/main/res/values/colors.xml
+1
-0
colors.xml
library_base/src/main/res/values/colors.xml
+1
-1
No files found.
app/src/main/java/com/mints/street/common/Constant.kt
View file @
aa7a8865
...
...
@@ -22,4 +22,9 @@ object Constant {
// 协议地址
var
REGISTER_URL
=
BuildConfig
.
MainIp
+
"map/register.html"
//服务协议
var
PRIVACY_URL
=
BuildConfig
.
MainIp
+
"map/privacy.html"
//隐私协议
/**
* 第一次授权
*/
const
val
LOAN_PERMISSION_FLAG
=
"loan_permission_flag"
}
app/src/main/java/com/mints/street/splash/SplashActivity.kt
View file @
aa7a8865
package
com.mints.street.splash
import
android.os.Bundle
import
android.view.View
import
android.widget.FrameLayout
import
com.blankj.utilcode.util.ToastUtils
import
com.bytedance.msdk.adapter.pangle.PangleNetworkRequestInfo
import
com.bytedance.msdk.api.AdError
import
com.bytedance.msdk.api.AdSlot
...
...
@@ -12,12 +14,15 @@ import com.bytedance.msdk.api.splash.TTSplashAdLoadCallback
import
com.fry.base.base.BaseActivity
import
com.mints.street.BR
import
com.mints.street.R
import
com.mints.street.ad.CsjGroMoreManager
import
com.mints.street.common.Constant
import
com.mints.street.common.DeviceInfo
import
com.mints.street.databinding.ActivitySplashBinding
import
com.mints.street.main.MainActivity
import
com.mints.street.main.my.PermissionsActivity
import
com.mints.street.ad.CsjGroMoreManager
import
com.mints.street.webview.MintsWebViewActivity
import
com.mints.street.widget.dialog.DialogListener
import
com.mints.street.widget.dialog.PowerDialog
import
com.tencent.mmkv.MMKV
import
me.goldze.mvvmhabit.utils.systembar.StatusBarUtil
...
...
@@ -26,18 +31,19 @@ import me.goldze.mvvmhabit.utils.systembar.StatusBarUtil
* 作者:孟崔广
* 时间:2021/7/9 13:39
*/
class
SplashActivity
:
BaseActivity
<
ActivitySplashBinding
,
SplashViewModel
>()
{
class
SplashActivity
:
BaseActivity
<
ActivitySplashBinding
,
SplashViewModel
>()
{
private
var
powerDialog
:
PowerDialog
?
=
null
private
var
msplash
:
FrameLayout
?
=
null
private
var
mTTSplashAd
:
TTSplashAd
?
=
null
private
val
AD_TIME_OUT
=
3000
private
var
onPaused
=
false
//是否强制跳转到主页面
private
var
mForceGoMain
=
false
private
var
isClickAgree
=
false
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
}
override
fun
initContentView
(
savedInstanceState
:
Bundle
?)
=
R
.
layout
.
activity_splash
...
...
@@ -59,14 +65,17 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
}
override
fun
onResume
()
{
//判断是否该跳转到主页面
if
(
mForceGoMain
)
{
goToMainActivity
()
}
if
(
onPaused
)
{
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要自己在onResume中跳转主页。
goToMainActivity
()
if
(
isClickAgree
)
{
//判断是否该跳转到主页面
if
(
mForceGoMain
)
{
goToMainActivity
()
}
if
(
onPaused
)
{
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要自己在onResume中跳转主页。
goToMainActivity
()
}
}
super
.
onResume
()
}
...
...
@@ -84,10 +93,10 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
override
fun
onDestroy
()
{
super
.
onDestroy
()
mTTSplashAd
?.
destroy
()
mTTSplashAd
=
null
mTTSplashAd
=
null
msplash
?.
removeAllViews
()
msplash
=
null
msplash
=
null
}
/**
...
...
@@ -98,14 +107,7 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
if
(!
deviceInfo
.
signInfo
)
{
finish
()
}
else
{
// try {
// msplash = findViewById(R.id.splash_container)
// //加载开屏广告
// loadSplashAd()
// } catch (e: Exception) {
// goToMainActivity()
// }
goToMainActivity
()
showPowerDialog
()
}
}
...
...
@@ -122,8 +124,8 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
//step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
val
adSlot
=
AdSlot
.
Builder
()
.
setImageAdSize
(
1080
,
1920
)
// 既适用于原生类型,也适用于模版类型。
.
build
()
.
setImageAdSize
(
1080
,
1920
)
// 既适用于原生类型,也适用于模版类型。
.
build
()
//自定义兜底方案 选择使用
val
ttNetworkRequestInfo
:
TTNetworkRequestInfo
...
...
@@ -172,11 +174,68 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
* 跳转到主页面
*/
private
fun
goToMainActivity
()
{
if
(
MMKV
.
mmkvWithID
(
Constant
.
FIRST_OPEN_PERMISSIONS
).
decodeBool
(
Constant
.
FIRST_OPEN_PERMISSIONS
,
false
))
{
if
(
MMKV
.
mmkvWithID
(
Constant
.
FIRST_OPEN_PERMISSIONS
).
decodeBool
(
Constant
.
FIRST_OPEN_PERMISSIONS
,
false
))
{
// 非新用户
startActivityThenKill
(
MainActivity
::
class
.
java
)
}
else
{
}
else
{
startActivityThenKill
(
PermissionsActivity
::
class
.
java
)
}
}
private
fun
showPowerDialog
()
{
if
(
MMKV
.
mmkvWithID
(
Constant
.
LOAN_PERMISSION_FLAG
).
decodeBool
(
Constant
.
LOAN_PERMISSION_FLAG
,
true
))
{
powerDialog
()
}
else
{
isClickAgree
=
true
try
{
msplash
=
findViewById
(
R
.
id
.
fl_splash
)
//加载开屏广告
loadSplashAd
()
}
catch
(
e
:
Exception
)
{
goToMainActivity
()
}
}
}
/**
* 权限弹窗
*/
private
fun
powerDialog
()
{
powerDialog
=
PowerDialog
(
this
,
object
:
DialogListener
()
{
override
fun
onClick
(
v
:
View
)
{
when
(
v
.
id
)
{
R
.
id
.
tv_dialogper_agreement
->
{
MintsWebViewActivity
.
startWebView
(
name
=
"用户协议"
,
url
=
Constant
.
REGISTER_URL
)
}
R
.
id
.
tv_dialogper_policy
->
{
MintsWebViewActivity
.
startWebView
(
name
=
"隐私协议"
,
url
=
Constant
.
PRIVACY_URL
)
}
R
.
id
.
btn_dialogper_back
->
{
if
(
powerDialog
!=
null
&&
powerDialog
!!
.
isShowing
)
{
ToastUtils
.
showLong
(
"请您同意授权,否则将无法使用APP功能"
)
}
}
R
.
id
.
btn_dialogper_next
->
{
if
(
powerDialog
!=
null
&&
powerDialog
!!
.
isShowing
)
{
powerDialog
!!
.
dismiss
()
try
{
msplash
=
findViewById
(
R
.
id
.
fl_splash
)
//加载开屏广告
loadSplashAd
()
}
catch
(
e
:
Exception
)
{
goToMainActivity
()
}
isClickAgree
=
true
MMKV
.
mmkvWithID
(
Constant
.
LOAN_PERMISSION_FLAG
).
encode
(
Constant
.
LOAN_PERMISSION_FLAG
,
true
)
}
}
}
}
})
powerDialog
?.
show
()
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/widget/dialog/PowerDialog.kt
0 → 100644
View file @
aa7a8865
package
com.mints.street.widget.dialog
import
android.app.Dialog
import
android.content.Context
import
android.view.Gravity
import
android.view.KeyEvent
import
android.view.View
import
android.view.WindowManager
import
android.widget.TextView
import
com.mints.street.R
/**
* 授权弹窗
*/
class
PowerDialog
(
context
:
Context
,
private
val
listener
:
DialogListener
)
:
Dialog
(
context
,
R
.
style
.
dialog
)
{
private
val
lp
:
WindowManager
.
LayoutParams
private
val
tv_dialogper_agreement
:
TextView
private
val
tv_dialogper_policy
:
TextView
private
val
btn_dialogper_back
:
TextView
private
val
btn_dialogper_next
:
TextView
init
{
setContentView
(
R
.
layout
.
dialog_power
)
// 设置window属性
lp
=
window
!!
.
attributes
lp
.
gravity
=
Gravity
.
CENTER
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
lp
.
windowAnimations
=
R
.
style
.
DialogAnimBottom
// lp.dimAmount = 0; // 去背景遮盖
// lp.alpha = 1.0f;//透明效果
window
!!
.
attributes
=
lp
// 设置外部不可关闭
setCancelable
(
false
)
setCanceledOnTouchOutside
(
false
)
setOnKeyListener
{
_
,
i
,
_
->
i
==
KeyEvent
.
KEYCODE_BACK
}
// 查找View
tv_dialogper_agreement
=
findViewById
<
View
>(
R
.
id
.
tv_dialogper_agreement
)
as
TextView
tv_dialogper_policy
=
findViewById
<
View
>(
R
.
id
.
tv_dialogper_policy
)
as
TextView
btn_dialogper_back
=
findViewById
<
View
>(
R
.
id
.
btn_dialogper_back
)
as
TextView
btn_dialogper_next
=
findViewById
<
View
>(
R
.
id
.
btn_dialogper_next
)
as
TextView
tv_dialogper_policy
.
setOnClickListener
(
listener
)
tv_dialogper_agreement
.
setOnClickListener
(
listener
)
btn_dialogper_back
.
setOnClickListener
(
listener
)
btn_dialogper_next
.
setOnClickListener
(
listener
)
}
}
\ No newline at end of file
app/src/main/res/drawable/shape_bg_write.xml
0 → 100644
View file @
aa7a8865
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<!-- 填充的颜色 -->
<solid
android:color=
"#FFFFFF"
/>
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners
android:radius=
"5dip"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/dialog_power.xml
0 → 100644
View file @
aa7a8865
<?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"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"20dp"
android:text=
"用户协议及隐私条款"
android:textColor=
"@color/black"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginRight=
"16dp"
android:text=
"我们依据最新的法律,向您说明流量宝盒软件的隐私政策,特向您推送本提示。请您阅读并充分理解相关条款。"
android:textColor=
"@color/black"
android:textSize=
"14sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"16dp"
android:text=
"我们承诺"
android:textColor=
"@color/black"
android:textSize=
"16sp"
android:textStyle=
"bold"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"18dp"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"16dp"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center_vertical"
android:src=
"@mipmap/ic_dialog_permission_top"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginLeft=
"4dp"
android:text=
"我们会严格按照《网络安全法》、《信息网络传播保护条例》等保护您的个人信息"
android:textColor=
"@color/color_60000000"
android:textSize=
"14sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"18dp"
android:layout_marginTop=
"16dp"
android:layout_marginRight=
"16dp"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center_vertical"
android:src=
"@mipmap/ic_dialog_permission_bottom"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginLeft=
"4dp"
android:text=
"如果未经您的授权,我们不会使用您的个人信息用于您未授权的其他途径和目的"
android:textColor=
"@color/color_60000000"
android:textSize=
"14sp"
/>
</LinearLayout>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginRight=
"16dp"
android:gravity=
"center_horizontal"
android:text=
"您点击“同意”,即表示您已阅读并同意更新后的《用户注册协议》及《隐私政策》"
android:textColor=
"@color/black"
android:textSize=
"14sp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:gravity=
"center_horizontal"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingTop=
"4dp"
android:paddingBottom=
"6dp"
android:text=
"查看完整版"
android:textColor=
"@color/color_60000000"
android:textSize=
"12sp"
/>
<TextView
android:id=
"@+id/tv_dialogper_agreement"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingLeft=
"4dp"
android:paddingTop=
"6dp"
android:paddingRight=
"2dp"
android:paddingBottom=
"6dp"
android:text=
"用户注册协议"
android:textColor=
"@color/main_color"
android:textSize=
"12sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingTop=
"6dp"
android:paddingBottom=
"6dp"
android:text=
"及"
android:textColor=
"@color/color_60000000"
android:textSize=
"12sp"
/>
<TextView
android:id=
"@+id/tv_dialogper_policy"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingLeft=
"2dp"
android:paddingTop=
"6dp"
android:paddingRight=
"2dp"
android:paddingBottom=
"6dp"
android:text=
"隐私政策"
android:textColor=
"@color/main_color"
android:textSize=
"12sp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1px"
android:layout_marginTop=
"6dp"
android:layout_marginBottom=
"10dp"
android:background=
"#E1E1E1"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/btn_dialogper_next"
android:layout_width=
"match_parent"
android:layout_height=
"36dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:background=
"@color/main_color"
android:gravity=
"center"
android:text=
"同意"
android:textColor=
"@color/white"
/>
<TextView
android:id=
"@+id/btn_dialogper_back"
android:layout_width=
"match_parent"
android:layout_height=
"36dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:layout_marginBottom=
"10dp"
android:background=
"@color/white"
android:gravity=
"center"
android:text=
"不同意"
android:textColor=
"@color/color_BEC2CC"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
app/src/main/res/mipmap-xhdpi/ic_dialog_permission_bottom.png
0 → 100644
View file @
aa7a8865
6.91 KB
app/src/main/res/mipmap-xhdpi/ic_dialog_permission_top.png
0 → 100644
View file @
aa7a8865
7.76 KB
app/src/main/res/values/colors.xml
View file @
aa7a8865
...
...
@@ -21,6 +21,7 @@
<color
name=
"color_555"
>
#555555
</color>
<color
name=
"color_8F6D21"
>
#8F6D21
</color>
<color
name=
"color_0000"
>
#00000000
</color>
<color
name=
"color_60000000"
>
#60000000
</color>
<color
name=
"color_2B3238"
>
#2B3238
</color>
<color
name=
"color_002444"
>
#002444
</color>
...
...
library_base/src/main/res/values/colors.xml
View file @
aa7a8865
...
...
@@ -3,7 +3,7 @@
<color
name=
"colorPrimary"
>
#ffffffff
</color>
<color
name=
"colorPrimaryDark"
>
#ffffffff
</color>
<color
name=
"main_color"
>
#
FB673E
</color>
<color
name=
"main_color"
>
#
668BFF
</color>
<color
name=
"main_blue_color"
>
#536792
</color>
<color
name=
"colorAccent"
>
#FF4081
</color>
...
...
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