Commit 382f9bc4 authored by jiangjiantao's avatar jiangjiantao

dev

parent 242c34f2
......@@ -13,7 +13,7 @@ android {
targetSdkVersion 31
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......@@ -46,8 +46,10 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:4.9.3")
implementation("com.squareup.okhttp3:logging-interceptor:3.9.0")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.google.android.material:material:1.2.0")
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.github.GrenderG:Toasty:1.5.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.+'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation('com.squareup.retrofit2:converter-simplexml:2.9.0') {
......@@ -56,7 +58,8 @@ dependencies {
exclude group: 'stax', module: 'stax'
}
implementation 'com.alibaba:fastjson:1.2.8'
implementation 'com.blankj:utilcode:1.30.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation files('libs/miya-print-1.0.22.aar')
implementation files('libs/miya-print-1.0.23.aar')
}
\ No newline at end of file
......@@ -7,27 +7,36 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".BaseApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name=".BaseApplication"
android:theme="@style/Theme.MiYaFastCashier">
android:supportsRtl="true">
<activity
android:name=".ui.login.LoginActivity"
android:name=".ui.LoginActivity"
android:exported="true"
android:label="@string/title_activity_login">
android:label="@string/title_activity_login"
android:theme="@style/Theme.MiYaFastCashier.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.main.MainActivity" />
<activity android:name=".ui.splash.SplashActivity" />
<activity
android:name=".ui.MainActivity"
android:launchMode="singleTask"
android:theme="@style/Theme.MiYaFastCashier.Dark" />
<activity
android:name=".ui.PriceInputActivity"
android:theme="@style/Theme.MiYaFastCashier.Dark" />
<activity
android:name=".ui.PayCodeActivity"
android:theme="@style/Theme.MiYaFastCashier.Dark" />
<activity
android:name=".ui.PayResultActivity"
android:theme="@style/Theme.MiYaFastCashier.Light" />
</application>
</manifest>
\ No newline at end of file
package com.miya.fastcashier
import android.app.Activity
import android.app.Application
import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.multidex.MultiDexApplication
import com.miya.print.PrinterManager
class BaseApplication : Application() {
class BaseApplication : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
PrinterManager.instance.init(this)
//打印机初始化
PrinterManager.getInstance().init(this)
//屏幕适配
screenAdapt()
}
private fun screenAdapt() {
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
setDensity(activity, this@BaseApplication)
}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityResumed(activity: Activity) {}
override fun onActivityPaused(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
})
}
fun setDensity(context: Context, application: Application) {
val appDiaplayMetrics = application.resources.displayMetrics
val targetDensity = (appDiaplayMetrics.widthPixels / 540).toFloat()
val targetDensityDpi = (160 * targetDensity).toInt()
appDiaplayMetrics.scaledDensity = targetDensity
appDiaplayMetrics.density = appDiaplayMetrics.scaledDensity
appDiaplayMetrics.densityDpi = targetDensityDpi
val activityDisplayMetrics = context.resources.displayMetrics
activityDisplayMetrics.scaledDensity = targetDensity
activityDisplayMetrics.density = activityDisplayMetrics.scaledDensity
activityDisplayMetrics.densityDpi = targetDensityDpi
}
}
\ No newline at end of file
package com.miya.fastcashier.beans
/**
* Data validation state of the login form.
*/
data class LoginFormState(
val usernameError: Int? = null,
val passwordError: Int? = null,
val isDataValid: Boolean = false
)
\ No newline at end of file
package com.miya.fastcashier.repository
import androidx.annotation.WorkerThread
import com.miya.fastcashier.service.AccountService
import com.sdy.miya.moblie.component.pay.core.constance.AppTagConstance
import com.sdy.miya.moblie.component.pay.core.result.MiYaMobilePayResult
import com.sdy.miya.moblie.component.pay.core.result.ResultBuilder
......@@ -142,5 +143,100 @@ object PayRepository {
}
}
/**
* 只支持微信或者支付宝
* payType 2是微信 1是支付宝
*/
fun generatePayCode(orderNo:String,payPrice:String,payType:String): PayServiceResponse {
val shopInfo = AccountService.getAccountInfo()?.shopInfo
val baseUrl = shopInfo?.miyaPayPlatformUrl;
val signKey = shopInfo?.miyaPayPlatformSignKey
val saasid = shopInfo?.saasid
val marketid = shopInfo?.storeId
val posId = shopInfo?.posId
val cashierCode = shopInfo?.operatorId
val version = "1.5"
checkNotNull(baseUrl) { "baseUrl is null" }
checkNotNull(payPrice) { "payPrice is null" }
checkNotNull(payType) { "payType is null" }
checkNotNull(signKey) { "signKey is null" }
checkNotNull(saasid) { "saasid is null" }
checkNotNull(marketid) { "marketid is null" }
// checkNotNull(posId) { "posId is null" }
// checkNotNull(cashierCode) { "cashierCode is null" }
checkNotNull(orderNo) { "orderNo is null" }
val paramsMap: MutableMap<String, Any?> = HashMap(14, 1.0f)
paramsMap["baseUrl"] = baseUrl
paramsMap["signKey"] = signKey
paramsMap["saasId"] = saasid
paramsMap["marketId"] = marketid
paramsMap["posId"] = posId
paramsMap["cashierCode"] = cashierCode
paramsMap["version"] = version
paramsMap["payPrice"] = payPrice
paramsMap["payType"] = payType
paramsMap["orderNo"] = orderNo
try {
val miYaMobilePayResult =
MiYaPlatformPayService.getService().syncGenMiYaPayCode(paramsMap)
if (miYaMobilePayResult != null && miYaMobilePayResult.resultCode == ResultBuilder.SUCCESS) {
return miYaMobilePayResult.payServiceResponse
} else {
throw RuntimeException(miYaMobilePayResult!!.errorMsg)
}
} catch (e: Exception) {
e.printStackTrace()
throw RuntimeException(e.message)
}
}
fun payResultQuery(orderNo:String): PayServiceResponse{
val shopInfo = AccountService.getAccountInfo()?.shopInfo
val baseUrl = shopInfo?.miyaPayPlatformUrl;
val signKey = shopInfo?.miyaPayPlatformSignKey
val saasid = shopInfo?.saasid
val marketid = shopInfo?.storeId
val posId = shopInfo?.posId
val cashierCode = shopInfo?.operatorId
val version = "1.5"
checkNotNull(baseUrl) { "baseUrl is null" }
checkNotNull(signKey) { "signKey is null" }
checkNotNull(saasid) { "saasid is null" }
checkNotNull(marketid) { "marketid is null" }
// checkNotNull(posId) { "posId is null" }
// checkNotNull(cashierCode) { "cashierCode is null" }
checkNotNull(orderNo) { "orderNo is null" }
val paramsMap: MutableMap<String, Any?> = HashMap(14, 1.0f)
paramsMap["baseUrl"] = baseUrl
paramsMap["signKey"] = signKey
paramsMap["saasId"] = saasid
paramsMap["marketId"] = marketid
paramsMap["posId"] = posId
paramsMap["cashierCode"] = cashierCode
paramsMap["version"] = version
paramsMap["orderNo"] = orderNo
try {
val miYaMobilePayResult =
MiYaPlatformPayService.getService().syncRequestOrderStateByOrderId(paramsMap)
if (miYaMobilePayResult != null && miYaMobilePayResult.resultCode == ResultBuilder.SUCCESS) {
return miYaMobilePayResult.payServiceResponse
} else {
throw RuntimeException(miYaMobilePayResult!!.errorMsg)
}
} catch (e: Exception) {
e.printStackTrace()
throw RuntimeException(e.message)
}
}
}
\ No newline at end of file
package com.miya.fastcashier.service
import android.text.TextUtils
import com.miya.fastcashier.beans.SelfCashierAccountInfo
import com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import com.miya.fastcashier.utils.StringPriceFormat
import com.miya.print.IPrinter
import com.miya.print.PrinterManager
import com.miya.print.utils.Page58MmPrintUtils
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import java.util.*
object PrintService{
......@@ -15,4 +21,55 @@ object PrintService{
}
}
/**
* 扣款信息打印
*/
fun payInfoPrint(payServiceResponse: PayServiceResponse,selfCashierAccountInfo: SelfCashierAccountInfo){
val printer = PrinterManager.getInstance().printer
printer.beginPrint()
printer.set58mm()
printer.setAlign(IPrinter.ALIGN_CENTER)
//检查打印机状态
printer.printerStatus
val shopInfo = selfCashierAccountInfo.shopInfo
printer.printText(shopInfo.storeName)
printer.setAlign(IPrinter.ALIGN_LEFT)
printer.printText("持卡人存根")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("商户编号:${shopInfo.appId}")
printer.printText("终端编号:${shopInfo.posId}")
printer.printText("商户名称:converse")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("交易类型:${
MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc}")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("日期/时间:${com.miya.fastcashier.utils.DateUtils.format18(Date())}")
//todo 流水号
printer.printText("商户订单号:")
printer.printText(payServiceResponse.shopTradeNo)
printer.printText("支付平台交易号:")
printer.printText(payServiceResponse.chanelSerialNumber)
printer.printText("金额:RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.tradPrice)}")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("备注:")
val couponDetail: Array<String> = payServiceResponse.transformCouponMessage
if (couponDetail.size >= 2 && !TextUtils.isEmpty(couponDetail[1]) && couponDetail[1] != "0" && couponDetail[1] != "0.00") {
val shopCoupon = couponDetail[1]
//打印商家优惠
printer.printText("商家优惠:${StringPriceFormat.transStringPriceToDecimalString(shopCoupon)}元")
}
if (couponDetail.size >= 3 && !TextUtils.isEmpty(couponDetail[2]) && couponDetail[2] != "0" && couponDetail[2] != "0.00") {
//平台优惠
val platformCoupon = couponDetail[2]
val channel = MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText("$channel 优惠:${StringPriceFormat.transStringPriceToDecimalString(platformCoupon)}元")
}
if (couponDetail.isNotEmpty() && !TextUtils.isEmpty(couponDetail[0])) {
val payPrice = couponDetail[0]
printer.printText("客户支付:${StringPriceFormat.transStringPriceToDecimalString(payPrice)}元")
}
printer.endPrint()
}
}
\ No newline at end of file
package com.miya.fastcashier.ui
import androidx.appcompat.app.AppCompatActivity
open class BaseActivity : AppCompatActivity() {
}
\ No newline at end of file
package com.miya.fastcashier.ui
import android.content.Intent
import android.os.Bundle
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.viewmodel.LoginViewModel
class LoginActivity : AppCompatActivity() {
private lateinit var loginViewModel: LoginViewModel
private lateinit var binding: ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
val username = binding.username
val password = binding.password
val loading = binding.loading
val login = binding.login
val tvErrInfo = binding.tvErrInfo
loginViewModel = ViewModelProvider(this)
.get(LoginViewModel::class.java)
loginViewModel.loginLiveData.observe(this) { result ->
loading.visibility = View.GONE
result.getOrElse {
tvErrInfo.text = it.message
return@observe
}
result.getOrNull().also {
it?.let { it1 ->
AccountService.setAccountInfo(it1)
val intent = Intent()
intent.setClass(this@LoginActivity, MainActivity::class.java)
startActivity(intent)
finish()
}
}
}
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
login.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null) {
password.error = getString(loginState.passwordError)
}
})
username.afterTextChanged {
loginViewModel.loginDataChanged(
username.text.toString(),
password.text.toString()
)
}
password.apply {
afterTextChanged {
loginViewModel.loginDataChanged(
username.text.toString(),
password.text.toString()
)
}
setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_DONE ->
loginViewModel.login(
username.text.toString(),
password.text.toString()
)
}
false
}
binding.login.setOnClickListener {
loading.visibility = View.VISIBLE
loginViewModel.login(username.text.toString(), password.text.toString())
}
}
if(!TextUtils.isEmpty(username.text)
&& !TextUtils.isEmpty(password.text)){
loginViewModel.login(username.text.toString(), password.text.toString())
}
}
/**
* Extension function to simplify setting an afterTextChanged action to EditText components.
*/
fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) {
this.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(editable: Editable?) {
afterTextChanged.invoke(editable.toString())
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
})
}
}
package com.miya.fastcashier.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.databinding.ActivityMainBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.viewmodel.MainViewModel
class MainActivity : BaseActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
val llPay = binding.llPay
val llRefund = binding.llRefund
val tvPrintLast = binding.tvPrintLast
llPay.setOnClickListener{
val intent = Intent()
intent.setClass(this@MainActivity, PriceInputActivity::class.java)
startActivity(intent)
}
llRefund.setOnClickListener{
CenterToasty.normal(this,"暂时不支持此功能",Toast.LENGTH_SHORT).show();
}
tvPrintLast.setOnClickListener{
CenterToasty.normal(this,"暂时不支持此功能",Toast.LENGTH_SHORT).show();
}
}
}
\ No newline at end of file
package com.miya.fastcashier.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import com.alibaba.fastjson.JSON
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.SizeUtils
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityPayCodeBinding
import com.miya.fastcashier.databinding.ActivityPriceInputBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.StringPriceFormat
import com.miya.fastcashier.viewmodel.PayViewModel
import com.miya.print.utils.BitmapUtils
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import java.util.*
import kotlin.concurrent.timerTask
class PayCodeActivity : AppCompatActivity() {
private lateinit var viewModel: PayViewModel
private lateinit var binding: ActivityPayCodeBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityPayCodeBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(PayViewModel::class.java)
val ivPayCode = binding.ivPayCode
val tvBack = binding.tvBack
val ivBack = binding.ivBack
val loading = binding.loading
val tvPrice = binding.tvPrice
val extra = intent.getSerializableExtra("payServiceResponse")
extra?.let {
val payServiceResponse = it as PayServiceResponse
LogUtils.e(JSON.toJSONString(payServiceResponse))
tvPrice.text = "¥".plus(StringPriceFormat.transStringPriceToDecimalString( payServiceResponse.tradPrice))
runBlocking(Dispatchers.IO) {
val qrcode = BitmapUtils.createBarcodeBitmap(payServiceResponse.payQrCode, 9, 303, 303)
runOnUiThread {
ivPayCode.setImageBitmap(qrcode)
//支付结果查询
viewModel.payResultQuery(payServiceResponse)
}
}
}
viewModel.payResultLiveData.observe(this,{ result ->
result.getOrElse {
it.message?.let { it1 -> CenterToasty.error(this, it1,Toast.LENGTH_LONG).show() }
return@observe
}
result.getOrNull().also {
it?.let { it1 ->
val intent = Intent()
intent.setClass(this@PayCodeActivity, PayResultActivity::class.java)
intent.putExtra("payServiceResponse",it1)
startActivity(intent)
}
}
})
}
override fun onStop() {
super.onStop()
viewModel.payResultJob.cancel()
}
}
\ No newline at end of file
package com.miya.fastcashier.ui
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.databinding.ActivityPayResultBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import com.miya.fastcashier.utils.StringPriceFormat
import com.miya.fastcashier.viewmodel.PrintViewModel
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
class PayResultActivity : AppCompatActivity() {
private lateinit var viewModel: PrintViewModel
private lateinit var binding: ActivityPayResultBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityPayResultBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(PrintViewModel::class.java)
val tvPayPrice = binding.tvPayPrice
val tvOrderNo = binding.tvOrderNo
val tvPayWay = binding.tvPayWay
val tvTradeNo = binding.tvTradeNo
val tvTradeTime = binding.tvTradeTime
val tvStatus = binding.tvStatus
val tvRePrint = binding.tvRePrint
val tvGoHome = binding.tvGoHome
val extra = intent.getSerializableExtra("payServiceResponse")
extra?.let {
val payServiceResponse = it as PayServiceResponse
tvPayPrice.text = "¥".plus(StringPriceFormat.transStringPriceToDecimalString(
payServiceResponse.tradPrice))
tvOrderNo.text = payServiceResponse.shopTradeNo
tvPayWay.text = MiYaPayPlantformPayWayEnum.MiyaPayType.find(
payServiceResponse.chanelTag
).desc
tvTradeNo.text = payServiceResponse.chanelSerialNumber
tvTradeTime.text = payServiceResponse.miyaResponseTime
viewModel.printOrder(payServiceResponse)
}
viewModel.printResultLiveData.observe(this,{ result ->
result.getOrElse {
it.message?.let { it1 -> {
tvStatus.text = it1
tvRePrint.visibility = View.VISIBLE
} }
return@observe
}
result.getOrNull().also {
it?.let {
tvStatus.text = "小票打印成功!"
}
}
})
tvRePrint.setOnClickListener {
tvStatus.text = "小票打印中,请稍等…"
viewModel.printOrder(extra as PayServiceResponse)
}
tvGoHome.setOnClickListener {
val intent = Intent()
intent.setClass(this@PayResultActivity, MainActivity::class.java)
startActivity(intent)
}
}
}
\ No newline at end of file
package com.miya.fastcashier.ui
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import com.alibaba.fastjson.JSON
import com.miya.fastcashier.databinding.ActivityPriceInputBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.viewmodel.PayViewModel
import com.miya.fastcashier.widget.NumKeyboard.DELETE
import com.miya.fastcashier.widget.NumKeyboard.DOT
import java.math.BigDecimal
class PriceInputActivity : BaseActivity() {
private lateinit var viewModel: PayViewModel
private lateinit var binding: ActivityPriceInputBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityPriceInputBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(PayViewModel::class.java)
val tvGeneratePayCode = binding.tvGeneratePayCode
val tvScanPayCode = binding.tvScanPayCode
val tvBack = binding.tvBack
val ivBack = binding.ivBack
val etPrice = binding.etPrice
val loading = binding.loading
val numKeyboard = binding.numKeyboard
tvScanPayCode.setOnClickListener{
CenterToasty.normal(this,"暂时不支持此功能", Toast.LENGTH_SHORT).show();
}
tvGeneratePayCode.setOnClickListener{
loading.visibility = View.VISIBLE
viewModel.generatePayCode(etPrice.text.toString(),"1")
}
tvBack.setOnClickListener{ finish() }
ivBack.setOnClickListener{ finish() }
numKeyboard.setKeyboardClickListener {
when (it) {
DELETE -> {
if (TextUtils.isEmpty(etPrice.text.toString())) {
return@setKeyboardClickListener
}
var currentCode: String = etPrice.text.toString()
currentCode = if (currentCode.length <= 1) {
""
} else {
currentCode.substring(0, currentCode.length - 1)
}
etPrice.setText(currentCode)
}
DOT -> {
var currentCode: String = etPrice.text.toString()
if (!currentCode.contains(".") && !TextUtils.isEmpty(currentCode)) {
currentCode += "."
etPrice.setText(currentCode)
} else {
CenterToasty.error(this,"金额格式有误!",Toast.LENGTH_LONG).show()
}
}
else -> {
var currentCode: String = etPrice.text.toString()
if (currentCode.contains(".")) {
val tmp = currentCode.substring(currentCode.indexOf("."), currentCode.length - 1)
if (tmp.length < 2) {
if (BigDecimal(currentCode + it).compareTo(BigDecimal.ZERO) == 0 && tmp.length == 1) {
CenterToasty.error(this,"金额不能为0!",Toast.LENGTH_LONG).show()
} else {
currentCode += it
etPrice.setText(currentCode)
}
} else {
CenterToasty.error(this,"金额最多设置2位小数!",Toast.LENGTH_LONG).show()
}
} else {
if (currentCode.startsWith("0") && currentCode.length == 1 && it == 0) {
CenterToasty.error(this,"第二位不能输入0!",Toast.LENGTH_LONG).show()
} else {
if (BigDecimal(currentCode + it).compareTo(BigDecimal("99999")) == 1) {
CenterToasty.error(this,"金额不能超过99999!",Toast.LENGTH_LONG).show()
} else {
currentCode += it
etPrice.setText(currentCode)
}
}
}
}
}
}
viewModel.payServiceResponseLiveData.observe(this,{ result ->
loading.visibility = View.GONE
result.getOrElse {
it.message?.let { it1 -> CenterToasty.error(this, it1,Toast.LENGTH_LONG).show() }
return@observe
}
result.getOrNull().also {
it?.let { it1 ->
val intent = Intent()
intent.setClass(this@PriceInputActivity, PayCodeActivity::class.java)
intent.putExtra("payServiceResponse",it1)
startActivity(intent)
}
}
})
}
}
\ No newline at end of file
package com.miya.fastcashier.ui.login
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.alibaba.fastjson.JSON
import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.viewmodel.LoginViewModel
class LoginActivity : AppCompatActivity() {
private lateinit var loginViewModel: LoginViewModel
private lateinit var binding: ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
val username = binding.username
val password = binding.password
loginViewModel = ViewModelProvider(this)
.get(LoginViewModel::class.java)
loginViewModel.loginLiveData.observe(this) { result ->
result.getOrElse {
Toast.makeText(this,it.message, Toast.LENGTH_SHORT).show()
return@observe
}
result.getOrNull().also {
Toast.makeText(this,JSON.toJSONString(it), Toast.LENGTH_SHORT).show()
}
}
binding.login.setOnClickListener{
loginViewModel.login("miyago","123456")
}
}
}
package com.miya.fastcashier.ui.main
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.R
import com.miya.fastcashier.viewmodel.MainViewModel
class MainActivity : AppCompatActivity() {
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
}
}
\ No newline at end of file
package com.miya.fastcashier.ui.splash
import android.os.Bundle
import android.os.PersistableBundle
import androidx.appcompat.app.AppCompatActivity
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
\ No newline at end of file
package com.miya.fastcashier.utils;
import android.content.Context;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;
import es.dmoral.toasty.Toasty;
/**
* 居中的Toasty弹窗 将图片和文字的左右排布,改为了 上下排布
* Created by fengyu on 2018/10/8.
*/
public class CenterToasty {
@CheckResult
public static Toast info(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
Toast toast = Toasty.info(context, message, duration, withIcon);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast info(@NonNull Context context, @NonNull CharSequence message, int duration) {
Toast toast = Toasty.info(context, message, duration);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast info(@NonNull Context context, @NonNull CharSequence message) {
Toast toast = Toasty.info(context, message);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast infox(@NonNull Context context, @NonNull CharSequence message, @NonNull int xOffset) {
Toast toast = Toasty.info(context, message);
transformToast(toast, xOffset, 0);
return toast;
}
@CheckResult
public static Toast normal(@NonNull Context context, @NonNull CharSequence message, int duration) {
Toast toast = Toasty.normal(context, message, duration);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast warning(@NonNull Context context, @NonNull CharSequence message, int duration) {
Toast toast = Toasty.warning(context, message, duration);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast warning(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
Toast toast = Toasty.warning(context, message, duration, withIcon);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast success(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
Toast toast = Toasty.success(context, message, duration, withIcon);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast success(@NonNull Context context, @NonNull CharSequence message, int duration) {
Toast toast = Toasty.success(context, message, duration);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast error(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
Toast toast = Toasty.error(context, message, duration, withIcon);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast error(@NonNull Context context, @NonNull CharSequence message) {
Toast toast = Toasty.error(context, message);
transformToast(toast);
return toast;
}
@CheckResult
public static Toast error(@NonNull Context context, @NonNull CharSequence message, int duration) {
Toast toast = Toasty.error(context, message, duration);
transformToast(toast);
return toast;
}
private static void transformToast(Toast toast) {
LinearLayout linearLayout = (LinearLayout) toast.getView();
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setPadding(20, 20, 20, 20);
ImageView icon = (ImageView) linearLayout.getChildAt(0);
icon.setLayoutParams(new LinearLayout.LayoutParams(50, 50));
TextView messageTextView = (TextView) linearLayout.getChildAt(1);
messageTextView.setTextSize(28);
messageTextView.setPadding(0, 30, 0, 30);
messageTextView.setGravity(Gravity.CENTER);
toast.setGravity(Gravity.CENTER, 0, 0);
}
private static void transformToast(Toast toast, int xOffset, int yOffset) {
LinearLayout linearLayout = (LinearLayout) toast.getView();
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setPadding(20, 20, 20, 20);
ImageView icon = (ImageView) linearLayout.getChildAt(0);
icon.setLayoutParams(new LinearLayout.LayoutParams(50, 50));
TextView messageTextView = (TextView) linearLayout.getChildAt(1);
messageTextView.setTextSize(28);
messageTextView.setPadding(0, 30, 0, 30);
messageTextView.setGravity(Gravity.CENTER);
toast.setGravity(Gravity.CENTER, xOffset, yOffset);
}
}
package com.miya.fastcashier.utils;
import com.blankj.utilcode.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 日期相关工具类
*/
public class DateUtils {
public static final String DF_YYYYMMDD = "yyyyMMdd";
public static final String DF_YYMMDD = "yyMMdd";
public static final String DF_YYYY_MM_DD = "yyyy-MM-dd";
public static final String DF_YYYY_MM_DD2 = "yyyy/MM/dd";
public static final String DF_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static final String DF_YYYY_MM_DDHHMMSS = "yyyy-MM-dd HH:mm:ss";
public static final String DF_HHMMSS = "HHmmss";
public static final String DF_HHMMSS2 = "HH:mm:ss";
public static final String DF_CN_YYYY_MM_DD = "yyyy年MM月dd日";
public static final String DF_HHMM = "HH:mm";
/**
* 带ms的时间戳,与poshub对接时添加
*/
public static final String DF_YYYY_MM_DD_HHMMSSSS = "yyyy-MM-dd HH:mm:ss.SSS";
public static final String DF_YYYYMMDDHHMM = "yyyy/MM/dd HH:mm";
private static final String TAG = "DateUtils";
/**
* 将日期转换成yyyy-MM-dd HH:mm:ss.SSS字符串
*
* @return yyyy-MM-dd HH:mm:ss.SSS
*/
public static String format17(Date date) {
return format(date, DF_YYYY_MM_DD_HHMMSSSS);
}
/**
* 将日期转换成字符串
*
* @param date
* @param format
* @return
*/
public static String format(Date date, String format) {
if (date == null) {
throw new IllegalArgumentException("Param date is null!");
}
if (StringUtils.isEmpty(format)) {
throw new IllegalArgumentException("Param format is blank!");
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
/**
* 将日期转换成yyyyMMddHHmmss字符串
*
* @param date
* @return
*/
public static String format14(Date date) {
return format(date, DF_YYYYMMDDHHMMSS);
}
/**
* 将日期转换成yyyy-MM-dd- HH:mm:ss字符串
*
* @param date
* @return
*/
public static String format18(Date date) {
return format(date, DF_YYYY_MM_DDHHMMSS);
}
public static String format8(Date date) {
return format(date, DF_YYYYMMDD);
}
public static String format6(Date date) {
return format(date, DF_YYMMDD);
}
public static String format10(Date date) {
return format(date, DF_YYYY_MM_DD);
}
public static String formatCN(Date date) {
return format(date, DF_CN_YYYY_MM_DD);
}
public static String formatCustom(Date date, String style) {
return format(date, style);
}
public static Date parse8(String dateStr) throws ParseException {
return parse(dateStr, DF_YYYYMMDD);
}
public static Date parse10(String dateStr) throws ParseException {
return parse(dateStr, DF_YYYY_MM_DD);
}
/**
* 返回当前日期 yyyyMMdd格式 字符串
*
* @return
*/
public static String getNow8() {
return format8(new Date());
}
/**
* 返回当前日期 yyyyMMdd格式 字符串
*
* @return
*/
public static String getNow6() {
return format6(new Date());
}
/**
* 返回当前日期 yyyyMMdd格式 字符串
*
* @return
*/
public static String getNow10() {
return format10(new Date());
}
/**
* 获取当天0点 date对象
*
* @return
*/
public static Date getToday() {
Date today = null;
try {
today = parse(getNow8(), DF_YYYYMMDD);
} catch (ParseException e) {
//unreachable
today = new Date();
}
return today;
}
/**
* 根据时间的字符串转成Date对象
* yyyy-MM-dd HH:mm:ss
*
* @return
*/
public static Date getDateByDateString(String dateStr) {
Date today = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat(DF_YYYY_MM_DDHHMMSS);
return sdf.parse(dateStr);
} catch (ParseException e) {
//unreachable
today = new Date();
}
return today;
}
/**
* 将不同格式的 String 转换成 时间戳
*
* @param str
* @param formatStyle
* @return
*/
public static long stringToLong(String str, String formatStyle) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(formatStyle);
return sdf.parse(str).getTime();//毫秒
}
/**
* 根据时间的字符串转成Date对象
* yyyy-MM-dd HH:mm:ss
*
* @return
*/
public static Date getDateByDateString2(String dateStr) {
Date today = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat(DF_YYYYMMDDHHMMSS);
return sdf.parse(dateStr);
} catch (ParseException e) {
//unreachable
today = new Date();
}
return today;
}
public static String getDateStringByTimeStamp(long timestamp) {
Calendar c = Calendar.getInstance();
c.setTimeInMillis(timestamp);
SimpleDateFormat sdf = new SimpleDateFormat(DF_YYYY_MM_DDHHMMSS);
return sdf.format(c.getTime());
}
public static String getDateStringByTimeStamp(long timestamp, String pattern) {
Calendar c = Calendar.getInstance();
c.setTimeInMillis(timestamp);
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(c.getTime());
}
/**
* 获取当年1月1日0点 date对象
*
* @return
*/
public static Date getNowYear() {
Date year = null;
try {
String format = "yyyy";
year = parse(format(new Date(), format), format);
} catch (ParseException e) {
//unreachable
year = new Date();
}
return year;
}
/**
* 获取当月1号0点 date对象
*
* @return
*/
public static Date getNowMonth() {
Date month = null;
try {
String format = "yyyy-MM";
month = parse(format(new Date(), format), format);
} catch (ParseException e) {
//unreachable
month = new Date();
}
return month;
}
public static int getMonthSpace(Date date1, Date date2) {
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(date1);
c2.setTime(date2);
int result = c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR);
return result == 0 ? 1 : Math.abs(result);
}
public static int getYearSpace4Now(String date) throws ParseException {
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
c1.setTime(new Date());
c2.setTime(sdf.parse(date));
int result = c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR);
return result == 0 ? 1 : Math.abs(result);
}
public static Date parse(String dateStr, String format) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.parse(dateStr);
}
/**
* @return 获取当前月第一天:
*/
public static Date getFirstDateOfCurrentMonth() {
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
try {
return parse(format8(c.getTime()), DF_YYYYMMDD);
} catch (ParseException e) {
return null;
}
}
/**
* @return 获取下月第一天:
*/
public static Date getFirstDateOfNextMonth() {
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 1);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
try {
return parse(format8(c.getTime()), DF_YYYYMMDD);
} catch (ParseException e) {
return null;
}
}
/**
* @return 获取当前月最后一天
*/
public static Date getListDateOfCurrentMonth() {
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
try {
return parse(format8(c.getTime()), DF_YYYYMMDD);
} catch (ParseException e) {
return null;
}
}
/**
* @return 当月的总天数
*/
public static int getCurrentMonthDay() {
Calendar a = Calendar.getInstance();
a.set(Calendar.DATE, 1);
a.roll(Calendar.DATE, -1);
int maxDate = a.get(Calendar.DATE);
return maxDate;
}
/**
* 计算时间间隔
*
* @param fDate 上次时间
* @param oDate 本次时间
* @return 精确到天
*/
public static int getIntervalDays(Date fDate, Date oDate) {
if (fDate == null || oDate == null) {
return -1;
}
try {
fDate = parse(format8(fDate), DF_YYYYMMDD);
oDate = parse(format8(oDate), DF_YYYYMMDD);
} catch (ParseException e) {
}
long nd = 1000 * 24 * 60 * 60;//一天的毫秒数
//获得两个时间的毫秒时间差异
long diff = oDate.getTime() - fDate.getTime();
Long day = diff / nd;//计算差多少天
return day.intValue();
}
/**
* @param date
* @return
* @throws ParseException
*/
public static Date getDate8(Date date) {
try {
return parse8(format8(date));
} catch (ParseException e) {
//unreachable
}
return null;
}
/**
* 时间加days天
*
* @param date
* @param days
* @return
*/
public static Date addDate(Date date, int days) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, days);
return calendar.getTime();
}
/**
* 日期加法运算
*
* @param sourceDate
* @param months 增加的月数,可为负数
* @return
*/
public static Date addMonths(Date sourceDate, int months) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(sourceDate);
calendar.add(Calendar.MONTH, months);
return calendar.getTime();
}
/**
* 时间戳转换成日期格式字符串
*
* @param mseconds 精确到毫秒的字符串
* @param format
* @return
*/
public static String timeStamp2Date(String mseconds, String format) {
if (mseconds == null || mseconds.isEmpty() || mseconds.equals("null")) {
return "";
}
if (format == null || format.isEmpty()) {
format = "yyyy-MM-dd HH:mm:ss";
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new Date(Long.valueOf(mseconds)));
}
/**
* @param startDate 开始时间
* @param endDate 结束时间
* @return true在时间段内,false不在时间段内
*/
public static boolean hourMinuteBetween(String startDate, String endDate) {
try {
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
Date now = format.parse(format(new Date(),DF_HHMM));
Date start = format.parse(startDate);
Date end = format.parse(endDate);
long nowTime = now.getTime();
long startTime = start.getTime();
long endTime = end.getTime();
return nowTime >= startTime && nowTime <= endTime;
} catch (Exception e) {
return false;
}
}
}
package com.miya.fastcashier.utils;
public class MiYaPayPlantformPayWayEnum {
public enum MiyaPayType {
WEIXIN("1", "微信"),
MIAOJIE("2", "喵街"),
ALIPAY("3", "支付宝"),
BAIDU("4", "百度"),
YIZHIFU("5", "翼支付"),
QQ("6", "QQ钱包"),
YINSHANG("7", "银商资讯"),
SUNING("8", "苏宁易付宝"),
WENZHONG("9", "微众有折"),
DAZHONGDIANPING("A", "大众点评"),
YINSHANGPRE("B", "银商预付卡"),
JINGDONG("C", "京东"),
ALIPAY_L2("D", "支付宝"),
ZHAOSHANGYINHANG("E", "招行"),
ALIPAYINTERNATION("F", "支付宝国际"),
WEIXININTERNATION("H", "微信国际"),
BAINUO("I", "百糯"),
GONGHANG("K", "工行"),
FEIFAN("L", "飞凡"),
HUARUIYINHANG("M", "华润银行"),
YINLIANQIANBAO("N", "银联钱包"),
JINGDONG2("P", "京东钱包2.0"),
RUNQIANBAO("T", "润钱包"),
YIDONG("U", "移动钱包"),
MINSHENG("S", "民生银行"),
YINLIANSHANGWU("Q", "银联商务");
/**
* 资源id
*/
int resId;
/**
* code
*/
String code;
/**
* 支付类型名称
*/
String desc;
MiyaPayType(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static MiyaPayType find(String code) {
for (MiyaPayType ec : MiyaPayType.values()) {
if (ec.code.equals(code)) {
return ec;
}
}
return null;
}
}
}
package com.miya.fastcashier.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
/**
* Created by fengyu on 2018/4/17.
*/
public class StringPriceFormat {
/**
* 分转元
*
* @param p
* @return
*/
public static String transStringPriceToDecimalString(String p) {
DecimalFormat numberFormat = new DecimalFormat("0.00");
//防止参数不合法异常崩溃
try {
BigDecimal price = new BigDecimal(p);
BigDecimal x = new BigDecimal("100");
return price.divide(x, 2, RoundingMode.HALF_UP).toString();
} catch (Exception ex) {
ex.printStackTrace();
//空或转换异常则显示--.--
return "--.--";
}
}
public static String transDoubleStringPriceToDecimalString(String p) {
DecimalFormat numberFormat = new DecimalFormat("0.00");
//防止参数不合法异常崩溃
try {
Double price = Double.parseDouble(p);
return numberFormat.format(price / 100.00);
} catch (Exception ex) {
ex.printStackTrace();
//空或转换异常则显示--.--
return "--.--";
}
}
public static String transStringPriceToDecimalString(double p) {
DecimalFormat numberFormat = new DecimalFormat("0.00");
//防止参数不合法异常崩溃
try {
return numberFormat.format(p / 100.00);
} catch (Exception ex) {
ex.printStackTrace();
//空或转换异常则显示--.--
return "--.--";
}
}
/**
* 字符元转字符分
*
* @param yuan 字符元
* @return 字符分
*/
public static String transStringYuan2Fen(String yuan) {
String result = yuan;
String tmp1 = "", tmp2 = "";
if (yuan.contains(".")) {
int index = yuan.indexOf(".");
tmp1 = yuan.substring(0, index);
tmp2 = yuan.substring(index + 1, yuan.length());
result = yuan.replace(".", "");
if (tmp2.length() <= 0) {
result = result + "00";
} else if (tmp2.length() == 1) {
result = result + "0";
} else if (tmp2.length() > 2) {
//如果小数点后有3位或以上说明服务器出现异常,此时仍然只取前两位
result = result.substring(0, index + 2);
}
} else {
result = result + "00";
}
return result;
}
/**
* 获取实付金额,单位:分
*
* @param totalPrice 总价,单位:元
* @param promPrice 优惠价,单位:元
* @return 实付金额,单位:分
*/
public static String getPayPriceFenStringFromYuan(String totalPrice, String promPrice) {
try {
int totalPriceInt = Integer.parseInt(transStringYuan2Fen(totalPrice));
int promPriceInt = Integer.parseInt(transStringYuan2Fen(promPrice));
int payPriceInt = totalPriceInt - promPriceInt;
//检查数字正确性
if (totalPriceInt < promPriceInt ||
totalPriceInt < 0 ||
promPriceInt < 0 ||
payPriceInt < 0) {
//参数不正确,返回0
return "0";
}
return payPriceInt + "";
} catch (Exception ex) {
ex.printStackTrace();
return "0";
}
}
/**
* 获取实付金额,单位:元
*
* @param totalPrice 总价,单位:元
* @param promPrice 优惠价,单位:元
* @return 实付金额,单位:元
*/
public static String getPayPriceYuanStringFromYuan(String totalPrice, String promPrice) {
try {
int totalPriceInt = Integer.parseInt(transStringYuan2Fen(totalPrice));
int promPriceInt = Integer.parseInt(transStringYuan2Fen(promPrice));
int payPriceInt = totalPriceInt - promPriceInt;
//检查数字正确性
if (totalPriceInt < promPriceInt ||
totalPriceInt < 0 ||
promPriceInt < 0 ||
payPriceInt < 0) {
//参数不正确,返回0
return "0";
}
return transStringPriceToDecimalString(payPriceInt);
} catch (Exception ex) {
ex.printStackTrace();
return "0";
}
}
/**
* 获取实付金额,单位:分
*
* @param totalPrice 总价,单位:分
* @param promPrice 优惠价,单位:分
* @return 实付金额,单位:分
*/
public static String getPayPriceFenStringFromFen(String totalPrice, String promPrice) {
try {
int totalPriceInt = Integer.parseInt(totalPrice);
int promPriceInt = Integer.parseInt(promPrice);
int payPriceInt = totalPriceInt - promPriceInt;
//检查数字正确性
if (totalPriceInt < promPriceInt ||
totalPriceInt < 0 ||
promPriceInt < 0 ||
payPriceInt < 0) {
//参数不正确,返回0
return "0";
}
return payPriceInt + "";
} catch (Exception ex) {
ex.printStackTrace();
return "0";
}
}
}
package com.miya.fastcashier.viewmodel
import android.util.Patterns
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.miya.fastcashier.R
import com.miya.fastcashier.beans.LoginRequest
import com.miya.fastcashier.beans.SelfCashierAccountInfo
import com.miya.fastcashier.net.BaseResult
import com.miya.fastcashier.service.LoginService
import com.miya.fastcashier.beans.LoginFormState
import kotlinx.coroutines.launch
import java.lang.RuntimeException
class LoginViewModel : ViewModel() {
val loginLiveData: MutableLiveData<Result<SelfCashierAccountInfo>> = MutableLiveData()
val _loginForm = MutableLiveData<LoginFormState>()
val loginFormState: LiveData<LoginFormState> = _loginForm
fun login(userName:String,passWord:String) {
viewModelScope.launch {
......@@ -26,6 +33,7 @@ class LoginViewModel : ViewModel() {
}
}
//TODO 待优化
private fun <T> errorHandle(result: BaseResult<T>): T {
if(result.code != "200"){
throw RuntimeException(result.msg)
......@@ -33,4 +41,26 @@ class LoginViewModel : ViewModel() {
return result.data;
}
fun loginDataChanged(username: String, password: String) {
if (!isUserNameValid(username)) {
_loginForm.value = LoginFormState(usernameError = R.string.invalid_username)
} else if (!isPasswordValid(password)) {
_loginForm.value = LoginFormState(passwordError = R.string.invalid_password)
} else {
_loginForm.value = LoginFormState(isDataValid = true)
}
}
private fun isUserNameValid(username: String): Boolean {
return if (username.contains('@')) {
Patterns.EMAIL_ADDRESS.matcher(username).matches()
} else {
username.isNotBlank()
}
}
private fun isPasswordValid(password: String): Boolean {
return password.length > 5
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ class MainViewModel : ViewModel() {
printResult.await()
refundLiveData.value = Result.success()
// refundLiveData.value = Result.success()
}
......
package com.miya.fastcashier.viewmodel
import android.text.TextUtils
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.NumberUtils
import com.miya.fastcashier.beans.LoginRequest
import com.miya.fastcashier.beans.SelfCashierAccountInfo
import com.miya.fastcashier.repository.PayRepository
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.LoginService
import com.miya.fastcashier.service.PrintService
import com.sdy.miya.moblie.component.pay.core.error.ParamInvalidException
import com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import kotlinx.coroutines.*
import java.util.*
import kotlin.collections.HashMap
class PayViewModel : ViewModel() {
lateinit var payResultJob: Job
val refundLiveData: MutableLiveData<Result<PayRepository>> = MutableLiveData()
val payServiceResponseLiveData: MutableLiveData<Result<PayServiceResponse>> = MutableLiveData()
val payResultLiveData: MutableLiveData<Result<PayServiceResponse>> = MutableLiveData()
/**
* oriOrderNo 原订单号
* refundOrderNo 退款订单号
* refundPrice 退款金额
*/
fun refund(oriOrderNo: String, refundOrderNo: String, refundPrice: String) = runBlocking {
val refundParams = HashMap<String, String>()
refundParams["oriOrderNo"] = oriOrderNo;
refundParams["refundOrderNo"] = refundOrderNo;
refundParams["refundPrice"] = refundPrice;
val refundResult = async(Dispatchers.IO) {
PayRepository.refundByOrderNo(refundParams)
}
refundResult.await()
val printResult = async(Dispatchers.IO) {
AccountService.getAccountInfo()
?.let { PrintService.refundPrint(it, refundResult.await()) }
}
printResult.await()
// refundLiveData.value = Result.success()
}
/**
* payType 只支持微信或者支付宝
* 2是微信 1是支付宝
*
* price 目前是元 转成分
*/
fun generatePayCode(price: String,payType: String){
if(TextUtils.isEmpty(price)){
payServiceResponseLiveData.value = Result.failure(ParamInvalidException("请输入金额!"))
return
}
//todo 检查小数字是否合法
val orderNo = System.currentTimeMillis()
viewModelScope.launch(Dispatchers.IO){
try {
val payServiceResponse = PayRepository.generatePayCode(orderNo.toString(),"1","1")
payServiceResponseLiveData.postValue(Result.success(payServiceResponse))
}catch (e:Exception){
payServiceResponseLiveData.postValue(Result.failure(e))
}
}
}
/**
* 订单查询
*/
fun payResultQuery(payServiceResponse: PayServiceResponse){
payResultJob = viewModelScope.launch(Dispatchers.IO){
while (isActive){
try {
LogUtils.e("订单查询!!")
val payServiceResponseResult = PayRepository.payResultQuery(payServiceResponse.shopTradeNo)
payResultLiveData.postValue(Result.success(payServiceResponseResult))
break
}catch (e:Exception){
payResultLiveData.postValue(Result.failure(e))
Thread.sleep(3000)
}
}
}
}
}
\ No newline at end of file
package com.miya.fastcashier.viewmodel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.PrintService
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import kotlinx.coroutines.*
class PrintViewModel : ViewModel() {
val printResultLiveData: MutableLiveData<Result<Any>> = MutableLiveData()
fun printOrder(payServiceResponse: PayServiceResponse){
//todo 检查参数
viewModelScope.launch(Dispatchers.IO){
try {
AccountService.getAccountInfo()?.let {
PrintService.payInfoPrint(payServiceResponse, it)
}
printResultLiveData.postValue(Result.success(Any()))
}catch (e:Exception){
printResultLiveData.postValue(Result.failure(e))
}
}
}
}
\ No newline at end of file
package com.miya.fastcashier.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import com.miya.fastcashier.R;
import java.util.ArrayList;
import java.util.List;
public class NumKeyboard extends LinearLayout {
public static final int DELETE = -2;
public static final int DOT = -3;
private View btn_7, btn_8, btn_9, btn_6, btn_5, btn_4, btn_3, btn_2, btn_1, btn_0;
private View delete;
private Button btn_dot;
private List<View> buttons;
private KeyboardClickListener keyboardClickListener;
public NumKeyboard(Context context) {
this(context, null);
}
public NumKeyboard(Context context, AttributeSet attrs) {
super(context, attrs);
View view = LayoutInflater.from(context).inflate(R.layout.keyboard_number, this, true);
buttons = new ArrayList<>(12);
ClickListener clickListener = new ClickListener();
btn_7 = view.findViewById(R.id.btn_7);
btn_8 = view.findViewById(R.id.btn_8);
btn_9 = view.findViewById(R.id.btn_9);
btn_6 = view.findViewById(R.id.btn_6);
btn_5 = view.findViewById(R.id.btn_5);
btn_4 = view.findViewById(R.id.btn_4);
btn_3 = view.findViewById(R.id.btn_3);
btn_2 = view.findViewById(R.id.btn_2);
btn_1 = view.findViewById(R.id.btn_1);
btn_0 = view.findViewById(R.id.btn_0);
delete = view.findViewById(R.id.btn_delete);
btn_dot = view.findViewById(R.id.btn_dot);
buttons.add(btn_7);
buttons.add(btn_8);
buttons.add(btn_9);
buttons.add(btn_6);
buttons.add(btn_5);
buttons.add(btn_4);
buttons.add(btn_3);
buttons.add(btn_2);
buttons.add(btn_1);
buttons.add(btn_0);
buttons.add(delete);
buttons.add(btn_dot);
for (View btn : buttons) {
btn.setOnClickListener(clickListener);
}
}
class ClickListener implements OnClickListener {
@Override
public void onClick(View v) {
if (keyboardClickListener == null) {
return;
}
int i = v.getId();
if (i == R.id.btn_7) {
keyboardClickListener.onNumClick(7);
}
if (i == R.id.btn_8) {
keyboardClickListener.onNumClick(8);
}
if (i == R.id.btn_9) {
keyboardClickListener.onNumClick(9);
}
if (i == R.id.btn_6) {
keyboardClickListener.onNumClick(6);
}
if (i == R.id.btn_5) {
keyboardClickListener.onNumClick(5);
}
if (i == R.id.btn_4) {
keyboardClickListener.onNumClick(4);
}
if (i == R.id.btn_3) {
keyboardClickListener.onNumClick(3);
}
if (i == R.id.btn_2) {
keyboardClickListener.onNumClick(2);
}
if (i == R.id.btn_1) {
keyboardClickListener.onNumClick(1);
}
if (i == R.id.btn_0) {
keyboardClickListener.onNumClick(0);
}
if (i == R.id.btn_delete) {
keyboardClickListener.onNumClick(DELETE);
}
if (i == R.id.btn_dot) {
keyboardClickListener.onNumClick(DOT);
}
}
}
public KeyboardClickListener getKeyboardClickListener() {
return keyboardClickListener;
}
public void setKeyboardClickListener(KeyboardClickListener keyboardClickListener) {
this.keyboardClickListener = keyboardClickListener;
}
public interface KeyboardClickListener {
void onNumClick(int num);
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:endColor="@color/white"
android:startColor="@color/white" />
<corners android:radius="16dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="@color/white"
android:width="2dp"/>
<corners android:radius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:drawable="@drawable/app_keybord_btn_normal"/>
<item android:state_pressed="true" android:drawable="@drawable/app_keybord_btn_pressed"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:endColor="@color/white"
android:startColor="@color/white" />
<corners android:radius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:endColor="#E7E7EB"
android:startColor="#E7E7EB" />
<corners android:radius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@color/colorPrimary_50"/>
<item android:state_enabled="true" android:drawable="@color/colorPrimary"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#D73672"
android:endColor="#FF4B8A"
android:angle="90" />
<corners android:radius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#111235"
android:endColor="#262855"
android:angle="90" />
<corners android:radius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2px" android:color="#111235" />
<corners android:radius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2px" android:color="#111235" />
<corners android:radius="16dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
......@@ -5,37 +5,35 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".ui.login.LoginActivity">
tools:context=".ui.LoginActivity">
<EditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="96dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_email"
android:layout_marginStart="46dp"
android:layout_marginTop="475dp"
android:layout_marginEnd="46dp"
android:hint="请输入用户名"
android:text="miyago"
android:textSize="32sp"
android:inputType="textEmailAddress"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_password"
android:layout_marginStart="46dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="46dp"
android:hint="请输入密码"
android:imeActionLabel="@string/action_sign_in_short"
android:text="123456"
android:textSize="32sp"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:selectAllOnFocus="true"
......@@ -45,21 +43,69 @@
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="656dp"
android:layout_height="100dp"
android:layout_gravity="start"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="48dp"
android:layout_marginBottom="64dp"
android:enabled="true"
android:text="@string/action_sign_in"
android:layout_marginTop="142dp"
android:enabled="false"
android:text="登录"
android:background="@drawable/app_login_btn"
android:textSize="32sp"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password"
app:layout_constraintVertical_bias="0.2" />
<ImageView
android:id="@+id/ivLogo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="259dp"
android:layout_marginLeft="39dp"
android:layout_marginStart="39dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@mipmap/app_store_round_logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="您好,欢迎登录!"
android:textSize="48sp"
android:textColor="@color/black"
android:layout_marginStart="23dp"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintTop_toTopOf="@+id/ivLogo"
android:layout_marginLeft="26dp" />
<TextView
android:id="@+id/tvSlog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="欢迎使用匡威商米收银"
android:textSize="28sp"
android:textColor="#666666"
android:layout_marginStart="23dp"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintBottom_toBottomOf="@+id/ivLogo"
android:layout_marginLeft="26dp" />
<TextView
android:id="@+id/tvErrInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="账号或密码输入错误,请重新输入"
android:textSize="24sp"
android:textColor="#FF5A59"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@+id/username"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintTop_toBottomOf="@+id/password"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
......@@ -75,4 +121,5 @@
app:layout_constraintStart_toStartOf="@+id/password"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -2,42 +2,154 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/colorPrimary"
tools:context=".ui.LoginActivity">
<ImageView
android:layout_width="661dp"
android:layout_height="214dp"
android:layout_marginTop="208dp"
android:layout_marginEnd="335dp"
android:layout_marginRight="335dp"
android:background="@mipmap/app_home_bg_stripe"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="72dp"
android:layout_height="85dp"
android:layout_marginTop="173dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:background="@mipmap/app_home_bg_right_arrow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_marginTop="192dp"
android:layout_marginEnd="78dp"
android:layout_marginRight="78dp"
android:background="@mipmap/app_home_bg_star"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivLogo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginStart="39dp"
android:layout_marginLeft="39dp"
android:layout_marginTop="259dp"
android:background="@mipmap/app_store_round_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvPay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="定额收款"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
android:layout_marginStart="23dp"
android:layout_marginLeft="26dp"
android:text="匡威-杭州滨江店!"
android:textColor="@color/white"
android:textSize="48sp"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintTop_toTopOf="@+id/ivLogo" />
<TextView
android:id="@+id/tvSlog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:layout_marginLeft="26dp"
android:text="ID1274911047"
android:textColor="@color/white"
android:textSize="28sp"
app:layout_constraintBottom_toBottomOf="@+id/ivLogo"
app:layout_constraintStart_toEndOf="@+id/ivLogo" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/llPay"
android:layout_width="292dp"
android:layout_height="292dp"
android:layout_marginTop="471dp"
android:background="@drawable/app_home_function_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layout_constraintEnd_toStartOf="@+id/llRefund"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.258" />
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_marginTop="48dp"
android:background="@mipmap/app_home_icon_pay" />
<TextView
android:id="@+id/tvRefund"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="退款"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="32dp"
android:text="去收款"
android:textColor="@color/black"
android:textSize="32sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/llRefund"
android:layout_width="292dp"
android:layout_height="292dp"
android:layout_marginTop="471dp"
android:background="@drawable/app_home_function_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toEndOf="@+id/llPay"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_marginTop="48dp"
android:background="@mipmap/app_home_icon_refund" />
<TextView
android:id="@+id/tvPrint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="去退款"
android:textColor="@color/black"
android:textSize="32sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
<TextView
android:id="@+id/tvPrintLast"
android:layout_width="624dp"
android:layout_height="100dp"
android:gravity="center"
android:text="打印上一单"
app:layout_constraintBottom_toBottomOf="parent"
android:textSize="32sp"
android:layout_marginTop="80dp"
android:textColor="@color/white"
android:background="@drawable/app_home_print_last_bg"
app:layout_constraintTop_toBottomOf="@+id/llPay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.723" />
app:layout_constraintVertical_bias="0.2" />
<ImageView
android:layout_width="220dp"
android:layout_height="40dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="24dp"
android:background="@mipmap/app_home_bottom_store_logo" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".ui.PriceInputActivity">
<TextView
android:id="@+id/tvBack"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginLeft="60dp"
android:layout_marginTop="32dp"
android:textColor="@color/white"
android:text="@string/back"
android:textSize="24sp"/>
<ImageView
android:id="@+id/ivBack"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tvBack"
app:layout_constraintTop_toTopOf="@+id/tvBack"
app:layout_constraintBottom_toBottomOf="@+id/tvBack"
android:layout_width="24dp"
android:layout_height="48dp"
android:padding="6dp"
android:src="@mipmap/ic_left_arrow"
android:contentDescription="@string/back" />
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textColor="@color/white"
android:text="收款码"
android:textSize="36sp"/>
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="600dp"
android:layout_height="869dp"
android:background="@drawable/app_home_function_bg">
<TextView
android:id="@+id/tvPrice"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:textColor="#141C30"
android:textStyle="bold"
android:text="¥319.00"
android:textSize="56sp"/>
<TextView
android:id="@+id/tvPayGuide"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="215dp"
android:textColor="#141C30"
android:text="扫描二维码 向我付款"
android:textSize="32sp"/>
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="44dp"
android:textColor="#878E9D"
android:text="请在1分钟内扫描二维码付款"
android:textSize="24sp"/>
<ImageView
android:id="@+id/ivPayCode"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvPayGuide"
android:layout_width="323dp"
android:layout_height="323dp"
android:layout_marginTop="30dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="32dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="64dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintVertical_bias="0.3" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:keepScreenOn="true">
<View
android:id="@+id/vPayResultIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="50dp"
android:background="@mipmap/ic_success"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvPayResultTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="收款成功"
android:textColor="@color/black"
android:textSize="48sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/vPayResultIcon"
app:layout_constraintLeft_toRightOf="@+id/vPayResultIcon"
app:layout_constraintTop_toTopOf="@+id/vPayResultIcon" />
<TextView
android:id="@+id/tvOrderStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="68dp"
android:text="订单已完成"
android:textColor="@color/black"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vPayResultIcon"/>
<TextView
android:id="@+id/tvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="26dp"
android:text="小票正在打印,请稍等…"
android:textColor="#88000000"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvOrderStatus"/>
<TextView
android:id="@+id/tvRePrint"
android:layout_width="132dp"
android:layout_height="58dp"
android:layout_marginRight="30dp"
android:text="重新打印"
android:visibility="invisible"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:background="@drawable/app_payresult_reprint_bg"
android:textColor="#111235"
android:textSize="24sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvStatus"
app:layout_constraintBottom_toBottomOf="@+id/tvStatus"/>
<View
android:id="@+id/vOrderStatusline"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginLeft="40dp"
android:layout_marginTop="40dp"
android:layout_marginRight="40dp"
android:background="#E6E9EF"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvStatus" />
<TextView
android:id="@+id/tvOrderTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="40dp"
android:text="订单详情"
android:textColor="@color/black"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vOrderStatusline"/>
<TextView
android:id="@+id/tvOrderPriceHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="40dp"
android:text="订单金额"
android:textColor="#141C30"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvOrderTitle" />
<TextView
android:id="@+id/tvPayPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:gravity="right"
android:text="--------"
android:textColor="#878E9D"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="@+id/tvOrderPriceHint"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvOrderPriceHint" />
<TextView
android:id="@+id/tvOrderNoHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="40dp"
android:text="订单号"
android:textColor="#141C30"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvOrderPriceHint" />
<TextView
android:id="@+id/tvOrderNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:gravity="right"
android:text="--------"
android:textColor="#878E9D"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="@+id/tvOrderNoHint"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvOrderNoHint" />
<TextView
android:id="@+id/tvPayWayHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="35dp"
android:text="支付方式"
android:textColor="#141C30"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvOrderNoHint" />
<TextView
android:id="@+id/tvPayWay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:gravity="right"
android:text="--------"
android:textColor="#878E9D"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="@+id/tvPayWayHint"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvPayWayHint" />
<TextView
android:id="@+id/tvTradeNoHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="35dp"
android:text="交易单号"
android:textColor="#141C30"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvPayWayHint" />
<TextView
android:id="@+id/tvTradeNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:gravity="right"
android:text="--------"
android:textColor="#878E9D"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="@+id/tvTradeNoHint"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvTradeNoHint" />
<TextView
android:id="@+id/tvTradeTimeHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="35dp"
android:text="交易时间"
android:textColor="#141C30"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvTradeNoHint" />
<TextView
android:id="@+id/tvTradeTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:gravity="right"
android:text="--------"
android:textColor="#878E9D"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="@+id/tvTradeTimeHint"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvTradeTimeHint" />
<TextView
android:id="@+id/tvGoHome"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginBottom="120dp"
android:layout_marginStart="80dp"
android:layout_marginEnd="80dp"
android:background="@drawable/app_payresult_reprint_bg"
android:enabled="false"
android:gravity="center"
android:text="返回首页"
android:textColor="#111235"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ImageView
android:id="@+id/tvAccountInfo"
android:layout_width="220dp"
android:layout_height="40dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@mipmap/ic_light_logo_converse"
android:layout_marginBottom="24dp"
android:gravity="center"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".ui.PriceInputActivity">
<TextView
android:id="@+id/tvBack"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginLeft="60dp"
android:layout_marginTop="32dp"
android:textColor="@color/white"
android:text="@string/back"
android:textSize="24sp"/>
<ImageView
android:id="@+id/ivBack"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tvBack"
app:layout_constraintTop_toTopOf="@+id/tvBack"
app:layout_constraintBottom_toBottomOf="@+id/tvBack"
android:layout_width="24dp"
android:layout_height="48dp"
android:padding="6dp"
android:src="@mipmap/ic_left_arrow"
android:contentDescription="@string/back" />
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textColor="@color/white"
android:text="收款"
android:textSize="36sp"/>
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="80dp"
android:textColor="@color/white"
android:text="收款金额"
android:textSize="24sp"/>
<ImageView
android:id="@+id/ivRmb"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvBack"
android:layout_width="42dp"
android:layout_height="96dp"
android:layout_marginStart="32dp"
android:layout_marginTop="145dp"
android:src="@mipmap/ic_rmb"
android:layout_marginLeft="32dp" />
<View
android:id="@+id/vBaseLine"
android:layout_width="match_parent"
android:layout_height="2dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvBack"
android:layout_marginTop="263dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:background="#89889A"
android:layout_marginLeft="32dp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/etPrice"
android:layout_width="591dp"
android:layout_height="wrap_content"
android:hint="输入收款金额"
app:met_textColorHint="#89889A"
app:met_textColor="@color/white"
android:textAlignment="textEnd"
android:textSize="47sp"
android:paddingTop="5dp"
android:layout_marginEnd="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/ivRmb"
app:layout_constraintBottom_toBottomOf="@+id/ivRmb"
android:layout_marginRight="32dp"
android:gravity="end" />
<com.miya.fastcashier.widget.NumKeyboard
android:id="@+id/numKeyboard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
app:layout_constraintBottom_toTopOf="@+id/tvScanPayCode"
android:layout_height="637dp"/>
<TextView
android:id="@+id/tvScanPayCode"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="130dp"
android:textColor="@color/white"
android:text="扫码收款"
android:textSize="36sp"
android:gravity="center"
android:background="@drawable/app_paycode_scan"
android:layout_width="0dp"/>
<TextView
android:id="@+id/tvGeneratePayCode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="130dp"
android:textColor="@color/white"
android:textSize="36sp"
android:text="生成收款码"
android:gravity="center"
android:background="@drawable/app_paycode_generate"
android:layout_width="0dp"/>
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="32dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="64dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintVertical_bias="0.3" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7EB"
android:orientation="vertical"
android:padding="12dp"
android:splitMotionEvents="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:splitMotionEvents="false">
<Button
android:id="@+id/btn_1"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/app_keybord_btn"
android:text="1"
android:textColor="#333333"
android:textSize="69sp"/>
<Button
android:id="@+id/btn_2"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:textColor="#333333"
android:background="@drawable/app_keybord_btn"
android:text="2"
android:textSize="69sp" />
<Button
android:id="@+id/btn_3"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:textColor="#333333"
android:layout_weight="1"
android:background="@drawable/app_keybord_btn"
android:text="3"
android:textSize="69sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:splitMotionEvents="false">
<Button
android:id="@+id/btn_4"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:textColor="#333333"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/app_keybord_btn"
android:text="4"
android:textSize="69sp" />
<Button
android:id="@+id/btn_5"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:textColor="#333333"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/app_keybord_btn"
android:text="5"
android:textSize="69sp" />
<Button
android:id="@+id/btn_6"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:textColor="#333333"
android:background="@drawable/app_keybord_btn"
android:text="6"
android:textSize="69sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:splitMotionEvents="false">
<Button
android:id="@+id/btn_7"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:textColor="#333333"
android:layout_weight="1"
android:background="@drawable/app_keybord_btn"
android:text="7"
android:textSize="69sp" />
<Button
android:id="@+id/btn_8"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:textColor="#333333"
android:background="@drawable/app_keybord_btn"
android:text="8"
android:textSize="69sp" />
<Button
android:id="@+id/btn_9"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:textColor="#333333"
android:background="@drawable/app_keybord_btn"
android:text="9"
android:textSize="69sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:splitMotionEvents="false">
<Button
android:id="@+id/btn_0"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:textColor="#333333"
android:layout_weight="1"
android:background="@drawable/app_keybord_btn"
android:text="0"
android:textSize="69sp" />
<Button
android:id="@+id/btn_dot"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_weight="1"
android:textColor="#333333"
android:background="@drawable/app_keybord_btn"
android:text="."
android:paddingBottom="30dp"
android:textSize="69sp" />
<FrameLayout
android:id="@+id/btn_delete"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@drawable/app_keybord_btn"
android:layout_margin="4dp"
android:layout_weight="1">
<ImageView
android:layout_width="54dp"
android:layout_height="54dp"
android:layout_gravity="center"
android:scaleType="fitXY"
android:src="@mipmap/ic_delete" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MiYaFastCashier" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MiYaFastCashier.Light" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@color/transWhite</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="colorPrimary">#111235</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="transWhite">#00FFFFFF</color>
<!--50代表透明度-->
<color name="colorPrimary_50">#80111235</color>
</resources>
\ No newline at end of file
......@@ -9,4 +9,8 @@
<string name="invalid_username">Not a valid username</string>
<string name="invalid_password">Password must be >5 characters</string>
<string name="login_failed">"Login failed"</string>
<string name="back">返回</string>
<string name="printing">小票打印中,请稍等…</string>
<string name="print_sucesss">小票打印成功</string>
<string name="print_fail">小票打印失败,请重试~</string>
</resources>
\ No newline at end of file
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MiYaFastCashier" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<style name="Theme.MiYaFastCashier.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="android:statusBarColor" tools:targetApi="l">@color/colorPrimary</item>
</style>
<style name="Theme.MiYaFastCashier.Light" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor" tools:targetApi="l">@color/transWhite</item>
</style>
</resources>
\ No newline at end of file
......@@ -19,6 +19,7 @@ allprojects {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" }
}
}
......
......@@ -17,3 +17,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.enableJetifier=true
android.jetifier.blacklist=miya-print
android.useDeprecatedNdk=true
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment