Commit 99259dea authored by mengcuiguang2's avatar mengcuiguang2

修改权限弹窗界面

parent 09ffc425
......@@ -21,6 +21,8 @@
<uses-permission android:name="android.permission.CAMERA" />
<!-- 获取手机状态信息 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- android10以后 后台运行位置 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<application
android:name="com.mints.street.AppApplication"
......
......@@ -12,4 +12,8 @@ object Constant {
*/
const val MINTS_PKG_NAME = "com.mints.street"
/**
* 第一次打开权限页面
*/
const val FIRST_OPEN_PERMISSIONS = "first_open_permissions"
}
......@@ -46,7 +46,7 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
}
fun login(mobile: String, smsCode: String) {
showDialog()
// showDialog()
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
vo["smsCode"] = smsCode
......@@ -56,14 +56,16 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
object : HttpSubscribeImpl<BaseResponse<UserBean>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<UserBean>) {
dismissDialog()
// dismissDialog()
this@LoginViewModel.saveTerminalInfo()
UserManager.INSTANCE.saveUserInfo(response.result)
data.value = response.message
KLog.e("login", response.result.toString())
ToastUtils.showShort("登录信息="+response.result.consumer?.idcode)
data.value = response.message
}
override fun onError(e: Throwable) {
......
......@@ -134,6 +134,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
binding.imageOut.setOnClickListener {
mBaiduMap?.setMapStatus(MapStatusUpdateFactory.zoomOut())
}
//历史影像
binding.imageMapHistory.setOnClickListener {
startActivity(HistoricalimageActivity::class.java)
}
mRecommendStopSearch = RecommendStopSearch.newInstance()
mRecommendStopSearch?.setOnGetRecommendStopResultListener { result ->
if (result != null) {
......
......@@ -74,7 +74,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
when (v?.id) {
R.id.ly_aboutus -> {
startActivity(AboutusActivity::class.java)
// startActivity(HistoricalimageActivity::class.java)
// startActivity(PermissionsActivity::class.java)
}
R.id.ly_moresettings -> {
startActivity(MoresettingsActivity::class.java)
......
package com.mints.street.main.my
import android.Manifest
import android.os.Build
import android.os.Bundle
import android.view.View
import com.fry.base.base.BaseActivity
import com.github.iielse.switchbutton.SwitchView
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityMoresettingsBinding
import com.mints.street.common.Constant
import com.mints.street.databinding.ActivityPermissionsBinding
import com.mints.street.main.MainActivity
import com.tbruyelle.rxpermissions2.RxPermissions
import com.tencent.mmkv.MMKV
import kotlinx.android.synthetic.main.activity_permissions.*
import me.goldze.mvvmhabit.utils.ToastUtils
/**
* 描述:权限授权
* 作者:孟崔广
* 时间:2021/7/14 15:51
*/
class PermissionsActivity : BaseActivity<ActivityPermissionsBinding, PermissionsViewModel>(), View.OnClickListener {
class PermissionsActivity : BaseActivity<ActivityPermissionsBinding, PermissionsViewModel>() {
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_permissions
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
btnPermissionsDont.setOnClickListener(this)
btnPermissionsNext.setOnClickListener(this)
}
private fun initView() {
sv_positioning.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
svPosition.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
override fun toggleToOn(view: SwitchView?) {
svPosition?.isOpened = true
}
override fun toggleToOff(view: SwitchView?) {
svPosition?.isOpened = false
}
})
svStrong.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
override fun toggleToOn(view: SwitchView?) {
svStrong?.isOpened = true
}
override fun toggleToOff(view: SwitchView?) {
svStrong?.isOpened = false
}
})
svReadmsg.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
override fun toggleToOn(view: SwitchView?) {
sv_positioning?.isOpened = true
svReadmsg?.isOpened = true
}
override fun toggleToOff(view: SwitchView?) {
sv_positioning?.isOpened = false
svReadmsg?.isOpened = false
}
})
}
override fun onClick(v: View?) {
when(v?.id){
R.id.btnPermissionsDont -> ToastUtils.showLong("请您同意授权,否则将无法使用APP功能")
R.id.btnPermissionsNext->{
val rxPermissions = RxPermissions(this)
rxPermissions.request(
if(svPosition.isOpened&&Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else "",
if(svPosition.isOpened) Manifest.permission.ACCESS_FINE_LOCATION else "",
if(svStrong.isOpened) Manifest.permission.WRITE_EXTERNAL_STORAGE else "",
if(svReadmsg.isOpened) Manifest.permission.READ_PHONE_STATE else ""
)
.subscribe {
startActivityThenKill(MainActivity::class.java)
}
MMKV.mmkvWithID(Constant.FIRST_OPEN_PERMISSIONS).encode(Constant.FIRST_OPEN_PERMISSIONS, true)
}
}
}
}
\ No newline at end of file
......@@ -83,11 +83,13 @@ class UserManager {
val mobile: String? = user.mobile
val openid: String? = user.openid
MMKV.mmkvWithID(USER_ID).encode(USER_ID, user.pk_id.toString())
MMKV.mmkvWithID(CODE_ID).encode(CODE_ID, user.idcode.toString())
MMKV.mmkvWithID(CODE_ID).encode(CODE_ID, user.idcode)
if (!TextUtils.isEmpty(mobile)) {
MMKV.mmkvWithID(MOBILE).encode(MOBILE, mobile)
}
MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname.toString())
if (!TextUtils.isEmpty(user.nickname)) {
MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname)
}
MMKV.mmkvWithID(IS_FOREVER).encode(IS_FOREVER, user.isForever)
MMKV.mmkvWithID(EXPIRETIME).encode(EXPIRETIME, user.expireTime)
if (!TextUtils.isEmpty(openid)) {
......
......@@ -12,10 +12,14 @@ 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.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.manager.CsjGroMoreManager
import com.mints.street.manager.UserManager
import com.tencent.mmkv.MMKV
/**
* 描述:gromore开屏页
......@@ -163,6 +167,12 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
* 跳转到主页面
*/
private fun goToMainActivity() {
if(MMKV.mmkvWithID(Constant.FIRST_OPEN_PERMISSIONS).decodeBool(Constant.FIRST_OPEN_PERMISSIONS, false)){
// 非新用户
startActivityThenKill(MainActivity::class.java)
}else{
startActivityThenKill(PermissionsActivity::class.java)
}
}
}
\ No newline at end of file
......@@ -2,6 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#2196F3" />
<corners android:radius="21dp" />
<corners android:radius="30dp" />
</shape>
\ No newline at end of file
......@@ -7,6 +7,6 @@
android:color="#74000000"
/>
<solid android:color="#ffffffff" />
<corners android:radius="21dp" />
<corners android:radius="30dp" />
</shape>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment