diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..61a9130 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..5291e4c --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 894f3f9..cbbe561 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,18 +4,16 @@ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..7e340a7 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index fc8ffa2..9decbad 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 763e0c8..06ef6ed 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,9 +30,13 @@ android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true"> + + + android:process=":dexopt" /> (), NetworkUtils.OnNetworkStatus override fun initView() { if (NetworkUtils.isConnected()) { if (!User.isLogin() && User.getUser().token.isEmpty()) { - WebActivity.active(this, "${Config.OA_URL}/login") +// WebActivity.active(this, "${Config.OA_URL}/login") + LoginActivity.active(this) finish() } if (!User.isLogin()) { @@ -174,12 +175,12 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus private fun checkAuto() { isAutoShowLeave = SPUtils.getInstance().getBoolean("auto_show_leave", false) isAutoShowChange = SPUtils.getInstance().getBoolean("auto_show_change", false) -// if (isAutoShowLeave || isAutoShowChange) { -// mHandler.removeCallbacks(runnable) -// mHandler.postDelayed(runnable, 2000) -// } else { -// mHandler.removeCallbacks(runnable) -// } + if (isAutoShowLeave || isAutoShowChange) { + mHandler.removeCallbacks(runnable) + mHandler.postDelayed(runnable, 2000) + } else { + mHandler.removeCallbacks(runnable) + } } //接收消息 @@ -187,10 +188,11 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus fun onMessageEvent(event: AutoSwitchChange) { checkAuto() } + //接收消息 @Subscribe(threadMode = ThreadMode.MAIN) fun onMessageEvent(event: UserLoginEvent) { - if (client?.isOpen == true){ + if (client?.isOpen == true) { client?.close() } client = null @@ -326,48 +328,48 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus } private fun initWs() { - client = - object : WebSocketClient(URI.create(Config.WS_URL), Draft_6455(), null, 10 * 1000) { - override fun onOpen(handshakedata: ServerHandshake?) { - LogUtils.d("WebSocketClient-onOpen", handshakedata) - val user = User.getUser() - val clientInfo = YzxClientInfo() - clientInfo.type = 70 - clientInfo.user_id = user.user_id.toString() - clientInfo.unit_id = user.school_id.toString() - clientInfo.token = user.token - - client?.send(Gson().toJson(clientInfo)) + Thread { + client = + object : WebSocketClient(URI.create(Config.WS_URL), Draft_6455(), null, 10 * 1000) { + override fun onOpen(handshakedata: ServerHandshake?) { + LogUtils.d("WebSocketClient-onOpen", handshakedata) + val user = User.getUser() + val clientInfo = YzxClientInfo() + clientInfo.type = 70 + clientInfo.user_id = user.user_id.toString() + clientInfo.unit_id = user.school_id.toString() + clientInfo.token = user.token + + client?.send(Gson().toJson(clientInfo)) - } + } - override fun onClose(code: Int, reason: String?, remote: Boolean) { - LogUtils.d("WebSocketClient-onClose", code, reason, remote) + override fun onClose(code: Int, reason: String?, remote: Boolean) { + LogUtils.d("WebSocketClient-onClose", code, reason, remote) - } + } - override fun onMessage(message: String?) { - LogUtils.d("WebSocketClient-onMessage", message) - if (message?.startsWith("ECHO:", true) == false) { - viewPager2.post { - wsMessage(message) + override fun onMessage(message: String?) { + LogUtils.d("WebSocketClient-onMessage", message) + if (message?.startsWith("ECHO:", true) == false) { + wsMessage(message) } } - } - override fun onError(ex: Exception?) { - LogUtils.d("WebSocketClient-onError", ex) + override fun onError(ex: Exception?) { + LogUtils.d("WebSocketClient-onError", ex) - } + } + } + try { + client?.connectBlocking() + wsHeart() + } catch (e: InterruptedException) { + e.printStackTrace() + LogUtils.d("WebSocketClient-catch", e) } - try { - client?.connectBlocking() - wsHeart() - } catch (e: InterruptedException) { - e.printStackTrace() - LogUtils.d("WebSocketClient-catch", e) - } + }.start() } private fun wsMessage(msg: String) { @@ -376,13 +378,23 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus val res = gson.fromJson(msg, resultType) if (res.data.student_id > 0) { if (isAutoShowLeave || isAutoShowChange) { - mPresenter?.getLeaveShowIds("${res.data.student_id}") + EventBus.getDefault().post(EventLeaveIds("${res.data.student_id}")) +// mPresenter?.getLeaveShowIds("${res.data.student_id}") } } } + //请假消息 + @Subscribe(threadMode = ThreadMode.MAIN) + fun onMessageEvent(detail: EventLeaveIds) { + mPresenter?.getLeaveShowIds("${detail.ids}") + } + + + private fun wsHeart() { - viewPager2.postDelayed({ + Thread{ + Thread.sleep(10 * 1000) if (client?.isOpen == true) { client?.apply { send(Gson().toJson(YzxHeart().getYzxHeader())) @@ -395,7 +407,7 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus } } wsHeart() - }, 10 * 1000) + }.start() } private fun showNetworkError() { @@ -464,7 +476,8 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus } viewPager2.removeCallbacks(netLoadingRun) if (!User.isLogin()) { - WebActivity.active(this, "${Config.OA_URL}/login?logout=1") +// WebActivity.active(this, "${Config.OA_URL}/login?logout=1") + LoginActivity.active(this) finish() } checkVersion() @@ -497,9 +510,11 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus res.data.type == 1 -> { //强制升级 updateApp(res.data) } + curr - lastTipTime > 24 * 60 * 60 * 1000 -> { //非强制一天以内提示一次 updateApp(res.data) } + userCheck -> { // updateApp(res.data) } @@ -618,17 +633,20 @@ class HomePagerAdapter(act: AppCompatActivity) : FragmentStateAdapter(act) { 0 -> { return HomeFragment.getNewInstance() } + 1 -> { return ChangeFragment.getNewInstance() } + 2 -> { return VisitorFragment.getNewInstance() } + 3 -> { return MyFragment.getNewInstance() } } - return HomeFragment.getNewInstance() + return HomeFragment() } } \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt b/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt new file mode 100644 index 0000000..ce26009 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt @@ -0,0 +1,247 @@ +package com.yzx.escreen.activity + +import android.app.Activity +import android.view.View +import com.blankj.utilcode.util.KeyboardUtils +import com.blankj.utilcode.util.LogUtils +import com.blankj.utilcode.util.SPUtils +import com.flyco.tablayout.listener.CustomTabEntity +import com.flyco.tablayout.listener.OnTabSelectListener +import com.qmuiteam.qmui.widget.dialog.QMUIDialog +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog.Builder.ICON_TYPE_FAIL +import com.yzx.escreen.MainActivity +import com.yzx.escreen.R +import com.yzx.escreen.activity.base.BaseActivity +import com.yzx.escreen.model.BaseUser +import com.yzx.escreen.model.TabEntity +import com.yzx.escreen.model.User +import com.yzx.escreen.presenter.LoginPresenter +import com.yzx.escreen.presenter.LoginView +import com.yzx.escreen.utils.hideNavigationBar +import com.yzx.escreen.utils.setSrc +import kotlinx.android.synthetic.main.activity_login.accountEdit +import kotlinx.android.synthetic.main.activity_login.accountLayout +import kotlinx.android.synthetic.main.activity_login.loginBtn +import kotlinx.android.synthetic.main.activity_login.pswCheckbox +import kotlinx.android.synthetic.main.activity_login.pswEdit +import kotlinx.android.synthetic.main.activity_login.qrCodeImg +import kotlinx.android.synthetic.main.activity_login.qrLayout +import kotlinx.android.synthetic.main.activity_login.tabLayout +import org.jetbrains.anko.startActivity + +class LoginActivity : BaseActivity(), LoginView { + + companion object { + fun active(act: Activity) { + act.startActivity() + } + } + + private var mTicket = "" + + override val inflateId: Int + get() = R.layout.activity_login + + override fun initView() { + val tabData = arrayListOf() + tabData.add(TabEntity("账号密码登录", 0, 0)) + tabData.add(TabEntity("微信扫码登录", 0, 0)) + tabLayout.setTabData(tabData) + tabLayout.setOnTabSelectListener(object : OnTabSelectListener { + override fun onTabSelect(position: Int) { + if (position == 0) { + qrLayout.visibility = View.GONE + accountLayout.visibility = View.VISIBLE + SPUtils.getInstance().put("last_login_tab_index",0) + } else { + qrLayout.visibility = View.VISIBLE + accountLayout.visibility = View.GONE + SPUtils.getInstance().put("last_login_tab_index",1) + KeyboardUtils.hideSoftInput(this@LoginActivity) + } + } + + override fun onTabReselect(position: Int) { + + } + }) + val lastLoginTabIndex = SPUtils.getInstance().getInt("last_login_tab_index",0) + if(lastLoginTabIndex == 1){ + qrLayout.visibility = View.VISIBLE + accountLayout.visibility = View.GONE + tabLayout.currentTab = 1 + } + loginBtn.setOnClickListener { + this.doLogin() + } + val isSavePsw = SPUtils.getInstance().getBoolean("is_save_psw", false) + if (isSavePsw) { + pswCheckbox.isChecked = true + val phone = SPUtils.getInstance().getString("login_save_phone", "") + val psw = SPUtils.getInstance().getString("login_save_psw", "") + accountEdit.setText(phone) + pswEdit.setText(psw) + } else { + pswCheckbox.isChecked = false + } + } + + private fun doLogin() { + val phone = accountEdit.text.toString() + val psw = pswEdit.text.toString() + if (phone.isBlank()) { + showDialogToast("请输入账号", icon = QMUITipDialog.Builder.ICON_TYPE_FAIL) + return + } + if (psw.isBlank()) { + showDialogToast("请输入密码", icon = QMUITipDialog.Builder.ICON_TYPE_FAIL) + return + } + showLoading("登录中...") + if(pswCheckbox.isChecked){ + SPUtils.getInstance().put("is_save_psw",true) + SPUtils.getInstance().put("login_save_phone",phone) + SPUtils.getInstance().put("login_save_psw",psw) + }else{ + SPUtils.getInstance().put("is_save_psw",false) + SPUtils.getInstance().remove("login_save_phone") + SPUtils.getInstance().remove("login_save_psw") + } + mPresenter?.login(phone, psw) + } + + override fun initData() { + mPresenter?.getWXQrCode() + } + + override fun initPresenter(): LoginPresenter = LoginPresenter(this) + + override fun onLoginSuccess(user: BaseUser, list: MutableList) { + val teaList = list.filter { + return@filter it.type == 0 + } + when { + teaList.isEmpty() -> { + + if(user.type == 0){ + mPresenter?.switchUser(user.token, user.user_id, user.school_id) + }else{ + hideLoading() + this.showDialogToast("无登录权限", icon = ICON_TYPE_FAIL) + } + } + + teaList.size == 1 -> { //多个角色 + val item = teaList[0] + mPresenter?.switchUser(user.token, item.user_id, item.unit_id) + } + + else -> { + mPresenter?.getUserRoleList(user.token) + } + } + } + + override fun onLoginError(msg: String) { + hideLoading() + showDialogToast(msg, icon = ICON_TYPE_FAIL) + } + + override fun onUserInfoSuccess(user: User) { + hideLoading() + startActivity() + finish() + } + + override fun onWxQrCodeSuccess(imgUrl: String, ticket: String) { + qrCodeImg.setSrc(imgUrl) + mTicket = ticket + mPresenter?.loginQuery(ticket) + } + + override fun onDestroy() { + qrCodeImg?.apply { + removeCallbacks(null) + } + super.onDestroy() + } + + private var mBindDialog: QMUIDialog? = null + private var mOverTimeDialog: QMUIDialog? = null + + override fun onLoginQuerySuccess(user: BaseUser, code: Int) { + when (code) { + 0 -> { + if (user.direct_login == 1) { + mPresenter?.getUserLoginInfo(user.token) + } else { + mPresenter?.getUserRoleInfoByPhone(user.phone, user.tmp_token) + } + } + + 451 -> { + if (mBindDialog == null) { + mBindDialog = QMUIDialog.MessageDialogBuilder(this) + .setTitle("温馨提示") + .setMessage("您还未绑定微信公众,请绑定后再试!") + .addAction("知道了") { dialog, index -> + dialog.dismiss() + } + .create() + mBindDialog?.show() + mBindDialog?.hideNavigationBar() + } else if (!mBindDialog!!.isShowing) { + mBindDialog?.show() + } + qrCodeImg.postDelayed({ + mPresenter?.loginQuery(mTicket) + }, 1000) + } + + 452 -> { + qrCodeImg.postDelayed({ + mPresenter?.loginQuery(mTicket) + }, 1000) + } + + else -> { + if (mOverTimeDialog == null) { + mOverTimeDialog = QMUIDialog.MessageDialogBuilder(this) + .setTitle("温馨提示") + .setMessage("二维码已使用,请重新扫码!") + .addAction("知道了") { dialog, index -> + dialog.dismiss() + } + .create() + mOverTimeDialog!!.show() + mOverTimeDialog!!.hideNavigationBar() + } else if (!mOverTimeDialog!!.isShowing) { + mOverTimeDialog?.show() + } + mPresenter?.getWXQrCode() + } + } + } + + override fun onUserListSuccess(list: MutableList, token: String) { + LogUtils.d("onUserListSuccess", list) + hideLoading() + val builder = QMUIDialog.MenuDialogBuilder(this) + list.forEach { + builder.addItem( + it.unit_name + ) { dialog, which -> + LogUtils.d("itemClick", which) + val item = list[which] + showLoading("登录中...") + if(item.school_id>0){ + mPresenter?.switchUnit(item.user_id, item.unit_id,token) + }else{ + mPresenter?.switchUser(token, item.user_id, item.unit_id) + } + } + } + builder.show() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/activity/TestActivity.kt b/app/src/main/java/com/yzx/escreen/activity/TestActivity.kt new file mode 100644 index 0000000..e035143 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/activity/TestActivity.kt @@ -0,0 +1,65 @@ +package com.yzx.escreen.activity + + +import androidx.viewpager2.widget.ViewPager2 +import com.blankj.utilcode.util.KeyboardUtils +import com.flyco.tablayout.listener.CustomTabEntity +import com.flyco.tablayout.listener.OnTabSelectListener +import com.yzx.escreen.HomePagerAdapter +import com.yzx.escreen.R +import com.yzx.escreen.activity.base.BaseActivity +import com.yzx.escreen.model.LeaveID +import com.yzx.escreen.model.TabEntity +import com.yzx.escreen.presenter.MainPresenter +import com.yzx.escreen.presenter.MainView +import kotlinx.android.synthetic.main.activity_test.tabLayout +import kotlinx.android.synthetic.main.activity_test.viewPager2 + +class TestActivity : BaseActivity(), MainView { + override val inflateId: Int + get() = R.layout.activity_test + + override fun initView() { + val tabData = arrayListOf() + tabData.add(TabEntity("学生请假", R.mipmap.leave_select, R.mipmap.leave_unselect)) + tabData.add(TabEntity("学籍异动", R.mipmap.change_select, R.mipmap.change_unselect)) + tabData.add(TabEntity("访客管理", R.mipmap.visitor_select, R.mipmap.visitor_unselect)) + tabData.add(TabEntity("我的", R.mipmap.my_select, R.mipmap.my_unselect)) + tabLayout.setTabData(tabData) + + viewPager2.adapter = HomePagerAdapter(this) + viewPager2.offscreenPageLimit = 3 + viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { + override fun onPageSelected(position: Int) { + super.onPageSelected(position) + tabLayout.currentTab = position + } + }) + tabLayout.setOnTabSelectListener(object : OnTabSelectListener { + override fun onTabSelect(position: Int) { +// viewPager2.currentItem = position + viewPager2.setCurrentItem(position, false) + KeyboardUtils.hideSoftInput(viewPager2) + } + + override fun onTabReselect(position: Int) { + } + + }) + } + + override fun initData() { + + } + + override fun initPresenter(): MainPresenter=MainPresenter(this) + + + override fun onLeaveIDsSuccess(list: MutableList) { + + } + + override fun onLeaveIDsError() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/activity/base/BaseActivity.kt b/app/src/main/java/com/yzx/escreen/activity/base/BaseActivity.kt index 0e23f6a..a5edcb7 100644 --- a/app/src/main/java/com/yzx/escreen/activity/base/BaseActivity.kt +++ b/app/src/main/java/com/yzx/escreen/activity/base/BaseActivity.kt @@ -4,10 +4,9 @@ import android.os.Bundle import android.view.View import android.view.WindowManager import androidx.appcompat.app.AppCompatActivity -import com.blankj.utilcode.util.BarUtils -import com.gyf.immersionbar.ktx.immersionBar -import com.yzx.escreen.R +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog import com.yzx.escreen.presenter.base.BasePresenter +import com.yzx.escreen.utils.hideNavigationBar /** * 类名:BaseActivity @@ -25,6 +24,8 @@ abstract class BaseActivity> : AppCompatActivity() { */ abstract val inflateId: Int + private var mLoadingDialog: QMUITipDialog? = null + /** * 初始化视图操作在这里执行,执行时机为onCreate之后 */ @@ -82,4 +83,39 @@ abstract class BaseActivity> : AppCompatActivity() { } + fun showDialogToast( + msg: String, + duration: Long = 1500, + @QMUITipDialog.Builder.IconType icon: Int = QMUITipDialog.Builder.ICON_TYPE_SUCCESS + ) { + val tipDialog = QMUITipDialog.Builder(this) + .setIconType(icon) + .setTipWord(msg) + .create() + tipDialog.show() + tipDialog.hideNavigationBar() + window.decorView.postDelayed({ + tipDialog.dismiss() + }, duration) + + } + + fun showLoading(msg: String = "加载中...") { + mLoadingDialog = QMUITipDialog.Builder(this) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(msg) + .create() + mLoadingDialog?.apply { + show() + } + } + + fun hideLoading() { + mLoadingDialog?.apply { + if (isShowing) { + dismiss() + } + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/adapter/VisitorListAdapter.kt b/app/src/main/java/com/yzx/escreen/adapter/VisitorListAdapter.kt index ee29b4f..21e1cbd 100644 --- a/app/src/main/java/com/yzx/escreen/adapter/VisitorListAdapter.kt +++ b/app/src/main/java/com/yzx/escreen/adapter/VisitorListAdapter.kt @@ -7,90 +7,35 @@ import com.chad.library.adapter.base.BaseQuickAdapter import com.chad.library.adapter.base.viewholder.BaseViewHolder import com.yzx.escreen.R import com.yzx.escreen.model.Visitor -import com.yzx.escreen.utils.setSrc import com.yzx.escreen.utils.toTime -import kotlinx.android.synthetic.main.layout_visitor_table.view.* +import kotlinx.android.synthetic.main.layout_visitor_table.view.applyTime +import kotlinx.android.synthetic.main.layout_visitor_table.view.bottomLine +import kotlinx.android.synthetic.main.layout_visitor_table.view.inOutTime +import kotlinx.android.synthetic.main.layout_visitor_table.view.isDrive +import kotlinx.android.synthetic.main.layout_visitor_table.view.receptionUser +import kotlinx.android.synthetic.main.layout_visitor_table.view.statusName +import kotlinx.android.synthetic.main.layout_visitor_table.view.userName import org.jetbrains.anko.textColor class VisitorListAdapter(list: MutableList) : BaseQuickAdapter(R.layout.layout_visitor_table, list) { init { - addChildClickViewIds(R.id.faceEmpty,R.id.nucleinEmpty,R.id.tripCodeEmpty,R.id.healthCodeEmpty) +// addChildClickViewIds(R.id.faceEmpty) } @SuppressLint("SetTextI18n", "Range") override fun convert(holder: BaseViewHolder, item: Visitor) { holder.itemView.userName.text = item.user_name - if (item.face_key.isNotEmpty()) { - holder.itemView.faceImg.visibility = View.VISIBLE - holder.itemView.faceEmpty.visibility = View.GONE - holder.itemView.faceImg.setSrc(item.face_identity, item.face_key) - } else { - holder.itemView.faceEmpty.visibility = View.VISIBLE - holder.itemView.faceImg.visibility = View.GONE - } - when { - item.health_code_status >= 0 -> { - holder.itemView.healthCodeStatusLayout.visibility = View.VISIBLE - holder.itemView.healthCodeImg.visibility = View.GONE - holder.itemView.healthCodeEmpty.visibility = View.GONE - when (item.health_code_status) { - 0 -> { - holder.itemView.healthCodeStatus.text = "状态:绿码" - holder.itemView.healthCodeStatus.textColor = Color.parseColor("#5DAD64") - } - 1 -> { - holder.itemView.healthCodeStatus.text = "状态:黄码" - holder.itemView.healthCodeStatus.textColor = Color.parseColor("#FCCF13") - } - 10 -> { - holder.itemView.healthCodeStatus.text = "状态:红码" - holder.itemView.healthCodeStatus.textColor = Color.parseColor("#FC0416") - } - } - } - item.health_code_key.isNotEmpty() -> { - holder.itemView.healthCodeStatusLayout.visibility = View.GONE - holder.itemView.healthCodeImg.visibility = View.VISIBLE - holder.itemView.healthCodeEmpty.visibility = View.GONE - holder.itemView.healthCodeImg.setSrc( - item.health_code_identity, - item.health_code_key - ) - - } - else -> { - holder.itemView.healthCodeStatusLayout.visibility = View.GONE - holder.itemView.healthCodeEmpty.visibility = View.VISIBLE - holder.itemView.healthCodeImg.visibility = View.GONE - } - } - if(item.nuclein_file_key.isNullOrBlank()){ - holder.itemView.nucleinEmpty.visibility = View.VISIBLE - holder.itemView.nucleinImg.visibility = View.GONE - }else{ - holder.itemView.nucleinImg.visibility = View.VISIBLE - holder.itemView.nucleinEmpty.visibility = View.GONE - holder.itemView.nucleinImg.setSrc(item.nuclein_file_identity, item.nuclein_file_key) - } - if(item.nuclein_time>0){ - holder.itemView.nucleinStatusLayout.visibility = View.VISIBLE - holder.itemView.nucleinStatus.text = item.getNucleinStatusObj().nuclein_name - holder.itemView.nucleinStatus.setTextColor(Color.parseColor(item.getNucleinStatusObj().nuclein_color)) - }else{ - holder.itemView.nucleinStatusLayout.visibility = View.GONE - } - if (item.trip_code_key.isNullOrBlank()) { - holder.itemView.tripCodeEmpty.visibility = View.VISIBLE - holder.itemView.tripCodeImg.visibility = View.GONE - } else { - holder.itemView.tripCodeImg.visibility = View.VISIBLE - holder.itemView.tripCodeEmpty.visibility = View.GONE - holder.itemView.tripCodeImg.setSrc(item.trip_code_identity, item.trip_code_key) - } +// holder.itemView.userTypeName.text = when (item.user_type) { +// 0 -> "" +// 1 -> "老师" +// 2 -> "学生" +// 3 -> "访客" +// else -> "--" +// } holder.itemView.isDrive.text = if (item.is_drive == 1) { - "是" + "是(${item.license_plate})" } else { "否" } @@ -111,6 +56,7 @@ class VisitorListAdapter(list: MutableList) : } holder.itemView.applyTime.text = item.add_time.toTime() + holder.itemView.inOutTime.text = "${item.start_time.toTime()} - ${item.end_time.toTime()}" holder.itemView.bottomLine.visibility = if (holder.adapterPosition == data.size - 1) { View.GONE diff --git a/app/src/main/java/com/yzx/escreen/config/RefreshToken.kt b/app/src/main/java/com/yzx/escreen/config/RefreshToken.kt index 6f98cb3..859568a 100644 --- a/app/src/main/java/com/yzx/escreen/config/RefreshToken.kt +++ b/app/src/main/java/com/yzx/escreen/config/RefreshToken.kt @@ -7,7 +7,7 @@ import com.lzy.okgo.OkGo import com.lzy.okgo.model.Response import com.yzx.escreen.App.Companion.getContext import com.yzx.escreen.MainActivity -import com.yzx.escreen.activity.WebActivity +import com.yzx.escreen.activity.LoginActivity import com.yzx.escreen.config.Config.OA_URL import com.yzx.escreen.model.ReToken import com.yzx.escreen.model.RefreshTokenEvent @@ -15,7 +15,7 @@ import com.yzx.escreen.model.User import com.yzx.escreen.presenter.base.JsonCallBack import com.yzx.escreen.presenter.base.YzxResponse import org.greenrobot.eventbus.EventBus -import java.util.* +import java.util.Date object RefreshToken { fun refresh(callBack:RefreshCallback) { @@ -47,7 +47,8 @@ object RefreshToken { super.onError(response) LogUtils.d(response) User.clearUserInfo() - val intent = Intent(getContext(), WebActivity::class.java) +// val intent = Intent(getContext(), WebActivity::class.java) + val intent = Intent(getContext(), LoginActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK intent.putExtra("link", OA_URL + "/login?logout=1") ActivityUtils.startActivity(intent) @@ -57,7 +58,8 @@ object RefreshToken { }) }else{ User.clearUserInfo() - val intent = Intent(getContext(), WebActivity::class.java) +// val intent = Intent(getContext(), WebActivity::class.java) + val intent = Intent(getContext(), LoginActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK intent.putExtra("link", OA_URL + "/login?logout=1") ActivityUtils.startActivity(intent) @@ -67,7 +69,8 @@ object RefreshToken { }else{ if (currTime - lastLoginTime > 365L * 24 * 60 * 60 * 1000){ User.clearUserInfo() - val intent = Intent(getContext(), WebActivity::class.java) +// val intent = Intent(getContext(), WebActivity::class.java) + val intent = Intent(getContext(), LoginActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK intent.putExtra("link", OA_URL + "/login?logout=1") ActivityUtils.startActivity(intent) diff --git a/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt b/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt index 03b7a6c..3c8bc71 100644 --- a/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt +++ b/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt @@ -4,10 +4,21 @@ object YzxInterface { const val FILE_UPLOAD_URL = "https://fileupload.oa.qbjjyyun.net/edufile/fileUpload" + const val INTERFACE_LOGIN_ALL= "/login/user2/doLoginAll" //老师学生统一登录 + const val INTERFACE_USER_ROLE_LIST= "/login/user2/getUserLoginRoleList" //多角色获取角色列表 + const val INTERFACE_USER_ROLE_LIST_BY_PHONE= "/edu/weixin/getRolesByPhone" //多角色获取角色列表 + const val INTERFACE_USER_SWITCH= "/login/user2/switchLoginRole" //切换角色 + const val INTERFACE_USER_SWITCH_UNIT= "/edu/weixin/switchUnit" //切换角色 + const val INTERFACE_COMMON_LOGIN_BY_TOKEN= "/login/user2/getUserLoginInfo" // 通过token登陆 + const val INTERFACE_GET_COMMON_YUN_AVATAR= "/edu/activeApi/getYkjHeadPortrait" //根据登录人获取云空间头像 + const val INTERFACE_REFRESH_TOKEN = "/login/user2/refreshToken"// 刷新token const val INTERFACE_GET_ACCESS_TOKEN= "/rights/weixin/getAccessTokenByAppId" // 通过app_id获取access_token const val INTERFACE_GET_MINI_CODE= "/parent/mini/getMiniCode" // 获取小程序二维码 + const val INTERFACE_GENERATE_WX_QR_TICKET= "/login/wechat/generateQrTicket" // 获取微信带参数二维码的ticket + const val INTERFACE_WX_DO_LOGIN_QUERY= "/edu/user/common/doLoginQuery" // 微信登录的轮询 + /** * 学生请假 */ diff --git a/app/src/main/java/com/yzx/escreen/fragment/BlankFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/BlankFragment.kt new file mode 100644 index 0000000..987be7b --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/fragment/BlankFragment.kt @@ -0,0 +1,60 @@ +package com.yzx.escreen.fragment + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.yzx.escreen.R + +// TODO: Rename parameter arguments, choose names that match +// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER +private const val ARG_PARAM1 = "param1" +private const val ARG_PARAM2 = "param2" + +/** + * A simple [Fragment] subclass. + * Use the [BlankFragment.newInstance] factory method to + * create an instance of this fragment. + */ +class BlankFragment : Fragment() { + // TODO: Rename and change types of parameters + private var param1: String? = null + private var param2: String? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + arguments?.let { + param1 = it.getString(ARG_PARAM1) + param2 = it.getString(ARG_PARAM2) + } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_blank, container, false) + } + + companion object { + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment BlankFragment. + */ + // TODO: Rename and change types and number of parameters + @JvmStatic + fun newInstance(param1: String, param2: String) = + BlankFragment().apply { + arguments = Bundle().apply { + putString(ARG_PARAM1, param1) + putString(ARG_PARAM2, param2) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt index 5a5e1ca..818c135 100644 --- a/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt +++ b/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt @@ -7,8 +7,7 @@ import com.blankj.utilcode.util.ScreenUtils import com.qmuiteam.qmui.widget.dialog.QMUIDialog import com.qmuiteam.qmui.widget.dialog.QMUITipDialog import com.yzx.escreen.R -import com.yzx.escreen.activity.WebActivity -import com.yzx.escreen.config.Config +import com.yzx.escreen.activity.LoginActivity import com.yzx.escreen.fragment.base.BaseFragment import com.yzx.escreen.model.TeacherInfo import com.yzx.escreen.model.TimeShow @@ -16,7 +15,19 @@ import com.yzx.escreen.model.User import com.yzx.escreen.presenter.MyPresenter import com.yzx.escreen.presenter.MyView import com.yzx.escreen.utils.hideNavigationBar -import kotlinx.android.synthetic.main.fragment_my.* +import kotlinx.android.synthetic.main.fragment_my.density +import kotlinx.android.synthetic.main.fragment_my.groupName +import kotlinx.android.synthetic.main.fragment_my.idCard +import kotlinx.android.synthetic.main.fragment_my.isLeader +import kotlinx.android.synthetic.main.fragment_my.jobName +import kotlinx.android.synthetic.main.fragment_my.jobType +import kotlinx.android.synthetic.main.fragment_my.logoutBtn +import kotlinx.android.synthetic.main.fragment_my.phone +import kotlinx.android.synthetic.main.fragment_my.sex +import kotlinx.android.synthetic.main.fragment_my.sysExitBtn +import kotlinx.android.synthetic.main.fragment_my.timeView +import kotlinx.android.synthetic.main.fragment_my.unitName +import kotlinx.android.synthetic.main.fragment_my.userName import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode @@ -103,7 +114,8 @@ class MyFragment : BaseFragment(), MyView { logoutBtn.setOnClickListener { activity?.apply { User.clearUserInfo() - WebActivity.active(this, "${Config.OA_URL}/login?logout=1") +// WebActivity.active(this, "${Config.OA_URL}/login?logout=1") + LoginActivity.active(this) finish() } } diff --git a/app/src/main/java/com/yzx/escreen/fragment/VisitorFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/VisitorFragment.kt index 7180479..193dc87 100644 --- a/app/src/main/java/com/yzx/escreen/fragment/VisitorFragment.kt +++ b/app/src/main/java/com/yzx/escreen/fragment/VisitorFragment.kt @@ -113,11 +113,11 @@ class VisitorFragment : BaseFragment(), VisitorView, val curr = TimeUtils.getNowMills() if (curr - lastClickTime > 500) { lastClickTime = curr - when (view.id) { - R.id.faceEmpty, R.id.nucleinEmpty, R.id.tripCodeEmpty, R.id.healthCodeEmpty -> { - mPresenter?.getDetail(mAdapter.getItem(position).id) - } - } +// when (view.id) { +// R.id.faceEmpty, R.id.nucleinEmpty, R.id.tripCodeEmpty, R.id.healthCodeEmpty -> { +// mPresenter?.getDetail(mAdapter.getItem(position).id) +// } +// } } } diff --git a/app/src/main/java/com/yzx/escreen/model/CBClassInfo.kt b/app/src/main/java/com/yzx/escreen/model/CBClassInfo.kt new file mode 100644 index 0000000..85dc1dc --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/model/CBClassInfo.kt @@ -0,0 +1,75 @@ +package com.yzx.escreen.model + +import com.yzx.escreen.utils.getImgUrl +import java.net.URLDecoder + +data class CBClassInfo( + val brushed_face_num: Int = 0, + val class_student_num: Int = 0, + val class_teacher: ClassTeacher = ClassTeacher(), + val leave_num: Int = 0, + val unbrushed_face_num: Int = 0, + val user_photo: UserPhoto = UserPhoto() +) + +data class ClassTeacher( + val user_id: Int = 0, + val user_name: String = "" +) + +data class UserPhoto( + val head_portrait: String = "", + val identity: String = "" +) + +data class ClassTeaInfo( + val subject_name: String = "", + val subject_id: String = "", + val user_name: String = "", + val user_id: String = "", + val type: Int = 0 +) + +data class TimeTable( + val lesson_no: Int = 0, + val lesson_name: String = "", + val subject_id: String = "", + val subject_name: String = "" +) + +data class ClassActiveInfo( + val add_time: Int = 0, + val user_name: String = "", + val content: String = "", + val attachments: MutableList = mutableListOf() +){ + fun getNewContent():String{ + return URLDecoder.decode(content,"UTF-8") + } + + fun getImgUrls():MutableList{ + val list = mutableListOf() + attachments.forEach { + if (it.file_id?.isNotEmpty()) + list.add(it.file_identity.getImgUrl(it.file_id)) + } + return list + } +} + +data class ActiveAttachment( + val file_id: String = "", + val file_identity: String = "" +) + +data class ClassStylePic( + val identity: String = "", + val picture_id: String = "" +) + +data class HeadClassInfo( + val class_id: Int = 0, + val class_name: String = "", + val grade_id: Int = 0, + val grade_name: String = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt b/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt new file mode 100644 index 0000000..4e678b6 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt @@ -0,0 +1,6 @@ +package com.yzx.escreen.model + +class EventBugBean { +} + +data class EventLeaveIds(var ids:String="") \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/model/StuLeave.kt b/app/src/main/java/com/yzx/escreen/model/StuLeave.kt index 5d40d1e..9e86f65 100644 --- a/app/src/main/java/com/yzx/escreen/model/StuLeave.kt +++ b/app/src/main/java/com/yzx/escreen/model/StuLeave.kt @@ -19,7 +19,7 @@ data class StuLeave( val end_time: Int = 0, val entry_flag: Int = 0, val face_identity: String = "", - val face_key: String = "", + val face_key: String ?= "", val ftime: Int = 0, val grade_id: Int = 0, val grade_name: String = "", diff --git a/app/src/main/java/com/yzx/escreen/model/User.kt b/app/src/main/java/com/yzx/escreen/model/User.kt index 71dce3e..41d4f40 100644 --- a/app/src/main/java/com/yzx/escreen/model/User.kt +++ b/app/src/main/java/com/yzx/escreen/model/User.kt @@ -3,7 +3,22 @@ package com.yzx.escreen.model import com.blankj.utilcode.util.SPUtils import com.blankj.utilcode.util.TimeUtils +class BaseUser(var token: String, + var type:Int, + var role:String, + var user_id:Int, + var unit_id:Int, + var school_id:Int, + var unit_name:String, + var school_name:String, + var direct_login:Int, + var tmp_token:String, + var phone:String +) +class UserAvatar(val identity:String,val head_portrait:String) + +class WxQrTicket(val ticket:String) class User( var user_name: String, var user_id: Int, diff --git a/app/src/main/java/com/yzx/escreen/model/Visitor.kt b/app/src/main/java/com/yzx/escreen/model/Visitor.kt index fc00685..5b6d6ff 100644 --- a/app/src/main/java/com/yzx/escreen/model/Visitor.kt +++ b/app/src/main/java/com/yzx/escreen/model/Visitor.kt @@ -11,7 +11,7 @@ data class Visitor( val card_no: String = "", val end_time: Int = 0, val face_identity: String = "", - val face_key: String = "", + val face_key: String ?= "", val health_code_identity: String = "", val health_code_key: String = "", val health_code_status: Int = -1, diff --git a/app/src/main/java/com/yzx/escreen/presenter/LoginPresenter.kt b/app/src/main/java/com/yzx/escreen/presenter/LoginPresenter.kt new file mode 100644 index 0000000..f8a9aa4 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/presenter/LoginPresenter.kt @@ -0,0 +1,207 @@ +package com.yzx.escreen.presenter + +import com.blankj.utilcode.util.LogUtils +import com.lzy.okgo.OkGo +import com.lzy.okgo.model.Response +import com.yzx.escreen.config.Config +import com.yzx.escreen.model.BaseUser +import com.yzx.escreen.model.User +import com.yzx.escreen.model.WxQrTicket +import com.yzx.escreen.presenter.base.BasePresenter +import com.yzx.escreen.presenter.base.IView +import com.yzx.escreen.presenter.base.JsonCallBack +import com.yzx.escreen.presenter.base.YzxResponse +import com.yzx.escreen.config.YzxInterface + +class LoginPresenter(view: LoginView) : BasePresenter(view) { + fun login(phone: String, psw: String) { + val url = Config.BASE_URL + YzxInterface.INTERFACE_LOGIN_ALL + OkGo.post>(url) + .tag(this) + .params("phone", phone) + .params("password", psw) + .params("original_password", psw) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + mView?.onLoginSuccess(response.body().data, response.body().list) + LogUtils.d("login", response.body().list) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onLoginError(response?.body()?.msg ?: "") + } + }) + } + + fun switchUser(token: String, user_id: Int, unit_id: Int) { + val url = Config.BASE_URL + YzxInterface.INTERFACE_USER_SWITCH + OkGo.post>(url) + .tag(this) + .params("token", token) + .params("user_id", user_id) + .params("unit_id", unit_id) + .params("type", 0) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + response.body().data.save() + getUserLoginInfo(response.body().data.token) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onLoginError(response?.body()?.msg ?: "") + } + }) + } + + fun switchUnit(user_id: Int, school_id: Int, tmp_token: String) { + val url = Config.BASE_URL + YzxInterface.INTERFACE_USER_SWITCH_UNIT + OkGo.post>(url) + .tag(this) + .params("school_id", school_id) + .params("user_id", user_id) + .params("tmp_token", tmp_token) + .params("client_id", 201) + .params("type", 0) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + getUserLoginInfo(response.body().data.token) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onLoginError(response?.body()?.msg ?: "") + } + }) + } + + fun getUserLoginInfo(token: String) { + val url = Config.BASE_URL + YzxInterface.INTERFACE_COMMON_LOGIN_BY_TOKEN + OkGo.post>(url) + .tag(this) + .params("token", token) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + response.body().data.save() + mView?.onUserInfoSuccess(response.body().data) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onLoginError(response?.body()?.msg ?: "") + } + }) + } + + fun getUserRoleInfoByPhone(phone: String, temp_token: String = "") { + val url = Config.BASE_URL + YzxInterface.INTERFACE_USER_ROLE_LIST_BY_PHONE + OkGo.post>(url) + .tag(this) + .params("phone", phone) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + val teaList = response.body().list.filter { return@filter it.role.toInt() == 0 } + .toMutableList() + teaList.forEach { + it.unit_name = it.school_name + it.unit_id = it.school_id + } + mView?.onUserListSuccess(teaList, temp_token) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onLoginError(response?.body()?.msg ?: "") + } + }) + } + + fun getUserRoleList(token: String) { + val url = Config.BASE_URL + YzxInterface.INTERFACE_USER_ROLE_LIST + OkGo.post>(url) + .tag(this) + .params("token", token) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + val teaList = response.body().list.filter { return@filter it.type == 0 } + .toMutableList() + mView?.onUserListSuccess(teaList, token) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onLoginError(response?.body()?.msg ?: "") + } + }) + } + + fun getWXQrCode() { + val url = Config.BASE_URL + YzxInterface.INTERFACE_GENERATE_WX_QR_TICKET + OkGo.post>(url) + .tag(this) + .params("mp_id", 4) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + val url = + "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${response.body().data.ticket}" + mView?.onWxQrCodeSuccess(url, response.body().data.ticket) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + } + }) + } + + fun loginQuery(ticket: String) { + val url = Config.BASE_URL + YzxInterface.INTERFACE_WX_DO_LOGIN_QUERY + + OkGo.post>(url) + .tag(this) + .params("ticket", ticket) + .execute(object : JsonCallBack>() { + override fun onSuccess(response: Response>?) { + if (response?.isSuccessful == true) { + val res = response.body() + mView?.onLoginQuerySuccess(res.data, res.code) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + } + }) + } +} + +interface LoginView : IView { + fun onLoginSuccess(user: BaseUser, list: MutableList) + fun onLoginError(msg: String) + fun onUserInfoSuccess(user: User) + fun onUserListSuccess(list: MutableList, token: String) + fun onWxQrCodeSuccess(imgUrl: String, ticket: String) + fun onLoginQuerySuccess(user: BaseUser, code: Int) +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/presenter/VisitorPresenter.kt b/app/src/main/java/com/yzx/escreen/presenter/VisitorPresenter.kt index 5db8a97..6de7db7 100644 --- a/app/src/main/java/com/yzx/escreen/presenter/VisitorPresenter.kt +++ b/app/src/main/java/com/yzx/escreen/presenter/VisitorPresenter.kt @@ -5,7 +5,11 @@ import com.lzy.okgo.OkGo import com.lzy.okgo.model.Response import com.yzx.escreen.config.Config import com.yzx.escreen.config.YzxInterface -import com.yzx.escreen.model.* +import com.yzx.escreen.model.AccessToken +import com.yzx.escreen.model.Pager +import com.yzx.escreen.model.QrCode +import com.yzx.escreen.model.User +import com.yzx.escreen.model.Visitor import com.yzx.escreen.presenter.base.BasePresenter import com.yzx.escreen.presenter.base.IView import com.yzx.escreen.presenter.base.JsonCallBack @@ -24,7 +28,7 @@ class VisitorPresenter(view: VisitorView) : BasePresenter(view) { .params("keyword", keyword) .params("audit_status", status) .params("user_type", 3) - .params("page_size", 6) + .params("page_size", 9) .params("page_no", pageNo) .execute(object : JsonCallBack>() { diff --git a/app/src/main/java/com/yzx/escreen/presenter/base/JsonCallBack.java b/app/src/main/java/com/yzx/escreen/presenter/base/JsonCallBack.java index 1d55fe5..53887ca 100644 --- a/app/src/main/java/com/yzx/escreen/presenter/base/JsonCallBack.java +++ b/app/src/main/java/com/yzx/escreen/presenter/base/JsonCallBack.java @@ -10,8 +10,7 @@ import com.lzy.okgo.model.HttpHeaders; import com.lzy.okgo.request.base.Request; import com.yzx.escreen.App; import com.yzx.escreen.MainActivity; -import com.yzx.escreen.activity.WebActivity; -import com.yzx.escreen.config.Config; +import com.yzx.escreen.activity.LoginActivity; import com.yzx.escreen.config.RefreshToken; import com.yzx.escreen.model.User; import com.yzx.escreen.utils.Monitor; @@ -162,9 +161,9 @@ public abstract class JsonCallBack extends AbsCallback { public void onError() { LogUtils.d("onError"); User.Companion.clearUserInfo(); - Intent intent = new Intent(App.Companion.getContext(),WebActivity.class); + Intent intent = new Intent(App.Companion.getContext(), LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra("link", Config.INSTANCE.getOA_URL()+"/login?logout=1"); +// intent.putExtra("link", Config.INSTANCE.getOA_URL()+"/login?logout=1"); ActivityUtils.startActivity(intent); ActivityUtils.finishActivity(MainActivity.class); } diff --git a/app/src/main/java/com/yzx/escreen/utils/KotlinX.kt b/app/src/main/java/com/yzx/escreen/utils/KotlinX.kt index cb0b016..9dbccc5 100644 --- a/app/src/main/java/com/yzx/escreen/utils/KotlinX.kt +++ b/app/src/main/java/com/yzx/escreen/utils/KotlinX.kt @@ -5,16 +5,24 @@ import android.view.View import android.widget.ImageView import com.blankj.utilcode.util.TimeUtils import com.bumptech.glide.Glide +import com.yzx.escreen.R import java.text.SimpleDateFormat -import java.util.* +import java.util.TimeZone fun ImageView.setSrc(identity: String, key: String) { - val url = "https://${identity}.oa.qbjjyyun.net/edufile/imageView?uniqueKey=${key}" + val url = "https://${identity.ifEmpty { "filea" }}.oa.qbjjyyun.net/edufile/imageView?uniqueKey=${key}" Glide.with(this) .load(url) + .placeholder(R.color.gray_1) .into(this) + this.setTag(R.id.image_src_tag,url) } +fun String.getImgUrl(key: String):String{ + return "https://${this.ifEmpty { "filea" }}.oa.qbjjyyun.net/edufile/imageView?uniqueKey=${key}" +} + + fun ImageView.setSrc(url: String) { Glide.with(this) .load(url) diff --git a/app/src/main/java/com/yzx/escreen/widget/LeaveDialog.kt b/app/src/main/java/com/yzx/escreen/widget/LeaveDialog.kt index 39cd1e0..92f7cbe 100644 --- a/app/src/main/java/com/yzx/escreen/widget/LeaveDialog.kt +++ b/app/src/main/java/com/yzx/escreen/widget/LeaveDialog.kt @@ -55,7 +55,7 @@ class LeaveDialog( @SuppressLint("SetTextI18n") fun setData(detail: StuLeave) { leave_student_name.text = detail.leave_student_name - if (detail.face_key.isNotEmpty()) { + if (detail.face_key?.isNotEmpty() == true) { val img = find(R.id.face_img) img.setSrc(detail.face_identity, detail.face_key) img.visibility = View.VISIBLE @@ -65,7 +65,7 @@ class LeaveDialog( find(R.id.face_img).visibility = View.GONE } find(R.id.face_img).setOnClickListener { - EventBus.getDefault().post(ViewImage(detail.id,detail.face_identity,detail.face_key)) + EventBus.getDefault().post(ViewImage(detail.id,detail.face_identity,detail?.face_key?:"")) } find(R.id.class_name).text = "${detail.grade_name}${detail.class_name}" find(R.id.leave_request_type_name).text = detail.leave_request_type_name diff --git a/app/src/main/java/com/yzx/escreen/widget/VisitorDialog.kt b/app/src/main/java/com/yzx/escreen/widget/VisitorDialog.kt index 33552ba..c8d0f3f 100644 --- a/app/src/main/java/com/yzx/escreen/widget/VisitorDialog.kt +++ b/app/src/main/java/com/yzx/escreen/widget/VisitorDialog.kt @@ -17,9 +17,7 @@ import com.yzx.escreen.adapter.VisitorDialogStepAdapter import com.yzx.escreen.model.ViewImage import com.yzx.escreen.model.Visitor import com.yzx.escreen.utils.setSrc -import com.yzx.escreen.utils.toDay import com.yzx.escreen.utils.toTime -import kotlinx.android.synthetic.main.dialog_visitor.view.* import org.greenrobot.eventbus.EventBus import org.jetbrains.anko.find import org.jetbrains.anko.textColor @@ -59,89 +57,91 @@ class VisitorDialog( //处理弹窗显示 find(R.id.userName).text = "${detail.user_name} ${detail.user_phone}" find(R.id.id_card_num).text = "${detail.card_no}" - if (detail.face_key.isNotEmpty()) { + if (detail.face_key?.isNotEmpty() == true) { val img = find(R.id.face_img) img.setSrc(detail.face_identity, detail.face_key) img.visibility = View.VISIBLE find(R.id.face_empty).visibility = View.GONE + find(R.id.face_layout).visibility = View.VISIBLE } else { find(R.id.face_empty).visibility = View.VISIBLE find(R.id.face_img).visibility = View.GONE + find(R.id.face_layout).visibility = View.GONE } find(R.id.face_img).setOnClickListener { - EventBus.getDefault().post(ViewImage(detail.id, detail.face_identity, detail.face_key)) + EventBus.getDefault().post(ViewImage(detail.id, detail.face_identity, detail?.face_key?:"")) } - when { - detail.health_code_status >= 0 -> { - healthCodeStatusLayout.visibility = VISIBLE - health_empty.visibility = GONE - health_img.visibility = GONE - when (detail.health_code_status) { - 0 -> { - healthCodeStatus.text = "状态:绿码" - healthCodeStatus.textColor = Color.parseColor("#5DAD64") - } - 1 -> { - healthCodeStatus.text = "状态:黄码" - healthCodeStatus.textColor = Color.parseColor("#FCCF13") - } - 10 -> { - healthCodeStatus.text = "状态:红码" - healthCodeStatus.textColor = Color.parseColor("#FC0416") - } - } - } - detail.health_code_key.isNotEmpty() -> { - healthCodeStatusLayout.visibility = GONE - val img = find(R.id.health_img) - img.setSrc(detail.health_code_identity, detail.health_code_key) - img.visibility = View.VISIBLE - find(R.id.health_empty).visibility = View.GONE - } - else -> { - healthCodeStatusLayout.visibility = GONE - find(R.id.health_empty).visibility = View.VISIBLE - find(R.id.health_img).visibility = View.GONE - } - } - find(R.id.health_img).setOnClickListener { - EventBus.getDefault() - .post(ViewImage(detail.id, detail.health_code_identity, detail.health_code_key)) - } - if (detail.trip_code_key.isNotEmpty()) { - val img = find(R.id.trip_img) - img.setSrc(detail.trip_code_identity, detail.trip_code_key) - img.visibility = View.VISIBLE - find(R.id.trip_empty).visibility = View.GONE - } else { - find(R.id.trip_empty).visibility = View.VISIBLE - find(R.id.trip_img).visibility = View.GONE - } - if(detail.nuclein_file_key.isNullOrBlank()){ - nuclein_img.visibility = View.GONE - nuclein_empty.visibility = View.VISIBLE - }else{ - nuclein_img.visibility = View.VISIBLE - nuclein_empty.visibility = View.GONE - nuclein_img.setSrc(detail.nuclein_file_identity, detail.nuclein_file_key) - } - if(detail.nuclein_time>0){ - nucleinStatusLayout.visibility = VISIBLE - nucleinStatus.text = detail.getNucleinStatusObj().nuclein_name - nucleinStatus.setTextColor(Color.parseColor(detail.getNucleinStatusObj().nuclein_color)) - }else{ - nucleinStatusLayout.visibility = GONE - } - find(R.id.trip_img).setOnClickListener { - EventBus.getDefault() - .post(ViewImage(detail.id, detail.trip_code_identity, detail.trip_code_key)) - } - find(R.id.nuclein_img).setOnClickListener { - EventBus.getDefault() - .post(ViewImage(detail.id, detail.nuclein_file_identity, detail.nuclein_file_key)) - } - find(R.id.reception_user).text = "${detail.reception_user}" - find(R.id.visit_reason).text = "${detail.visit_reason}" +// when { +// detail.health_code_status >= 0 -> { +// healthCodeStatusLayout.visibility = VISIBLE +// health_empty.visibility = GONE +// health_img.visibility = GONE +// when (detail.health_code_status) { +// 0 -> { +// healthCodeStatus.text = "状态:绿码" +// healthCodeStatus.textColor = Color.parseColor("#5DAD64") +// } +// 1 -> { +// healthCodeStatus.text = "状态:黄码" +// healthCodeStatus.textColor = Color.parseColor("#FCCF13") +// } +// 10 -> { +// healthCodeStatus.text = "状态:红码" +// healthCodeStatus.textColor = Color.parseColor("#FC0416") +// } +// } +// } +// detail.health_code_key.isNotEmpty() -> { +// healthCodeStatusLayout.visibility = GONE +// val img = find(R.id.health_img) +// img.setSrc(detail.health_code_identity, detail.health_code_key) +// img.visibility = View.VISIBLE +// find(R.id.health_empty).visibility = View.GONE +// } +// else -> { +// healthCodeStatusLayout.visibility = GONE +// find(R.id.health_empty).visibility = View.VISIBLE +// find(R.id.health_img).visibility = View.GONE +// } +// } +// find(R.id.health_img).setOnClickListener { +// EventBus.getDefault() +// .post(ViewImage(detail.id, detail.health_code_identity, detail.health_code_key)) +// } +// if (detail.trip_code_key.isNotEmpty()) { +// val img = find(R.id.trip_img) +// img.setSrc(detail.trip_code_identity, detail.trip_code_key) +// img.visibility = View.VISIBLE +// find(R.id.trip_empty).visibility = View.GONE +// } else { +// find(R.id.trip_empty).visibility = View.VISIBLE +// find(R.id.trip_img).visibility = View.GONE +// } +// if(detail.nuclein_file_key.isNullOrBlank()){ +// nuclein_img.visibility = View.GONE +// nuclein_empty.visibility = View.VISIBLE +// }else{ +// nuclein_img.visibility = View.VISIBLE +// nuclein_empty.visibility = View.GONE +// nuclein_img.setSrc(detail.nuclein_file_identity, detail.nuclein_file_key) +// } +// if(detail.nuclein_time>0){ +// nucleinStatusLayout.visibility = VISIBLE +// nucleinStatus.text = detail.getNucleinStatusObj().nuclein_name +// nucleinStatus.setTextColor(Color.parseColor(detail.getNucleinStatusObj().nuclein_color)) +// }else{ +// nucleinStatusLayout.visibility = GONE +// } +// find(R.id.trip_img).setOnClickListener { +// EventBus.getDefault() +// .post(ViewImage(detail.id, detail.trip_code_identity, detail.trip_code_key)) +// } +// find(R.id.nuclein_img).setOnClickListener { +// EventBus.getDefault() +// .post(ViewImage(detail.id, detail.nuclein_file_identity, detail.nuclein_file_key)) +// } +// find(R.id.reception_user).text = "${detail.reception_user}" +// find(R.id.visit_reason).text = "${detail.visit_reason}" find(R.id.is_drive).text = when (detail.is_drive) { 1 -> "是" 0 -> "否" @@ -171,7 +171,7 @@ class VisitorDialog( else -> Color.parseColor("#333333") } find(R.id.start_time).text = - "${detail.start_time.toDay()} - ${detail.end_time.toDay()} 可进出${detail.in_out_num}次" + "${detail.start_time.toTime()} - ${detail.end_time.toTime()}" } find(R.id.statusImg).setSrc(detail.getStatusImg()) diff --git a/app/src/main/res/drawable/btn_blue_select.xml b/app/src/main/res/drawable/btn_blue_select.xml new file mode 100644 index 0000000..c293a3c --- /dev/null +++ b/app/src/main/res/drawable/btn_blue_select.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/login_bg.xml b/app/src/main/res/drawable/login_bg.xml new file mode 100644 index 0000000..1626ff9 --- /dev/null +++ b/app/src/main/res/drawable/login_bg.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_login_form.xml b/app/src/main/res/drawable/shape_login_form.xml new file mode 100644 index 0000000..415fd77 --- /dev/null +++ b/app/src/main/res/drawable/shape_login_form.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_login_round.xml b/app/src/main/res/drawable/shape_login_round.xml new file mode 100644 index 0000000..92d635d --- /dev/null +++ b/app/src/main/res/drawable/shape_login_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..f3a5ffd --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_test.xml b/app/src/main/res/layout/activity_test.xml new file mode 100644 index 0000000..3ba72c5 --- /dev/null +++ b/app/src/main/res/layout/activity_test.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_visitor.xml b/app/src/main/res/layout/dialog_visitor.xml index bf577e0..7afcdea 100644 --- a/app/src/main/res/layout/dialog_visitor.xml +++ b/app/src/main/res/layout/dialog_visitor.xml @@ -99,199 +99,227 @@ android:text="颜小华 18780170404" /> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:text="人脸信息" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_blank.xml b/app/src/main/res/layout/fragment_blank.xml new file mode 100644 index 0000000..39900b5 --- /dev/null +++ b/app/src/main/res/layout/fragment_blank.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_visitor.xml b/app/src/main/res/layout/fragment_visitor.xml index eeb5331..051f1e9 100644 --- a/app/src/main/res/layout/fragment_visitor.xml +++ b/app/src/main/res/layout/fragment_visitor.xml @@ -184,30 +184,15 @@ - - - - - - - - + + + + + - + + android:paddingTop="@dimen/d_20" + android:paddingBottom="@dimen/d_20"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + #3ca0e9 #883ca0e9 #00574B - #D81B60 + #3ca0e9 #FFFFFF #000000 #19000000 @@ -25,6 +25,7 @@ #53a051 #4d92dc #3ca0e9 + #aa3ca0e9 #ff8635 @android:color/transparent @color/white diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 4b431f6..4d73284 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -2,4 +2,5 @@ + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c00240e..9bf7717 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,4 +2,6 @@ 一体化平台 检测到新版本 解决了若干bug + + Hello blank fragment diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f6b961f..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 832c67f..1b16c34 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed May 06 13:56:55 CST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew index cccdd3d..3da45c1 100644 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright ? 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?, +# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?; +# * compound commands having a testable exit status, especially ?case?; +# * various built-in commands including ?command?, ?set?, and ?ulimit?. +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell