Commit d224c083 authored by 赵鹏翔's avatar 赵鹏翔

Merge branch 'dev_common' into 'develop'

dev_common 2  develop,合并渠道配置、部分优化

See merge request !8
parents 02a1d96a 6cc0d15a
......@@ -55,7 +55,7 @@ android {
variant.outputs.all { output ->
outputFileName = new File(output.outputFile.parent,
"${getAppChannel()}" + "_v" +
"Miya_FastCashier_v" +
variant.versionName + "_" +
variant.versionCode + "_" +
variant.buildType.name + "_" +
......@@ -89,8 +89,4 @@ static String buildTime() {
Date date = new Date()
String dates = date.format("yyyyMMddHHmm", TimeZone.getTimeZone("Asia/Shanghai"))
return dates
}
String getAppChannel() {
return project.CHANNEL
}
\ No newline at end of file
......@@ -58,10 +58,10 @@
android:name=".ui.ResetAuthorizePasswordActivity"
android:exported="true" />
<activity
android:name=".log.FunctionCenterActivity"
android:name=".ui.FunctionCenterActivity"
android:exported="true" />
<activity
android:name=".log.LFilePickerActivity"
android:name=".ui.LFilePickerActivity"
android:exported="true" />
</application>
......
[
{
"ChannelId": -1,
"ChannelName": "通用",
"ChannelNameEn": "common",
"ChannelAccountArray": ["6038001"]
},
{
"ChannelId": 1,
"ChannelName": "匡威",
"ChannelNameEn": "converse",
"ChannelAccountArray": ["6011001","6013001","6014001","6017001","6021001"]
}
]
\ No newline at end of file
......@@ -17,10 +17,11 @@ import com.fastcashier.lib_common.base.BaseApplication
import com.fastcashier.lib_common.function.account.AccountService
import com.fastcashier.lib_common.function.pay.OrderRecordManageKit
import com.fastcashier.lib_common.util.DateUtils
import com.miya.fastcashier.utils.ContextUtils
import com.miya.fastcashier.utils.DensityUtils
import com.miya.fastcashier.utils.LogFileUtils
import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import com.fastcashier.lib_common.util.LogFileUtils
import com.miya.fastcashier.util.ContextUtils
import com.miya.fastcashier.util.DensityUtils
import com.miya.fastcashier.util.manage.ChannelManageKit
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.print.PrinterManager
import com.sdy.miya.moblie.component.pay.core.net.MiYaPayMobileApiClient
import com.sdy.miya.moblie.component.pay.core.net.MiyaHttpLoggingInterceptor
......@@ -42,6 +43,8 @@ class MiyaApplication : BaseApplication() {
instance = this
ContextUtils.init(this)
//初始化账号数据
ChannelManageKit.initChannelRes(this)
//打印机初始化
PrinterManager.getInstance().init(this)
//屏幕适配
......@@ -203,5 +206,7 @@ class MiyaApplication : BaseApplication() {
OrderRecordManageKit.clearOrderDataYeaterday()
//清除本地个人信息
AccountService.clear()
//清除本地渠道数据信息
ChannelManageKit.clearChannelResData()
}
}
\ No newline at end of file
package com.miya.fastcashier.bean;
import com.fastcashier.lib_common.base.BaseBean;
import java.util.List;
/**
* 类描述:渠道配置信息
* 创建人:zpxiang
* 创建时间:
* 修改人:
* 修改时间:
*/
public class ChannelInfoBean extends BaseBean {
/**
* ChannelId : 1
* ChannelName : 匡威
* ChannelNameEn : converse
* ChannelAccountArray : ["6011","6013","6014","6017","6021"]
*/
private String ChannelId;
private String ChannelName;
private String ChannelNameEn;
private List<String> ChannelAccountArray;
public void setChannelId(String channelId) {
ChannelId = channelId;
}
public String getChannelId() {
return ChannelId;
}
public String getChannelName() {
return ChannelName;
}
public void setChannelName(String channelName) {
ChannelName = channelName;
}
public String getChannelNameEn() {
return ChannelNameEn;
}
public void setChannelNameEn(String channelNameEn) {
ChannelNameEn = channelNameEn;
}
public List<String> getChannelAccountArray() {
return ChannelAccountArray;
}
public void setChannelAccountArray(List<String> channelAccountArray) {
ChannelAccountArray = channelAccountArray;
}
}
package com.miya.fastcashier.log
package com.miya.fastcashier.bean
import java.io.Serializable
import com.fastcashier.lib_common.base.BaseBean
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
class LFileParamEntity : Serializable {
class LFileParamBean : BaseBean() {
var title: String? = null
@get:Deprecated("")
......
package com.miya.fastcashier.net.param
package com.miya.fastcashier.bean
/**
* Data validation state of the login form.
*/
data class LoginFormState(
data class LoginFormStateBean(
val usernameError: Int? = null,
val passwordError: Int? = null,
val isDataValid: Boolean = false
......
......@@ -3,7 +3,7 @@ package com.miya.fastcashier.dao
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.Room
import com.miya.fastcashier.utils.ContextUtils
import com.miya.fastcashier.util.ContextUtils
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.room.migration.Migration
......
package com.miya.fastcashier.net
import android.text.TextUtils
import android.util.Log
import com.fastcashier.lib_common.base.BaseApplication
import com.fastcashier.lib_common.function.account.SelfCashierAccountInfo
import com.fastcashier.lib_common.function.account.SelfCashierTerminalConfig
import com.fastcashier.lib_common.net.ApiConfig
import com.fastcashier.lib_common.net.CommonCallback
import com.fastcashier.lib_common.net.MiyaHttpLoggingInterceptor
import com.fastcashier.lib_common.net.SSLCertificatesInit
import com.miya.fastcashier.net.param.LoginParams
import com.miya.fastcashier.utils.LogFileUtils
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
class ApiRequest private constructor() {
companion object {
private var apiService: ApiService? = null
private var sInstance: ApiRequest? = null
@Synchronized
fun getInstance(): ApiRequest {
if (null == sInstance) {
sInstance = ApiRequest()
}
return sInstance!!
}
private fun getApiService(): ApiService {
if (null == apiService) {
val httpLoggingInterceptor =
MiyaHttpLoggingInterceptor {
Log.e("####", it)
if (!LogFileUtils.isProhibitWrite) {
LogFileUtils.writeLog(BaseApplication.getApplication(),it)
}
}.apply { level = MiyaHttpLoggingInterceptor.Level.BODY }
val socketFactory = arrayOfNulls<SSLSocketFactory>(1)
val trustManager = arrayOfNulls<X509TrustManager>(1)
SSLCertificatesInit.init(socketFactory, trustManager)
val client = OkHttpClient.Builder()
.addInterceptor(httpLoggingInterceptor)
.addInterceptor(RequestSignInterceptor())
.sslSocketFactory(socketFactory[0]!!, trustManager[0]!!)
.build()
val retrofit = Retrofit.Builder()
.baseUrl(ApiConfig.baseUrl)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
apiService = retrofit.create(ApiService::class.java)
}
return apiService!!
}
}
fun login(
loginParams: LoginParams,
commonCallback: CommonCallback<SelfCashierAccountInfo>
) {
getApiService().login(loginParams).enqueue(commonCallback)
}
fun uploadFile(
url: String,
part: MultipartBody.Part,
commonCallback: CommonCallback<String>
) {
getApiService().uploadFile(url, part).enqueue(commonCallback)
}
fun getDataSourceIp(
selfCashierTerminalConfig: SelfCashierTerminalConfig,
equType: String
): String? {
if (selfCashierTerminalConfig?.scoRuntimeConfig == null) {
throw RuntimeException("DataSourceIpUtils SelfCashierTerminalConfig is null")
}
val path = "${ApiService.UPLOAD_LOG_FILE}?equType=$equType"
return if (TextUtils.isEmpty(selfCashierTerminalConfig.scoRuntimeConfig.erpIp)) (ApiConfig.baseUrl + path)
else selfCashierTerminalConfig.scoRuntimeConfig.erpIp + path
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.miya.fastcashier.net
import com.fastcashier.lib_common.function.account.SelfCashierAccountInfo
import com.fastcashier.lib_common.net.ApiConfig
import com.fastcashier.lib_common.net.BaseApi
import com.fastcashier.lib_common.net.BaseResponse
import com.miya.fastcashier.net.param.LoginParams
import okhttp3.MultipartBody
......@@ -11,7 +12,7 @@ import retrofit2.http.*
/**
* 请求地址配置
*/
interface ApiService {
interface MiyaApi : BaseApi {
companion object {
......@@ -24,11 +25,6 @@ interface ApiService {
* 上传日志文件
*/
var UPLOAD_LOG_FILE: String = "verify/r-log/upload-log-file"
fun wrapUrl(suffix: String): String {
return ApiConfig.baseUrl.plus(suffix)
}
}
@POST(LOGIN)
......
package com.miya.fastcashier.net
import android.text.TextUtils
import com.fastcashier.lib_common.function.account.SelfCashierAccountInfo
import com.fastcashier.lib_common.function.account.SelfCashierTerminalConfig
import com.fastcashier.lib_common.net.*
import com.miya.fastcashier.net.param.LoginParams
import okhttp3.MultipartBody
class MiyaApiRequest {
companion object {
private var sMiyaApi: MiyaApi? = null
private fun getApi(): MiyaApi {
if (null == sMiyaApi) {
sMiyaApi = ApiClient.getInstance().creatApi(MiyaApi::class.java)
}
return sMiyaApi!!
}
fun login(
loginParams: LoginParams,
commonCallback: CommonCallback<SelfCashierAccountInfo>
) {
getApi().login(loginParams).enqueue(commonCallback)
}
fun uploadFile(
url: String,
part: MultipartBody.Part,
commonCallback: CommonCallback<String>
) {
getApi().uploadFile(url, part).enqueue(commonCallback)
}
fun getDataSourceIp(
selfCashierTerminalConfig: SelfCashierTerminalConfig,
equType: String
): String? {
if (selfCashierTerminalConfig?.scoRuntimeConfig == null) {
throw RuntimeException("DataSourceIpUtils SelfCashierTerminalConfig is null")
}
val path = "${MiyaApi.UPLOAD_LOG_FILE}?equType=$equType"
return if (TextUtils.isEmpty(selfCashierTerminalConfig.scoRuntimeConfig.erpIp))
(ApiConfig.baseUrl.plus(path))
else selfCashierTerminalConfig.scoRuntimeConfig.erpIp + path
}
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import com.fastcashier.lib_common.function.pay.OrderRecordManageKit
import com.fastcashier.lib_common.util.StringPriceFormatUtils
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityAliPayCodeBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.viewmodel.PayViewModel
import com.miya.print.utils.BitmapUtils
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
......
package com.miya.fastcashier.log
package com.miya.fastcashier.ui
import android.content.Intent
import android.os.Bundle
import com.fastcashier.lib_common.base.BaseActivity
import com.fastcashier.lib_common.util.LogFileUtils
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityFunctionCenterBinding
import com.miya.fastcashier.utils.LogFileUtils
import com.miya.fastcashier.util.manage.log.LFilePickerManageKit
import com.miya.fastcashier.ui.dialog.SystemParameterDialog
/**
* 功能中心
......@@ -35,7 +37,7 @@ class FunctionCenterActivity : BaseActivity() {
}
fun toUploadLog() {
LFilePicker()
LFilePickerManageKit()
.withActivity(this)
.withStartPath(LogFileUtils.CACHE_FILE_PATH) //指定初始显示路径
.withIsGreater(true) //过滤文件大小 小于指定大小的文件
......
package com.miya.fastcashier.log;
package com.miya.fastcashier.ui;
import android.content.Intent;
import android.graphics.Color;
......@@ -20,10 +20,16 @@ import com.fastcashier.lib_common.base.BaseActivity;
import com.fastcashier.lib_common.function.account.AccountService;
import com.fastcashier.lib_common.function.account.SelfCashierTerminalConfig;
import com.fastcashier.lib_common.net.CommonCallback;
import com.fastcashier.lib_common.util.LogFileUtils;
import com.miya.fastcashier.R;
import com.miya.fastcashier.net.ApiRequest;
import com.miya.fastcashier.net.ApiService;
import com.miya.fastcashier.utils.LogFileUtils;
import com.miya.fastcashier.util.manage.log.LFileFilter;
import com.miya.fastcashier.bean.LFileParamBean;
import com.miya.fastcashier.net.MiyaApiRequest;
import com.miya.fastcashier.net.MiyaApi;
import com.miya.fastcashier.ui.adapter.PathAdapter;
import com.miya.fastcashier.ui.dialog.CustomImageCenterDialog;
import com.miya.fastcashier.util.FileUtils;
import com.miya.fastcashier.widget.EmptyRecyclerView;
import java.io.File;
import java.util.ArrayList;
......@@ -49,7 +55,7 @@ public class LFilePickerActivity extends BaseActivity {
private String mPath;
private PathAdapter mPathAdapter;
private Toolbar mToolbar;
private LFileParamEntity mParamEntity;
private LFileParamBean mParamEntity;
private boolean mIsAllSelected = false;
private Menu mMenu;
private Toast successToast;
......@@ -61,7 +67,7 @@ public class LFilePickerActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
mParamEntity = (LFileParamEntity) getIntent().getExtras().getSerializable("param");
mParamEntity = (LFileParamBean) getIntent().getExtras().getSerializable("param");
setTheme(mParamEntity.getTheme());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lfile_picker);
......@@ -268,15 +274,15 @@ public class LFilePickerActivity extends BaseActivity {
File file = new File(path);
RequestBody requestBody = RequestBody.create(MediaType.parse(""), file);
MultipartBody.Part part = MultipartBody.Part.createFormData("logFile", file.getName(), requestBody);
String ip = ApiRequest.Companion.getInstance().getDataSourceIp(selfCashierTerminalConfig, equType);
String ip = MiyaApiRequest.Companion.getDataSourceIp(selfCashierTerminalConfig, equType);
if (!TextUtils.isEmpty(selfCashierTerminalConfig.getScoRuntimeConfig().getPlatformUrl())) {
ip = selfCashierTerminalConfig.getScoRuntimeConfig().getPlatformUrl()
+ ApiService.Companion.getUPLOAD_LOG_FILE();
+ MiyaApi.Companion.getUPLOAD_LOG_FILE();
}
LogUtils.e("ip = " + ip);
tryGenQrCodeMsg(file.getName());
ApiRequest.Companion.getInstance().uploadFile(ip, part,
MiyaApiRequest.Companion.uploadFile(ip, part,
new CommonCallback<String>() {
@Override
public void onSuccess(String data) {
......
......@@ -17,10 +17,11 @@ import com.blankj.utilcode.util.ToastUtils
import com.fastcashier.lib_common.function.account.AccountService
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.manage.ChannelManageKit
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.viewmodel.LoginViewModel
import com.permissionx.guolindev.PermissionX
import com.permissionx.guolindev.callback.RequestCallback
class LoginActivity : AppCompatActivity() {
......@@ -41,30 +42,24 @@ class LoginActivity : AppCompatActivity() {
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
binding.vLoading.visibility = View.GONE
result.getOrElse {
tvErrInfo.text = it.message
tvErrInfo.visibility = View.VISIBLE
binding.tvErrorInfo.text = it.message
binding.tvErrorInfo.visibility = View.VISIBLE
return@observe
}
result.getOrNull().also {
it?.let { it1 ->
val userName = username.text.toString()
val passWord = password.text.toString()
val userName = binding.etUsername.text.toString()
val passWord = binding.etPassword.text.toString()
LocalKeyDataMKManageKit.putLoginIngfo(userName, passWord)
AccountService.init(it1, userName)
......@@ -80,75 +75,68 @@ class LoginActivity : AppCompatActivity() {
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
login.isEnabled = loginState.isDataValid
binding.btnLogin.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
binding.etUsername.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null && !TextUtils.isEmpty(password.text)) {
password.error = getString(loginState.passwordError)
if (loginState.passwordError != null && !TextUtils.isEmpty(binding.etPassword.text)) {
binding.etPassword.error = getString(loginState.passwordError)
}
})
username.apply {
binding.etUsername.apply {
afterTextChanged {
loginViewModel.loginDataChanged(
username.text.toString(),
password.text.toString()
binding.etUsername.text.toString(),
binding.etPassword.text.toString()
)
}
setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_NEXT -> {
password.requestFocus()
password.text?.let { password.setSelection(it.length) };
binding.etPassword.requestFocus()
binding.etPassword.text?.let { binding.etPassword.setSelection(it.length) };
}
}
false
}
}
password.apply {
binding.etPassword.apply {
afterTextChanged {
loginViewModel.loginDataChanged(
username.text.toString(),
password.text.toString()
binding.etUsername.text.toString(),
binding.etPassword.text.toString()
)
}
setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_DONE -> {
loading.visibility = View.VISIBLE;
loginViewModel.login(
username.text.toString(),
password.text.toString()
)
if (!TextUtils.isEmpty(binding.etUsername.text.toString())) {
checkPermissions()
}
}
}
false
}
binding.login.clickWithTrigger {
binding.btnLogin.clickWithTrigger {
checkPermissions()
}
}
LocalKeyDataMKManageKit.getLoginUserName()?.let {
username.setText(it)
binding.etUsername.setText(it)
}
LocalKeyDataMKManageKit.getLoginUserPassword()?.let {
password.setText(it)
binding.etPassword.setText(it)
}
if (!TextUtils.isEmpty(username.text) && !TextUtils.isEmpty(password.text)) {
loading.visibility = View.VISIBLE;
loginViewModel.login(
username.text.toString(),
password.text.toString()
)
if (!TextUtils.isEmpty(binding.etUsername.text) && !TextUtils.isEmpty(binding.etPassword.text)) {
checkPermissions()
}
}
private fun checkPermissions() {
......@@ -157,23 +145,40 @@ class LoginActivity : AppCompatActivity() {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
)
.request(RequestCallback { allGranted: Boolean, grantedList: List<String?>?, deniedList: List<String?>? ->
.request { allGranted: Boolean, grantedList: List<String?>?, deniedList: List<String?>? ->
if (allGranted) {
binding.loading.visibility = View.VISIBLE
loginViewModel.login(
binding.username.text.toString(),
binding.password.text.toString()
)
login()
} else {
ToastUtils.showShort("请检查权限后重试")
}
})
}
}
private fun login() {
binding.vLoading.visibility = View.VISIBLE
val userName = binding.etUsername.text.toString()
loginViewModel.login(
userName,
binding.etPassword.text.toString()
)
//暂不加账号过滤
// if (ChannelManageKit.containsAccount(this, userName)) {
// loginViewModel.login(
// userName,
// binding.etPassword.text.toString()
// )
// } else {
// binding.vLoading.visibility = View.GONE
// CenterToasty.error(this, "账号有误,请检查后重试").show()
// }
}
/**
* Extension function to simplify setting an afterTextChanged action to EditText components.
*/
private fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) {
this.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(editable: Editable?) {
afterTextChanged.invoke(editable.toString())
......
......@@ -2,7 +2,6 @@ package com.miya.fastcashier.ui
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.Gravity
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
......@@ -15,18 +14,16 @@ 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
import com.miya.fastcashier.utils.*
import com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.util.*
import com.miya.fastcashier.util.manage.AccountPasswordManageKit
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.viewmodel.MainViewModel
import com.sdy.miya.moblie.component.pay.core.utils.PayLogFileUtils
import es.dmoral.toasty.Toasty
import com.fastcashier.lib_common.util.LogFileUtils
import java.util.*
class MainActivity : BaseActivity() {
......@@ -48,6 +45,13 @@ class MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initView()
initData()
initListener()
}
private fun initView() {
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
......@@ -55,7 +59,34 @@ class MainActivity : BaseActivity() {
binding.tvStoreName.text = AccountService.getAccountInfo()?.shopInfo?.storeName
binding.tvSlog.text = AccountService.getUserName()
binding.tvVersion.text = getVersionName(this)
}
private fun initData() {
viewModel.statisticsLiveData.observe(this, { result ->
result.onSuccess {
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
viewModel.balanceLiveData.observe(this, { result ->
result.onSuccess {
LocalKeyDataMKManageKit.putBalanceDate(it)
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
checkAccountPassword()
OrderRecordManageKit.clearOrderDataYeaterday()
LogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
PayLogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
}
private fun initListener() {
binding.llPay.clickWithTrigger {
PriceInputActivity.start(this@MainActivity)
}
......@@ -82,8 +113,9 @@ class MainActivity : BaseActivity() {
dateSelectHelper = DateSelectHelper(this@MainActivity) {
var currentDate = Date()
if (currentDate.time <= it.time){
CenterToasty.error(this@MainActivity,getString(R.string.toast_warn_time)).show()
if (currentDate.time <= it.time) {
CenterToasty.error(this@MainActivity, getString(R.string.toast_warn_time))
.show()
return@DateSelectHelper
}
viewModel.orderStatistics(it, currentDate, false)
......@@ -94,12 +126,10 @@ class MainActivity : BaseActivity() {
binding.llBalance.clickWithTrigger {
showConfirmBalanceDialog()
}
}
initData()
checkAccountPassword()
OrderRecordManageKit.clearOrderDataYeaterday()
LogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
PayLogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
private fun checkAccountPassword() {
AccountPasswordManageKit.get().checkAccountPassword(this)
}
private fun toRefund() {
......@@ -112,30 +142,6 @@ class MainActivity : BaseActivity() {
AuthorizePasswordInputDialog.newInstance().show(fm, FRAGMENT_TAG)
}
private fun checkAccountPassword() {
AccountPasswordManageKit.get().checkAccountPassword(this)
}
private fun initData() {
viewModel.statisticsLiveData.observe(this, { result ->
result.onSuccess {
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
viewModel.balanceLiveData.observe(this, { result ->
result.onSuccess {
LocalKeyDataMKManageKit.putBalanceDate(it)
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
}
private fun showConfirmBalanceDialog() {
if (confirmDialog == null || !confirmDialog!!.isShowing) {
confirmDialog = CommonDialog(this)
......
......@@ -10,8 +10,8 @@ import com.fastcashier.lib_common.config.IntentExtra
import com.fastcashier.lib_common.function.pay.OrderRecordManageKit
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityPayBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.ScanGunKeyEventHelper
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.ScanGunKeyEventHelper
import com.miya.fastcashier.viewmodel.PayViewModel
import java.util.*
......
......@@ -14,7 +14,7 @@ import com.miya.fastcashier.R
import com.miya.fastcashier.R.mipmap.ic_alipay
import com.miya.fastcashier.R.mipmap.ic_wxpay
import com.miya.fastcashier.databinding.ActivityPayCodeBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.viewmodel.PayViewModel
import com.miya.print.utils.BitmapUtils
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
......
......@@ -17,8 +17,8 @@ import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityPriceInputBinding
import com.miya.fastcashier.ui.dialog.PayChooseDialog
import com.miya.fastcashier.ui.dialog.PayChooseDialog.GeneratePayCodeClickListener
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.WordUtil
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.WordUtil
import com.miya.fastcashier.viewmodel.PayViewModel
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import java.math.BigDecimal
......
......@@ -9,8 +9,8 @@ import com.fastcashier.lib_common.base.BaseActivity
import com.fastcashier.lib_common.ui.dialog.NumberManualDialog
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityRefundBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.ScanGunKeyEventHelper
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.ScanGunKeyEventHelper
import com.miya.fastcashier.viewmodel.PayViewModel
......
......@@ -7,8 +7,8 @@ import android.text.TextUtils
import com.fastcashier.lib_common.base.BaseActivity
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityResetAuthorizePasswordBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.manage.AccountPasswordManageKit
class ResetAuthorizePasswordActivity : BaseActivity() {
......
......@@ -29,8 +29,8 @@ import com.miya.fastcashier.dao.ViewPayOrderData
import com.miya.fastcashier.databinding.ActivitySearchOrderBinding
import com.miya.fastcashier.databinding.FragmentSearchOrderBinding
import com.miya.fastcashier.databinding.ItemSearchOrderListBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.viewmodel.SearchOrderViewModel
/**
......
......@@ -12,7 +12,6 @@ import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.MiyaApplication
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivitySettingBinding
import com.miya.fastcashier.log.FunctionCenterActivity
import com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog
class SettingActivity : BaseActivity() {
......
......@@ -12,7 +12,7 @@ import com.fastcashier.lib_common.function.pay.OrderRecordManageKit
import com.fastcashier.lib_common.util.StringPriceFormatUtils
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityWxPayCodeBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.viewmodel.PayViewModel
import com.miya.print.utils.BitmapUtils
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
......
package com.miya.fastcashier.log;
package com.miya.fastcashier.ui.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
......@@ -11,6 +11,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.miya.fastcashier.R;
import com.miya.fastcashier.util.FileUtils;
import java.io.File;
import java.io.FileFilter;
......
......@@ -14,8 +14,8 @@ import com.fastcashier.lib_common.base.BaseActivity
import com.fastcashier.lib_common.util.dp2px
import com.miya.fastcashier.databinding.DialogAuthorizePasswordInputBinding
import com.miya.fastcashier.ui.RefundActivity
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.manage.AccountPasswordManageKit
class AuthorizePasswordInputDialog : DialogFragment(), View.OnClickListener {
......
package com.miya.fastcashier.log
package com.miya.fastcashier.ui.dialog
import android.app.Dialog
import android.content.Context
import com.miya.fastcashier.R
import android.widget.TextView
import android.graphics.Bitmap
import com.miya.fastcashier.log.CustomImageCenterDialog
import android.os.Build
import android.view.WindowManager
import android.text.TextUtils
......@@ -17,6 +16,7 @@ import android.view.Window
import android.widget.ImageView
class CustomImageCenterDialog(context: Context) : Dialog(context, R.style.CommonDialog) {
private var tvOk: TextView? = null
private var tvHint: TextView? = null
private var ivContent: ImageView? = null
......
package com.miya.fastcashier.log
package com.miya.fastcashier.ui.dialog
import android.app.Dialog
import android.content.Context
......@@ -15,7 +15,7 @@ import com.fastcashier.lib_common.util.getVersionCode
import com.fastcashier.lib_common.util.getWifyName
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.DialogSystemParameterBinding
import com.miya.fastcashier.utils.*
import com.miya.fastcashier.util.manage.ChannelManageKit
import com.miya.print.PrinterManager
import java.util.*
......@@ -53,7 +53,7 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi
viewBinding.tvPrintType,
if (PrinterManager.getInstance().printer == null) context.resources.getString(R.string.app_unkown) else PrinterManager.getInstance().printer.printerName
)
setInfo(viewBinding.tvChannel, BuildConfig.CHANNEL)
setInfo(viewBinding.tvChannel, ChannelManageKit.getAppChannelName(context))
viewBinding.ivClose.setOnClickListener(View.OnClickListener { dismiss() })
resize()
}
......
package com.miya.fastcashier.utils;
package com.miya.fastcashier.util;
import android.content.Context;
import android.view.Gravity;
......
package com.miya.fastcashier.utils;
package com.miya.fastcashier.util;
import android.content.Context;
......
package com.miya.fastcashier.utils
package com.miya.fastcashier.util
import android.app.Activity
import com.bigkoo.pickerview.builder.TimePickerBuilder
......
package com.miya.fastcashier.utils
package com.miya.fastcashier.util
import android.app.Application
import android.content.ComponentCallbacks
......
package com.miya.fastcashier.log;
package com.miya.fastcashier.util;
import com.miya.fastcashier.util.manage.log.FileComparator;
import java.io.File;
import java.io.FileFilter;
......@@ -8,10 +10,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* Created by Dimorinny on 24.10.15.
*/
public class FileUtils {
public static List<File> getFileListByDirPath(String path, FileFilter filter) {
File directory = new File(path);
File[] files = directory.listFiles(filter);
......
package com.miya.fastcashier.utils;
package com.miya.fastcashier.util;
import android.os.Handler;
import android.text.TextUtils;
......
package com.miya.fastcashier.utils
package com.miya.fastcashier.util
import android.content.Context
import android.text.SpannableString
import com.miya.fastcashier.utils.WordUtil
import android.text.TextUtils
import android.text.style.ForegroundColorSpan
import androidx.core.content.ContextCompat
......
package com.miya.fastcashier.utils.manage
package com.miya.fastcashier.util.manage
import android.Manifest
import android.os.Environment
......
package com.miya.fastcashier.util.manage
import android.content.Context
import android.text.TextUtils
import com.blankj.utilcode.util.GsonUtils
import com.fastcashier.lib_common.function.account.AccountService.getUserName
import com.google.gson.reflect.TypeToken
import com.miya.fastcashier.bean.ChannelInfoBean
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.collections.HashMap
/**
* 类说明:渠道管理类(用于处理品牌全局设置,以及换肤所需渠道配置)
* 详细描述:目前通过本地资源文件加载 todo 后期能改成接口返回渠道最好
* 创建人:zpxiang
* 创建时间:
* 修改人:
* 修改时间:
*/
object ChannelManageKit {
private var channelMap: HashMap<String, ChannelInfoBean>? = null//key为账号,value为所属的品牌信息
private const val CHANNEL_OFFICIAL_ACCOUNT = "-1"
private const val CHANNEL_OFFICIAL_CHANNELNAME = "通用"
private const val CHANNEL_OFFICIAL_CHANNELNAME_EN = "common"
/**
* 初始化本地渠道数据
*/
fun initChannelRes(context: Context?) {
clearChannelResData()
if (null == context) {
initDefaultChannelRes()
return
}
val assetsJson = getAssetsJson(context, "channel.json")
if (TextUtils.isEmpty(assetsJson)) {
initDefaultChannelRes()
return
}
val channelInfoList = GsonUtils.fromJson<ArrayList<ChannelInfoBean>>(
assetsJson,
object : TypeToken<List<ChannelInfoBean?>?>() {}.type
)
channelMap = HashMap()
if (!channelInfoList.isEmpty()) {
for (i in channelInfoList.indices) {
val channelInfoBean = channelInfoList[i]
val channelAccountArray = channelInfoBean.channelAccountArray
if (channelAccountArray.isEmpty()) {
initDefaultChannelRes()
continue
}
for (j in channelAccountArray.indices) {
val account = channelAccountArray[j]
channelMap!![account] = channelInfoBean
}
}
}
}
private fun initDefaultChannelRes() {
if (channelMap == null) {
channelMap = HashMap()
}
val commonChannel = ChannelInfoBean()
commonChannel.channelId = "-1"
commonChannel.channelName = CHANNEL_OFFICIAL_CHANNELNAME
commonChannel.channelNameEn = CHANNEL_OFFICIAL_CHANNELNAME_EN
channelMap!![CHANNEL_OFFICIAL_ACCOUNT] = commonChannel
}
/**
* 判断本地是否包含本品牌账户,此处暂时用来处理区别大屏和手持账号
*/
fun containsAccount(context: Context?, account: String): Boolean {
if (channelMap == null || channelMap!!.isEmpty()) {
initChannelRes(context)
}
return channelMap!!.containsKey(account)
}
/**
* 获取渠道名称
*/
fun getAppChannelName(context: Context?): String {
if (channelMap == null || channelMap!!.isEmpty()) {
initChannelRes(context)
}
val containsKey = channelMap!!.containsKey(getUserName())
return if (!containsKey) {
CHANNEL_OFFICIAL_CHANNELNAME
} else channelMap!![getUserName()]!!.channelName
}
/**
* 获取App渠道编号
*/
fun getAppChannelId(context: Context?): String {
if (context == null) {
return CHANNEL_OFFICIAL_ACCOUNT
}
if (channelMap == null || channelMap!!.isEmpty()) {
initChannelRes(context)
}
return if (!channelMap!!.containsKey(getUserName())) {
CHANNEL_OFFICIAL_ACCOUNT
} else channelMap!![getUserName()]!!.channelId
}
fun clearChannelResData() {
if (null == channelMap) {
return
}
channelMap!!.clear()
channelMap = null
}
/**
* 读取json文件
*/
private fun getAssetsJson(context: Context, fileName: String): String {
val stringBuilder = StringBuilder()
val assetManager = context.assets
try {
val bf = BufferedReader(InputStreamReader(assetManager.open(fileName), "UTF-8"))
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
} catch (e: IOException) {
e.printStackTrace()
}
return stringBuilder.toString()
}
}
\ No newline at end of file
package com.miya.fastcashier.utils.manage
package com.miya.fastcashier.util.manage
import com.fastcashier.lib_common.function.account.AccountService
import com.tencent.mmkv.MMKV
import java.util.*
/**
* 类描述:本地关键数据MMKV统一管理
......@@ -17,7 +16,7 @@ class LocalKeyDataMKManageKit {
companion object {
/***************************************** 分账户的关键数据,分区存储ID为MMKV_ID *****************************************/
private val MMKV_ID = "fastcashier_key_data"
private val MMKV_KEY_ID = "fastcashier_key_data"
private val BALANCEDATE_ID = "balanceDate"
/**
......@@ -62,7 +61,7 @@ class LocalKeyDataMKManageKit {
}
private fun getKeyDataMK(): MMKV {
val MMKV_ID_WITH_USER = MMKV_ID.plus("_${AccountService.getUserName()}")
val MMKV_ID_WITH_USER = MMKV_KEY_ID.plus("_${AccountService.getUserName()}")
return MMKV.mmkvWithID(MMKV_ID_WITH_USER)
}
......
package com.miya.fastcashier.log
package com.miya.fastcashier.util.manage.log
import java.io.File
import java.util.Comparator
......
package com.miya.fastcashier.log
package com.miya.fastcashier.util.manage.log
import java.io.File
import java.io.FileFilter
/**
* 作者:Leon
* 时间:2017/3/24 13:43
*/
class LFileFilter(private val mTypes: Array<String>?) : FileFilter {
override fun accept(file: File): Boolean {
......
package com.miya.fastcashier.log
package com.miya.fastcashier.util.manage.log
import android.app.Activity
import android.app.Fragment
......@@ -6,12 +6,14 @@ import android.content.Intent
import android.os.Bundle
import androidx.annotation.StyleRes
import com.miya.fastcashier.R
import com.miya.fastcashier.bean.LFileParamBean
import com.miya.fastcashier.ui.LFilePickerActivity
/**
* 作者:Leon
* 时间:2017/3/20 16:57
* 功能中心日志界面跳转配置管理类
*/
class LFilePicker {
class LFilePickerManageKit {
private var mActivity: Activity? = null
private var mFragment: Fragment? = null
private var mTitle: String? = null
......@@ -39,7 +41,7 @@ class LFilePicker {
* @param activity
* @return
*/
fun withActivity(activity: Activity?): LFilePicker {
fun withActivity(activity: Activity?): LFilePickerManageKit {
mActivity = activity
return this
}
......@@ -50,7 +52,7 @@ class LFilePicker {
* @param fragment
* @return
*/
fun withFragment(fragment: Fragment?): LFilePicker {
fun withFragment(fragment: Fragment?): LFilePickerManageKit {
mFragment = fragment
return this
}
......@@ -61,7 +63,7 @@ class LFilePicker {
* @param title
* @return
*/
fun withTitle(title: String?): LFilePicker {
fun withTitle(title: String?): LFilePickerManageKit {
mTitle = title
return this
}
......@@ -73,7 +75,7 @@ class LFilePicker {
* @return
*/
@Deprecated("")
fun withTitleColor(color: String?): LFilePicker {
fun withTitleColor(color: String?): LFilePickerManageKit {
mTitleColor = color
return this
}
......@@ -84,7 +86,7 @@ class LFilePicker {
* @param theme
* @return
*/
fun withTheme(@StyleRes theme: Int): LFilePicker {
fun withTheme(@StyleRes theme: Int): LFilePickerManageKit {
this.theme = theme
return this
}
......@@ -95,7 +97,7 @@ class LFilePicker {
* @param style
* @return
*/
fun withTitleStyle(@StyleRes style: Int): LFilePicker {
fun withTitleStyle(@StyleRes style: Int): LFilePickerManageKit {
mTitleStyle = style
return this
}
......@@ -106,7 +108,7 @@ class LFilePicker {
* @param color
* @return
*/
fun withBackgroundColor(color: String?): LFilePicker {
fun withBackgroundColor(color: String?): LFilePickerManageKit {
mBackgroundColor = color
return this
}
......@@ -117,7 +119,7 @@ class LFilePicker {
* @param requestCode
* @return
*/
fun withRequestCode(requestCode: Int): LFilePicker {
fun withRequestCode(requestCode: Int): LFilePickerManageKit {
mRequestCode = requestCode
return this
}
......@@ -128,7 +130,7 @@ class LFilePicker {
* @param backStyle
* @return
*/
fun withBackIcon(backStyle: Int): LFilePicker {
fun withBackIcon(backStyle: Int): LFilePickerManageKit {
mBackStyle = 0 //默认样式
mBackStyle = backStyle
return this
......@@ -140,7 +142,7 @@ class LFilePicker {
* @param isMutily
* @return
*/
fun withMutilyMode(isMutily: Boolean): LFilePicker {
fun withMutilyMode(isMutily: Boolean): LFilePickerManageKit {
mMutilyMode = isMutily
return this
}
......@@ -151,7 +153,7 @@ class LFilePicker {
* @param text
* @return
*/
fun withAddText(text: String?): LFilePicker {
fun withAddText(text: String?): LFilePickerManageKit {
mAddText = text
return this
}
......@@ -162,12 +164,12 @@ class LFilePicker {
* @param style
* @return
*/
fun withIconStyle(style: Int): LFilePicker {
fun withIconStyle(style: Int): LFilePickerManageKit {
mIconStyle = style
return this
}
fun withFileFilter(arrs: Array<String>): LFilePicker {
fun withFileFilter(arrs: Array<String>): LFilePickerManageKit {
mFileTypes = arrs
return this
}
......@@ -178,7 +180,7 @@ class LFilePicker {
* @param notFoundFiles
* @return
*/
fun withNotFoundBooks(notFoundFiles: String?): LFilePicker {
fun withNotFoundBooks(notFoundFiles: String?): LFilePickerManageKit {
mNotFoundFiles = notFoundFiles
return this
}
......@@ -189,7 +191,7 @@ class LFilePicker {
* @param num
* @return
*/
fun withMaxNum(num: Int): LFilePicker {
fun withMaxNum(num: Int): LFilePickerManageKit {
mMaxNum = num
return this
}
......@@ -200,7 +202,7 @@ class LFilePicker {
* @param fileName
* @return
*/
fun withFileName(fileName: String?): LFilePicker {
fun withFileName(fileName: String?): LFilePickerManageKit {
mFileName = fileName
return this
}
......@@ -211,7 +213,7 @@ class LFilePicker {
* @param path
* @return
*/
fun withStartPath(path: String?): LFilePicker {
fun withStartPath(path: String?): LFilePickerManageKit {
mStartPath = path
return this
}
......@@ -222,7 +224,7 @@ class LFilePicker {
* @param chooseMode
* @return
*/
fun withChooseMode(chooseMode: Boolean): LFilePicker {
fun withChooseMode(chooseMode: Boolean): LFilePickerManageKit {
mChooseMode = chooseMode
return this
}
......@@ -233,7 +235,7 @@ class LFilePicker {
* @param isGreater true:大于 ;false:小于,同时包含指定大小在内
* @return
*/
fun withIsGreater(isGreater: Boolean): LFilePicker {
fun withIsGreater(isGreater: Boolean): LFilePickerManageKit {
mIsGreater = isGreater
return this
}
......@@ -244,7 +246,7 @@ class LFilePicker {
* @param fileSize
* @return
*/
fun withFileSize(fileSize: Long): LFilePicker {
fun withFileSize(fileSize: Long): LFilePickerManageKit {
mFileSize = fileSize
return this
}
......@@ -275,7 +277,7 @@ class LFilePicker {
private val bundle: Bundle
private get() {
val paramEntity = LFileParamEntity()
val paramEntity = LFileParamBean()
paramEntity.title = mTitle
paramEntity.theme = theme
paramEntity.titleColor = mTitleColor
......
......@@ -7,23 +7,23 @@ import androidx.lifecycle.viewModelScope
import com.fastcashier.lib_common.function.account.SelfCashierAccountInfo
import com.fastcashier.lib_common.net.CommonCallback
import com.miya.fastcashier.R
import com.miya.fastcashier.net.param.LoginFormState
import com.miya.fastcashier.bean.LoginFormStateBean
import com.miya.fastcashier.net.param.LoginParams
import com.miya.fastcashier.net.ApiRequest
import com.miya.fastcashier.net.MiyaApiRequest
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class LoginViewModel : ViewModel() {
val loginLiveData: MutableLiveData<Result<SelfCashierAccountInfo>> = MutableLiveData()
val _loginForm = MutableLiveData<LoginFormState>()
val loginFormState: LiveData<LoginFormState> = _loginForm
val _loginForm = MutableLiveData<LoginFormStateBean>()
val loginFormState: LiveData<LoginFormStateBean> = _loginForm
fun login(userName: String, passWord: String) {
viewModelScope.launch(Dispatchers.IO) {
ApiRequest.getInstance().login(
MiyaApiRequest.login(
LoginParams(userName, passWord, ""),
object : CommonCallback<SelfCashierAccountInfo>(){
override fun onSuccess(data: SelfCashierAccountInfo) {
......@@ -43,11 +43,11 @@ class LoginViewModel : ViewModel() {
fun loginDataChanged(username: String, password: String) {
if (!isUserNameValid(username)) {
_loginForm.value = LoginFormState(usernameError = R.string.username_not_empty)
_loginForm.value = LoginFormStateBean(usernameError = R.string.username_not_empty)
} else if (!isPasswordValid(password)) {
_loginForm.value = LoginFormState(passwordError = R.string.password_not_empty)
_loginForm.value = LoginFormStateBean(passwordError = R.string.password_not_empty)
} else {
_loginForm.value = LoginFormState(isDataValid = true)
_loginForm.value = LoginFormStateBean(isDataValid = true)
}
}
......
package com.miya.fastcashier.log
package com.miya.fastcashier.widget
import android.content.Context
import android.util.AttributeSet
......
......@@ -60,7 +60,7 @@
android:textColor="@color/lfile_white"
android:textSize="18sp" />
<com.miya.fastcashier.log.EmptyRecyclerView
<com.miya.fastcashier.widget.EmptyRecyclerView
android:id="@+id/recylerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -8,7 +8,7 @@
tools:context=".ui.LoginActivity">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/username"
android:id="@+id/et_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="46dp"
......@@ -25,7 +25,7 @@
app:met_bottomTextSize="26sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/password"
android:id="@+id/et_password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="46dp"
......@@ -39,11 +39,11 @@
android:textSize="32sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username"
app:layout_constraintTop_toBottomOf="@+id/et_username"
app:met_bottomTextSize="26sp" />
<Button
android:id="@+id/login"
android:id="@+id/btn_login"
android:layout_width="656dp"
android:layout_height="100dp"
android:layout_gravity="start"
......@@ -56,7 +56,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password"
app:layout_constraintTop_toBottomOf="@+id/et_password"
app:layout_constraintVertical_bias="0.2" />
<ImageView
......@@ -94,7 +94,7 @@
app:layout_constraintStart_toEndOf="@+id/ivLogo" />
<TextView
android:id="@+id/tvErrInfo"
android:id="@+id/tv_error_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="账号或密码输入错误,请重新输入"
......@@ -102,13 +102,13 @@
android:textSize="24sp"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintStart_toStartOf="@+id/username"
app:layout_constraintTop_toBottomOf="@+id/password" />
app:layout_constraintStart_toStartOf="@+id/et_username"
app:layout_constraintTop_toBottomOf="@+id/et_password" />
<!--封装成一个View-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/loading"
android:id="@+id/v_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
......@@ -148,6 +148,7 @@
app:SpinKit_Color="@color/white" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
# 版本历史
## tag
####优化版本 :
-基础业务组件抽取,libcommon库抽取
-混淆配置,灰度转正式
## tag
####v2.1.6 :
-统计打印业务逻辑优化,时间选择控件优化
......
......@@ -22,6 +22,6 @@ android.jetifier.blacklist=miya-print
android.useDeprecatedNdk=true
#区别品牌
CHANNEL=converse
#CHANNEL=converse
#区别环境 true:是测试环境,仅供内部人员测试使用;false:非测试包,供外部人员、渠道推广、应用商店等使用
ISTEST=false
\ No newline at end of file
......@@ -14,7 +14,6 @@ android {
multiDexEnabled true
consumerProguardFiles "consumer-rules.pro"
buildConfigField 'String', "CHANNEL", "\"$CHANNEL\""
buildConfigField "Boolean", "ISTEST", ISTEST.toString()
buildConfigField "String", "appType", "\"mpos\""
}
......
......@@ -19,7 +19,7 @@ object AccountService {
}
fun getUserName(): String {
return userName.toString();
return userName.toString()
}
fun getAccountPassword(): String {
......
package com.fastcashier.lib_common.net
import android.util.Log
import com.blankj.utilcode.util.LogUtils
import com.fastcashier.lib_common.base.BaseApplication
import com.fastcashier.lib_common.util.LogFileUtils
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
class ApiClient private constructor() {
companion object {
private var sInstance: ApiClient? = null
@Synchronized
fun getInstance(): ApiClient {
if (null == sInstance) {
sInstance = ApiClient()
}
return sInstance!!
}
}
private fun generateClient(): Retrofit {
val httpLoggingInterceptor =
MiyaHttpLoggingInterceptor {
Log.e("####", it)
if (!LogFileUtils.isProhibitWrite) {
LogFileUtils.writeLog(BaseApplication.getApplication(), it)
}
}.apply { level = MiyaHttpLoggingInterceptor.Level.BODY }
val socketFactory = arrayOfNulls<SSLSocketFactory>(1)
val trustManager = arrayOfNulls<X509TrustManager>(1)
SSLCertificatesInit.init(socketFactory, trustManager)
val client = OkHttpClient.Builder()
.addInterceptor(httpLoggingInterceptor)
.addInterceptor(RequestSignInterceptor())
.sslSocketFactory(socketFactory[0]!!, trustManager[0]!!)
.build()
val retrofit = Retrofit.Builder()
.baseUrl(ApiConfig.baseUrl)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
return retrofit
}
fun <T> creatApi(tClass: Class<T>?): T? {
return generateClient().create(tClass)
}
}
\ No newline at end of file
package com.fastcashier.lib_common.net
/**
* 请求Api基础配置
*/
interface BaseApi {
companion object {
fun wrapUrl(suffix: String): String {
return ApiConfig.baseUrl.plus(suffix)
}
}
}
\ No newline at end of file
package com.miya.fastcashier.net
package com.fastcashier.lib_common.net
import com.fastcashier.lib_common.function.account.AccountService.getAccountInfo
import com.fastcashier.lib_common.net.ApiConfig.getAuthorization
import com.miya.fastcashier.net.ApiService.Companion.wrapUrl
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
......@@ -21,17 +20,13 @@ class RequestSignInterceptor : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
val original: Request = chain.request()
val requestUrl = original.url.toString()
val requestBuilder: Request.Builder = original.newBuilder()
val accountInfo = getAccountInfo()
if (accountInfo != null && accountInfo.accessToken != null) {
val loginUrl = wrapUrl(ApiService.LOGIN)
if (requestUrl != loginUrl) {
requestBuilder.addHeader(
AUTHORIZATION,
getAuthorization(accountInfo.accessToken.accessToken)
)
}
requestBuilder.addHeader(
AUTHORIZATION,
getAuthorization(accountInfo.accessToken.accessToken)
)
}
val request: Request = requestBuilder.build()
return chain.proceed(request)
......
package com.miya.fastcashier.utils
package com.fastcashier.lib_common.util
import android.content.Context
import android.content.pm.PackageInfo
......
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