Merge remote-tracking branch 'origin/feature/v1.0.0' into feature/v1.0.0
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.mogo.launcher"
|
||||
android:sharedUserId="android.uid.system">
|
||||
package="com.mogo.launcher">
|
||||
<!-- android:sharedUserId="android.uid.system">-->
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
@@ -65,6 +65,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
private OrientedViewPager mCardsContainer;
|
||||
private VerticalStackTransformer transformer;
|
||||
private CardModulesAdapter mCardModulesAdapter;
|
||||
|
||||
private View mHeader;
|
||||
@@ -127,7 +128,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
protected void initViews() {
|
||||
mCardsContainer = findViewById( R.id.module_main_id_cards_container );
|
||||
mCardsContainer.setOrientation( OrientedViewPager.Orientation.VERTICAL );
|
||||
|
||||
transformer = new VerticalStackTransformer( this );
|
||||
mCardsContainer.setOnPageChangeListener( mOnPageChangeListener = new OnPageChangeListenerAdapter() {
|
||||
private boolean mIsLast = true;
|
||||
private boolean mCardFlipStatus = false;
|
||||
@@ -167,6 +168,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
} else if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||
mCardFlipStatus = false;
|
||||
transformer.resetOffsetScroll();
|
||||
}
|
||||
|
||||
int cardSize = mCardModulesAdapter.getCount();
|
||||
@@ -185,6 +187,13 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
Log.i( TAG, "onPageScrollStateChanged cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
Logger.d(TAG,"pageScrolled : offset --- " + positionOffset);
|
||||
transformer.offsetScrollChanged(positionOffset);
|
||||
}
|
||||
} );
|
||||
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( this );
|
||||
@@ -320,7 +329,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCardsModule();
|
||||
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||
mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||
mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
|
||||
mCardsContainer.setPageTransformer( true, transformer );
|
||||
mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||
|
||||
mCardCoverUpBottomLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
private Context context;
|
||||
private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
|
||||
private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
|
||||
private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
|
||||
|
||||
public VerticalStackTransformer( Context context ) {
|
||||
this.context = context;
|
||||
@@ -26,14 +27,25 @@ public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
|
||||
}
|
||||
|
||||
public void offsetScrollChanged(float offset){
|
||||
if(offset ==0){
|
||||
return;
|
||||
}
|
||||
offsetScroll = offset;
|
||||
}
|
||||
|
||||
public void resetOffsetScroll(){
|
||||
offsetScroll = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position <= 0.0f ) {
|
||||
if ( position == 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
page.setTranslationY( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else {
|
||||
} else if(position>0){
|
||||
float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
|
||||
Logger.d("VerticalStackTransformer","scale :" + scale);
|
||||
//控制下面卡片的可见度
|
||||
@@ -45,6 +57,20 @@ public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
page.setScaleX( scale );
|
||||
page.setScaleY( scale );
|
||||
page.setTranslationY( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
|
||||
}else{
|
||||
float currentPage;
|
||||
if(offsetScroll > 0.2f){
|
||||
currentPage = 0.2f;
|
||||
}else{
|
||||
currentPage = offsetScroll;
|
||||
}
|
||||
page.setAlpha( 1 );
|
||||
page.setScaleX(1-currentPage);
|
||||
page.setScaleY(1-currentPage);
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setTranslationY( 0f );
|
||||
page.setClickable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -74,6 +73,7 @@ dependencies {
|
||||
// implementation project(':modules:mogo-module-map')
|
||||
}
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation 'com.zhidaoauto.voice.controller:api:1.0.2'
|
||||
|
||||
|
||||
}
|
||||
|
||||
BIN
modules/mogo-module-search/libs/carmanager.jar
Normal file
BIN
modules/mogo-module-search/libs/carmanager.jar
Normal file
Binary file not shown.
@@ -0,0 +1,196 @@
|
||||
package com.mogo.module.navi.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.mogo.module.navi.BuildConfig;
|
||||
import com.zhidao.manager.audio.ZDAudioManager;
|
||||
import com.zhidao.manager.listener.OnListener;
|
||||
import com.zhidao.manager.system.CarSettingManager;
|
||||
import com.zhidao.manager.system.volume.IVolumeModel;
|
||||
import com.zhidao.manager.system.volume.VolumeModel;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* 音量管理
|
||||
*/
|
||||
|
||||
public class VolumeManager {
|
||||
|
||||
private final String TAG = "VolumeManager";
|
||||
private final int MAX_VOLUME = 100;
|
||||
private final int MIN_VOLUME = 0;
|
||||
private static Object lock = new Object();
|
||||
private static VolumeManager volumeManager;
|
||||
private Context mContext;
|
||||
private VolumeModel mVolumeModel;
|
||||
private final static int MAX_VOL = 100;
|
||||
private final static int MIN_VOL = 0;
|
||||
private AudioManager mAudioManager;
|
||||
private final int mStreamType = AudioManager.STREAM_MUSIC;
|
||||
|
||||
|
||||
public static VolumeManager getInstance(Context context) {
|
||||
if (volumeManager == null) {
|
||||
synchronized (lock) {
|
||||
if (volumeManager == null) {
|
||||
volumeManager = new VolumeManager(context.getApplicationContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
return volumeManager;
|
||||
}
|
||||
|
||||
private VolumeManager(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
mVolumeModel = (VolumeModel) CarSettingManager.getInstance(mContext).getModel(
|
||||
CarSettingManager.VOLUME_MODEL);
|
||||
mVolumeModel.registerOnChangedListener(new OnListener.OnChangedListener<Integer>() {
|
||||
@Override
|
||||
public void onChanged(Integer arg0) {
|
||||
Log.d(TAG, "当前音量:" + arg0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 增大音量
|
||||
*/
|
||||
public void incVolume() {
|
||||
if (isFuture()) {
|
||||
mAudioManager.adjustStreamVolume(mStreamType, AudioManager.ADJUST_RAISE, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
||||
Log.d(TAG, "当前音量:" + mAudioManager.getStreamVolume(mStreamType));
|
||||
} else {
|
||||
setSysVolume(mVolumeModel.getVolume() + 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getMaxVol(){
|
||||
if (isFuture()) {
|
||||
return MAX_VOLUME;
|
||||
}
|
||||
return MAX_VOL;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 减小音量
|
||||
*/
|
||||
public void decVolume() {
|
||||
if (isFuture()) {
|
||||
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
||||
Log.d(TAG, "当前音量:" + getSysVolume());
|
||||
} else {
|
||||
setSysVolume(mVolumeModel.getVolume() - 10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大音量
|
||||
*/
|
||||
public void maxVolume() {
|
||||
if (isFuture()) {
|
||||
mAudioManager.setStreamVolume(mStreamType, MAX_VOL, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
||||
Log.d(TAG, "当前音量:" + getSysVolume());
|
||||
} else {
|
||||
setSysVolume(MAX_VOLUME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最小音量
|
||||
*/
|
||||
public void minVolume() {
|
||||
if (isFuture()) {
|
||||
mAudioManager.setStreamVolume(mStreamType, MIN_VOL, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
||||
Log.d(TAG, "当前音量:" + getSysVolume());
|
||||
} else {
|
||||
setSysVolume(MIN_VOLUME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前音量
|
||||
*/
|
||||
public int getSysVolume() {
|
||||
if (isFuture()) {
|
||||
return mAudioManager.getStreamVolume(mStreamType);
|
||||
} else {
|
||||
return mVolumeModel.getVolume();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置音量
|
||||
*/
|
||||
public void setSysVolume(int volume) {
|
||||
if (isFuture()) {
|
||||
mAudioManager.setStreamVolume(mStreamType, volume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
||||
} else {
|
||||
mVolumeModel.setVolume(volume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
||||
Log.d(TAG, "future->当前音量:" + mVolumeModel.getVolume());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是最大音量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isMaxVolume() {
|
||||
if (isFuture()) {
|
||||
return mAudioManager.getStreamVolume(mStreamType) >= MAX_VOL;
|
||||
} else {
|
||||
return mVolumeModel.getVolume() >= MAX_VOLUME;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是最小音量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isMinVolume() {
|
||||
if (isFuture()) {
|
||||
return mAudioManager.getStreamVolume(mStreamType) <= MIN_VOL;
|
||||
} else {
|
||||
return mVolumeModel.getVolume() <= MIN_VOLUME;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否打开静音
|
||||
*
|
||||
* @param mute
|
||||
*/
|
||||
public void innerMute(boolean mute) {
|
||||
ZDAudioManager.getInstance().setMute(mute);
|
||||
}
|
||||
|
||||
/*
|
||||
判断是否future渠道
|
||||
*/
|
||||
private boolean isFuture() {
|
||||
|
||||
//return false;
|
||||
try {
|
||||
Class<?> buildConfig = Class.forName("com.mogo.launcher.BuildConfig");
|
||||
Field flavor = buildConfig.getDeclaredField("FLAVOR");
|
||||
//String descriptor= Modifier.toString(flavor.getModifiers());
|
||||
return TextUtils.equals((CharSequence) flavor.get(null),"zhidao");
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.mogo.module.navi.constants.DataConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.manager.AddressManager
|
||||
import com.mogo.module.navi.manager.SettingManager
|
||||
import com.mogo.module.navi.manager.VolumeManager
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.module.IMogoSettingManager
|
||||
@@ -136,11 +137,15 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
|
||||
private fun initEvent() {
|
||||
iv_sound_plus.setOnClickListener {
|
||||
sb_navi_volume_progress.progress = ++sb_navi_volume_progress.progress
|
||||
VolumeManager.getInstance(context)
|
||||
.incVolume()
|
||||
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.plus(10)
|
||||
SettingManager.volume = sb_navi_volume_progress.progress
|
||||
}
|
||||
iv_sound_minus.setOnClickListener {
|
||||
sb_navi_volume_progress.progress = --sb_navi_volume_progress.progress
|
||||
VolumeManager.getInstance(context)
|
||||
.decVolume()
|
||||
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.minus(10)
|
||||
SettingManager.volume = sb_navi_volume_progress.progress
|
||||
}
|
||||
|
||||
@@ -149,9 +154,10 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
rb_navi_no_high_way.setOnCheckedChangeListener(this)
|
||||
rb_navi_fee.setOnCheckedChangeListener(this)
|
||||
|
||||
var audioManager = activity?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
sb_navi_volume_progress.max = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
sb_navi_volume_progress.progress = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
sb_navi_volume_progress.max = VolumeManager.getInstance(context)
|
||||
.getMaxVol()
|
||||
sb_navi_volume_progress.progress = VolumeManager.getInstance(context)
|
||||
.sysVolume
|
||||
|
||||
|
||||
sb_navi_volume_progress.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
|
||||
@@ -160,9 +166,17 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
progress: Int,
|
||||
fromUser: Boolean
|
||||
) {
|
||||
audioManager.setStreamVolume(
|
||||
AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE
|
||||
)
|
||||
if (fromUser) {
|
||||
VolumeManager.getInstance(context)
|
||||
.setSysVolume(progress)
|
||||
SettingManager.volume = sb_navi_volume_progress.progress
|
||||
|
||||
}
|
||||
|
||||
// audioManager.setStreamVolume(
|
||||
// AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE
|
||||
// )
|
||||
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {
|
||||
@@ -240,15 +254,14 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearHome(){
|
||||
private fun clearHome() {
|
||||
tv_navi_clear_home_address.visibility = View.GONE
|
||||
tv_navi_home_address.text=getString(R.string.navi_set_home)
|
||||
tv_navi_home_address.text = getString(R.string.navi_set_home)
|
||||
}
|
||||
|
||||
|
||||
private fun clearCompany(){
|
||||
private fun clearCompany() {
|
||||
tv_navi_clear_company_address.visibility = View.GONE
|
||||
tv_navi_company_address.text=getString(R.string.navi_set_company)
|
||||
tv_navi_company_address.text = getString(R.string.navi_set_company)
|
||||
|
||||
}
|
||||
|
||||
@@ -271,17 +284,18 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
return
|
||||
}
|
||||
if (searchPoi?.type == DataConstants.TYPE_COMPANY_ADDRESS) {
|
||||
tv_navi_company_address.text=searchPoi.address
|
||||
tv_navi_clear_company_address.visibility=View.VISIBLE
|
||||
tv_navi_company_address.text = searchPoi.address
|
||||
tv_navi_clear_company_address.visibility = View.VISIBLE
|
||||
} else {
|
||||
tv_navi_home_address.text=searchPoi.address
|
||||
tv_navi_clear_home_address.visibility=View.VISIBLE
|
||||
tv_navi_home_address.text = searchPoi.address
|
||||
tv_navi_clear_home_address.visibility = View.VISIBLE
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
EventBus.getDefault().unregister(this)
|
||||
EventBus.getDefault()
|
||||
.unregister(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
super.handleMessage( msg );
|
||||
switch ( msg.what ) {
|
||||
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
stopAutoRefreshStrategy();
|
||||
return;
|
||||
}
|
||||
@@ -148,6 +148,9 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
}
|
||||
break;
|
||||
case ServiceConst.MSG_LOOP_REQUEST:
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( mLoopRequest ) {
|
||||
Logger.d( TAG, "补偿刷新触发" );
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
|
||||
Reference in New Issue
Block a user