Commit b4fdaf26 authored by wanglei's avatar wanglei

...

parent 213fec50
......@@ -133,9 +133,6 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
allowAllTimeDialog?.dismiss()
allowAllTimeDialog = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
launcher.launch(arrayOf(Manifest.permission.POST_NOTIFICATIONS)) {}
}
requestServiceLocationUpdates()
}
}
......
package com.base.locationsharewhite.ui.main
import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Intent
import android.graphics.Color
import android.view.View
......@@ -13,6 +14,7 @@ import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.bean.ViewerBean
import com.base.locationsharewhite.databinding.ActivityLocationShareBinding
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.location.LocationShareListUtils
import com.base.locationsharewhite.location.LocationShareUtils
......@@ -21,10 +23,14 @@ import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_MYSEL
import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SHARED
import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SUCCESS
import com.base.locationsharewhite.location.LocationStatusUtils
import com.base.locationsharewhite.service.StayJobService.Companion.requestServiceLocationUpdates
import com.base.locationsharewhite.ui.set.RenameActivity
import com.base.locationsharewhite.ui.views.DialogView.showViewerMoreDialog
import com.base.locationsharewhite.ui.views.LocationPermissionDialog.showLocationAllowAllTimeDialog
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.PermissionUtils.checkAllLocationPermission
import com.base.locationsharewhite.utils.PermissionUtils.requestLocationAllowAllTime
import com.base.locationsharewhite.utils.SpStringUtils
import com.base.locationsharewhite.utils.SpStringUtils.VIEWER_NICKNAME_KEY
import com.base.locationsharewhite.utils.SpStringUtils._DEVICE_NICKNAME_
......@@ -116,8 +122,8 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
override fun initListener() {
super.initListener()
onBackPressedDispatcher.addCallback {
if (AdsMgr.adsConfigBean.functionBackShowAd){
AdsMgr.showInsert(this@LocationShareActivity,false,object :AdsShowCallBack(){
if (AdsMgr.adsConfigBean.functionBackShowAd) {
AdsMgr.showInsert(this@LocationShareActivity, false, object : AdsShowCallBack() {
override fun close(where: Int) {
finishToMain()
}
......@@ -130,7 +136,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
finishToMain()
}
})
}else{
} else {
finishToMain()
}
}
......@@ -138,11 +144,19 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
onBackPressedDispatcher.onBackPressed()
}
binding.tvShare.setOnClickListener {
val code = binding.editCode.text.toString()
if (code.isEmpty()) {
toast("code is empty", true)
return@setOnClickListener
}
if (!checkAllLocationPermission()) {
showAllowAllTimeDialog()
return@setOnClickListener
}
hideKeyBoard()
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
override fun close(where: Int) {
......@@ -244,5 +258,31 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
}
}
private var allowAllTimeDialog: Dialog? = null
private fun showAllowAllTimeDialog() {
if (!checkAllLocationPermission()) {
// toast("显示权限始终允许弹窗")
if (allowAllTimeDialog == null) {
allowAllTimeDialog =
showLocationAllowAllTimeDialog(
setAction = {
sendAllAllowedNotification(this)
requestLocationAllowAllTime(launcher, jumpOutAction = {
LogEx.logDebug(TAG, "jumpOutAction")
}, permissionAllowCallBack = {})
},
dismissAction = {
allowAllTimeDialog = null
})
}
} else {
// toast("不显示权限始终允许弹窗")
allowAllTimeDialog?.dismiss()
allowAllTimeDialog = null
requestServiceLocationUpdates()
}
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.databinding.ActivityMainBinding
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.location.LocationLoginUtils
import com.base.locationsharewhite.map.MapUtils.addLocationMarker
import com.base.locationsharewhite.service.StayJobService.Companion.requestServiceLocationUpdates
......@@ -93,9 +94,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
if (!checkAllLocationPermission()) {
showAllowAllTimeDialog()
} else {
val flag = areNotificationsEnabled()
requestServiceLocationUpdates()
}
val flag = areNotificationsEnabled()
EventUtils.event("areNotificationsEnabled", "areNotificationsEnabled=$flag")
}
private var bannerShowed = AtomicBoolean(false)
......
......@@ -2,6 +2,9 @@ package com.base.locationsharewhite.ui.views
import android.app.AlertDialog
import android.content.Context
import android.graphics.Color
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.LinearLayout
......@@ -24,15 +27,35 @@ object LocationPermissionDialog {
dialog.show()
val params = dialog.window?.attributes
params?.width = resources.getDimensionPixelOffset(R.dimen.dp_345)
// params?.width = resources.getDimensionPixelOffset(R.dimen.dp_345)
params?.height = LinearLayout.LayoutParams.WRAP_CONTENT
params?.gravity = Gravity.CENTER
params?.gravity = Gravity.BOTTOM
params?.y = 50
dialog.window?.attributes = params
dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
binding.flClose.setOnClickListener {
dialog.dismiss()
}
val stepText1 = "1. Go to Settings>Location Share>Permissions, then select the location"
val spannableString1 = SpannableString(stepText1)
val spanText1 = "Settings>Location Share>Permissions"
spannableString1.setSpan(
ForegroundColorSpan(Color.parseColor("#03B887")),
stepText1.indexOf(spanText1),
stepText1.indexOf(spanText1) + spanText1.length,
SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE
)
binding.tvStep1.text = spannableString1
val stepText2 = "2. Click 'Always Allow'"
val spannableString2 = SpannableString(stepText2)
val spanText2 = "'Always Allow'"
spannableString2.setSpan(
ForegroundColorSpan(Color.parseColor("#03B887")),
stepText2.indexOf(spanText2),
stepText2.indexOf(spanText2) + spanText2.length,
SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE
)
binding.tvStep2.text = spannableString2
binding.tvSettings.setOnClickListener {
dialog.dismiss()
setAction?.invoke()
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#DEDEDE" />
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
......@@ -2,142 +2,157 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="345dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ffffff_15"
android:background="@android:color/transparent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fl_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:padding="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/guanbi"
tools:ignore="ContentDescription" />
</FrameLayout>
<ImageView
android:id="@+id/iv_tishi"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="58dp"
android:src="@mipmap/tishi_permission"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
android:layout_marginTop="50dp"
android:background="@drawable/bg_ffffff_15"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_tip"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="36dp"
android:layout_marginTop="27dp"
android:layout_marginTop="64dp"
android:gravity="center_horizontal"
android:text="@string/allow_all_time_tip"
android:text="@string/permission_request"
android:textColor="#001725"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_tishi" />
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/ll_step"
android:layout_width="wrap_content"
<TextView
android:id="@+id/tv_step_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="24dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_tip">
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/allow_all_time_step_1"
android:textColor="#81888D"
android:textSize="15sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="18dp"
android:background="@drawable/bg_stroke_dedede_10"
android:orientation="horizontal">
<TextView
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/allow_all_time_step_2"
android:textColor="#81888D"
android:textSize="15sp" />
android:layout_gravity="center_vertical"
android:layout_marginStart="18dp"
android:src="@mipmap/dingweixiaoicon"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/allow_all_time_step_3"
android:textColor="#81888D"
android:textSize="15sp" />
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:includeFontPadding="false"
android:text="@string/location"
android:textColor="#001725"
android:textSize="14sp" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:id="@+id/cardview"
android:layout_width="238dp"
android:layout_height="64dp"
android:layout_marginTop="50dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="10dp"
app:cardElevation="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ll_step">
<TextView
android:id="@+id/tv_step_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="18dp"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
android:layout_height="42dp"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="18dp"
android:background="@drawable/bg_stroke_dedede_10"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="22dp"
android:src="@mipmap/yuan_permission"
android:layout_marginStart="18dp"
android:src="@mipmap/dingweixiaoicon"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginStart="15dp"
android:includeFontPadding="false"
android:text="@string/allow_all_the_time"
android:textColor="#001725"
android:textSize="18sp" />
android:textSize="14sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="18dp"
android:text="@string/why_do_we_need_this_permission"
android:textColor="#001725"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:text="@string/permission_reason_1"
android:textColor="#81888D"
android:textSize="12sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="10dp"
android:text="@string/permission_reason_2"
android:textColor="#81888D"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_settings"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="34dp"
android:layout_marginBottom="27dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="18dp"
android:background="@drawable/bg_03b988_10"
android:gravity="center"
android:text="@string/open_settings"
android:text="@string/authorize"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardview" />
app:layout_constraintBottom_toBottomOf="parent" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/dingweiicon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -81,4 +81,10 @@
<string name="background_for_location">app is running in the background for location updates</string>
<string name="sharing_location_people">Sharing location with 1 people</string>
<string name="map">Map</string>
<string name="permission_request">Permission request</string>
<string name="location">Location</string>
<string name="why_do_we_need_this_permission">Why do we need this permission?</string>
<string name="permission_reason_1">1.By accessing your location data, our application can accurately track your location and share it with your friends,even when running in the background.</string>
<string name="permission_reason_2">2.Your privacy is protected and will not be used for any other commercial purposes. For more information, please refer to our privacy policy.</string>
<string name="authorize">AUTHORIZE</string>
</resources>
\ 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