Merge remote-tracking branch 'origin/qa_1.1.2' into qa_1.1.2

This commit is contained in:
董宏宇
2020-08-14 16:42:02 +08:00
17 changed files with 59 additions and 510 deletions

View File

@@ -266,9 +266,9 @@ dependencies {
exclude group: 'com.mogo.module', module: 'module-share'
}
implementation rootProject.ext.dependencies.moduletanluapi
implementation rootProject.ext.dependencies.mogomonitor
implementation rootProject.ext.dependencies.mogomodulewidgets
implementation rootProject.ext.dependencies.mogomoduleback
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
@@ -286,6 +286,7 @@ dependencies {
implementation project(':libraries:mogo-tanlu-api')
implementation project(':modules:mogo-module-monitor')
implementation project(':modules:mogo-module-widgets')
implementation project(':modules:mogo-module-back')
}
apply from: "./functions/baseservices.gradle"

View File

@@ -12,6 +12,7 @@ import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.Utils;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.back.BackToLauncherConst;
import com.mogo.module.carchatting.card.CallChatConstant;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
@@ -57,8 +58,8 @@ public class MogoApplication extends AbsMogoApplication {
// MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME));
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
//运营位卡片,需要默认显示,放在第一个加载
if ( DebugConfig.isLauncher() ) {
MogoModulePaths.addModule( new MogoModule( BackToLauncherConst.MODULE_PATH, BackToLauncherConst.MODULE_NAME ) );
MogoModulePaths.addModule( new MogoModule( MediaConstants.TAG, MediaConstants.MODULE_TYPE ) );
} else {
MogoModulePaths.addBaseModule( new MogoModule( MogoWidgetsProvider.PATH, MogoWidgetsProvider.NAME ) );

View File

@@ -7,15 +7,10 @@ import android.view.View;
import androidx.annotation.Nullable;
import com.mogo.module.back.BackToLauncherConst;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.module.extensions.utils.ExtensionsConfig;
import com.mogo.module.main.MainActivity;
import com.mogo.module.main.cards.MogoModulesManager;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.utils.logger.Logger;
/**
* 针对作为Launcher的情况做个性化操作
@@ -32,12 +27,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
ExtensionsConfig.setNeedRequestUserInfo( true );
}
@Override
protected void addModule() {
super.addModule();
MogoModulePaths.addModule( new MogoModule( BackToLauncherConst.MODULE_PATH, BackToLauncherConst.MODULE_NAME ) );
}
@Override
protected void loadContainerModules() {
super.loadContainerModules();

View File

@@ -1,33 +0,0 @@
package com.mogo.module.back;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
* @since 2020-02-26
* <p>
* 描述
*/
public class Back2LauncherFragment extends Fragment {
private static final String TAG = "Back2LauncherFragment";
@Override
public void onCreate( @Nullable Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
BackToMainHomeManager.addMainHomeView();
Logger.d( TAG, "addMainHomeView" );
}
@Override
public void onDestroy() {
super.onDestroy();
BackToMainHomeManager.removeMainHomeView();
Logger.d( TAG, "removeMainHomeView" );
}
}

View File

@@ -49,46 +49,11 @@ public class BackToLauncherModuleProvider implements IMogoModuleProvider {
return BackToLauncherConst.MODULE_NAME;
}
@Override
public IMogoModuleLifecycle getCardLifecycle() {
return null;
}
@Override
public IMogoMapListener getMapListener() {
return null;
}
@Override
public int getType() {
return ModuleType.TYPE_SERVICE;
}
@Override
public IMogoNaviListener getNaviListener() {
return null;
}
@Override
public IMogoLocationListener getLocationListener() {
return null;
}
@Override
public IMogoMarkerClickListener getMarkerClickListener() {
return null;
}
@Override
public String getAppPackage() {
return null;
}
@Override
public String getAppName() {
return null;
}
@Override
public void init( Context context ) {
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {

View File

@@ -1,28 +1,20 @@
package com.mogo.module.back;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.back.utils.WindowManagerViewHelper;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.utils.AppUtils;
import com.mogo.utils.logger.Logger;
public class BackToMainHomeManager {
private static final String TAG = "BackToMainHomeManager";
private static View mBackView;
private static IMogoFragmentManager mFragmentManager;
private static IMogoStatusManager mStatusManager;
private static IMogoServiceApis mApis;
@@ -45,7 +37,7 @@ public class BackToMainHomeManager {
return;
}
Intent intent2 = new Intent( );
Intent intent2 = new Intent();
// 是否发自系统消息
intent2.putExtra( "isHomeKeyDown", false );
mApis.getIntentManagerApi().invoke( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intent2 );
@@ -58,40 +50,34 @@ public class BackToMainHomeManager {
AbsMogoApplication.getApp().startActivity( intent );
}
private static WindowManagerView mWindowManagerView;
public static void addMainHomeView() {
Logger.d( "BackToMainHomeManager", "addMainHomeView" );
if ( mBackView != null ) WindowManagerViewHelper.removeView( mBackView );
mBackView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.mogo_module_back_home_back_layout, null );
final Context context = mBackView.getContext();
if ( context == null || context.getApplicationContext() == null ) {
return;
if ( mWindowManagerView == null ) {
mWindowManagerView = new WindowManagerView.Builder( AbsMogoApplication.getApp() )
.contentView( R.layout.mogo_module_back_home_back_layout )
.position( AbsMogoApplication.getApp().getResources().getDimensionPixelOffset( R.dimen.module_back_main_home_icon_left ),
AbsMogoApplication.getApp().getResources().getDimensionPixelOffset( R.dimen.module_back_main_home_icon_top ) )
.size( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT )
.gravity( Gravity.LEFT | Gravity.TOP )
.showInWindowManager();
mWindowManagerView.attachTouchEvent( view -> {
backToLauncher();
} );
}
WindowManager windowManager = ( WindowManager ) context.getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
if ( windowManager == null ) {
return;
try {
mWindowManagerView.show();
} catch ( Exception e ) {
e.printStackTrace();
}
mBackView.setOnClickListener( view -> {
backToLauncher();
} );
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.x = AbsMogoApplication.getApp().getResources().getDimensionPixelOffset( R.dimen.module_back_main_home_icon_left );
params.y = AbsMogoApplication.getApp().getResources().getDimensionPixelOffset( R.dimen.module_back_main_home_icon_top );
params.gravity = Gravity.LEFT | Gravity.CENTER;
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) {
params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
params.format = PixelFormat.RGBA_8888;
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
windowManager.addView( mBackView, params );
WindowManagerViewHelper.attachMovementEvent( mBackView, params );
}
public static void removeMainHomeView() {
WindowManagerViewHelper.removeView( mBackView );
if ( mWindowManagerView != null ) {
mWindowManagerView.dismiss();
}
}
}

View File

@@ -1,20 +0,0 @@
package com.mogo.module.back.utils;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import com.mogo.commons.AbsMogoApplication;
public class Utils {
public static boolean isActivityExits( String packageName, String classStr ) {
Intent intent = new Intent();
intent.setClassName( packageName, classStr );
ResolveInfo resolveInfo = AbsMogoApplication.getApp().getPackageManager().resolveActivity( intent, PackageManager.MATCH_DEFAULT_ONLY );
if ( resolveInfo != null ) {
return true;
} else {
return false;
}
}
}

View File

@@ -1,213 +0,0 @@
package com.mogo.module.back.utils;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Build;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
/**
* @author congtaowang
* @since 2019-04-30
* <p>
* 向 window manager 添加 view
*/
public class WindowManagerViewHelper {
public static void addView( View view ) {
final Context context = view.getContext();
if ( context == null || context.getApplicationContext() == null ) {
return;
}
WindowManager windowManager = ( WindowManager ) context.getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
if ( windowManager == null ) {
return;
}
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.LEFT | Gravity.CENTER;
params.type = getFitWindowParamsType();
params.format = PixelFormat.RGBA_8888;
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
windowManager.addView( view, params );
attachMovementEvent( view, params );
}
private static int getFitWindowParamsType() {
int type;
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 ) {
// Need request permission.
type = WindowManager.LayoutParams.TYPE_PHONE;
} else if ( Build.MODEL.equalsIgnoreCase( "MI 5" ) ) {
// MI 5 phone not display crawler dot in android 7.0
type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
} else {
// It's will be dismissed automatically 3s after showing in Android 25.
type = WindowManager.LayoutParams.TYPE_TOAST;
}
return type;
}
public static void removeView( View view ) {
if ( view == null || view.getContext() == null || view.getContext().getApplicationContext() == null ) {
return;
}
WindowManager windowManager = ( WindowManager ) view.getContext().getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
if ( windowManager == null ) {
return;
}
windowManager.removeViewImmediate( view );
DispatchTouchEventWrapper.getInstance().release();
}
public static void attachMovementEvent( View view, WindowManager.LayoutParams params ) {
if ( view == null ) {
return;
}
view.setOnTouchListener( ( v, event ) -> {
DispatchTouchEventWrapper.getInstance()
.attach( view, params )
.handle( event );
return false;
} );
}
static class DispatchTouchEventWrapper {
private WindowViewHandler mWindowViewHandler;
int mActionDownX = -1;
int mActionDownY = -1;
/**
* Flag whether move after touch down.
*/
boolean mMoveFlag = false;
private static volatile DispatchTouchEventWrapper INST;
private DispatchTouchEventWrapper() {
}
public static DispatchTouchEventWrapper getInstance() {
if ( INST == null ) {
synchronized ( DispatchTouchEventWrapper.class ) {
if ( INST == null ) {
INST = new DispatchTouchEventWrapper();
}
}
}
return INST;
}
public DispatchTouchEventWrapper attach( View windowView, WindowManager.LayoutParams params ) {
if ( mWindowViewHandler == null || mWindowViewHandler.getWindowView() != windowView ) {
mWindowViewHandler = new WindowViewHandler.DefaultHandler( windowView, params );
}
return this;
}
public boolean handle( MotionEvent event ) {
switch ( event.getAction() & MotionEvent.ACTION_MASK ) {
case MotionEvent.ACTION_DOWN:
if ( onActionDown( event ) ) {
return true;
}
break;
case MotionEvent.ACTION_MOVE:
if ( onActionMove( event ) ) {
return true;
}
break;
case MotionEvent.ACTION_UP:
if ( onActionUp( event ) ) {
return true;
}
break;
}
return false;
}
private boolean onActionDown( MotionEvent event ) {
mActionDownX = ( ( int ) event.getRawX() );
mActionDownY = ( ( int ) event.getRawY() );
if ( mWindowViewHandler != null ) {
mWindowViewHandler.recordNewPosition();
return true;
}
return false;
}
private boolean onActionMove( MotionEvent event ) {
if ( Math.abs( event.getRawX() - mActionDownX ) >= 20
|| Math.abs( event.getRawY() - mActionDownY ) >= 20 ) {
mMoveFlag = true;
}
if ( isLastDownValueLegal() ) {
moveWindowView( event );
return true;
}
return false;
}
private boolean onActionUp( MotionEvent event ) {
if ( isClickEventLike() ) {
if ( mWindowViewHandler != null ) {
mWindowViewHandler.performClickLike();
}
} else {
if ( mWindowViewHandler != null ) {
mWindowViewHandler.moveToEdge();
mWindowViewHandler.recordNewPosition();
}
}
mMoveFlag = false;
clearLastDownAxisValue();
return true;
}
private void clearLastDownAxisValue() {
mActionDownX = mActionDownY = -1;
}
private boolean isLastDownValueLegal() {
return mActionDownX != -1 && mActionDownY != -1;
}
private void moveWindowView( MotionEvent event ) {
if ( mWindowViewHandler != null ) {
mWindowViewHandler.move( event, mActionDownX, mActionDownY );
}
}
/**
* Simulate click event just like set {@link View.OnClickListener}
*
* @return
*/
private boolean isClickEventLike() {
System.out.println( mMoveFlag );
return isLastDownValueLegal() && !mMoveFlag;
}
public void release() {
if ( mWindowViewHandler != null ) {
mWindowViewHandler.release();
}
mWindowViewHandler = null;
mActionDownX = -1;
mActionDownY = -1;
mMoveFlag = false;
INST = null;
}
}
}

View File

@@ -1,119 +0,0 @@
package com.mogo.module.back.utils;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.utils.WindowUtils;
/**
* Created by congtaowang on 2017/6/20.
*/
public interface WindowViewHandler {
View getWindowView();
void recordNewPosition();
void move(MotionEvent event, int downX, int downY);
void release();
void moveToEdge();
void performClickLike();
class DefaultHandler implements WindowViewHandler {
protected View mWindowView;
protected int mWindowViewLeft = -1;
protected int mWindowViewTop = -1;
private WindowManager.LayoutParams mParams;
public DefaultHandler( View windowView, WindowManager.LayoutParams params ) {
this.mWindowView = windowView;
mParams = params;
}
@Override
public View getWindowView() {
return mWindowView;
}
@Override
public void recordNewPosition() {
mWindowViewLeft = mParams.x;
mWindowViewTop = mParams.y;
}
@Override
public void move( MotionEvent event, int downX, int downY ) {
move( ( ( int ) ( event.getRawX() - downX ) ),
( ( int ) ( event.getRawY() - downY ) ) );
}
private void move( int distanceX, int distanceY ) {
if ( mWindowView == null ) {
return;
}
mParams.x = mWindowViewLeft + distanceX;
mParams.y = mWindowViewTop + distanceY;
WindowManager wm = ( ( WindowManager ) mWindowView.getContext().getSystemService( Context.WINDOW_SERVICE ) );
if ( wm == null ) {
return;
}
if ( mWindowView instanceof WindowViewUIController ) {
if ( mParams.x > WindowUtils.getScreenWidth( AbsMogoApplication.getApp() ) / 2 ) {
( ( WindowViewUIController ) mWindowView ).rightMode();
} else {
( ( WindowViewUIController ) mWindowView ).leftMode();
}
}
wm.updateViewLayout( mWindowView, alignLayoutParamsBoundary( mParams ) );
}
@Override
public void moveToEdge() {
if ( mWindowView == null ) {
return;
}
WindowManager wm = ( ( WindowManager ) mWindowView.getContext().getSystemService( Context.WINDOW_SERVICE ) );
if ( mParams.x > WindowUtils.getScreenWidth( AbsMogoApplication.getApp() ) / 2 ) {
mParams.x = WindowUtils.getScreenWidth( AbsMogoApplication.getApp() ) - mWindowView.getMeasuredWidth();
} else {
mParams.x = 0;
}
wm.updateViewLayout( mWindowView, alignLayoutParamsBoundary( mParams ) );
}
protected WindowManager.LayoutParams alignLayoutParamsBoundary( WindowManager.LayoutParams params ) {
return params;
}
@Override
public void performClickLike() {
if ( mWindowView instanceof WindowViewUIController ) {
( ( WindowViewUIController ) mWindowView ).performClickLike();
}
}
@Override
public void release() {
mWindowView = null;
mWindowViewLeft = -1;
mWindowViewTop = -1;
}
}
}

View File

@@ -1,16 +0,0 @@
package com.mogo.module.back.utils;
/**
* @author congtaowang
* @since 2019-05-12
* <p>
* 描述
*/
public interface WindowViewUIController {
void leftMode();
void rightMode();
void performClickLike();
}

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_back_main_home_icon_size">140px</dimen>
<dimen name="module_back_main_home_icon_left">0px</dimen>
<dimen name="module_back_main_home_icon_top">190px</dimen>
<dimen name="module_back_main_home_icon_left">30px</dimen>
<dimen name="module_back_main_home_icon_top">230px</dimen>
</resources>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_back_main_home_icon_size">80px</dimen>
<dimen name="module_back_main_home_icon_left">0px</dimen>
<dimen name="module_back_main_home_icon_top">100px</dimen>
<dimen name="module_back_main_home_icon_left">16px</dimen>
<dimen name="module_back_main_home_icon_top">140px</dimen>
</resources>

View File

@@ -12,6 +12,7 @@
android:gravity="center"
android:paddingStart="@dimen/module_ext_weather_container_paddingLeft"
android:paddingEnd="@dimen/module_ext_weather_container_paddingRight"
android:layout_marginEnd="@dimen/module_ext_msg_marginRight"
android:visibility="invisible"
app:layout_constraintRight_toLeftOf="@+id/module_ext_id_msg"
app:layout_constraintTop_toTopOf="parent"

View File

@@ -50,7 +50,6 @@ dependencies {
api rootProject.ext.dependencies.moduleservice
api rootProject.ext.dependencies.moduleapps
api rootProject.ext.dependencies.moduleextensions
api rootProject.ext.dependencies.mogomoduleback
} else {
api project(":foudations:mogo-utils")
api project(":foudations:mogo-commons")
@@ -61,7 +60,6 @@ dependencies {
api project(':services:mogo-service')
api project(':modules:mogo-module-apps')
api project(':modules:mogo-module-extensions')
api project(':modules:mogo-module-back')
}
}

View File

@@ -152,7 +152,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
MapCenterPointStrategy.setMapCenterPointByScene( mMogoMapUIController, Scene.AIMLESS );
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
addModule();
loadContainerModules();
MogoModulesManager.getInstance().loadModules();
mPresenter.delayOperations();
@@ -185,13 +184,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
startService( intent );
}
/**
* 添加模块
*/
protected void addModule() {
}
protected void loadContainerModules() {
// MogoModulesManager.getInstance().loadExtensionsModule( R.id.module_main_id_header_fragment_container );
MogoModulesManager.getInstance().loadEntrancesModule( R.id.module_main_id_entrance_fragment_container );

View File

@@ -2,8 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="40px"
android:paddingBottom="40px">
android:paddingTop="16px"
android:paddingBottom="30px">
<TextView
android:id="@+id/event_share_load_no_more"
@@ -15,7 +15,7 @@
android:paddingBottom="12px"
android:text="没有更多记录了"
android:textColor="#FFFFFF"
android:textSize="18px" />
android:textSize="14px" />
<ImageView
android:id="@+id/left_line"

View File

@@ -51,7 +51,10 @@ public interface IMogoModuleProvider extends IProvider {
*
* @return
*/
IMogoModuleLifecycle getCardLifecycle();
@Deprecated
default IMogoModuleLifecycle getCardLifecycle() {
return null;
}
/**
* 地图监听对象
@@ -60,7 +63,9 @@ public interface IMogoModuleProvider extends IProvider {
* @return
*/
@Deprecated
IMogoMapListener getMapListener();
default IMogoMapListener getMapListener() {
return null;
}
/**
* 是哪种类型的提供者
@@ -78,7 +83,9 @@ public interface IMogoModuleProvider extends IProvider {
* @return
*/
@Deprecated
IMogoNaviListener getNaviListener();
default IMogoNaviListener getNaviListener() {
return null;
}
/**
* 定位变化监听:此接口接受地图定位信息
@@ -87,7 +94,9 @@ public interface IMogoModuleProvider extends IProvider {
* @return
*/
@Deprecated
IMogoLocationListener getLocationListener();
default IMogoLocationListener getLocationListener() {
return null;
}
/**
* marker 点击回调
@@ -96,19 +105,27 @@ public interface IMogoModuleProvider extends IProvider {
* @return
*/
@Deprecated
IMogoMarkerClickListener getMarkerClickListener();
default IMogoMarkerClickListener getMarkerClickListener() {
return null;
}
/**
* 获取模块对应 app 的包名
*
* @return
*/
String getAppPackage();
@Deprecated
default String getAppPackage() {
return "";
}
/**
* 获取对应模块 app 名称
*
* @return
*/
String getAppName();
@Deprecated
default String getAppName() {
return "";
}
}