Merge remote-tracking branch 'origin/dev_robobus_network_weak_230323' into dev_robobus_network_weak_230323
This commit is contained in:
@@ -57,6 +57,8 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
implementation rootProject.ext.dependencies.litezxing
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
api rootProject.ext.dependencies.mogoutils
|
||||
api rootProject.ext.dependencies.mogocommons
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.mogo.och.common.module.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import com.google.zxing.BarcodeFormat
|
||||
import com.google.zxing.EncodeHintType
|
||||
import com.google.zxing.common.BitMatrix
|
||||
import com.google.zxing.qrcode.QRCodeWriter
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* isDeleteWhite 是否删除白边
|
||||
*/
|
||||
fun createQRCode(address: String, width: Int, height: Int,isDeleteWhite: Boolean): Bitmap? {
|
||||
val hints = Hashtable<EncodeHintType, Any>()
|
||||
hints[EncodeHintType.CHARACTER_SET] = "utf-8"
|
||||
hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.H
|
||||
hints[EncodeHintType.MARGIN] = if (isDeleteWhite) 1 else 0
|
||||
var bitMatrix = QRCodeWriter().encode(
|
||||
address,
|
||||
BarcodeFormat.QR_CODE, width, height, hints
|
||||
)
|
||||
|
||||
if (isDeleteWhite) {
|
||||
//删除白边
|
||||
bitMatrix = deleteWhite(bitMatrix)
|
||||
}
|
||||
val widthNew = bitMatrix.width
|
||||
val heightNew = bitMatrix.height
|
||||
|
||||
val pixels = IntArray(widthNew * heightNew)
|
||||
//下面这里按照二维码的算法,逐个生成二维码的图片,
|
||||
//两个for循环是图片横列扫描的结果
|
||||
for (y in 0 until heightNew) {
|
||||
for (x in 0 until widthNew) {
|
||||
if (bitMatrix.get(x, y)) {
|
||||
pixels[y * widthNew + x] = -0x1000000
|
||||
} else {
|
||||
pixels[y * widthNew + x] = -0x1
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成二维码图片的格式,使用ARGB_8888
|
||||
var bitmap = Bitmap.createBitmap(widthNew, heightNew, Bitmap.Config.ARGB_8888)
|
||||
bitmap.setPixels(pixels, 0, widthNew, 0, 0, widthNew, heightNew)
|
||||
return bitmap
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除白色边框
|
||||
*
|
||||
* @param matrix matrix
|
||||
* @return BitMatrix
|
||||
*/
|
||||
private fun deleteWhite(matrix: BitMatrix): BitMatrix? {
|
||||
val rec = matrix.enclosingRectangle
|
||||
val resWidth = rec[2] + 1
|
||||
val resHeight = rec[3] + 1
|
||||
val resMatrix = BitMatrix(resWidth, resHeight)
|
||||
resMatrix.clear()
|
||||
for (i in 0 until resWidth) {
|
||||
for (j in 0 until resHeight) {
|
||||
if (matrix[i + rec[0], j + rec[1]]) resMatrix[i] = j
|
||||
}
|
||||
}
|
||||
return resMatrix
|
||||
}
|
||||
|
||||
fun createQRCodeWithPicture(bmCenter: Bitmap,address: String, width: Int, height: Int,isDeleteWhite: Boolean): Bitmap?{
|
||||
var qrCode = createQRCode(address,width,height,isDeleteWhite)
|
||||
//8,创建一个bitmap对象用于作为其图标
|
||||
qrCode?.let {
|
||||
val resultBitmap = addLogo(it,bmCenter)
|
||||
if (resultBitmap != null){
|
||||
return resultBitmap
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于向创建的二维码中添加一个logo
|
||||
* @param bmQr
|
||||
* @param bmCenter
|
||||
* @return
|
||||
*/
|
||||
fun addLogo(bmQr: Bitmap, bmCenter:Bitmap) :Bitmap?{
|
||||
if (bmQr == null) {
|
||||
return null
|
||||
}
|
||||
if (bmCenter == null) {
|
||||
return bmQr
|
||||
}
|
||||
|
||||
//获取图片的宽高
|
||||
val bmQrWidth = bmQr.width
|
||||
val bmQrHeight = bmQr.height
|
||||
val bmCenterWidth = bmCenter.width
|
||||
val bmCenterHeight = bmCenter.height
|
||||
|
||||
var bitmap = Bitmap.createBitmap(bmQrWidth, bmQrHeight, Bitmap.Config.ARGB_8888)
|
||||
try {
|
||||
var canvas = Canvas(bitmap)
|
||||
canvas.drawBitmap(bmQr, 0f, 0f, null)
|
||||
canvas.drawBitmap(bmCenter, ((bmQrWidth-bmCenterWidth)/2-bmCenterWidth/2).toFloat(),
|
||||
((bmQrHeight-bmCenterHeight)/2-bmCenterHeight/2).toFloat(), null)
|
||||
|
||||
canvas.save()
|
||||
canvas.restore()
|
||||
} catch (e: Exception) {
|
||||
bitmap = null
|
||||
e.stackTrace
|
||||
}
|
||||
return bitmap
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.och.common.module.wigets
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import com.mogo.och.common.module.R
|
||||
|
||||
/**
|
||||
* 带有title, tip,confirm,cancel的dialog
|
||||
*/
|
||||
class BindQRCodeDialog: BaseFloatDialog, LifecycleObserver {
|
||||
|
||||
private var qrBm : AppCompatImageView? = null
|
||||
private var qrCancel: AppCompatTextView? = null
|
||||
private var qrTitle: AppCompatTextView? = null
|
||||
|
||||
private var clickListener: ClickListener? = null
|
||||
|
||||
constructor(builder: Builder,context: Context) : super(context) {
|
||||
qrTitle?.text = builder.titleStr
|
||||
qrCancel?.text = builder.cancelStr
|
||||
qrBm?.setImageBitmap(builder.qrBm)
|
||||
}
|
||||
|
||||
init{
|
||||
setContentView(R.layout.bind_driver_qr_view)
|
||||
|
||||
setCanceledOnTouchOutside(true)
|
||||
|
||||
qrTitle = findViewById(R.id.qr_title)
|
||||
qrBm = findViewById(R.id.qr_bm)
|
||||
qrCancel = findViewById(R.id.bind_qr_cancel)
|
||||
|
||||
qrCancel?.setOnClickListener {
|
||||
clickListener?.cancel()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
interface ClickListener{
|
||||
fun cancel()
|
||||
}
|
||||
|
||||
class Builder{
|
||||
var titleStr:String = ""
|
||||
var cancelStr:String = ""
|
||||
var qrBm: Bitmap? = null
|
||||
|
||||
fun title(title: String) : Builder{
|
||||
this.titleStr = title
|
||||
return this
|
||||
}
|
||||
|
||||
fun cancelStr(cancel: String) : Builder{
|
||||
this.cancelStr = cancel
|
||||
return this
|
||||
}
|
||||
|
||||
fun qrBm(bm: Bitmap) : Builder{
|
||||
this.qrBm = bm
|
||||
return this
|
||||
}
|
||||
|
||||
fun build(context: Context): BindQRCodeDialog? {
|
||||
return BindQRCodeDialog(this,context)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,13 +49,6 @@ class OCHCommitDialog: BaseFloatDialog, LifecycleObserver {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
fun showUpgradeDialog(){
|
||||
if(isShowing){
|
||||
return
|
||||
}
|
||||
show()
|
||||
}
|
||||
|
||||
interface ClickListener{
|
||||
fun confirm()
|
||||
fun cancel()
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="@dimen/dp_32"/>
|
||||
<solid android:color="@color/qr_bg_color"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/dp_890"
|
||||
android:layout_height="@dimen/dp_780"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:ignore="MissingDefaultResource"
|
||||
android:background="@drawable/bind_driver_qr_bg">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/qr_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/bind_driver_qr_title"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/dp_56"
|
||||
android:layout_marginTop="@dimen/dp_48"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/qr_bm"
|
||||
android:layout_width="@dimen/dp_357"
|
||||
android:layout_height="@dimen/dp_357"
|
||||
android:padding="8dp"
|
||||
android:background="@android:color/white"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/qr_title"
|
||||
app:layout_constraintBottom_toTopOf="@+id/line"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/line"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:background="@color/qr_line_bg_color"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bind_qr_cancel"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/bind_qr_cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_162"
|
||||
android:gravity="center"
|
||||
android:text="@string/qr_cancel"
|
||||
android:textSize="@dimen/dp_52"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:textColor="@android:color/white" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -11,4 +11,7 @@
|
||||
<color name="taxi_4D000000">#4D000000</color>
|
||||
|
||||
<color name="och_dialog_bg_color">#3B4577</color>
|
||||
|
||||
<color name="qr_line_bg_color">#66B8BFE8</color>
|
||||
<color name="qr_bg_color">#3B4577</color>
|
||||
</resources>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<string name="module_och_taxi_login_title">欢迎您登录</string>
|
||||
<string name="module_och_taxi_login_btn">登录</string>
|
||||
@@ -30,4 +30,7 @@
|
||||
<string name="end_order_zh">感谢您体验\'蘑菇车联\'自动驾驶小巴车,本次旅程已结束,我们下次乘车再见</string>
|
||||
<string name="end_order_en">Thank you for experiencing the self-driving minibus. See you next time</string>
|
||||
<string name="end_order_ko">자율주행 버스를 체험해 주셔서 감사합니다. 다음에 또 뵙겠습니다</string>
|
||||
|
||||
<string name="qr_cancel">取消</string>
|
||||
<string name="bind_driver_qr_title">扫描二维码完成车辆绑定</string>
|
||||
</resources>
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.mogo.och.bus.constant
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
|
||||
/**
|
||||
* Created on 2021/12/6
|
||||
*/
|
||||
class URLConst {
|
||||
companion object {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.mogo.och.bus.fragment;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -13,7 +14,9 @@ import androidx.constraintlayout.widget.Group;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.temp.EventLogout;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
@@ -36,6 +39,8 @@ import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
import com.mogo.och.common.module.biz.provider.LoginService;
|
||||
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
|
||||
import com.mogo.och.common.module.utils.OCHThreadPoolManager;
|
||||
import com.mogo.och.common.module.utils.QRUtilsKt;
|
||||
import com.mogo.och.common.module.wigets.BindQRCodeDialog;
|
||||
import com.mogo.och.common.module.wigets.MarqueeTextView;
|
||||
import com.mogo.och.common.module.wigets.OCHCommitDialog;
|
||||
|
||||
@@ -45,6 +50,8 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 网约车小巴界面
|
||||
@@ -124,6 +131,22 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
if (eventLogout.getMessgae() == EventLogout.LOGOUT_TYPE){
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"changeOverview Event消息去登出");
|
||||
mPresenter.logout();
|
||||
}else if (eventLogout.getMessgae() == EventLogout.SHOW_QR_TYPE){ //显示二维码
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"changeOverview Event qrcode");
|
||||
String qrUrl = String.format(FunctionBuildConfig.urlJson.getBindDriverQRUrl(),
|
||||
MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
Bitmap bmQr = QRUtilsKt.createQRCodeWithPicture(
|
||||
BitmapFactory.decodeResource(getResources(), R.drawable.icon_qr_center_logo)
|
||||
,qrUrl, AutoSizeUtils.dp2px(getContext(),340f),
|
||||
AutoSizeUtils.dp2px(getContext(),340f),true);
|
||||
if (bmQr != null){
|
||||
BindQRCodeDialog.Builder builder = new BindQRCodeDialog.Builder();
|
||||
builder.title(getString(R.string.bind_driver_qr_title))
|
||||
.cancelStr(getString(R.string.qr_cancel))
|
||||
.qrBm(bmQr).build(getContext()).show();
|
||||
}else {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"bmQr = null ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user