[dev_arch_opt_3.0]

[Change]
[
1、优化在副屏幕启动调用个
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-02-16 18:45:04 +08:00
parent e0007ad81b
commit 88ffcfdc71
3 changed files with 9 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ project.android.productFlavors {
//高德地图鉴权信息
manifestPlaceholders = [
AMAP_API_VALUE : rootProject.ext.android.fLauncherAmapApiValue,
CHANNEL_VALUE : "fPadLenovoOchBus",
CHANNEL_VALUE : "fMultiDisplayOchBus",
ACTIVITY_ROOT : true,
SCREEN_ORIENTATION: "landscape"
]

View File

@@ -23,7 +23,7 @@ project.android.productFlavors {
// 高德地图鉴权信息
AMAP_API_VALUE : rootProject.ext.android.fLauncherAmapApiValue,
// BUGLY_APP_CHANNEL
CHANNEL_VALUE : "fPadLenovoOchTaxi",
CHANNEL_VALUE : "fMultiDisplayOchTaxi",
// 在启动的时候把Task给清空
ACTIVITY_ROOT : true,
// Activity的朝向

View File

@@ -7,7 +7,6 @@ import android.content.pm.PackageManager
import android.hardware.display.DisplayManager
import android.util.Log
import android.view.Display
import androidx.appcompat.app.AppCompatActivity
/**
* 多屏幕操作工具类
@@ -51,6 +50,7 @@ object MultiDisplayUtils {
for (j in lcd_sub_port_six_lcd_mode.indices) { // 这里增加port的匹配, 如果不需要对应的匹配 可看下面的other LCD
if (strDisplayString.indexOf(lcd_sub_port_six_lcd_mode[j]) != -1) { // 查找我们实际屏幕的匹配port
displaysList[j] = displays[i]
break
}
}
}
@@ -66,7 +66,9 @@ object MultiDisplayUtils {
}
// 获取 是否支持扩展屏幕打开应用
/**
* 获取 是否支持扩展屏幕打开应用
*/
fun isSupportMultiDisplay(context: Context): Boolean {
// 先检查一下是不是支持在第二屏上显示activity这个特性
// 在ActivityOptions.java setLaunchDisplayId 上面有相关的说明
@@ -74,13 +76,6 @@ object MultiDisplayUtils {
return packageManager.hasSystemFeature(PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS)
}
// 获取 当前接入的屏幕集合(含主屏幕)
fun getMultiDisplay(context: Context): Array<out Display> {
// 多次创建副屏 则副屏的id都是增加的所以不一定是1这里还是获取一下
val displayManager =
context.getSystemService(AppCompatActivity.DISPLAY_SERVICE) as DisplayManager
return displayManager.displays
}
/**
* 在指定ID的屏幕打开Activity当前应用的当前进程
@@ -90,8 +85,8 @@ object MultiDisplayUtils {
fun startActWithSecond(context: Context, activity: Class<*>) {
val launchDisplayId: Int
if (isSupportMultiDisplay(context)) {
if (getMultiDisplay(context).size > 1) {
launchDisplayId = getMultiDisplay(context)[1].displayId
if (getOtherDisplay().size > 1 && getOtherDisplay()[0] != null) {
launchDisplayId = getOtherDisplay()[0]!!.displayId
// 要加上Intent.FLAG_ACTIVITY_NEW_TASK
val options = ActivityOptions.makeBasic()
@@ -113,7 +108,7 @@ object MultiDisplayUtils {
* @param launchDisplayId 指定屏幕ID
* @param activity 要在副屏幕启动的页面
*/
fun startActWithProcess(context: Context, launchDisplayId: Int, activity: Class<*>) {
fun startActWithOther(context: Context, launchDisplayId: Int, activity: Class<*>) {
// 要加上Intent.FLAG_ACTIVITY_NEW_TASK
val options = ActivityOptions.makeBasic()
options.launchDisplayId = launchDisplayId