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

修改主界面版本处理

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