完成设置页面
This commit is contained in:
@@ -180,7 +180,8 @@ public class NaviClient implements IMogoNavi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void updateNaviConfig() {
|
||||
@Override public MogoNaviConfig getNaviConfig() {
|
||||
return mMogoNaviConfig;
|
||||
}
|
||||
|
||||
// -- end
|
||||
|
||||
@@ -105,6 +105,6 @@ public interface IMogoNavi {
|
||||
void setCalculatePathDisplayBounds( Rect bounds );
|
||||
|
||||
|
||||
void updateNaviConfig();
|
||||
MogoNaviConfig getNaviConfig();
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,9 @@ public class MogoNaviConfig {
|
||||
*/
|
||||
public MogoNaviConfig avoidSpeed( boolean avoidSpeed ) {
|
||||
this.avoidSpeed = avoidSpeed;
|
||||
this.highSpeed = false;
|
||||
if (avoidSpeed) {
|
||||
this.highSpeed = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -55,7 +57,9 @@ public class MogoNaviConfig {
|
||||
*/
|
||||
public MogoNaviConfig cost( boolean cost ) {
|
||||
this.cost = cost;
|
||||
this.highSpeed = false;
|
||||
if (cost) {
|
||||
this.highSpeed = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -64,8 +68,10 @@ public class MogoNaviConfig {
|
||||
*/
|
||||
public MogoNaviConfig highSpeed( boolean highSpeed ) {
|
||||
this.highSpeed = highSpeed;
|
||||
this.avoidSpeed = false;
|
||||
this.cost = false;
|
||||
if (highSpeed) {
|
||||
this.avoidSpeed = false;
|
||||
this.cost = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,9 +136,10 @@ public class MogoNavi implements IMogoNavi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void updateNaviConfig() {
|
||||
@Override public MogoNaviConfig getNaviConfig() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.updateNaviConfig();
|
||||
return mDelegate.getNaviConfig();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,11 +41,7 @@ object SearchServiceHolder{
|
||||
val statusManager: IMogoStatusManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_STATUS_MANAGER
|
||||
).navigation() as IMogoStatusManager
|
||||
val settingManager: MogoSettingManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_SETTING_MANAGER
|
||||
).navigation() as MogoSettingManager
|
||||
var geoSearch: IMogoGeoSearch? = null
|
||||
|
||||
fun init(context: Context) {
|
||||
this.context = context
|
||||
}
|
||||
|
||||
@@ -23,5 +23,6 @@ public class MogoAddressManager implements IMogoAddressManager {
|
||||
@Override public void init(Context context) {
|
||||
AddressManager.INSTANCE.init(context);
|
||||
SearchServiceHolder.INSTANCE.init(context);
|
||||
SettingManager.INSTANCE.init(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,59 +2,35 @@ package com.mogo.module.navi.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.IMogoSettingManager;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-12.
|
||||
* 设置代理类
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_SETTING_MANAGER)
|
||||
@Route( path = MogoServicePaths.PATH_SETTING_MANAGER )
|
||||
public class MogoSettingManager implements IMogoSettingManager {
|
||||
|
||||
private static final String KEY_PAHT_PREFER="keyPath";
|
||||
private static final String KEY_VOLUME="keyVolume";
|
||||
private static final String KEY_VOICE_STYLE="keyVoice";
|
||||
private static final String KEY_MAP_TYPE="keyMapType";
|
||||
private SharedPreferences settings;
|
||||
|
||||
@Override public int getPathPrefer() {
|
||||
return settings.getInt(KEY_PAHT_PREFER,0);
|
||||
return SettingManager.INSTANCE.getPathPrefer();
|
||||
}
|
||||
|
||||
@Override public int getVolume() {
|
||||
return settings.getInt(KEY_VOLUME,0);
|
||||
return SettingManager.INSTANCE.getVolume();
|
||||
}
|
||||
|
||||
@Override public int getVoiceStyle() {
|
||||
return settings.getInt(KEY_VOICE_STYLE,0);
|
||||
return SettingManager.INSTANCE.getVoiceStyle();
|
||||
}
|
||||
|
||||
@Override public int getMapType() {
|
||||
return settings.getInt(KEY_MAP_TYPE,0);
|
||||
}
|
||||
|
||||
public void setPathPrefer(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
public void setVolume(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
public void setVoiceStyle(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
public void setMapType(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
return SettingManager.INSTANCE.getMapType();
|
||||
}
|
||||
|
||||
@Override public void init(Context context) {
|
||||
settings = context.getSharedPreferences("settings", Context.MODE_PRIVATE);
|
||||
SettingManager.INSTANCE.init(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.mogo.module.navi.manager
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.mogo.map.navi.MogoNaviConfig
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.service.module.IMogoSettingManager
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 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 var congestion = false
|
||||
|
||||
/**
|
||||
* 不走高速
|
||||
*/
|
||||
private var avoidSpeed = false
|
||||
|
||||
/**
|
||||
* 避免收费
|
||||
*/
|
||||
private var cost = false
|
||||
|
||||
/**
|
||||
* 高速优先
|
||||
*/
|
||||
private var highSpeed = 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 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)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,20 +2,69 @@ package com.mogo.module.navi.ui.setting
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener
|
||||
import android.widget.SeekBar
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.manager.SettingManager
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.module.IMogoSettingManager
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_back
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.tv_navi_sound_type
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_navi_sound_high
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_navi_sound_low
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_sound_minus
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_sound_plus
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_auto
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_day
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_detail
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_draft
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_fee
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_high_way
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_jam
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_night
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rb_navi_no_high_way
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rg_navi_day_night
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.rg_navi_sound_type
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.sb_navi_volume_progress
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-07.
|
||||
*/
|
||||
@Route(path= MogoModulePaths.PATH_FRAGMENT_SETTING)
|
||||
class NaviSettingFragment : BaseFragment() {
|
||||
@Route(path = MogoModulePaths.PATH_FRAGMENT_SETTING)
|
||||
class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
|
||||
override fun onCheckedChanged(
|
||||
buttonView: CompoundButton?,
|
||||
isChecked: Boolean
|
||||
) {
|
||||
if (buttonView?.id == R.id.rb_navi_fee) {
|
||||
SettingManager.cost(isChecked)
|
||||
if (isChecked) {
|
||||
rb_navi_high_way.isChecked = false
|
||||
}
|
||||
} else if (buttonView?.id == R.id.rb_navi_high_way) {
|
||||
SettingManager.highSpeed(isChecked)
|
||||
if (isChecked) {
|
||||
rb_navi_no_high_way.isChecked = false
|
||||
rb_navi_fee.isChecked = false
|
||||
}
|
||||
} else if (buttonView?.id == R.id.rb_navi_no_high_way) {
|
||||
SettingManager.avoidSpeed(isChecked)
|
||||
if (isChecked) {
|
||||
rb_navi_high_way.isChecked = false
|
||||
}
|
||||
} else if (buttonView?.id == R.id.rb_navi_jam) {
|
||||
SettingManager.congestion(isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_navi_setting
|
||||
}
|
||||
@@ -29,5 +78,63 @@ class NaviSettingFragment : BaseFragment() {
|
||||
iv_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
|
||||
|
||||
rb_navi_high_way.isChecked = SettingManager.isHighSpeed()
|
||||
rb_navi_jam.isChecked = SettingManager.isCongestion()
|
||||
rb_navi_no_high_way.isChecked = SettingManager.isAvoidSpeed()
|
||||
rb_navi_fee.isChecked = SettingManager.isCost()
|
||||
|
||||
sb_navi_volume_progress.progress = SettingManager.volume
|
||||
|
||||
rb_navi_day.isChecked = SettingManager.mapType == R.id.rb_navi_day
|
||||
rb_navi_night.isChecked = SettingManager.mapType == R.id.rb_navi_night
|
||||
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
|
||||
|
||||
|
||||
iv_sound_plus.setOnClickListener {
|
||||
sb_navi_volume_progress.progress = ++sb_navi_volume_progress.progress
|
||||
SettingManager.volume = sb_navi_volume_progress.progress
|
||||
}
|
||||
iv_sound_minus.setOnClickListener {
|
||||
sb_navi_volume_progress.progress = --sb_navi_volume_progress.progress
|
||||
SettingManager.volume = sb_navi_volume_progress.progress
|
||||
}
|
||||
|
||||
rb_navi_jam.setOnCheckedChangeListener(this)
|
||||
rb_navi_high_way.setOnCheckedChangeListener(this)
|
||||
rb_navi_no_high_way.setOnCheckedChangeListener(this)
|
||||
rb_navi_fee.setOnCheckedChangeListener(this)
|
||||
|
||||
|
||||
sb_navi_volume_progress.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(
|
||||
seekBar: SeekBar?,
|
||||
progress: Int,
|
||||
fromUser: Boolean
|
||||
) {
|
||||
if (fromUser) {
|
||||
SettingManager.volume = progress
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar?) {
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
rg_navi_day_night.setOnCheckedChangeListener { group, checkedId ->
|
||||
SettingManager.mapType = checkedId
|
||||
}
|
||||
rg_navi_sound_type.setOnCheckedChangeListener { group, checkedId ->
|
||||
SettingManager.voiceStyle = checkedId
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
android:id="@+id/iv_navi_sound_high"
|
||||
app:layout_constraintTop_toTopOf="@id/ll_navi_sound"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ll_navi_sound"
|
||||
app:layout_constraintRight_toRightOf="@id/rg_navi_path"
|
||||
app:layout_constraintRight_toRightOf="@id/ll_navi_path"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
/>
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/player_progress"
|
||||
android:id="@+id/sb_navi_volume_progress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:splitTrack="false"
|
||||
@@ -95,8 +95,8 @@
|
||||
|
||||
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/rg_navi_path"
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_navi_path"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="26dp"
|
||||
@@ -106,7 +106,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_navi_prefer"
|
||||
>
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rb_navi_jam"
|
||||
android:layout_marginRight="20dp"
|
||||
android:checked="true"
|
||||
@@ -115,7 +115,7 @@
|
||||
/>
|
||||
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rb_navi_fee"
|
||||
android:layout_marginRight="20dp"
|
||||
android:text="@string/navi_prefer_fee"
|
||||
@@ -123,20 +123,20 @@
|
||||
/>
|
||||
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_time_no_high_way"
|
||||
<CheckBox
|
||||
android:id="@+id/rb_navi_no_high_way"
|
||||
android:layout_marginRight="20dp"
|
||||
android:text="@string/navi_prefer_no_high_way"
|
||||
style="@style/rb_setting"
|
||||
/>
|
||||
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rb_navi_high_way"
|
||||
android:text="@string/navi_prefer_high_way"
|
||||
style="@style/rb_setting"
|
||||
/>
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
@@ -182,7 +182,7 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/txt_normal"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/rg_navi_path"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_navi_path"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user