Commit 20cf5615 authored by 赵鹏翔's avatar 赵鹏翔 Committed by 赵鹏翔

Revert "系统参数弹窗相关 java code 2 kotlin"

This reverts commit 4555bc21.
parent 4555bc21
package com.miya.fastcashier.log package com.miya.fastcashier.log;
import android.app.Activity import android.app.Activity;
import android.app.Fragment import android.app.Fragment;
import android.content.Intent import android.content.Intent;
import android.os.Bundle import android.os.Bundle;
import androidx.annotation.StyleRes
import com.miya.fastcashier.R import com.miya.fastcashier.R;
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
/** /**
* 作者:Leon * 作者:Leon
* 时间:2017/3/20 16:57 * 时间:2017/3/20 16:57
*/ */
class LFilePicker { public class LFilePicker {
private Activity mActivity;
private var mActivity: Activity? = null private Fragment mFragment;
private var mFragment: Fragment? = null private String mTitle;
private var mTitle: String? = null private String mTitleColor;
private var mTitleColor: String? = null private int theme = R.style.LFileTheme;
private var theme = R.style.LFileTheme private int mTitleStyle = R.style.LFileToolbarTextStyle;
private var mTitleStyle = R.style.LFileToolbarTextStyle private String mBackgroundColor;
private var mBackgroundColor: String? = null private int mBackStyle;
private var mBackStyle = 0 private int mRequestCode;
private var mRequestCode = 0 private boolean mMutilyMode = true;
private var mMutilyMode = true private boolean mChooseMode = true;
private var mChooseMode = true private String mAddText;
private var mAddText: String? = null private int mIconStyle;
private var mIconStyle = 0 private String[] mFileTypes;
private var mFileTypes: Array<String>? = null private String mNotFoundFiles;
private var mNotFoundFiles: String? = null private int mMaxNum;
private var mMaxNum = 0 private String mStartPath;
private var mStartPath: String? = null private boolean mIsGreater = true;//是否大于
private var mIsGreater = true //是否大于 private long mFileSize;
private var mFileSize: Long = 0 private String mFileName;
private var mFileName: String? = null
/** /**
* 绑定Activity * 绑定Activity
...@@ -40,9 +42,9 @@ class LFilePicker { ...@@ -40,9 +42,9 @@ class LFilePicker {
* @param activity * @param activity
* @return * @return
*/ */
fun withActivity(activity: Activity?): LFilePicker { public LFilePicker withActivity(Activity activity) {
mActivity = activity this.mActivity = activity;
return this return this;
} }
/** /**
...@@ -51,9 +53,9 @@ class LFilePicker { ...@@ -51,9 +53,9 @@ class LFilePicker {
* @param fragment * @param fragment
* @return * @return
*/ */
fun withFragment(fragment: Fragment?): LFilePicker { public LFilePicker withFragment(Fragment fragment) {
mFragment = fragment this.mFragment = fragment;
return this return this;
} }
/** /**
...@@ -62,9 +64,9 @@ class LFilePicker { ...@@ -62,9 +64,9 @@ class LFilePicker {
* @param title * @param title
* @return * @return
*/ */
fun withTitle(title: String?): LFilePicker { public LFilePicker withTitle(String title) {
mTitle = title this.mTitle = title;
return this return this;
} }
/** /**
...@@ -73,10 +75,10 @@ class LFilePicker { ...@@ -73,10 +75,10 @@ class LFilePicker {
* @param color * @param color
* @return * @return
*/ */
@Deprecated("") @Deprecated
fun withTitleColor(color: String?): LFilePicker { public LFilePicker withTitleColor(String color) {
mTitleColor = color this.mTitleColor = color;
return this return this;
} }
/** /**
...@@ -85,9 +87,9 @@ class LFilePicker { ...@@ -85,9 +87,9 @@ class LFilePicker {
* @param theme * @param theme
* @return * @return
*/ */
fun withTheme(@StyleRes theme: Int): LFilePicker { public LFilePicker withTheme(@StyleRes int theme) {
this.theme = theme this.theme = theme;
return this return this;
} }
/** /**
...@@ -96,9 +98,9 @@ class LFilePicker { ...@@ -96,9 +98,9 @@ class LFilePicker {
* @param style * @param style
* @return * @return
*/ */
fun withTitleStyle(@StyleRes style: Int): LFilePicker { public LFilePicker withTitleStyle(@StyleRes int style) {
mTitleStyle = style this.mTitleStyle = style;
return this return this;
} }
/** /**
...@@ -107,9 +109,9 @@ class LFilePicker { ...@@ -107,9 +109,9 @@ class LFilePicker {
* @param color * @param color
* @return * @return
*/ */
fun withBackgroundColor(color: String?): LFilePicker { public LFilePicker withBackgroundColor(String color) {
mBackgroundColor = color this.mBackgroundColor = color;
return this return this;
} }
/** /**
...@@ -118,9 +120,9 @@ class LFilePicker { ...@@ -118,9 +120,9 @@ class LFilePicker {
* @param requestCode * @param requestCode
* @return * @return
*/ */
fun withRequestCode(requestCode: Int): LFilePicker { public LFilePicker withRequestCode(int requestCode) {
mRequestCode = requestCode this.mRequestCode = requestCode;
return this return this;
} }
/** /**
...@@ -129,10 +131,10 @@ class LFilePicker { ...@@ -129,10 +131,10 @@ class LFilePicker {
* @param backStyle * @param backStyle
* @return * @return
*/ */
fun withBackIcon(backStyle: Int): LFilePicker { public LFilePicker withBackIcon(int backStyle) {
mBackStyle = 0 //默认样式 this.mBackStyle = 0;//默认样式
mBackStyle = backStyle this.mBackStyle = backStyle;
return this return this;
} }
/** /**
...@@ -141,9 +143,9 @@ class LFilePicker { ...@@ -141,9 +143,9 @@ class LFilePicker {
* @param isMutily * @param isMutily
* @return * @return
*/ */
fun withMutilyMode(isMutily: Boolean): LFilePicker { public LFilePicker withMutilyMode(boolean isMutily) {
mMutilyMode = isMutily this.mMutilyMode = isMutily;
return this return this;
} }
/** /**
...@@ -152,9 +154,9 @@ class LFilePicker { ...@@ -152,9 +154,9 @@ class LFilePicker {
* @param text * @param text
* @return * @return
*/ */
fun withAddText(text: String?): LFilePicker { public LFilePicker withAddText(String text) {
mAddText = text this.mAddText = text;
return this return this;
} }
/** /**
...@@ -163,14 +165,14 @@ class LFilePicker { ...@@ -163,14 +165,14 @@ class LFilePicker {
* @param style * @param style
* @return * @return
*/ */
fun withIconStyle(style: Int): LFilePicker { public LFilePicker withIconStyle(int style) {
mIconStyle = style this.mIconStyle = style;
return this return this;
} }
fun withFileFilter(arrs: Array<String>): LFilePicker { public LFilePicker withFileFilter(String[] arrs) {
mFileTypes = arrs this.mFileTypes = arrs;
return this return this;
} }
/** /**
...@@ -179,9 +181,9 @@ class LFilePicker { ...@@ -179,9 +181,9 @@ class LFilePicker {
* @param notFoundFiles * @param notFoundFiles
* @return * @return
*/ */
fun withNotFoundBooks(notFoundFiles: String?): LFilePicker { public LFilePicker withNotFoundBooks(String notFoundFiles) {
mNotFoundFiles = notFoundFiles this.mNotFoundFiles = notFoundFiles;
return this return this;
} }
/** /**
...@@ -190,9 +192,9 @@ class LFilePicker { ...@@ -190,9 +192,9 @@ class LFilePicker {
* @param num * @param num
* @return * @return
*/ */
fun withMaxNum(num: Int): LFilePicker { public LFilePicker withMaxNum(int num) {
mMaxNum = num this.mMaxNum = num;
return this return this;
} }
/** /**
...@@ -201,20 +203,21 @@ class LFilePicker { ...@@ -201,20 +203,21 @@ class LFilePicker {
* @param fileName * @param fileName
* @return * @return
*/ */
fun withFileName(fileName: String?): LFilePicker { public LFilePicker withFileName(String fileName) {
mFileName = fileName this.mFileName = fileName;
return this return this;
} }
/** /**
* 设置初始显示路径 * 设置初始显示路径
* *
* @param path * @param path
* @return * @return
*/ */
fun withStartPath(path: String?): LFilePicker { public LFilePicker withStartPath(String path) {
mStartPath = path this.mStartPath = path;
return this return this;
} }
/** /**
...@@ -223,9 +226,9 @@ class LFilePicker { ...@@ -223,9 +226,9 @@ class LFilePicker {
* @param chooseMode * @param chooseMode
* @return * @return
*/ */
fun withChooseMode(chooseMode: Boolean): LFilePicker { public LFilePicker withChooseMode(boolean chooseMode) {
mChooseMode = chooseMode this.mChooseMode = chooseMode;
return this return this;
} }
/** /**
...@@ -234,9 +237,9 @@ class LFilePicker { ...@@ -234,9 +237,9 @@ class LFilePicker {
* @param isGreater true:大于 ;false:小于,同时包含指定大小在内 * @param isGreater true:大于 ;false:小于,同时包含指定大小在内
* @return * @return
*/ */
fun withIsGreater(isGreater: Boolean): LFilePicker { public LFilePicker withIsGreater(boolean isGreater) {
mIsGreater = isGreater this.mIsGreater = isGreater;
return this return this;
} }
/** /**
...@@ -245,57 +248,59 @@ class LFilePicker { ...@@ -245,57 +248,59 @@ class LFilePicker {
* @param fileSize * @param fileSize
* @return * @return
*/ */
fun withFileSize(fileSize: Long): LFilePicker { public LFilePicker withFileSize(long fileSize) {
mFileSize = fileSize this.mFileSize = fileSize;
return this return this;
} }
fun start() { public void start() {
if (mActivity == null && mFragment == null) { if (mActivity == null && mFragment == null) {
throw RuntimeException("You must pass Activity or Fragment by withActivity or withFragment or withSupportFragment method") throw new RuntimeException("You must pass Activity or Fragment by withActivity or withFragment or withSupportFragment method");
} }
val intent = initIntent() Intent intent = initIntent();
val bundle = bundle Bundle bundle = getBundle();
intent.putExtras(bundle) intent.putExtras(bundle);
if (mActivity != null) { if (mActivity != null) {
mActivity!!.startActivityForResult(intent, mRequestCode) mActivity.startActivityForResult(intent, mRequestCode);
} else { } else {
mFragment!!.startActivityForResult(intent, mRequestCode) mFragment.startActivityForResult(intent, mRequestCode);
} }
} }
private fun initIntent(): Intent {
val intent: Intent private Intent initIntent() {
intent = if (mActivity != null) { Intent intent;
Intent(mActivity, LFilePickerActivity::class.java) if (mActivity != null) {
intent = new Intent(mActivity, LFilePickerActivity.class);
} else { } else {
Intent(mFragment!!.activity, LFilePickerActivity::class.java) intent = new Intent(mFragment.getActivity(), LFilePickerActivity.class);
} }
return intent return intent;
} }
private val bundle: Bundle @NonNull
private get() { private Bundle getBundle() {
val paramEntity = ParamEntity() ParamEntity paramEntity = new ParamEntity();
paramEntity.title = mTitle paramEntity.setTitle(mTitle);
paramEntity.theme = theme paramEntity.setTheme(theme);
paramEntity.titleColor = mTitleColor paramEntity.setTitleColor(mTitleColor);
paramEntity.titleStyle = mTitleStyle paramEntity.setTitleStyle(mTitleStyle);
paramEntity.backgroundColor = mBackgroundColor paramEntity.setBackgroundColor(mBackgroundColor);
paramEntity.backIcon = mBackStyle paramEntity.setBackIcon(mBackStyle);
paramEntity.isMutilyMode = mMutilyMode paramEntity.setMutilyMode(mMutilyMode);
paramEntity.addText = mAddText paramEntity.setAddText(mAddText);
paramEntity.iconStyle = mIconStyle paramEntity.setIconStyle(mIconStyle);
paramEntity.fileTypes = mFileTypes paramEntity.setFileTypes(mFileTypes);
paramEntity.notFoundFiles = mNotFoundFiles paramEntity.setNotFoundFiles(mNotFoundFiles);
paramEntity.maxNum = mMaxNum paramEntity.setMaxNum(mMaxNum);
paramEntity.isChooseMode = mChooseMode paramEntity.setChooseMode(mChooseMode);
paramEntity.path = mStartPath paramEntity.setPath(mStartPath);
paramEntity.fileSize = mFileSize paramEntity.setFileSize(mFileSize);
paramEntity.fileName = mFileName paramEntity.setFileName(mFileName);
paramEntity.isGreater = mIsGreater paramEntity.setGreater(mIsGreater);
val bundle = Bundle() Bundle bundle = new Bundle();
bundle.putSerializable("param", paramEntity) bundle.putSerializable("param", paramEntity);
return bundle return bundle;
} }
} }
package com.miya.fastcashier.log;
import java.io.Serializable;
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
public class ParamEntity implements Serializable {
private String title;
private String titleColor;
private int titleStyle ;
private int theme ;
private String backgroundColor;
private int backIcon;
private boolean mutilyMode;
private String addText;
private int iconStyle;
private String[] fileTypes;
private String notFoundFiles;
private int maxNum;
private boolean chooseMode = true;
private String path;
private long fileSize;
private boolean isGreater;
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Deprecated
public String getTitleColor() {
return titleColor;
}
@Deprecated
public void setTitleColor(String titleColor) {
this.titleColor = titleColor;
}
public int getTheme() {
return theme;
}
public void setTheme(int theme) {
this.theme = theme;
}
public int getTitleStyle() {
return titleStyle;
}
public void setTitleStyle(int titleStyle) {
this.titleStyle = titleStyle;
}
public String getBackgroundColor() {
return backgroundColor;
}
public void setBackgroundColor(String backgroundColor) {
this.backgroundColor = backgroundColor;
}
public boolean isMutilyMode() {
return mutilyMode;
}
public void setMutilyMode(boolean mutilyMode) {
this.mutilyMode = mutilyMode;
}
public int getBackIcon() {
return backIcon;
}
public void setBackIcon(int backIcon) {
this.backIcon = backIcon;
}
public String getAddText() {
return addText;
}
public void setAddText(String addText) {
this.addText = addText;
}
public int getIconStyle() {
return iconStyle;
}
public void setIconStyle(int iconStyle) {
this.iconStyle = iconStyle;
}
public String[] getFileTypes() {
return fileTypes;
}
public void setFileTypes(String[] fileTypes) {
this.fileTypes = fileTypes;
}
public String getNotFoundFiles() {
return notFoundFiles;
}
public void setNotFoundFiles(String notFoundFiles) {
this.notFoundFiles = notFoundFiles;
}
public int getMaxNum() {
return maxNum;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
}
public boolean isChooseMode() {
return chooseMode;
}
public void setChooseMode(boolean chooseMode) {
this.chooseMode = chooseMode;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public long getFileSize() {
return fileSize;
}
public void setFileSize(long fileSize) {
this.fileSize = fileSize;
}
public boolean isGreater() {
return isGreater;
}
public void setGreater(boolean greater) {
isGreater = greater;
}
}
package com.miya.fastcashier.log
import java.io.Serializable
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
class ParamEntity : Serializable {
var title: String? = null
@get:Deprecated("")
@set:Deprecated("")
var titleColor: String? = null
var titleStyle = 0
var theme = 0
var backgroundColor: String? = null
var backIcon = 0
var isMutilyMode = false
var addText: String? = null
var iconStyle = 0
var fileTypes: Array<String>? = null
var notFoundFiles: String? = null
var maxNum = 0
var isChooseMode = true
var path: String? = null
var fileSize: Long = 0
var isGreater = false
var fileName: String? = null
}
\ No newline at end of file
package com.miya.fastcashier.log;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import com.miya.fastcashier.BuildConfig;
import com.miya.fastcashier.R;
import com.miya.fastcashier.beans.SelfCashierAccountInfo;
import com.miya.fastcashier.databinding.DialogSystemParameterBinding;
import com.miya.fastcashier.net.ApiConfig;
import com.miya.fastcashier.service.AccountService;
import com.miya.fastcashier.utils.BaseFunctionKt;
import com.miya.print.PrinterManager;
import androidx.annotation.NonNull;
public class SystemParameterDialog extends Dialog {
private DialogSystemParameterBinding viewBinding;
public SystemParameterDialog(@NonNull Context context) {
super(context, R.style.CommonDialog);
viewBinding = DialogSystemParameterBinding.inflate(getLayoutInflater());
setContentView(viewBinding.getRoot());
setCanceledOnTouchOutside(false);
setCancelable(true);
init();
}
private void init() {
SelfCashierAccountInfo accountInfo = AccountService.INSTANCE.getAccountInfo();
setInfo(viewBinding.tvVersion, BaseFunctionKt.getVersion(getContext()));
setInfo(viewBinding.tvStoreName, accountInfo.getShopInfo().getStoreName());
setInfo(viewBinding.tvStoreNum, accountInfo.getShopInfo().getStoreId());
setInfo(viewBinding.tvMerchantNum, accountInfo.getShopInfo().getHhMerchant());
setInfo(viewBinding.tvPos, accountInfo.getShopInfo().getPosId());
setInfo(viewBinding.tvCashier, accountInfo.getShopInfo().getOperatorId());
setInfo(viewBinding.tvVersionType, "fastCashier_" + BuildConfig.appType);
setInfo(viewBinding.tvEquipment, "sunmi_v2pro");
setInfo(viewBinding.tvServerUrl, ApiConfig.getBaseUrl());
setInfo(viewBinding.tvWifiName, BaseFunctionKt.getWifyName(getContext()));
setInfo(viewBinding.tvNetIp, BaseFunctionKt.getNetIp(getContext()) == null ? "未知" : BaseFunctionKt.getNetIp(getContext()));
setInfo(viewBinding.tvPrintType, PrinterManager.getInstance().getPrinter() == null ?
getContext().getResources().getString(R.string.app_unkown) :
PrinterManager.getInstance().getPrinter().getPrinterName());
setInfo(viewBinding.tvChannel, BuildConfig.CHANNEL);
viewBinding.ivClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
resize();
}
private void setInfo(View view, String info) {
((TextView) view).setText(info);
}
/**
* 设置对话框大小
*
* @param width 宽度,传0表示走默认宽度
* @param height 高度,传0表示走默认高度
*/
public SystemParameterDialog setSize(int width, int height) {
if (width < 0 || height < 0) {
return this;
}
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
if (width != 0 && height != 0) {
layoutParams.width = width;
layoutParams.height = height;
} else if (width == 0 && height != 0) {
layoutParams.height = height;
} else if (width != 0 && height == 0) {
layoutParams.width = width;
}
getWindow().setGravity(Gravity.CENTER);
getWindow().setAttributes(layoutParams);
return this;
}
private void resize() {
this.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
}
}
\ No newline at end of file
package com.miya.fastcashier.log
import android.app.Dialog
import android.content.Context
import com.miya.fastcashier.service.AccountService.getAccountInfo
import com.miya.fastcashier.utils.getVersion
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.beans.SelfCashierAccountInfo
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.net.ApiConfig
import com.miya.print.PrinterManager
import android.widget.TextView
import com.miya.fastcashier.log.SystemParameterDialog
import android.view.WindowManager
import android.view.Gravity
import android.view.View
import com.miya.fastcashier.BuildConfig
import com.miya.fastcashier.databinding.DialogSystemParameterBinding
class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDialog) {
private val viewBinding: DialogSystemParameterBinding
init {
viewBinding = DialogSystemParameterBinding.inflate(
layoutInflater
)
setContentView(viewBinding.root)
setCanceledOnTouchOutside(false)
setCancelable(true)
init()
}
private fun init() {
val accountInfo = getAccountInfo()
setInfo(viewBinding.tvVersion, getVersion(context))
setInfo(viewBinding.tvStoreName, accountInfo!!.shopInfo.storeName)
setInfo(viewBinding.tvStoreNum, accountInfo.shopInfo.storeId)
setInfo(viewBinding.tvMerchantNum, accountInfo.shopInfo.hhMerchant)
setInfo(viewBinding.tvPos, accountInfo.shopInfo.posId)
setInfo(viewBinding.tvCashier, accountInfo.shopInfo.operatorId)
setInfo(viewBinding.tvVersionType, "fastCashier_" + BuildConfig.appType)
setInfo(viewBinding.tvEquipment, "sunmi_v2pro")
setInfo(viewBinding.tvServerUrl, baseUrl)
setInfo(viewBinding.tvWifiName, getWifyName(context))
setInfo(viewBinding.tvNetIp, if (getNetIp(context) == null) "未知" else getNetIp(context))
setInfo(
viewBinding.tvPrintType,
if (PrinterManager.getInstance().printer == null) context.resources.getString(R.string.app_unkown) else PrinterManager.getInstance().printer.printerName
)
setInfo(viewBinding.tvChannel, BuildConfig.CHANNEL)
viewBinding.ivClose.setOnClickListener(View.OnClickListener { dismiss() })
resize()
}
private fun setInfo(view: View, info: String?) {
(view as TextView).text = info
}
/**
* 设置对话框大小
*
* @param width 宽度,传0表示走默认宽度
* @param height 高度,传0表示走默认高度
*/
fun setSize(width: Int, height: Int): SystemParameterDialog {
if (width < 0 || height < 0) {
return this
}
val layoutParams = window!!.attributes
if (width != 0 && height != 0) {
layoutParams.width = width
layoutParams.height = height
} else if (width == 0 && height != 0) {
layoutParams.height = height
} else if (width != 0 && height == 0) {
layoutParams.width = width
}
window!!.setGravity(Gravity.CENTER)
window!!.attributes = layoutParams
return this
}
private fun resize() {
this.window!!.setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT
)
}
}
\ 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