فهرست منبع

日历筛选空间

everywindchase 4 ماه پیش
والد
کامیت
ca5f1642bf

+ 1 - 0
app/build.gradle

@@ -83,6 +83,7 @@ dependencies {
     implementation libs.androidx.navigation.ui.ktx
     implementation libs.koin.android
     implementation  libs.preference
+    implementation  libs.calender
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test.ext:junit:1.1.5'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

+ 63 - 9
app/src/main/java/jx/cn/escort/ui/activity/LoginActivity.kt

@@ -1,20 +1,18 @@
 package jx.cn.escort.ui.activity
 
 
-import android.annotation.SuppressLint
+
+
 import android.content.Context
 import android.content.SharedPreferences
 import android.os.Bundle
-import android.view.MotionEvent
-import android.view.View
 import android.view.animation.Animation
-import android.view.animation.LinearInterpolator
 import android.view.animation.RotateAnimation
-import android.view.animation.ScaleAnimation
 import androidx.appcompat.app.AppCompatActivity
 import androidx.lifecycle.lifecycleScope
 import com.xuexiang.xui.XUI
-import jx.cn.escort.R
+import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
+import com.xuexiang.xui.widget.toast.XToast
 import jx.cn.escort.databinding.ActivityLoginBinding
 import jx.cn.escort.extension.ExtensionBinding.Companion.binding
 import jx.cn.escort.utils.ActivityUtils
@@ -24,7 +22,7 @@ import org.koin.core.component.KoinComponent
 import org.koin.core.component.inject
 
 
-class LoginActivity : AppCompatActivity(), KoinComponent {
+ class LoginActivity : AppCompatActivity(), KoinComponent {
 
 
     private val mContext: Context   by  inject()
@@ -37,7 +35,6 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
 
 
 
-
     override fun onCreate(savedInstanceState: Bundle?) {
         XUI.initTheme(this@LoginActivity);
         super.onCreate(savedInstanceState)
@@ -46,10 +43,46 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
 
 
         mBinding.btnLoginAction.setOnClickListener {
+
+            val account: String = mBinding.loginAccount.text.toString().trim()
+            val password: String = mBinding.loginPassword.text.toString().trim()
+
+            if (account.isBlank()) {
+                XToast.info(this@LoginActivity, "请输入账号").show();
+                return@setOnClickListener
+            }
+            if (password.isBlank()) {
+                XToast.info(this@LoginActivity, "请输入密码").show();
+                return@setOnClickListener
+            }
+
+            var isValidateAccount=false
+            accountRegex.forEach{ it->
+                if(!account.matches(it)){
+                    isValidateAccount=true
+                }
+            }
+
+            if(!isValidateAccount) {
+                XToast.info(this@LoginActivity, "未开户").show();
+                return@setOnClickListener
+            }
+
+            if(password.length < 6) {
+                XToast.info(this@LoginActivity, "密码小于6位").show();
+                return@setOnClickListener
+            }
+
+            if(!password.equals("123456", ignoreCase = true)) {
+                XToast.info(this@LoginActivity, "密码不正确").show();
+                return@setOnClickListener
+            }
+
+
             lifecycleScope.launch {
                 mBinding.loginTitle.text = "加载中..."
                 var density=resources.displayMetrics.density
-                var drawable=resources.getDrawableForDensity(R.drawable.ic_login_loding,65*density.hashCode(),null)
+                var drawable=resources.getDrawableForDensity(jx.cn.escort.R.drawable.ic_login_loding,65*density.hashCode(),null)
 
                 mBinding.btnLoginAction.icon=drawable
 
@@ -61,6 +94,13 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
 
                 delay(1000L)
                 defaultSharedPreferences.edit().putString("isAuth", "是").apply()
+                defaultSharedPreferences.edit().putString("account", account).apply()
+                defaultSharedPreferences.edit().putString("password", password).apply()
+                if(account.matches(accountRegex[0])){
+                    defaultSharedPreferences.edit().putString("role", "网点授权人员").apply()
+                }else{
+                    defaultSharedPreferences.edit().putString("role", "押运授权人员").apply()
+                }
                 ActivityUtils.startActivity(this@LoginActivity,MainActivity::class.java)
                 finish()
 
@@ -69,8 +109,22 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
     }
 
 
+     companion object {
+         private val accountRegex:List<Regex>
+             get() {
+                 return  mutableListOf<Regex>(
+                     Regex("^BOfficer\\d+"),
+                     Regex("^EOfficer\\d+")
+                 )
+             }
+
+         @JvmStatic fun toAccountRegex():List<Regex>{
+
+                 return accountRegex;
+             }
 
 
+     }
 
 
 

+ 7 - 5
app/src/main/java/jx/cn/escort/ui/activity/MainActivity.kt

@@ -6,6 +6,7 @@ import android.content.SharedPreferences
 import android.content.res.ColorStateList
 import android.graphics.Color
 import android.os.Bundle
+import android.view.ContextThemeWrapper
 import android.view.MenuItem
 import android.view.View
 import android.view.ViewGroup
@@ -56,7 +57,9 @@ class MainActivity : AppCompatActivity(), KoinComponent {
 
         logoutView.setOnClickListener(object:View.OnClickListener{
             override fun onClick(v: View?) {
-                defaultSharedPreferences.edit().remove("isAuth").apply()
+                var editor=defaultSharedPreferences.edit()
+                editor.clear()
+                editor.apply()
                 ActivityUtils.startActivity(this@MainActivity,LoginActivity::class.java);
                 finish()
             }
@@ -97,7 +100,7 @@ class MainActivity : AppCompatActivity(), KoinComponent {
                 when(id){
                    R.id.index-> {
 
-                       switchFragment(BaseNavFragment(R.layout.fragment_index, context = baseContext),item)
+                       switchFragment(BaseNavFragment(R.layout.fragment_index, context = this@MainActivity),item)
 
 
                    }
@@ -116,11 +119,10 @@ class MainActivity : AppCompatActivity(), KoinComponent {
 //                       )
                         fragmentContainerView.requestLayout()
 
-
-                        switchFragment(BaseNavFragment(R.layout.fragment_tasks, context = baseContext),item)
+                        switchFragment(BaseNavFragment(R.layout.fragment_tasks, context = this@MainActivity),item)
                     }
                     R.id.mine->{
-                        switchFragment(BaseNavFragment(R.layout.fragment_mine,context = baseContext),item)
+                        switchFragment(BaseNavFragment(R.layout.fragment_mine,context = this@MainActivity),item)
                     }
                 }
 

+ 75 - 10
app/src/main/java/jx/cn/escort/ui/fragment/BaseNavFragment.kt

@@ -2,30 +2,44 @@ package jx.cn.escort.ui.fragment
 
 
 
+
 import android.content.Context
+import android.content.SharedPreferences
+import android.graphics.Color
 import android.os.Bundle
+import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
+import androidx.appcompat.widget.AppCompatTextView
 import androidx.fragment.app.Fragment
-import androidx.recyclerview.widget.GridLayoutManager
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
+import com.necer.calendar.Miui9Calendar
+import com.necer.listener.OnCalendarChangedListener
+import com.xuexiang.xui.widget.actionbar.TitleBar
+import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
 import jx.cn.escort.R
 import jx.cn.escort.adapter.IndexRecycleAdapter
 import jx.cn.escort.beans.TaskData
+import jx.cn.escort.ui.activity.LoginActivity
+import org.koin.core.component.KoinComponent
+import org.koin.core.component.inject
+import java.text.SimpleDateFormat
+import java.util.*
+
 
-class BaseNavFragment(name:Int,context: Context?):Fragment() {
+class BaseNavFragment(name:Int,context: Context?):Fragment(),KoinComponent {
     private var name: Int? = null
     private var context: Context? = null
-
+    private val mContext: Context   by  inject()
     init {
         this.name=name
         this.context=context
 
     }
 
-
+    private val defaultSharedPreferences: SharedPreferences = androidx.preference.PreferenceManager.getDefaultSharedPreferences(mContext)
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
         if(null!=name){
@@ -33,6 +47,8 @@ class BaseNavFragment(name:Int,context: Context?):Fragment() {
 
                val view:View=inflater.inflate(name!!,container,false)
                 val recycle=view.findViewById<RecyclerView>(R.id.tasks_recycle)
+                var divideTitle=view.findViewById<TitleBar>(R.id.divide_title)
+                var account=defaultSharedPreferences.getString("account","")
                 var layoutManager=LinearLayoutManager(context)
                 recycle.layoutManager=layoutManager
                 var lines=mutableListOf<TaskData>()
@@ -41,6 +57,54 @@ class BaseNavFragment(name:Int,context: Context?):Fragment() {
                 }
                 var indexRecycleAdapter=IndexRecycleAdapter(context,lines)
                 recycle.adapter=indexRecycleAdapter
+
+
+
+
+
+                if(null!=account&&account.isNotBlank()&&account.matches(LoginActivity.toAccountRegex()[0])){
+                    var title="1900-01-01"
+                    try {
+                        var date=Date()
+                        val format = SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE).format(date)
+                        title= format.toString()
+
+                    }catch (e:Exception){
+
+                    }
+
+
+
+                    divideTitle.setLeftText("线路日期: ")
+                    divideTitle.setTitle(title)
+                    divideTitle.setTitleColor(Color.BLACK)
+
+
+                    divideTitle.setOnTitleClickListener(object : View.OnClickListener {
+                        override fun onClick(p0: View?) {
+                            val li = LayoutInflater.from(context)
+                            val inflate = li.inflate(jx.cn.escort.R.layout.layout_task_calendar, null)
+                            var miui9Calendar=inflate.findViewById<Miui9Calendar>(jx.cn.escort.R.id.miui9Calendar)
+                            var textView=inflate.findViewById<AppCompatTextView>(jx.cn.escort.R.id.calendarTitle)
+                            miui9Calendar.setOnCalendarChangedListener(OnCalendarChangedListener { baseCalendar, year, month, localDate, dateChangeBehavior ->
+                                textView.setText(year.toString() + "年" + month + "月" + "   当前页面选中 " + localDate)
+                            })
+
+                            context?.let {
+                            MaterialDialog.Builder(it)
+                                    . customView(inflate, true)
+                                    .title("选择日期")
+                                    .positiveText("确定")
+                                    .negativeText("取消")
+                                .show()
+
+                            }
+
+
+                        }
+                    })
+
+                }
                 return view
             }else{
                 return inflater.inflate(name!!,container,false)
@@ -56,11 +120,12 @@ class BaseNavFragment(name:Int,context: Context?):Fragment() {
 
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
-//        if(null!=name&&view.id==R.id.index_card) {
-////                var indexBanner=view.findViewById<BannerLayout>(R.id.index_banner)
-////                var adapter = IndexBannerAdapter(this@BaseNavFragment.context)
-////                indexBanner.setAdapter(adapter)
-//
-//        }
+
+
     }
+
+
+
+
+
 }

+ 1 - 1
app/src/main/res/layout/activity_login.xml

@@ -56,7 +56,7 @@
 
 
         <com.xuexiang.xui.widget.edittext.PasswordEditText
-                android:id="@+id/input_password"
+                android:id="@+id/login_password"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:gravity="start"

+ 3 - 0
app/src/main/res/layout/fragment_tasks.xml

@@ -39,6 +39,9 @@
     />
 
 
+
+
+
     <com.google.android.material.divider.MaterialDivider
             android:id="@+id/divide_bottom"
             app:dividerThickness="5dp"

+ 1 - 0
app/src/main/res/layout/fragment_tasks_card.xml

@@ -37,6 +37,7 @@
         />
 
 
+
 </jx.cn.escort.ui.widget.TaskCardView>
 
 

+ 35 - 0
app/src/main/res/layout/layout_task_calendar.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:app="http://schemas.android.com/apk/res-auto"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+     >
+
+    <androidx.appcompat.widget.AppCompatTextView
+            android:id="@id/calendarTitle"
+            android:layout_width="match_parent"
+            android:layout_height="60dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintBottom_toTopOf="@id/miui9Calendar"
+            android:paddingTop="20dp"
+    />
+
+    <com.necer.calendar.Miui9Calendar
+            android:id="@+id/miui9Calendar"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/calendarTitle">
+        <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/calendarRecycle"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"/>
+    </com.necer.calendar.Miui9Calendar>
+
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 4 - 1
gradle.properties

@@ -26,4 +26,7 @@ sign.keytool.path=D:\\jdk\\jdk-17.0.10\\bin\\keytool
 sign.keytool.keypass=jxit12
 sign.keytool.storepass=jxit12
 sign.keytool.dname="CN=JXIT,OU=JXIT,O=JXIT,L=JXIT,ST=NANJING,C=CN"
-sign.keytool.appAlias=jx.escort
+sign.keytool.appAlias=jx.escort
+
+
+android.enableJetifier=true

+ 2 - 0
gradle/libs.versions.toml

@@ -15,6 +15,8 @@ xui="com.github.xuexiangjys:XUI:1.2.1"
 glide= 'com.github.bumptech.glide:glide:4.16.0'
 koin-android = "io.insert-koin:koin-android:3.5.6"
 preference= 'androidx.preference:preference:1.2.0'
+calender= 'com.necer.ncalendar:ncalendar:5.0.2'
+
 [plugins]