Commit 7b072ec1 authored by 赵鹏翔's avatar 赵鹏翔

修改主界面版本处理

parent 310b9de6
......@@ -15,6 +15,9 @@ import com.fastcashier.lib_common.function.print.PrintService
import com.fastcashier.lib_common.ui.dialog.CommonDialog
import com.fastcashier.lib_common.util.DateUtils
import com.fastcashier.lib_common.util.clickWithTrigger
import com.fastcashier.lib_common.util.getVersion
import com.fastcashier.lib_common.util.getVersionName
import com.miya.fastcashier.BuildConfig
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityMainBinding
import com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog
......@@ -48,23 +51,17 @@ class MainActivity : BaseActivity() {
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
val llPay = binding.llPay
val llRefund = binding.llRefund
val tvPrintLast = binding.tvPrintLast
val ivSetting = binding.ivSetting
val tvStoreName = binding.tvStoreName
val tvSlog = binding.tvSlog
binding.tvStoreName.text = AccountService.getAccountInfo()?.shopInfo?.storeName
binding.tvSlog.text = AccountService.getUserName()
binding.tvVersion.text = getVersionName(this)
tvStoreName.text = AccountService.getAccountInfo()?.shopInfo?.storeName
tvSlog.text = AccountService.getUserName()
llPay.clickWithTrigger {
binding.llPay.clickWithTrigger {
PriceInputActivity.start(this@MainActivity)
}
llRefund.clickWithTrigger {
binding.llRefund.clickWithTrigger {
toRefund()
}
tvPrintLast.clickWithTrigger {
binding.tvPrintLast.clickWithTrigger {
try {
PrintService.printLastOrderInfo()
} catch (e: Exception) {
......@@ -75,7 +72,7 @@ class MainActivity : BaseActivity() {
SearchOrderActivity.start(this@MainActivity)
}
ivSetting.clickWithTrigger {
binding.ivSetting.clickWithTrigger {
SettingActivity.start(this@MainActivity)
}
......
......@@ -57,7 +57,7 @@
android:layout_marginTop="23dp"
android:ellipsize="end"
android:maxLines="1"
android:text="匡威-杭州滨江店"
android:text="匡威-杭州滨江店"
android:textColor="@color/white"
android:textSize="36sp"
app:layout_constraintEnd_toStartOf="@+id/ivSetting"
......@@ -244,8 +244,18 @@
<ImageView
android:layout_width="220dp"
android:layout_height="40dp"
android:layout_marginBottom="24dp"
android:layout_marginBottom="10dp"
android:background="@mipmap/app_home_bottom_store_logo"
app:layout_constraintBottom_toTopOf="@id/tv_version"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="26sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
......
......@@ -2,4 +2,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fastcashier.lib_common">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
\ No newline at end of file
......@@ -96,7 +96,7 @@ fun getVersion(context: Context): String? {
var version = ""
try {
packageInfo = packageManager.getPackageInfo(context.packageName, 0)
version = "${packageInfo.versionCode}_v${packageInfo.versionName}"
version = "${packageInfo.versionCode}_V${packageInfo.versionName}"
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
......@@ -116,6 +116,19 @@ fun getVersionCode(context: Context): String? {
return version
}
fun getVersionName(context: Context): String? {
val packageManager = context.packageManager
val packageInfo: PackageInfo
var versionName = ""
try {
packageInfo = packageManager.getPackageInfo(context.packageName, 0)
versionName = "V${packageInfo.versionName}"
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
return versionName
}
/**
* 判断是否有网络连接
* @param context
......
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