bug修改,同步

master
lijie 2023-08-04 15:29:09 +08:00
parent 9ee5468010
commit 9c7fd037ad
30 changed files with 316 additions and 80 deletions

View File

@ -5,16 +5,19 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.core.app.ActivityCompat
import com.cmx.wanhui.R
import com.cmx.wanhui.constant.Events
import com.cmx.wanhui.model.LoginBean
import com.cmx.wanhui.model.LoginRes
import com.cmx.wanhui.retrofit.RetrofitAPIManager
import com.cmx.wanhui.utils.MyUtils.setAndroidNativeLightStatusBar
import com.cmx.wanhui.utils.MyUtils.setFullscreen
import com.cmx.wanhui.utils.SpUtils.putString
import com.cmx.wanhui.view.ConfirmDialog
import com.lsxiao.apollo.core.Apollo
import es.dmoral.toasty.Toasty
import kotlinx.android.synthetic.main.activity_login.btn_login
import kotlinx.android.synthetic.main.activity_login.edt_password
@ -24,9 +27,8 @@ import retrofit2.Callback
import retrofit2.Response
class LoginActivity : BaseActivity() {
private val REQUIRED_PERMISSION_LIST = arrayOf(
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA
)
private val REQUIRED_PERMISSION_LIST = arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA)
private val REQUEST_PERMISSION_CODE = 99
private var allPermission = true
@ -42,7 +44,6 @@ class LoginActivity : BaseActivity() {
Toasty.info(this, "请输入用户名").show()
return@OnClickListener
}
if (TextUtils.isEmpty(edt_password.text.toString().trim { it <= ' ' })) {
Toasty.info(this@LoginActivity, "请输入密码").show()
return@OnClickListener
@ -51,7 +52,7 @@ class LoginActivity : BaseActivity() {
})
}
/**
* 权限检查
*/
@ -94,18 +95,31 @@ class LoginActivity : BaseActivity() {
startActivity(intent)
finish()
} else {
Toasty.error(this@LoginActivity, response.body()!!.message!!).show()
if (null != response.body() && null != response.body()!!.message) {
Toasty.error(this@LoginActivity, response.body()!!.message!!).show()
} else {
Toasty.error(this@LoginActivity, "登录失败").show()
}
}
}
override fun onFailure(call: Call<LoginRes?>, t: Throwable) {
disDialog()
Toasty.info(this@LoginActivity, "登录失败").show()
val intent = Intent(this@LoginActivity, MainActivity::class.java)
startActivity(intent)
finish()
}
})
}
override fun onBackPressed() {
ConfirmDialog(this, object : ConfirmDialog.IBack {
override fun confirmBack() {
finish()
}
override fun cancelBack() {
}
}).show()
}
}

View File

@ -3,14 +3,16 @@ package com.cmx.wanhui.activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.navigation.NavController
import androidx.navigation.Navigation
import androidx.navigation.ui.NavigationUI
import com.cmx.wanhui.R
import com.cmx.wanhui.constant.Events
import com.cmx.wanhui.view.ConfirmDialog
import com.cmx.wanhui.view.ConfirmDialog.*
import com.google.zxing.integration.android.IntentIntegrator
import com.lsxiao.apollo.core.Apollo
import com.lsxiao.apollo.core.annotations.Receive
@ -25,8 +27,10 @@ class MainActivity : BaseActivity() {
setContentView(R.layout.activity_main)
navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main)
NavigationUI.setupWithNavController(nav_view, navController!!)
nav_view.itemIconTintList = null
}
/**
* 显示tabbar
*/
@ -35,6 +39,7 @@ class MainActivity : BaseActivity() {
nav_view.visibility = View.VISIBLE
}
/**
* 隐藏tabbar
*/
@ -83,6 +88,7 @@ class MainActivity : BaseActivity() {
}
}
/**
* 退出登录
*/
@ -94,6 +100,7 @@ class MainActivity : BaseActivity() {
startActivity(intent)
}
/**
* 二维码扫描
*/
@ -106,6 +113,7 @@ class MainActivity : BaseActivity() {
integrator.initiateScan()
}
// 处理扫描结果
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
@ -114,10 +122,27 @@ class MainActivity : BaseActivity() {
} else { // 扫描成功,处理结果
val scannedData = result.contents
Apollo.emit(Events.JS_OPEN_SCANQR_BACK, scannedData)
Toast.makeText(this, "扫描结果: $scannedData", Toast.LENGTH_LONG).show()
}
} else {
super.onActivityResult(requestCode, resultCode, data)
}
}
override fun onBackPressed() {
Apollo.emit(Events.JS_OPEN_WEB_BACK)
}
@Receive(Events.JS_OPEN_WEB_BACK_EXIT)
fun exitApp() {
ConfirmDialog(this, object : IBack {
override fun confirmBack() {
finish()
}
override fun cancelBack() {
}
}).show()
}
}

View File

@ -19,6 +19,7 @@ class MyApplication : Application() {
companion object {
private var mInstance: Context? = null
private var mToken: String? = null
@JvmStatic
fun getmInstance(): Context? {
return mInstance

View File

@ -6,8 +6,17 @@ package com.cmx.wanhui.constant
*/
interface Events {
companion object {
const val WEB_SERVER_URL = "http://8.222.137.126:80"
const val SERVER_URL = "http://192.168.110.174:8000"
//const val SERVER_URL = "http://192.168.110.174:8000"
//const val WBE_URL = "http://192.168.110.253:5173"
const val SERVER_URL = "http://120.46.182.114:7777"
const val WBE_URL = "http://120.46.182.114:7788"
const val WEB_HOME_URL = WBE_URL
const val WEB_MODE_URL = "$WBE_URL/function"
const val WEB_MY_URL = "$WBE_URL/my"
/**
* tabbar显示
@ -49,7 +58,14 @@ interface Events {
*/
const val JS_OPEN_SCANQR_BACK = "js_open_scan_qr_back"
/**
* 原生返回_发送给web返回
*/
const val JS_OPEN_WEB_BACK = "js_open_web_back"
/**
* web无法在返回退出APP
*/
const val JS_OPEN_WEB_BACK_EXIT = "js_open_web_back_exit"
}
}

View File

@ -0,0 +1,5 @@
package com.cmx.wanhui.model
class QRBean {
var msg: String? = null
}

View File

@ -42,7 +42,7 @@ open class BaseFragment : Fragment() {
fun setWebView(webView: WebView) {
val webSettings = webView!!.settings
webSettings.javaScriptEnabled = true
webSettings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
webSettings.cacheMode = WebSettings.LOAD_NO_CACHE
webSettings.domStorageEnabled = true
webSettings.allowFileAccess = true //文件访问
webSettings.allowFileAccessFromFileURLs = true

View File

@ -29,10 +29,13 @@ import androidx.lifecycle.ViewModelProvider;
import com.cmx.wanhui.activity.LoginActivity;
import com.cmx.wanhui.constant.Events;
import com.cmx.wanhui.databinding.FragmentHomeBinding;
import com.cmx.wanhui.model.QRBean;
import com.cmx.wanhui.utils.AndroidtoJs;
import com.cmx.wanhui.utils.L;
import com.cmx.wanhui.utils.MyUtils;
import com.cmx.wanhui.view.BaseLoadingDialog;
import com.cmx.wanhui.view.ConfirmDialog;
import com.google.gson.Gson;
import com.lsxiao.apollo.core.Apollo;
import com.lsxiao.apollo.core.annotations.Receive;
import com.lsxiao.apollo.core.contract.ApolloBinder;
@ -57,18 +60,11 @@ public class HomeFragment extends BaseFragment {
View root = binding.getRoot();
mWebView = binding.wvHome;
setWebView(mWebView);
mWebView.loadUrl("https://www.baidu.com/");
mWebView.loadUrl(Events.WEB_HOME_URL);
mWebView.setWebChromeClient(new PQChromeClient());
binding.tvTe.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Apollo.emit(Events.JS_OPEN_SCANQR);
}
});
return root;
}
@Override
public void onDestroyView() {
super.onDestroyView();
@ -187,17 +183,35 @@ public class HomeFragment extends BaseFragment {
}
}
/**
*
*/
@Receive(Events.JS_OPEN_SCANQR_BACK)
public void onQRBack(String msg) {
String jsString = "javascript:onQRBack(" + msg + ")";
L.e("JS二维码扫描返回>>>>", jsString);
QRBean mQRBean = new QRBean();
mQRBean.setMsg(msg);
String ms = new Gson().toJson(mQRBean);
String jsString = "javascript:window.onQRBack(" + ms + ")";
L.e("JS二维码扫描返回>>>>", ms + "<<>>" + jsString);
mWebView.evaluateJavascript(jsString, new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
}
});
}
/**
* web
*/
@Receive(Events.JS_OPEN_WEB_BACK)
public void webBack() {
if (mWebView.canGoBack()) {
mWebView.goBack();
} else {
Apollo.emit(Events.JS_OPEN_WEB_BACK_EXIT);
}
}
}

View File

@ -26,10 +26,12 @@ import androidx.fragment.app.Fragment;
import com.cmx.wanhui.constant.Events;
import com.cmx.wanhui.databinding.FragmentDashboardBinding;
import com.cmx.wanhui.model.QRBean;
import com.cmx.wanhui.utils.AndroidtoJs;
import com.cmx.wanhui.utils.L;
import com.cmx.wanhui.utils.MyUtils;
import com.cmx.wanhui.view.BaseLoadingDialog;
import com.google.gson.Gson;
import com.lsxiao.apollo.core.Apollo;
import com.lsxiao.apollo.core.annotations.Receive;
import com.lsxiao.apollo.core.contract.ApolloBinder;
@ -47,12 +49,13 @@ public class ModeFragment extends BaseFragment {
private long size = 0;
private static final int INPUT_FILE_REQUEST_CODE = 1;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentDashboardBinding.inflate(inflater, container, false);
View root = binding.getRoot();
mWebView = binding.wvLoan;
setWebView(mWebView);
mWebView.loadUrl("https://www.baidu.com/");
mWebView.loadUrl(Events.WEB_MODE_URL);
mWebView.setWebChromeClient(new PQChromeClient());
return root;
}
@ -176,12 +179,27 @@ public class ModeFragment extends BaseFragment {
*/
@Receive(Events.JS_OPEN_SCANQR_BACK)
public void onQRBack(String msg) {
String jsString = "javascript:onQRBack(" + msg + ")";
L.e("JS二维码扫描返回>>>>", jsString);
QRBean mQRBean = new QRBean();
mQRBean.setMsg(msg);
String ms = new Gson().toJson(mQRBean);
String jsString = "javascript:window.onQRBack(" + ms + ")";
L.e("JS二维码扫描返回>>>>", ms + "<<>>" + jsString);
mWebView.evaluateJavascript(jsString, new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
}
});
}
/**
* web
*/
@Receive(Events.JS_OPEN_WEB_BACK)
public void webBack() {
if (mWebView.canGoBack()) {
mWebView.goBack();
} else {
Apollo.emit(Events.JS_OPEN_WEB_BACK_EXIT);
}
}
}

View File

@ -1,20 +1,22 @@
package com.cmx.wanhui.ui
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.ValueCallback
import com.cmx.wanhui.R
import com.cmx.wanhui.constant.Events
import com.cmx.wanhui.utils.L
import com.cmx.wanhui.model.QRBean
import com.cmx.wanhui.utils.L.Companion.e
import com.google.gson.Gson
import com.lsxiao.apollo.core.Apollo
import com.lsxiao.apollo.core.annotations.Receive
import kotlinx.android.synthetic.main.fragment_home.tv_te
import kotlinx.android.synthetic.main.fragment_notifications.wv_mine
class PersonalFragment : BaseFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_notifications, container, false)
}
@ -22,7 +24,7 @@ class PersonalFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setWebView(wv_mine!!)
wv_mine!!.loadUrl("https://www.baidu.com/")//SERVER_URL
wv_mine!!.loadUrl(Events.WEB_MY_URL)
//wv_mine!!.webChromeClient = PQChromeClient()
}
@ -32,8 +34,23 @@ class PersonalFragment : BaseFragment() {
*/
@Receive(Events.JS_OPEN_SCANQR_BACK)
fun onQRBack(msg: String) {
val jsString = "javascript:onQRBack($msg)"
L.e("JS二维码扫描返回>>>>", jsString)
wv_mine!!.evaluateJavascript(jsString) { }
val mQRBean = QRBean()
mQRBean.msg = msg
val ms = Gson().toJson(mQRBean)
val jsString = "javascript:window.onQRBack($ms)"
e("JS二维码扫描返回>>>>", "$ms<<>>$jsString")
wv_mine!!.evaluateJavascript(jsString, ValueCallback<String?> { })
}
/**
* web返回
*/
@Receive(Events.JS_OPEN_WEB_BACK)
fun webBack() {
if (wv_mine!!.canGoBack()) {
wv_mine!!.goBack()
} else {
Apollo.emit(Events.JS_OPEN_WEB_BACK_EXIT)
}
}
}

View File

@ -0,0 +1,59 @@
package com.cmx.wanhui.view;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.cmx.wanhui.R;
/**
*
*/
public class ConfirmDialog extends Dialog {
private TextView mConfirm;
private TextView mCancel;
private IBack mIBack;
public ConfirmDialog(Context context, IBack mIBack) {
super(context, R.style.CustomDialog);
this.mIBack = mIBack;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_confirm_all);
setCancelable(false);
setCanceledOnTouchOutside(false);
mConfirm = findViewById(R.id.con_con);
mCancel = findViewById(R.id.con_cancel);
mConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mIBack.confirmBack();
dismiss();
}
});
mCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mIBack.cancelBack();
dismiss();
}
});
}
public interface IBack {
void confirmBack();
void cancelBack();
}
}

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/icon_home_on" android:state_checked="true" />
<item android:drawable="@mipmap/icon_home_off" android:state_checked="false" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/icon_mode_on" android:state_checked="true" />
<item android:drawable="@mipmap/icon_mode_off" android:state_checked="false" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/icon_my_on" android:state_checked="true" />
<item android:drawable="@mipmap/icon_my_off" android:state_checked="false" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/black" android:state_checked="false" />
<item android:color="#284891" android:state_checked="true" />
</selector>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--边框颜色-->
<corners android:radius="5dp" />
<stroke
android:width="1dp"
android:color="@color/white" />
<solid android:color="@color/white" />
</shape>

View File

@ -33,10 +33,11 @@
android:hint="请输入用户名"
android:paddingStart="10dip"
android:singleLine="true"
android:text="15102353035"
android:text="wanhui"
android:textColorHint="#919191"
android:textSize="16sp" />
<!-- wanhui-->
<!-- 15102353035-->
<EditText
android:id="@+id/edt_password"
android:layout_width="match_parent"
@ -55,7 +56,6 @@
android:textColorHint="#919191"
android:textSize="16sp" />
<View
android:layout_width="wrap_content"
android:layout_height="0dp"

View File

@ -13,6 +13,7 @@
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:itemTextColor="@drawable/sel_tab_col"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_eh_line"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="40dp"
android:paddingRight="40dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:padding="20dp"
android:text="提示"
android:textColor="@color/black"
android:textSize="22sp" />
<TextView
android:id="@+id/tv_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="确认退出软件?"
android:textColor="@color/black"
android:textSize="20sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="38dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<TextView
android:id="@+id/con_con"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/shape_eh_line"
android:backgroundTint="@color/base_col"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="确 认"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/con_cancel"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="50dp"
android:background="@drawable/shape_eh_line"
android:backgroundTint="#999999"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="取 消"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>

View File

@ -4,14 +4,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_te"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="首页"
android:textSize="30sp" />
<WebView
android:id="@+id/wv_home"
android:layout_width="match_parent"

View File

@ -3,17 +3,17 @@
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home_black_24dp"
android:icon="@drawable/sel_home"
android:title="首页" />
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_dashboard_black_24dp"
android:icon="@drawable/sel_mode"
android:title="功能" />
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:icon="@drawable/sel_my"
android:title="我的" />
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -1,8 +1,8 @@
<resources>
<string name="app_name">万汇</string>
<string name="title_home">Home</string>
<string name="title_dashboard">Loan</string>
<string name="title_notifications">Mine</string>
<string name="title_home">首页</string>
<string name="title_dashboard">功能</string>
<string name="title_notifications">我的</string>
<string name="title_activity_login">Login</string>
<string name="prompt_email">Email</string>
<string name="prompt_password">Password</string>