StatusBar 高度计算 设置background后需要重新设置padding

This commit is contained in:
yangyakun
2022-11-18 12:49:34 +08:00
parent 1607c60435
commit 4be507613b
23 changed files with 108 additions and 302 deletions

View File

@@ -73,7 +73,7 @@
android:ellipsize="end"
android:lineSpacingExtra="10dp"
android:textColor="#FFFFFF"
android:textSize="dp_46"
android:textSize="@dimen/dp_46"
app:layout_constraintRight_toLeftOf="@+id/module_och_taxi_navi_end_iv"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/module_och_taxi_order_station_title_2"

View File

@@ -140,15 +140,15 @@ public class ConnectStatusFloatWindow implements View.OnTouchListener {
mInViewY = motionEvent.getY();
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.getRawX();
mDownInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mDownInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
btn_drag.setSelected(true);
break;
case MotionEvent.ACTION_MOVE:
// 更新浮动窗口位置参数
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
mWindowParams.x = (int) (mInScreenX - mInViewX);
mWindowParams.y = (int) (mInScreenY - mInViewY);
// 手指移动的时候更新小悬浮窗的位置
@@ -192,25 +192,4 @@ public class ConnectStatusFloatWindow implements View.OnTouchListener {
private int sbar = -1;
// 获取系统状态栏高度
public int getSysBarHeight(Context contex) {
if (sbar == -1) {
Class<?> c;
Object obj;
Field field;
int x;
sbar = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = contex.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return sbar;
}
}

View File

@@ -12,6 +12,7 @@ import android.view.WindowManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.utilcode.util.BarUtils;
import com.zhidao.adas.client.R;
import com.zhidao.adas.client.adapter.ConnectStatusAdapter;
import com.zhidao.adas.client.adapter.DataShowAdapter;
@@ -108,14 +109,14 @@ public class FloatWindow implements View.OnTouchListener {
mInViewY = motionEvent.getY();
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.getRawX();
mDownInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mDownInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
break;
case MotionEvent.ACTION_MOVE:
// 更新浮动窗口位置参数
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
mWindowParams.x = (int) (mInScreenX - mInViewX);
mWindowParams.y = (int) (mInScreenY - mInViewY);
// 手指移动的时候更新小悬浮窗的位置
@@ -157,25 +158,4 @@ public class FloatWindow implements View.OnTouchListener {
private int sbar = -1;
// 获取系统状态栏高度
public int getSysBarHeight(Context contex) {
if (sbar == -1) {
Class<?> c;
Object obj;
Field field;
int x;
sbar = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = contex.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return sbar;
}
}

View File

@@ -22,6 +22,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatButton;
import com.mogo.eagle.core.utilcode.util.BarUtils;
import com.zhidao.adas.client.R;
import com.zhidao.adas.client.bean.SpecialVehicleBean;
import com.zhidao.adas.client.bean.SpecialVehicleOption;
@@ -129,9 +130,9 @@ public class SpecialVehicleFloatWindow extends LinearLayout {
mInViewY = event.getY();
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = event.getRawX();
mDownInScreenY = event.getRawY() - getSysBarHeight(getContext());
mDownInScreenY = event.getRawY() - BarUtils.getStatusBarHeight();
mInScreenX = event.getRawX();
mInScreenY = event.getRawY() - getSysBarHeight(getContext());
mInScreenY = event.getRawY() - BarUtils.getStatusBarHeight();
if (!isMaximize) {
btn_maximize.setPressed(true);
@@ -142,7 +143,7 @@ public class SpecialVehicleFloatWindow extends LinearLayout {
case MotionEvent.ACTION_MOVE:
// 更新浮动窗口位置参数
mInScreenX = event.getRawX();
mInScreenY = event.getRawY() - getSysBarHeight(getContext());
mInScreenY = event.getRawY() - BarUtils.getStatusBarHeight();
wmParams.x = (int) (mInScreenX - mInViewX);
wmParams.y = (int) (mInScreenY - mInViewY);
updateViewLayout();
@@ -195,24 +196,7 @@ public class SpecialVehicleFloatWindow extends LinearLayout {
// 获取系统状态栏高度
private int sbar = -1;
public int getSysBarHeight(Context contex) {
if (sbar == -1) {
Class<?> c;
Object obj;
Field field;
int x;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = contex.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return sbar;
}
/*****************************业务逻辑*******************************************/

View File

@@ -12,6 +12,7 @@ import android.view.WindowManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.utilcode.util.BarUtils;
import com.zhidao.adas.magic.R;
import com.zhidao.adas.magic.adapter.ConnectStatusAdapter;
import com.zhidao.adas.magic.bean.IPCConnectState;
@@ -108,14 +109,14 @@ public class FloatWindow implements View.OnTouchListener {
mInViewY = motionEvent.getY();
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.getRawX();
mDownInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mDownInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
break;
case MotionEvent.ACTION_MOVE:
// 更新浮动窗口位置参数
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenY = motionEvent.getRawY() - BarUtils.getStatusBarHeight();
mWindowParams.x = (int) (mInScreenX - mInViewX);
mWindowParams.y = (int) (mInScreenY - mInViewY);
// 手指移动的时候更新小悬浮窗的位置
@@ -156,27 +157,4 @@ public class FloatWindow implements View.OnTouchListener {
mFloatLayout.setAlpha(1);
}
private int sbar = -1;
// 获取系统状态栏高度
public int getSysBarHeight(Context contex) {
if (sbar == -1) {
Class<?> c;
Object obj;
Field field;
int x;
sbar = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = contex.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return sbar;
}
}

View File

@@ -19,6 +19,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
@@ -299,14 +300,14 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
mInViewY = motionEvent.y
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.rawX
mDownInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mDownInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
}
MotionEvent.ACTION_MOVE -> {
// 更新浮动窗口位置参数
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mWindowParams!!.x = (mInScreenX - mInViewX).toInt()
mWindowParams!!.y = (mInScreenY - mInViewY).toInt()
// 手指移动的时候更新小悬浮窗的位置
@@ -322,7 +323,7 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)-350
mWindowParams!!.y = metrics.heightPixels / 2 - BarUtils.getStatusBarHeight()-350
mWindowManager!!.addView(mFloatLayout, mWindowParams)
}
}
@@ -335,25 +336,6 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
}
// 获取系统状态栏高度
private fun getSysBarHeight(activity: Activity): Int {
val c: Class<*>
val obj: Any
val field: Field
val x: Int
var sbar = 0
try {
c = Class.forName("com.android.internal.R\$dimen")
obj = c.newInstance()
field = c.getField("status_bar_height")
x = field.get(obj).toString().toInt()
sbar = activity.resources.getDimensionPixelSize(x)
} catch (e1: Exception) {
e1.printStackTrace()
}
return sbar
}
fun setClickListener(clickListener: ClickListener) {
this.clickListener = clickListener
}

View File

@@ -23,6 +23,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
@@ -314,14 +315,14 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
mInViewY = motionEvent.y
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.rawX
mDownInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mDownInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
}
MotionEvent.ACTION_MOVE -> {
// 更新浮动窗口位置参数
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mWindowParams!!.x = (mInScreenX - mInViewX).toInt()
mWindowParams!!.y = (mInScreenY - mInViewY).toInt()
// 手指移动的时候更新小悬浮窗的位置
@@ -337,7 +338,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)-350
mWindowParams!!.y = metrics.heightPixels / 2 - BarUtils.getStatusBarHeight()-350
mWindowManager!!.addView(mFloatLayout, mWindowParams)
//开启录包
if(recordCaseEntity!=null){
@@ -358,25 +359,6 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
}
// 获取系统状态栏高度
private fun getSysBarHeight(activity: Activity): Int {
val c: Class<*>
val obj: Any
val field: Field
val x: Int
var sbar = 0
try {
c = Class.forName("com.android.internal.R\$dimen")
obj = c.newInstance()
field = c.getField("status_bar_height")
x = field.get(obj).toString().toInt()
sbar = activity.resources.getDimensionPixelSize(x)
} catch (e1: Exception) {
e1.printStackTrace()
}
return sbar
}
override fun onAutopilotRecordResult(recordPanel: RecordPanelOuterClass.RecordPanel) {
CallerLogger.d("${M_DEVA}${TAG}", "-- 收到工控机录制任务回调 -- $recordPanel")
ThreadUtils.runOnUiThread {

View File

@@ -21,10 +21,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListe
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.SizeUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
import com.zhidao.loglib.call.LogInfoManagerFactory
import com.zhidao.loglib.upload.OnUploadListener
@@ -270,14 +267,14 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
mInViewY = motionEvent.y
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.rawX
mDownInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mDownInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
}
MotionEvent.ACTION_MOVE -> {
// 更新浮动窗口位置参数
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mWindowParams!!.x = (mInScreenX - mInViewX).toInt()
mWindowParams!!.y = (mInScreenY - mInViewY).toInt()
// 手指移动的时候更新小悬浮窗的位置
@@ -293,7 +290,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)-350
mWindowParams!!.y = metrics.heightPixels / 2 - BarUtils.getStatusBarHeight()-350
mWindowManager!!.addView(mFloatLayout, mWindowParams)
}
@@ -346,25 +343,6 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
}
// 获取系统状态栏高度
private fun getSysBarHeight(activity: Activity): Int {
val c: Class<*>
val obj: Any
val field: Field
val x: Int
var sbar = 0
try {
c = Class.forName("com.android.internal.R\$dimen")
obj = c.newInstance()
field = c.getField("status_bar_height")
x = field.get(obj).toString().toInt()
sbar = activity.resources.getDimensionPixelSize(x)
} catch (e1: Exception) {
e1.printStackTrace()
}
return sbar
}
fun setRecord(key:String,fileName:String){
recordKey = key
recordFileName = fileName

View File

@@ -13,6 +13,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
import com.mogo.eagle.core.utilcode.reminder.Reminder
import com.mogo.eagle.core.utilcode.reminder.api.impl.ViewReminder
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.WindowUtils
/**
@@ -108,7 +109,7 @@ class WarningFloat {
@JvmOverloads
fun setBorder(
left: Int = 0,
top: Int = -WindowUtils.getStatusBarHeight(activity),
top: Int = -BarUtils.getStatusBarHeight(),
right: Int = WindowUtils.getScreenWidth(activity),
bottom: Int = WindowUtils.getScreenHeight(activity)
) = apply {

View File

@@ -13,6 +13,7 @@ import com.mogo.eagle.core.function.hmi.notification.anim.AnimatorManager
import com.mogo.eagle.core.function.hmi.notification.widget.ParentFrameLayout
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.WindowUtils
@@ -261,7 +262,7 @@ internal class WarningFloatWindowHelper(
view.getLocationOnScreen(location)
// 通过绝对高度和相对高度比较,判断包含顶部状态栏
val statusBarHeight =
if (location[1] > params.y) WindowUtils.getStatusBarHeight(view.context.applicationContext) else 0
if (location[1] > params.y) BarUtils.getStatusBarHeight() else 0
val parentBottom =
WindowUtils.getScreenHeight(view.context.applicationContext) - statusBarHeight
when (config.gravity) {

View File

@@ -8,7 +8,7 @@ import android.view.View
import android.view.WindowManager
import com.mogo.eagle.core.data.enums.SidePattern
import com.mogo.eagle.core.function.hmi.notification.interfaces.OnFloatAnimator
import com.mogo.eagle.core.utilcode.util.WindowUtils
import com.mogo.eagle.core.utilcode.util.BarUtils
import kotlin.math.min
/**
@@ -142,7 +142,7 @@ open class DefaultAnimator : OnFloatAnimator {
// 获取在整个屏幕内的绝对坐标
view.getLocationOnScreen(location)
// 绝对高度和相对高度相等说明是单页面浮窗popupWindow计算底部动画时需要加上状态栏高度
return if (location[1] == params.y) WindowUtils.getStatusBarHeight(view.context.applicationContext) else 0
return if (location[1] == params.y) BarUtils.getStatusBarHeight() else 0
}
}

View File

@@ -195,7 +195,7 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
}
override fun initViews() {
toggleStatusBarView()
//toggleStatusBarView()
initViewShowWithConfig()

View File

@@ -8,6 +8,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.mogo.eagle.core.data.gnss.AccelerationEntity
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.BarUtils
import java.lang.reflect.Field
/**
@@ -76,14 +77,14 @@ class AccelerationFloatWindow constructor(activity: Activity) : View.OnTouchList
mInViewY = motionEvent.y
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.rawX
mDownInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mDownInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
}
MotionEvent.ACTION_MOVE -> {
// 更新浮动窗口位置参数
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mWindowParams!!.x = (mInScreenX - mInViewX).toInt()
mWindowParams!!.y = (mInScreenY - mInViewY).toInt()
// 手指移动的时候更新小悬浮窗的位置
@@ -102,7 +103,7 @@ class AccelerationFloatWindow constructor(activity: Activity) : View.OnTouchList
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)
mWindowParams!!.y = metrics.heightPixels / 2 - BarUtils.getStatusBarHeight()
mWindowManager!!.addView(mFloatLayout, mWindowParams)
}
}
@@ -111,23 +112,4 @@ class AccelerationFloatWindow constructor(activity: Activity) : View.OnTouchList
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
}
// 获取系统状态栏高度
private fun getSysBarHeight(activity: Activity): Int {
val c: Class<*>
val obj: Any
val field: Field
val x: Int
var sbar = 0
try {
c = Class.forName("com.android.internal.R\$dimen")
obj = c.newInstance()
field = c.getField("status_bar_height")
x = field.get(obj).toString().toInt()
sbar = activity.resources.getDimensionPixelSize(x)
} catch (e1: Exception) {
e1.printStackTrace()
}
return sbar
}
}

View File

@@ -63,6 +63,7 @@ import com.mogo.eagle.core.function.hmi.ui.logcatch.ILogViewListener
import com.mogo.eagle.core.function.hmi.ui.logcatch.LogInfoView
import com.mogo.eagle.core.function.hmi.ui.upgrade.UpgradeListAdapter
import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView
import com.mogo.eagle.core.utilcode.kotlin.currentPadding
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel
@@ -80,6 +81,8 @@ import com.zhidao.easysocket.utils.L
import com.zhidao.support.adas.high.other.permission.BackgrounderPermission
import com.zhjt.mogo_core_function_devatools.env.*
import kotlinx.android.synthetic.main.view_debug_setting.view.*
import kotlinx.android.synthetic.main.view_debug_setting.view.tbRouteDynamicEffect
import kotlinx.android.synthetic.main.view_sop_setting.view.*
import mogo.telematics.pad.MessagePad
import mogo_msg.MogoReportMsg
import java.text.SimpleDateFormat
@@ -1862,6 +1865,7 @@ class DebugSettingView @JvmOverloads constructor(
when (type) {
BIZ_BEAUTY_MODE -> {
tbIsDemoMode.isClickable = !lock
val (left,top,right,bottom) = tbIsDemoMode.currentPadding()
if (lock) {
tbIsDemoMode.background =
resources.getDrawable(R.drawable.radio_button_lock_background)
@@ -1869,9 +1873,11 @@ class DebugSettingView @JvmOverloads constructor(
tbIsDemoMode.background =
resources.getDrawable(R.drawable.radio_button_normal_background_right)
}
tbIsDemoMode.setPadding(left,top,right,bottom)
}
BIZ_RAIN_MODE -> {
tbIsRainMode.isClickable = !lock
val (left,top,right,bottom) = tbIsRainMode.currentPadding()
if (lock) {
tbIsRainMode.background =
resources.getDrawable(R.drawable.radio_button_lock_background)
@@ -1879,17 +1885,21 @@ class DebugSettingView @JvmOverloads constructor(
tbIsRainMode.background =
resources.getDrawable(R.drawable.radio_button_normal_background_right)
}
tbIsRainMode.setPadding(left,top,right,bottom)
}
BIZ_WARNING_UPLOAD -> {
tbReportWarning.isClickable = !lock
val (left,top,right,bottom) = tbReportWarning.currentPadding()
if (lock) {
tbReportWarning.background =
resources.getDrawable(R.drawable.radio_button_lock_background)
} else {
tbReportWarning.background = null
}
tbReportWarning.setPadding(left,top,right,bottom)
}
BIZ_BAG_RECORD -> {
val (left,top,right,bottom) = btnRecordBag.currentPadding()
if (lock) {
btnRecordBag.isClickable = false
btnRecordBag.background =
@@ -1899,8 +1909,10 @@ class DebugSettingView @JvmOverloads constructor(
btnRecordBag.requestFocus()
btnRecordBag.background = null
}
btnRecordBag.setPadding(left,top,right,bottom)
}
BIZ_FULL_LOG -> {
val (left,top,right,bottom) = tbLogCatch.currentPadding()
if (lock) {
tbLogCatch.isClickable = false
tbLogCatch.background =
@@ -1910,6 +1922,7 @@ class DebugSettingView @JvmOverloads constructor(
tbLogCatch.requestFocus()
tbLogCatch.background = null
}
tbLogCatch.setPadding(left,top,right,bottom)
}
}
}

View File

@@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.mogo.eagle.core.data.report.ReportEntity
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper.getDrawable
import com.mogo.eagle.core.utilcode.util.BarUtils
import java.lang.reflect.Field
/**
@@ -107,14 +108,14 @@ class IPCReportWindow constructor(activity: Activity) : View.OnTouchListener{
mInViewY = motionEvent.y
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.rawX
mDownInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mDownInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
}
MotionEvent.ACTION_MOVE -> {
// 更新浮动窗口位置参数
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mWindowParams!!.x = (mInScreenX - mInViewX).toInt()
mWindowParams!!.y = (mInScreenY - mInViewY).toInt()
// 手指移动的时候更新小悬浮窗的位置
@@ -133,8 +134,8 @@ class IPCReportWindow constructor(activity: Activity) : View.OnTouchListener{
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels
// mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)
mWindowParams!!.y = metrics.heightPixels - getSysBarHeight(mActivity)-100
// mWindowParams!!.y = metrics.heightPixels / 2 - BarUtils.getStatusBarHeight()
mWindowParams!!.y = metrics.heightPixels - BarUtils.getStatusBarHeight()-100
mWindowManager!!.addView(mFloatLayout, mWindowParams)
}
}
@@ -143,25 +144,6 @@ class IPCReportWindow constructor(activity: Activity) : View.OnTouchListener{
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
}
// 获取系统状态栏高度
private fun getSysBarHeight(activity: Activity): Int {
val c: Class<*>
val obj: Any
val field: Field
val x: Int
var sbar = 0
try {
c = Class.forName("com.android.internal.R\$dimen")
obj = c.newInstance()
field = c.getField("status_bar_height")
x = field.get(obj).toString().toInt()
sbar = activity.resources.getDimensionPixelSize(x)
} catch (e1: Exception) {
e1.printStackTrace()
}
return sbar
}
fun setClickListener(clickListener: ClickListener) {
this.clickListener = clickListener
}

View File

@@ -8,6 +8,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.mogo.eagle.core.data.report.ReportEntity
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.BarUtils
import java.lang.reflect.Field
/**
@@ -68,14 +69,14 @@ class ReportListFloatWindow constructor(activity: Activity) : View.OnTouchListen
mInViewY = motionEvent.y
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.rawX
mDownInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mDownInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
}
MotionEvent.ACTION_MOVE -> {
// 更新浮动窗口位置参数
mInScreenX = motionEvent.rawX
mInScreenY = motionEvent.rawY - getSysBarHeight(mActivity)
mInScreenY = motionEvent.rawY - BarUtils.getStatusBarHeight()
mWindowParams!!.x = (mInScreenX - mInViewX).toInt()
mWindowParams!!.y = (mInScreenY - mInViewY).toInt()
// 手指移动的时候更新小悬浮窗的位置
@@ -94,7 +95,7 @@ class ReportListFloatWindow constructor(activity: Activity) : View.OnTouchListen
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)
mWindowParams!!.y = metrics.heightPixels / 2 - BarUtils.getStatusBarHeight()
mWindowManager!!.addView(mFloatLayout, mWindowParams)
}
}
@@ -103,23 +104,4 @@ class ReportListFloatWindow constructor(activity: Activity) : View.OnTouchListen
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
}
// 获取系统状态栏高度
private fun getSysBarHeight(activity: Activity): Int {
val c: Class<*>
val obj: Any
val field: Field
val x: Int
var sbar = 0
try {
c = Class.forName("com.android.internal.R\$dimen")
obj = c.newInstance()
field = c.getField("status_bar_height")
x = field.get(obj).toString().toInt()
sbar = activity.resources.getDimensionPixelSize(x)
} catch (e1: Exception) {
e1.printStackTrace()
}
return sbar
}
}

View File

@@ -14,6 +14,7 @@ import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsFuncConfigList
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.obu.CallerOBUManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.kotlin.currentPadding
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.module.service.routeoverlay.RouteStrategy
@@ -199,6 +200,7 @@ class SOPSettingView @JvmOverloads constructor(
when (type) {
FuncBizConfig.BIZ_BEAUTY_MODE -> {
tbDemoMode.isClickable = !lock
val (left,top,right,bottom) = tbDemoMode.currentPadding()
if (lock) {
tbDemoMode.background =
resources.getDrawable(R.drawable.radio_button_lock_background)
@@ -206,9 +208,11 @@ class SOPSettingView @JvmOverloads constructor(
tbDemoMode.background =
resources.getDrawable(R.drawable.radio_button_normal_background_right)
}
tbDemoMode.setPadding(left,top,right,bottom)
}
FuncBizConfig.BIZ_RAIN_MODE -> {
tbRainMode.isClickable = !lock
val (left,top,right,bottom) = tbRainMode.currentPadding()
if (lock) {
tbRainMode.background =
resources.getDrawable(R.drawable.radio_button_lock_background)
@@ -216,9 +220,11 @@ class SOPSettingView @JvmOverloads constructor(
tbRainMode.background =
resources.getDrawable(R.drawable.radio_button_normal_background_right)
}
tbRainMode.setPadding(left,top,right,bottom)
}
FuncBizConfig.BIZ_PNC_WARNING -> {
tbMarkingObstacles.isClickable = !lock
val (left,top,right,bottom) = tbMarkingObstacles.currentPadding()
if (lock) {
tbMarkingObstacles.background =
resources.getDrawable(R.drawable.radio_button_lock_background)
@@ -226,6 +232,7 @@ class SOPSettingView @JvmOverloads constructor(
tbMarkingObstacles.background =
resources.getDrawable(R.drawable.radio_button_normal_background_right)
}
tbMarkingObstacles.setPadding(left,top,right,bottom)
}
}
}

View File

@@ -173,7 +173,7 @@
<TextView
android:id="@+id/tv_check_title"
android:layout_width="84dp"
android:layout_width="wrap_content"
android:layout_height="86dp"
android:layout_marginStart="19dp"
android:gravity="center"
@@ -195,7 +195,7 @@
<TextView
android:id="@+id/tvSpeedTitle"
android:layout_width="168dp"
android:layout_width="wrap_content"
android:layout_height="86dp"
android:layout_marginStart="113dp"
android:layout_marginTop="76dp"
@@ -276,7 +276,7 @@
android:textColor="#A7B6F0"
android:textSize="32dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/llSpeedPosition" />
app:layout_constraintTop_toBottomOf="@id/ivSpeedReduce" />
<View
android:layout_width="14dp"

View File

@@ -22,6 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="开启绕障类功能"
@@ -35,6 +36,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="开启「危险障碍物颜色标记」"
@@ -48,6 +50,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="开启「引导线动态效果」"
@@ -61,6 +64,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="隐藏红绿灯标识"
@@ -74,6 +78,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="展示限速标识"
@@ -87,6 +92,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="开启美化模式"
@@ -100,6 +106,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="开启雨天模式"
@@ -113,6 +120,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="关闭OBU"
@@ -126,6 +134,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:padding="@dimen/dp_20"
android:background="@drawable/radio_button_normal_background_right"
android:textColor="#000"
android:textOff="开启异常上报提示"
@@ -141,15 +150,15 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tbIPCReport"
android:text="变道速度阈值:"
android:textSize="18sp"
android:textSize="@dimen/dp_36"
android:textColor="#1A1A1A"
android:layout_margin="10dp"
/>
<ImageView
android:id="@+id/ivSpeedReduce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/dp_64"
android:layout_height="@dimen/dp_64"
app:layout_constraintLeft_toRightOf="@id/tvSpeedThresholdTitle"
app:layout_constraintTop_toTopOf="@id/tvSpeedThresholdTitle"
app:layout_constraintBottom_toBottomOf="@id/tvSpeedThresholdTitle"
@@ -164,7 +173,7 @@
app:layout_constraintTop_toTopOf="@id/ivSpeedReduce"
app:layout_constraintBottom_toBottomOf="@id/ivSpeedReduce"
app:layout_constraintLeft_toRightOf="@id/ivSpeedReduce"
android:textSize="18sp"
android:textSize="@dimen/dp_36"
android:gravity="center"
android:background="@drawable/debug_setting_edit_bg"
android:paddingStart="10dp"
@@ -175,8 +184,8 @@
<ImageView
android:id="@+id/ivSpeedAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/dp_64"
android:layout_height="@dimen/dp_64"
app:layout_constraintTop_toTopOf="@id/tvSpeed"
app:layout_constraintBottom_toBottomOf="@id/tvSpeed"
app:layout_constraintLeft_toRightOf="@id/tvSpeed"
@@ -188,6 +197,7 @@
android:id="@+id/btnSpeedSet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dp_20"
app:layout_constraintTop_toTopOf="@id/ivSpeedAdd"
app:layout_constraintBottom_toBottomOf="@id/ivSpeedAdd"
app:layout_constraintLeft_toRightOf="@id/ivSpeedAdd"

View File

@@ -27,6 +27,10 @@ import kotlinx.coroutines.channels.Channel
import java.util.*
import kotlin.math.abs
fun View.currentPadding() : Array<Int> {
return arrayOf(paddingLeft,paddingTop,paddingRight,paddingBottom)
}
val <T: View> T.lifecycleOwner: LifecycleOwner
get() = getTag(R.id.view_lifecycle_owner) as? LifecycleOwner ?: object : LifecycleOwner, LifecycleEventObserver {

View File

@@ -57,9 +57,16 @@ public final class BarUtils {
* @return the status bar's height
*/
public static int getStatusBarHeight() {
Resources resources = Utils.getApp().getResources();
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
return resources.getDimensionPixelSize(resourceId);
int result = 0;
try {
int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = Resources.getSystem().getDimensionPixelSize(resourceId);
}
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
return result;
}
/**

View File

@@ -509,38 +509,6 @@ public class CommonUtils {
return "";
}
public static int getStatusBarHeight(Context context) {
if (context == null) {
return 0;
}
int statusBarHeight = 0;
try {
Class c = Class.forName("com.android.internal.R$dimen");
Object obj = c.newInstance();
Field field = c.getField("status_bar_height");
int x = Integer.parseInt(field.get(obj).toString());
statusBarHeight = context.getResources().getDimensionPixelSize(x);
} catch (Exception e) {
}
if (statusBarHeight > 0) {
return statusBarHeight;
}
try {
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
}
} catch (Exception e) {
}
return statusBarHeight;
}
/**
* 获取某个应用的版本名称
*

View File

@@ -4,20 +4,6 @@ import android.content.Context;
public class WindowUtils {
public static int getStatusBarHeight( Context context ) {
if ( context == null ) {
return 0;
} else {
int result = 0;
int resourceId = context.getResources().getIdentifier( "status_bar_height", "dimen", "android" );
if ( resourceId > 0 ) {
result = context.getResources().getDimensionPixelSize( resourceId );
}
return result;
}
}
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/