Commit 30bb8b6a authored by 赵鹏翔's avatar 赵鹏翔

Merge branch 'dev' into 'develop'

Dev

See merge request !6
parents 0b38225b e425d871
...@@ -97,7 +97,7 @@ class BaseApplication : MultiDexApplication() { ...@@ -97,7 +97,7 @@ class BaseApplication : MultiDexApplication() {
LogFileUtils.writeLog( LogFileUtils.writeLog(
ContextUtils.getContext(), ContextUtils.getContext(),
DateUtils.getDateStringByTimeStamp(System.currentTimeMillis()) DateUtils.getDateStringByTimeStamp(System.currentTimeMillis())
.toString() + " " + message + "\n" .toString() + " $message" + "\n"
) )
} }
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
...@@ -107,6 +107,13 @@ class BaseApplication : MultiDexApplication() { ...@@ -107,6 +107,13 @@ class BaseApplication : MultiDexApplication() {
loggingInterceptor.level = MiyaHttpLoggingInterceptor.Level.BODY loggingInterceptor.level = MiyaHttpLoggingInterceptor.Level.BODY
} catch (ex: Exception) { } catch (ex: Exception) {
ex.printStackTrace() ex.printStackTrace()
if (!LogFileUtils.isProhibitWrite) {
LogFileUtils.writeLog(
ContextUtils.getContext(),
DateUtils.getDateStringByTimeStamp(System.currentTimeMillis())
.toString() + "异常: ${ex.message}" + "\n"
)
}
} }
MiYaPayMobileApiClient.init(true, loggingInterceptor) MiYaPayMobileApiClient.init(true, loggingInterceptor)
} }
......
package com.miya.fastcashier.log;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
public class EmptyRecyclerView extends RecyclerView {
private View mEmptyView;
public EmptyRecyclerView(Context context) {
super(context);
}
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* 根据数据源判断是否显示空白view
*/
private void checkIfEmpty() {
if (mEmptyView != null || getAdapter() != null) {
mEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE);
}
}
public void setmEmptyView(View mEmptyView) {
this.mEmptyView = mEmptyView;
checkIfEmpty();
}
@Override
public void setAdapter(Adapter adapter) {
Adapter adapterOld = getAdapter();
if (adapterOld != null) {
adapterOld.unregisterAdapterDataObserver(observer);
}
super.setAdapter(adapter);
if (adapter != null) {
adapter.registerAdapterDataObserver(observer);
}
}
AdapterDataObserver observer = new AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
checkIfEmpty();
}
};
}
package com.miya.fastcashier.log
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.recyclerview.widget.RecyclerView
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
class EmptyRecyclerView : RecyclerView {
private var mEmptyView: View? = null
constructor(context: Context?) : super(context!!) {}
constructor(context: Context?, attrs: AttributeSet?) : super(
context!!, attrs
) {
}
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(
context!!, attrs, defStyle
) {
}
/**
* 根据数据源判断是否显示空白view
*/
private fun checkIfEmpty() {
if (mEmptyView != null || adapter != null) {
mEmptyView!!.visibility =
if (adapter!!.itemCount > 0) GONE else VISIBLE
}
}
fun setmEmptyView(mEmptyView: View?) {
this.mEmptyView = mEmptyView
checkIfEmpty()
}
override fun setAdapter(adapter: Adapter<*>?) {
val adapterOld = getAdapter()
adapterOld?.unregisterAdapterDataObserver(observer)
super.setAdapter(adapter)
adapter?.registerAdapterDataObserver(observer)
}
var observer: AdapterDataObserver = object : AdapterDataObserver() {
override fun onChanged() {
super.onChanged()
checkIfEmpty()
}
}
}
\ No newline at end of file
...@@ -3,10 +3,7 @@ package com.miya.fastcashier.log ...@@ -3,10 +3,7 @@ package com.miya.fastcashier.log
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import com.miya.fastcashier.service.AccountService.getAccountInfo import com.miya.fastcashier.service.AccountService.getAccountInfo
import com.miya.fastcashier.utils.getVersion
import com.miya.fastcashier.net.ApiConfig.baseUrl import com.miya.fastcashier.net.ApiConfig.baseUrl
import com.miya.fastcashier.utils.getWifyName
import com.miya.fastcashier.utils.getNetIp
import com.miya.fastcashier.R import com.miya.fastcashier.R
import com.miya.fastcashier.beans.SelfCashierAccountInfo import com.miya.fastcashier.beans.SelfCashierAccountInfo
import com.miya.fastcashier.service.AccountService import com.miya.fastcashier.service.AccountService
...@@ -19,6 +16,8 @@ import android.view.Gravity ...@@ -19,6 +16,8 @@ import android.view.Gravity
import android.view.View import android.view.View
import com.miya.fastcashier.BuildConfig import com.miya.fastcashier.BuildConfig
import com.miya.fastcashier.databinding.DialogSystemParameterBinding import com.miya.fastcashier.databinding.DialogSystemParameterBinding
import com.miya.fastcashier.utils.*
import java.util.*
class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDialog) { class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDialog) {
...@@ -46,7 +45,10 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi ...@@ -46,7 +45,10 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi
setInfo(viewBinding.tvEquipment, "sunmi_v2pro") setInfo(viewBinding.tvEquipment, "sunmi_v2pro")
setInfo(viewBinding.tvServerUrl, baseUrl) setInfo(viewBinding.tvServerUrl, baseUrl)
setInfo(viewBinding.tvWifiName, getWifyName(context)) setInfo(viewBinding.tvWifiName, getWifyName(context))
setInfo(viewBinding.tvNetIp, if (getNetIp(context) == null) "未知" else getNetIp(context)) setInfo(
viewBinding.tvLog,
"${getVersionCode(context)}_${DateUtils.format8(Date())}.txt"
)
setInfo( setInfo(
viewBinding.tvPrintType, viewBinding.tvPrintType,
if (PrinterManager.getInstance().printer == null) context.resources.getString(R.string.app_unkown) else PrinterManager.getInstance().printer.printerName if (PrinterManager.getInstance().printer == null) context.resources.getString(R.string.app_unkown) else PrinterManager.getInstance().printer.printerName
......
...@@ -2,20 +2,23 @@ package com.miya.fastcashier.ui ...@@ -2,20 +2,23 @@ package com.miya.fastcashier.ui
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Gravity
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.BaseApplication
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityMainBinding import com.miya.fastcashier.databinding.ActivityMainBinding
import com.miya.fastcashier.service.AccountService import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.PrintService import com.miya.fastcashier.service.PrintService
import com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog import com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog
import com.miya.fastcashier.ui.dialog.CommonDialog
import com.miya.fastcashier.utils.* import com.miya.fastcashier.utils.*
import com.miya.fastcashier.utils.manage.AccountPasswordManageKit import com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.utils.manage.OrderRecordManageKit import com.miya.fastcashier.utils.manage.OrderRecordManageKit
import com.miya.fastcashier.viewmodel.MainViewModel import com.miya.fastcashier.viewmodel.MainViewModel
import com.miya.print.utils.PrintLogger
import java.util.* import java.util.*
class MainActivity : BaseActivity() { class MainActivity : BaseActivity() {
...@@ -24,6 +27,7 @@ class MainActivity : BaseActivity() { ...@@ -24,6 +27,7 @@ class MainActivity : BaseActivity() {
private lateinit var binding: ActivityMainBinding private lateinit var binding: ActivityMainBinding
private lateinit var viewModel: MainViewModel private lateinit var viewModel: MainViewModel
private var dateSelectHelper: DateSelectHelper? = null private var dateSelectHelper: DateSelectHelper? = null
private var confirmDialog: CommonDialog? = null
companion object { companion object {
@JvmStatic @JvmStatic
...@@ -81,27 +85,7 @@ class MainActivity : BaseActivity() { ...@@ -81,27 +85,7 @@ class MainActivity : BaseActivity() {
} }
binding.llBalance.clickWithTrigger { binding.llBalance.clickWithTrigger {
//上次记录的时间,或者当天0点 showConfirmBalanceDialog()
var timeMillis = LocalKeyDataMKManageKit.getBalanceDate()
if (timeMillis > 0L && timeMillis <= System.currentTimeMillis()) {
val currentDate = Date()
var daysAgoCurrent: Long = DateUtils.getDaysAgo(currentDate, 1)
if (timeMillis <= daysAgoCurrent) {
timeMillis = daysAgoCurrent
}
viewModel.orderStatistics(Date(timeMillis), currentDate, true)
} else {
val startDate = Calendar.getInstance()
startDate.set(
startDate.get(Calendar.YEAR),
startDate.get(Calendar.MONTH),
startDate.get(Calendar.DAY_OF_MONTH),
0,
0,
0
)
viewModel.orderStatistics(startDate.time, Date(), true)
}
} }
initData() initData()
...@@ -144,6 +128,53 @@ class MainActivity : BaseActivity() { ...@@ -144,6 +128,53 @@ class MainActivity : BaseActivity() {
}) })
} }
private fun showConfirmBalanceDialog(){
if (confirmDialog == null || !confirmDialog!!.isShowing) {
confirmDialog = CommonDialog(this)
confirmDialog!!.setCustomMessage(getString(R.string.app_text_confirm_balance))
.setNegativeStr(getString(R.string.cancel))
.setPositiveStr(getString(R.string.sure))
.setMessageGravity(Gravity.CENTER_HORIZONTAL)
.setOnClickListener(object : CommonDialog.OnDialogClickListener {
override fun onNegativeClick() {
confirmDialog!!.dismiss()
confirmDialog = null
}
override fun onPositiveClick() {
toBalance()
confirmDialog!!.dismiss()
confirmDialog = null
}
})
.show()
}
}
private fun toBalance(){
//上次记录的时间,或者当天0点
var timeMillis = LocalKeyDataMKManageKit.getBalanceDate()
if (timeMillis > 0L && timeMillis <= System.currentTimeMillis()) {
val currentDate = Date()
var daysAgoCurrent: Long = DateUtils.getDaysAgo(currentDate, 1)
if (timeMillis <= daysAgoCurrent) {
timeMillis = daysAgoCurrent
}
viewModel.orderStatistics(Date(timeMillis), currentDate, true)
} else {
val startDate = Calendar.getInstance()
startDate.set(
startDate.get(Calendar.YEAR),
startDate.get(Calendar.MONTH),
startDate.get(Calendar.DAY_OF_MONTH),
0,
0,
0
)
viewModel.orderStatistics(startDate.time, Date(), true)
}
}
override fun onDestroy() { override fun onDestroy() {
dateSelectHelper?.dismiss() dateSelectHelper?.dismiss()
super.onDestroy() super.onDestroy()
......
...@@ -69,12 +69,6 @@ class SettingActivity : BaseActivity() { ...@@ -69,12 +69,6 @@ class SettingActivity : BaseActivity() {
// } // }
// } // }
if (countClick < 5) { if (countClick < 5) {
if (countClick >= 2 && countClick < 5) {
Toasty.info(
applicationContext,
getString(R.string.toast_click_again, 5 - countClick)
).show()
}
return return
} }
......
...@@ -103,6 +103,18 @@ fun getVersion(context: Context): String? { ...@@ -103,6 +103,18 @@ fun getVersion(context: Context): String? {
return version return version
} }
fun getVersionCode(context: Context): String? {
val packageManager = context.packageManager
val packageInfo: PackageInfo
var version = ""
try {
packageInfo = packageManager.getPackageInfo(context.packageName, 0)
version = "${packageInfo.versionCode}"
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
return version
}
/** /**
* 判断是否有网络连接 * 判断是否有网络连接
......
...@@ -18,7 +18,7 @@ class PrintViewModel : ViewModel() { ...@@ -18,7 +18,7 @@ class PrintViewModel : ViewModel() {
viewModelScope.launch(Dispatchers.IO){ viewModelScope.launch(Dispatchers.IO){
try { try {
AccountService.getAccountInfo()?.let { AccountService.getAccountInfo()?.let {
PrintService.payInfoPrint(payServiceResponse, it) PrintService.payPrint(payServiceResponse, it)
} }
printResultLiveData.postValue(Result.success(Any())) printResultLiveData.postValue(Result.success(Any()))
}catch (e:Exception){ }catch (e:Exception){
......
...@@ -277,18 +277,18 @@ ...@@ -277,18 +277,18 @@
app:layout_constraintTop_toTopOf="@id/tv_wifi_name_text" /> app:layout_constraintTop_toTopOf="@id/tv_wifi_name_text" />
<TextView <TextView
android:id="@+id/tv_net_ip_text" android:id="@+id/tv_log_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:text="网络IP" android:text="日志名称"
android:textColor="@color/color_333333" android:textColor="@color/color_333333"
android:textSize="30sp" android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_wifi_name_text" /> app:layout_constraintTop_toBottomOf="@id/tv_wifi_name_text" />
<TextView <TextView
android:id="@+id/tv_net_ip" android:id="@+id/tv_log"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="right"
...@@ -296,7 +296,7 @@ ...@@ -296,7 +296,7 @@
android:textColor="@color/color_333333" android:textColor="@color/color_333333"
android:textSize="30sp" android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_net_ip_text" /> app:layout_constraintTop_toTopOf="@id/tv_log_text" />
<TextView <TextView
android:id="@+id/tv_print_type_text" android:id="@+id/tv_print_type_text"
...@@ -307,7 +307,7 @@ ...@@ -307,7 +307,7 @@
android:textColor="@color/color_333333" android:textColor="@color/color_333333"
android:textSize="30sp" android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_net_ip_text" /> app:layout_constraintTop_toBottomOf="@id/tv_log_text" />
<TextView <TextView
android:id="@+id/tv_print_type" android:id="@+id/tv_print_type"
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<string name="sure">确定</string> <string name="sure">确定</string>
<string name="search_order_prompt_text">还没有明细哦~</string> <string name="search_order_prompt_text">还没有明细哦~</string>
<string name="app_text_login_out">是否确认退出账号</string> <string name="app_text_login_out">是否确认退出账号</string>
<string name="app_text_confirm_balance">是否确认结算打印</string>
<string name="text_login_out_sure">确认退出</string> <string name="text_login_out_sure">确认退出</string>
<string name="app_login_out">退出登录</string> <string name="app_login_out">退出登录</string>
<string name="text_refund_amount">退款金额¥%s,是否确认退款</string> <string name="text_refund_amount">退款金额¥%s,是否确认退款</string>
......
# 版本历史 # 版本历史
## tag
####v2.1.5 :
-打印第二联做延时处理、结算打印添加二次确认
## tag ## tag
#### 优化版本: #### 优化版本:
-添加日志上传功能 -添加日志上传功能
......
ext { ext {
VERSION_CODE = 25 VERSION_CODE = 26
VERSION_NAME = '2.1.4' VERSION_NAME = '2.1.5'
} }
\ 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