This commit is contained in:
wangcongtao
2020-04-15 16:25:25 +08:00
parent 2fdb909ea4
commit df1e308684
32 changed files with 749 additions and 482 deletions

View File

@@ -36,8 +36,6 @@ object NaviManager {
SearchServiceHolder.getNavi().stopNavi()
} else if (key_type == 20009) {
SearchServiceHolder.mogoLauncher.backToLauncher(context)
gotoSearch()
} else if (key_type == 10005) {
// * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。

View File

@@ -12,186 +12,195 @@ import com.mogo.service.module.IMogoSettingManager
* 2020-01-12.
*/
object SettingManager : IMogoSettingManager {
private val KEY_PAHT_PREFER = "keyPath"
private val KEY_VOLUME = "keyVolume"
private val KEY_VOICE_STYLE = "keyVoice"
private val KEY_MAP_TYPE = "keyMapType"
private lateinit var settings: SharedPreferences
private val KEY_PAHT_PREFER = "keyPath"
private val KEY_VOLUME = "keyVolume"
private val KEY_VOICE_STYLE = "keyVoice"
private val KEY_MAP_TYPE = "keyMapType"
private val KEY_AIMLESS_MODE_TYPE = "keyAimlessModeType"
private lateinit var settings: SharedPreferences
/**
* 是否躲避拥堵
*/
private var congestion = false
/**
* 是否躲避拥堵
*/
private var congestion = false
/**
* 不走高速
*/
private var avoidSpeed = false
/**
* 不走高速
*/
private var avoidSpeed = false
/**
* 避免收费
*/
private var cost = false
/**
* 避免收费
*/
private var cost = false
/**
* 高速优先
*/
private var highSpeed = false
/**
* 模拟导航
*/
private var isMonitor: Boolean = false
/**
* 高速优先
*/
private var highSpeed = false
/**
* 模拟导航
*/
private var isMonitor: Boolean = false
/**
* GPS 模拟
*/
private var isGpsSimulator: Boolean = false
/**
* GPS 模拟
*/
private var isGpsSimulator: Boolean = false
override fun getPathPrefer(): Int {
return settings!!.getInt(KEY_PAHT_PREFER, 0)
}
override fun getVolume(): Int {
return settings!!.getInt(KEY_VOLUME, 0)
}
override fun getVoiceStyle(): Int {
return settings!!.getInt(KEY_VOICE_STYLE, R.id.rb_navi_detail)
}
override fun getMapType(): Int {
return settings!!.getInt(KEY_MAP_TYPE, R.id.rb_navi_day)
}
fun setPathPrefer(type: Int) {
settings!!.edit()
.putInt(KEY_PAHT_PREFER, type)
.apply()
}
fun setVolume(type: Int) {
settings!!.edit()
.putInt(KEY_VOLUME, type)
.apply()
}
fun setVoiceStyle(type: Int) {
settings!!.edit()
.putInt(KEY_VOICE_STYLE, type)
.apply()
}
fun setMapType(type: Int) {
settings!!.edit()
.putInt(KEY_MAP_TYPE, type)
.apply()
}
fun setMonitor(type: Boolean) {
isMonitor = type
}
fun isMonitor(): Boolean {
return isMonitor
}
fun setGpsSimulator(type:Boolean){
isGpsSimulator = type
}
fun isGpsSimulator(): Boolean {
return isGpsSimulator
}
/**
* 是否躲避拥堵
*/
fun congestion(congestion: Boolean) {
this.congestion = congestion
save()
}
/**
* 不走高速
*/
fun avoidSpeed(avoidSpeed: Boolean) {
this.avoidSpeed = avoidSpeed
if (avoidSpeed) {
this.highSpeed = false
override fun getPathPrefer(): Int {
return settings!!.getInt(KEY_PAHT_PREFER, 0)
}
save()
}
/**
* 避免收费
*/
fun cost(cost: Boolean) {
this.cost = cost
if (cost) {
this.highSpeed = false
override fun getVolume(): Int {
return settings!!.getInt(KEY_VOLUME, 0)
}
save()
}
/**
* 高速优先
*/
fun highSpeed(highSpeed: Boolean) {
this.highSpeed = highSpeed
if (highSpeed) {
this.avoidSpeed = false
this.cost = false
override fun getVoiceStyle(): Int {
return settings!!.getInt(KEY_VOICE_STYLE, R.id.rb_navi_detail)
}
save()
}
override fun getMapType(): Int {
return settings!!.getInt(KEY_MAP_TYPE, R.id.rb_navi_day)
}
fun isCongestion(): Boolean {
return congestion
}
fun setPathPrefer(type: Int) {
settings!!.edit()
.putInt(KEY_PAHT_PREFER, type)
.apply()
}
fun isAvoidSpeed(): Boolean {
return avoidSpeed
}
fun setVolume(type: Int) {
settings!!.edit()
.putInt(KEY_VOLUME, type)
.apply()
}
fun isCost(): Boolean {
return cost
}
fun setVoiceStyle(type: Int) {
settings!!.edit()
.putInt(KEY_VOICE_STYLE, type)
.apply()
}
fun isHighSpeed(): Boolean {
return highSpeed
}
fun setMapType(type: Int) {
settings!!.edit()
.putInt(KEY_MAP_TYPE, type)
.apply()
}
private fun save() {
settings.edit()
.putBoolean("congestion", congestion)
.putBoolean("avoidSpeed", avoidSpeed)
.putBoolean("cost", cost)
.putBoolean("highSpeed", highSpeed)
.apply()
updateConfig()
fun setMonitor(type: Boolean) {
isMonitor = type
}
}
fun isMonitor(): Boolean {
return isMonitor
}
override fun init(context: Context) {
settings = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
fun setGpsSimulator(type: Boolean) {
isGpsSimulator = type
}
congestion = settings.getBoolean("congestion", false)
avoidSpeed = settings.getBoolean("avoidSpeed", false)
cost = settings.getBoolean("cost", false)
highSpeed = settings.getBoolean("highSpeed", false)
updateConfig()
}
fun isGpsSimulator(): Boolean {
return isGpsSimulator
}
private fun updateConfig() {
SearchServiceHolder.getNavi()
.naviConfig
.cost(cost)
.avoidSpeed(avoidSpeed)
.highSpeed(highSpeed)
.congestion(congestion)
}
/**
* 是否躲避拥堵
*/
fun congestion(congestion: Boolean) {
this.congestion = congestion
save()
}
/**
* 不走高速
*/
fun avoidSpeed(avoidSpeed: Boolean) {
this.avoidSpeed = avoidSpeed
if (avoidSpeed) {
this.highSpeed = false
}
save()
}
/**
* 避免收费
*/
fun cost(cost: Boolean) {
this.cost = cost
if (cost) {
this.highSpeed = false
}
save()
}
/**
* 高速优先
*/
fun highSpeed(highSpeed: Boolean) {
this.highSpeed = highSpeed
if (highSpeed) {
this.avoidSpeed = false
this.cost = false
}
save()
}
fun isCongestion(): Boolean {
return congestion
}
fun isAvoidSpeed(): Boolean {
return avoidSpeed
}
fun isCost(): Boolean {
return cost
}
fun isHighSpeed(): Boolean {
return highSpeed
}
private fun save() {
settings.edit()
.putBoolean("congestion", congestion)
.putBoolean("avoidSpeed", avoidSpeed)
.putBoolean("cost", cost)
.putBoolean("highSpeed", highSpeed)
.apply()
updateConfig()
}
override fun init(context: Context) {
settings = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
congestion = settings.getBoolean("congestion", false)
avoidSpeed = settings.getBoolean("avoidSpeed", false)
cost = settings.getBoolean("cost", false)
highSpeed = settings.getBoolean("highSpeed", false)
updateConfig()
}
private fun updateConfig() {
SearchServiceHolder.getNavi()
.naviConfig
.cost(cost)
.avoidSpeed(avoidSpeed)
.highSpeed(highSpeed)
.congestion(congestion)
}
fun setAimlessMode(type: Int){
settings.edit().putInt(KEY_AIMLESS_MODE_TYPE, type).apply()
}
fun getAimlessMode():Int {
return settings.getInt(KEY_AIMLESS_MODE_TYPE, R.id.aimlessModeClose)
}
}

View File

@@ -9,6 +9,7 @@ import android.widget.SeekBar
import android.widget.SeekBar.OnSeekBarChangeListener
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.voice.AIAssist
import com.mogo.map.constants.BroadcastMode
import com.mogo.map.uicontroller.EnumMapUI
import com.mogo.module.common.MogoModulePaths
@@ -79,9 +80,6 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
iv_back.setOnClickListener {
SearchServiceHolder.fragmentManager.pop()
}
initViews()
initEvent()
EventBus.getDefault().register(this)
@@ -101,7 +99,8 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
rb_navi_auto.isChecked = SettingManager.mapType == R.id.rb_navi_auto
rb_navi_detail.isChecked = SettingManager.voiceStyle == R.id.rb_navi_detail
rb_navi_draft.isChecked = SettingManager.voiceStyle == R.id.rb_navi_draft
aimlessModeClose.isChecked = SettingManager.getAimlessMode() == aimlessModeClose.id
aimlessModeOpen.isChecked = SettingManager.getAimlessMode() == aimlessModeOpen.id
updateHome()
updateCompany()
@@ -109,6 +108,9 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
}
private fun initEvent() {
rl_navi_setting_title.setOnClickListener {
SearchServiceHolder.fragmentManager.pop()
}
iv_sound_plus.setOnClickListener {
VolumeManager.getInstance(context).incVolume()
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.plus(10)
@@ -177,6 +179,21 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
}
}
aimlessModeGroup.setOnCheckedChangeListener { group, checkedId ->
SettingManager.setAimlessMode(checkedId)
when (checkedId){
R.id.aimlessModeClose -> {
SearchServiceHolder.getNavi().setAimlessModeStatus(false)
AIAssist.getInstance(mContext).speakTTSVoice("已为您关闭巡航模式")
}
R.id.aimlessModeOpen -> {
SearchServiceHolder.getNavi().setAimlessModeStatus(true)
AIAssist.getInstance(mContext).speakTTSVoice("已为您开启巡航模式")
}
}
}
tv_navi_clear_home_address.setOnClickListener {
AddressManager.deleteHome(context!!)