Ver Fonte

指纹、下拉图标替换;删除冗余代码;SelectableInput同步物资柜项目调整;添加异常上报页

Frankensteinly há 8 meses atrás
pai
commit
a334ac9fc6

+ 3 - 3
app/src/main/java/com/grkj/iscs/presentation/PresentationActivity.kt

@@ -32,7 +32,7 @@ class PresentationActivity :
     override fun initView() {
         cardRfid = intent.getStringExtra("card")
 
-        mBinding?.siSop?.mOptionList = PresentationManager.mSopList.stream().map { it.sop }.collect(Collectors.toList())
+        mBinding?.siSop?.setOptionList(PresentationManager.mSopList.stream().map { it.sop }.collect(Collectors.toList()))
         mBinding?.siSop?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
             override fun onSelect(str: String?, index: Int) {
                 mSelectedSopIdx = index
@@ -46,8 +46,8 @@ class PresentationActivity :
             }
         })
 
-        mBinding?.siPersonLock?.mOptionList = PresentationManager.mLockerList.map { it.name } as MutableList
-        mBinding?.siPersonSafety?.mOptionList = PresentationManager.mSafetyList
+        mBinding?.siPersonLock?.setOptionList(PresentationManager.mLockerList.map { it.name } as MutableList)
+        mBinding?.siPersonSafety?.setOptionList(PresentationManager.mSafetyList)
 
         mBinding?.confirm?.setOnClickListener {
             confirm()

+ 5 - 0
app/src/main/java/com/grkj/iscs/util/CommonUtils.kt

@@ -23,6 +23,11 @@ object CommonUtils {
         return (dpValue * density + 0.5f).toInt()
     }
 
+    fun px2dip(pxValue: Float): Float {
+        val density = MyApplication.instance!!.resources.displayMetrics.density
+        return pxValue / density
+    }
+
     fun checkPermission(activity: AppCompatActivity, permissions: Array<String>, callBack: () -> Unit) {
         val isPermission = EasyPermissions.hasPermissions(activity, *permissions)
         if (isPermission) {

+ 2 - 2
app/src/main/java/com/grkj/iscs/view/activity/CreateTicketActivity.kt

@@ -84,7 +84,7 @@ class CreateTicketActivity : BaseMvpActivity<ICreateTicketView, CreateTicketPres
     }
 
     override fun showSopList(sopList: MutableList<SopPageRespVO.Record>) {
-        mBinding?.siSop?.mOptionList = sopList.stream().map { it.sopName }.collect(Collectors.toList())
+        mBinding?.siSop?.setOptionList(sopList.stream().map { it.sopName }.collect(Collectors.toList()))
         mBinding?.siSop?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
             override fun onSelect(str: String?, index: Int) {
                 presenter?.getSopInfo(sopList[index].sopId) {
@@ -102,7 +102,7 @@ class CreateTicketActivity : BaseMvpActivity<ICreateTicketView, CreateTicketPres
 
     override fun updateLockerList(lockerList: List<String>?) {
         lockerList?.let {
-            mBinding?.siPersonLock?.mOptionList = it as MutableList<String>
+            mBinding?.siPersonLock?.setOptionList(it as MutableList<String>)
         }
     }
 

+ 2 - 0
app/src/main/java/com/grkj/iscs/view/activity/HomeActivity.kt

@@ -21,6 +21,7 @@ import com.grkj.iscs.view.adapter.MenuAdapter
 import com.grkj.iscs.view.base.BaseFragment
 import com.grkj.iscs.view.base.BaseMvpActivity
 import com.grkj.iscs.view.fragment.DockTestFragment
+import com.grkj.iscs.view.fragment.ExceptionReportFragment
 import com.grkj.iscs.view.fragment.JobManagementFragment
 import com.grkj.iscs.view.fragment.SettingFragment
 import com.grkj.iscs.view.fragment.SystemSettingFragment
@@ -61,6 +62,7 @@ class HomeActivity : BaseMvpActivity<IHomeView, HomePresenter, ActivityHomeBindi
                 mMenuList.add(Menu(getString(R.string.system_setting), R.mipmap.menu_icon_sys_setting, SystemSettingFragment()))
             }
         }
+        mMenuList.add(Menu(getString(R.string.exception_report), R.mipmap.exception_handle, ExceptionReportFragment()))
         mMenuList.add(Menu(getString(R.string.settings), R.mipmap.settings, SettingFragment()))
 
         mBinding?.itemSetting?.ivIcon?.setImageResource(R.mipmap.settings)

+ 1 - 1
app/src/main/java/com/grkj/iscs/view/activity/test/WidgetTestActivity.kt

@@ -15,7 +15,7 @@ class WidgetTestActivity : BaseActivity<ActivityWidgetTestBinding>() {
         get() = ActivityWidgetTestBinding.inflate(layoutInflater)
 
     override fun initView() {
-        mBinding?.siTest?.mOptionList = mutableListOf("1", "2", "3")
+        mBinding?.siTest?.setOptionList(mutableListOf("1", "2", "3"))
         mBinding?.siTest?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
             override fun onSelect(str: String?, index: Int) {
                 ToastUtils.tip("$str - $index")

+ 23 - 0
app/src/main/java/com/grkj/iscs/view/fragment/ExceptionReportFragment.kt

@@ -0,0 +1,23 @@
+package com.grkj.iscs.view.fragment
+
+import com.grkj.iscs.databinding.FragmentExceptionReportBinding
+import com.grkj.iscs.view.base.BaseMvpFragment
+import com.grkj.iscs.view.iview.IExceptionReportView
+import com.grkj.iscs.view.presenter.ExceptionReportPresenter
+
+/**
+ * 异常上报页
+ */
+class ExceptionReportFragment : BaseMvpFragment<IExceptionReportView, ExceptionReportPresenter, FragmentExceptionReportBinding>() {
+
+    override val viewBinding: FragmentExceptionReportBinding
+        get() = FragmentExceptionReportBinding.inflate(layoutInflater)
+
+    override fun initView() {
+
+    }
+
+    override fun initPresenter(): ExceptionReportPresenter {
+        return ExceptionReportPresenter()
+    }
+}

+ 0 - 1
app/src/main/java/com/grkj/iscs/view/fragment/JobProgressFragment.kt

@@ -67,7 +67,6 @@ class JobProgressFragment(val goBack: () -> Unit) :
             }
 
         mBinding?.cbAction?.debounce(2000) {
-            println("haha : $mStep")
             if (mStep == 4) {
                 presenter?.handleLockProcess(mPageChangeBO?.ticketId!!)
             } else if (mStep == 7) {

+ 6 - 0
app/src/main/java/com/grkj/iscs/view/iview/IExceptionReportView.kt

@@ -0,0 +1,6 @@
+package com.grkj.iscs.view.iview
+
+import com.grkj.iscs.view.base.IView
+
+interface IExceptionReportView : IView {
+}

+ 7 - 0
app/src/main/java/com/grkj/iscs/view/presenter/ExceptionReportPresenter.kt

@@ -0,0 +1,7 @@
+package com.grkj.iscs.view.presenter
+
+import com.grkj.iscs.view.base.BasePresenter
+import com.grkj.iscs.view.iview.IExceptionReportView
+
+class ExceptionReportPresenter : BasePresenter<IExceptionReportView>() {
+}

+ 142 - 32
app/src/main/java/com/grkj/iscs/view/widget/SelectableInput.kt

@@ -1,7 +1,10 @@
 package com.grkj.iscs.view.widget
 
 import android.content.Context
+import android.text.Editable
+import android.text.TextWatcher
 import android.util.AttributeSet
+import android.view.Gravity
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
@@ -12,24 +15,30 @@ import androidx.appcompat.content.res.AppCompatResources
 import com.grkj.iscs.R
 import com.grkj.iscs.databinding.LayoutSelectableInputBinding
 import com.grkj.iscs.databinding.LayoutSelectableinputSpinnerBinding
+import com.grkj.iscs.util.CommonUtils
+import com.manu.mdatepicker.MDatePicker
 import com.zhy.adapter.recyclerview.CommonAdapter
 import com.zhy.adapter.recyclerview.base.ViewHolder
-
+import java.text.SimpleDateFormat
+import java.util.Date
 
 class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLayout(ctx, attrs) {
 
     companion object {
         const val MODE_INPUT = 0
         const val MODE_SELECT = 1
+        const val MODE_DATE = 2
     }
 
     private var mBinding: LayoutSelectableInputBinding
     private var mDropdownView: View? = null
     private var mPopWindow: PopupWindow? = null
-    var mOptionList = mutableListOf<String>()
+    private val mOptionList = mutableListOf<String>()
     private var isSkipListener: Boolean = true
     private var mSelectListener: OnSpinnerSelectListener? = null
+    private var mTextChangeListener: OnTextChangeListener? = null
     var mSelectIdx: Int? = null
+    private var mMode: Int = MODE_INPUT
 
     init {
         val root = View.inflate(ctx, R.layout.layout_selectable_input, this)
@@ -37,53 +46,141 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
 
         val attrSet = ctx.obtainStyledAttributes(attrs, R.styleable.SelectableInput)
 
-        val mode = attrSet.getInt(R.styleable.SelectableInput_mode, 0)
-        setMode(mode)
-
         val isRequired = attrSet.getBoolean(R.styleable.SelectableInput_required, false)
         mBinding.tvPrefix.visibility = if (isRequired) View.VISIBLE else View.INVISIBLE
 
         val isEnabled = attrSet.getBoolean(R.styleable.SelectableInput_enabled, true)
         mBinding.et.isEnabled = isEnabled
 
+        val mode = attrSet.getInt(R.styleable.SelectableInput_mode, MODE_INPUT)
+        setMode(mode)
+
         mBinding.tvName.text = attrSet.getString(R.styleable.SelectableInput_name)
         mBinding.et.hint = attrSet.getString(R.styleable.SelectableInput_edittext_hint)
 
+        val textSize = attrSet.getDimension(R.styleable.SelectableInput_text_size, -1f)
+        if (textSize != -1f) {
+            mBinding.tvPrefix.textSize = CommonUtils.px2dip(textSize)
+            mBinding.tvName.textSize = CommonUtils.px2dip(textSize)
+            mBinding.et.textSize = CommonUtils.px2dip(textSize)
+        }
+
+        val editWidth = attrSet.getDimensionPixelSize(R.styleable.SelectableInput_edit_width, -1)
+        if (editWidth != -1) {
+            mBinding.et.width = editWidth
+        }
+
+        val editHeight = attrSet.getDimensionPixelSize(R.styleable.SelectableInput_edit_height, -1)
+        if (editHeight != -1) {
+            mBinding.et.height = editHeight
+            mBinding.et.gravity = Gravity.LEFT
+        }
+
         attrSet.recycle()
     }
 
+    fun setEnableStatus(isEnabled: Boolean) {
+        mBinding.et.isEnabled = isEnabled
+        when (mMode) {
+            // 选择模式、日期模式
+            MODE_SELECT, MODE_DATE -> {
+                mBinding.et.background = if (mBinding.et.isEnabled) {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_bg)
+                } else {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_disabled_bg)
+                }
+            }
+            // 输入模式
+            MODE_INPUT -> {
+                mBinding.et.background = if (mBinding.et.isEnabled) {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_text_bg)
+                } else {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_text_disabled_bg)
+                }
+            }
+        }
+    }
+
     private fun setMode(mode: Int) {
-        if (mode == MODE_SELECT) {
-            mBinding.et.background = AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_bg)
-//            mBinding.et.isEnabled = false
-            mBinding.et.inputType = 0
-
-//            btnDropdown.visibility = View.VISIBLE
-            mBinding.et.setOnClickListener {
-                if (mOptionList.isNotEmpty()) {
-                    showDropdown()
+        when (mode) {
+            // 选择模式
+            MODE_SELECT -> {
+                mMode = MODE_SELECT
+
+                mBinding.et.background = if (mBinding.et.isEnabled) {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_bg)
+                } else {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_disabled_bg)
+                }
+
+                mBinding.et.inputType = 0
+
+                mBinding.et.setOnClickListener {
+                    if (mOptionList.isNotEmpty()) {
+                        showDropdown()
+                    }
+                }
+
+                mBinding.et.setOnTouchListener { view, _ ->
+                    view.requestFocus()
+                    return@setOnTouchListener false
                 }
             }
+            // 输入模式
+            MODE_INPUT -> {
+                mMode = MODE_INPUT
+
+                mBinding.et.background = if (mBinding.et.isEnabled) {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_text_bg)
+                } else {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_text_disabled_bg)
+                }
+
+                val textWatcher = object : TextWatcher {
+                    override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
+
+                    override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
+                        if (mBinding.et.hasFocus()) {
+                            mTextChangeListener?.onTextChange(p0.toString())
+                        }
+                    }
+
+                    override fun afterTextChanged(p0: Editable?) {}
+                }
 
-            mBinding.et.setOnTouchListener { view, _ ->
-                view.requestFocus()
-                return@setOnTouchListener false
+                mBinding.et.setOnFocusChangeListener { view, b ->
+                    if (b) {
+                        mBinding.et.addTextChangedListener(textWatcher)
+                    } else {
+                        mBinding.et.removeTextChangedListener(textWatcher)
+                        val imm = ctx.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+                        imm.hideSoftInputFromWindow(view.windowToken, 0)
+                    }
+                }
             }
-        } else {
-
-            mBinding.et.background = AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_text_bg)
-
-//            btnDropdown.visibility = View.GONE
-//            btnDropdown.setOnClickListener(null)
-//            clContainer.setOnClickListener {
-//                editText.requestFocus()
-//                val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-//                imm.showSoftInput(editText, 0)
-//            }
-            mBinding.et.setOnFocusChangeListener { view, b ->
-                if (!b) {
-                    val imm = ctx.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-                    imm.hideSoftInputFromWindow(view.windowToken, 0)
+            // 日期模式
+            else -> {
+                mMode = MODE_DATE
+
+                mBinding.et.background = if (mBinding.et.isEnabled) {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_bg)
+                } else {
+                    AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_disabled_bg)
+                }
+
+                mBinding.et.inputType = 0
+
+                mBinding.et.setOnClickListener {
+                    MDatePicker.create(ctx)
+                        .setCanceledTouchOutside(true)
+                        .setGravity(Gravity.CENTER)
+                        .setSupportTime(true)
+                        .setTwelveHour(false)
+                        .setOnDateResultListener {
+                            setText(SimpleDateFormat("yyyy-MM-dd").format(Date(it)))
+                            mTextChangeListener?.onTextChange(getText())
+                        }
+                        .build().show()
                 }
             }
         }
@@ -102,6 +199,11 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
         return mBinding.et.text.toString()
     }
 
+    fun setOptionList(list: MutableList<String>) {
+        mOptionList.clear()
+        mOptionList.addAll(list)
+    }
+
     private fun showDropdown() {
         mDropdownView?:let {
             mDropdownView = LayoutInflater.from(ctx).inflate(R.layout.layout_selectableinput_spinner, null)
@@ -136,7 +238,15 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
         mSelectListener = onSpinnerSelectListener
     }
 
+    fun setOnTextChangeListener(onTextChangeListener: OnTextChangeListener) {
+        mTextChangeListener = onTextChangeListener
+    }
+
     interface OnSpinnerSelectListener {
         fun onSelect(str: String?, index: Int)
     }
+
+    interface OnTextChangeListener {
+        fun onTextChange(str: String?)
+    }
 }

+ 15 - 0
app/src/main/res/drawable/selectable_input_spinner_disabled_bg.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/common_bg_white_60" />
+            <corners android:radius="@dimen/selectable_input_radius" />
+        </shape>
+    </item>
+    <item
+        android:width="@dimen/selectable_input_spinner_arrow_size"
+        android:height="@dimen/selectable_input_spinner_arrow_size"
+        android:drawable="@mipmap/ic_dropdown"
+        android:gravity="end|center_vertical"
+        android:right="@dimen/selectable_input_spinner_arrow_margin" />
+</layer-list>

+ 6 - 0
app/src/main/res/drawable/selectable_input_text_disabled_bg.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <solid android:color="@color/common_bg_white_60" />
+    <corners android:radius="@dimen/selectable_input_radius" />
+</shape>

+ 63 - 0
app/src/main/res/layout/fragment_exception_report.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    tools:context=".view.fragment.ExceptionReportFragment">
+
+    <com.grkj.iscs.view.widget.CommonBtn
+        android:id="@+id/cb_open"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
+        android:layout_marginRight="@dimen/common_spacing"
+        app:btn_bg="@drawable/common_btn_red_bg"
+        app:btn_name="@string/submit" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_above="@id/cb_open"
+        android:layout_marginVertical="@dimen/common_spacing"
+        android:background="@drawable/item_rv_technology_sop_bg_normal"
+        android:orientation="vertical"
+        android:padding="@dimen/common_spacing">
+
+        <com.grkj.iscs.view.widget.SelectableInput
+            android:id="@+id/ci_type"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginVertical="@dimen/common_spacing"
+            app:edit_width="200dp"
+            app:edittext_hint="@string/exception_report_type_hint"
+            app:mode="select"
+            app:name="@string/exception_report_type"
+            app:required="true"
+            app:text_size="@dimen/common_text_size" />
+
+        <com.grkj.iscs.view.widget.SelectableInput
+            android:id="@+id/ci_level"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginVertical="@dimen/common_spacing"
+            app:edit_width="200dp"
+            app:edittext_hint="@string/exception_report_level_hint"
+            app:mode="select"
+            app:name="@string/exception_report_level"
+            app:required="true"
+            app:text_size="@dimen/common_text_size" />
+
+        <com.grkj.iscs.view.widget.SelectableInput
+            android:id="@+id/ci_description"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginVertical="@dimen/common_spacing"
+            app:edit_height="200dp"
+            app:mode="input"
+            app:name="@string/exception_report_description"
+            app:required="false"
+            app:text_size="@dimen/common_text_size" />
+    </LinearLayout>
+</RelativeLayout>

BIN
app/src/main/res/mipmap/exception_handle.png


BIN
app/src/main/res/mipmap/ic_dropdown.png


BIN
app/src/main/res/mipmap/login_fingerprint.png


+ 3 - 0
app/src/main/res/values/attrs.xml

@@ -14,6 +14,9 @@
         <attr name="spinner_hint" format="string" />
         <attr name="edittext_hint" format="string" />
         <attr name="enabled" format="boolean" />
+        <attr name="edit_width" format="dimension" />
+        <attr name="edit_height" format="dimension" />
+        <attr name="text_size" format="dimension" />
     </declare-styleable>
 
     <declare-styleable name="CommonBtn">

+ 7 - 8
app/src/main/res/values/strings.xml

@@ -207,12 +207,11 @@
     <string name="can_not_do_colock_action">当前无法进行共锁相关操作</string>
     <string name="key_is_in_failure_mode">钥匙处于故障模式</string>
     <string name="uncaught_exception_tip">很抱歉,程序出现异常,即将退出</string>
-
-    <!-- 物资柜 -->
-    <string name="material_management_system">物资管理系统</string>
-    <string name="material_management">物资管理</string>
-    <string name="material_fetch_return">物资取还</string>
-    <string name="material_instruction">物资使用说明</string>
-    <string name="material_inspection">物资检查</string>
-    <string name="material_replacement">物资更换</string>
+    <string name="submit">提交</string>
+    <string name="exception_report">异常上报</string>
+    <string name="exception_report_type">异常类型:</string>
+    <string name="exception_report_type_hint">请选择异常类型</string>
+    <string name="exception_report_level">严重等级:</string>
+    <string name="exception_report_level_hint">请选择严重等级</string>
+    <string name="exception_report_description">异常描述:</string>
 </resources>