1.1.2发布
parent
9493b4861b
commit
2f15a3456c
@ -0,0 +1,231 @@
|
||||
package com.rehome.dywoa.ui.activity
|
||||
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.webkit.CookieManager
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import com.rehome.dywoa.App
|
||||
import com.rehome.dywoa.BuildConfig
|
||||
import com.rehome.dywoa.Contans
|
||||
import com.rehome.dywoa.R
|
||||
import com.rehome.dywoa.base.BaseActivityOaToolbarViewBinding
|
||||
import com.rehome.dywoa.base.BaseAgentWebActivity
|
||||
import com.rehome.dywoa.bean.FwSingleLoginResult
|
||||
import com.rehome.dywoa.bean.SisTokenBeanData
|
||||
import com.rehome.dywoa.bean.UserInfoBean
|
||||
import com.rehome.dywoa.databinding.ActivityRunLogBaseBinding
|
||||
import com.rehome.dywoa.databinding.ActivityUseCarBinding
|
||||
import com.rehome.dywoa.utils.GsonUtils
|
||||
import com.rehome.dywoa.utils.HttpListener
|
||||
import com.rehome.dywoa.utils.NoProgresshttpUtils
|
||||
import com.rehome.dywoa.utils.NohttpUtils
|
||||
import com.rehome.dywoa.utils.RSAUtils
|
||||
import com.rehome.dywoa.utils.UiUtlis
|
||||
import com.yolanda.nohttp.NoHttp
|
||||
import com.yolanda.nohttp.RequestMethod
|
||||
import com.yolanda.nohttp.rest.Response
|
||||
|
||||
|
||||
class UseCarActivity : BaseAgentWebActivity() {
|
||||
private val urlToken = "api/app/login/singleLogin?account="
|
||||
private lateinit var startUrl:String
|
||||
|
||||
private lateinit var type:String
|
||||
private lateinit var urlLog:String
|
||||
|
||||
private lateinit var mToolbar: Toolbar
|
||||
private lateinit var mTitleTextView: TextView
|
||||
|
||||
private lateinit var context: Context
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_wait_for_to_do)
|
||||
|
||||
context = this;
|
||||
type = intent.getStringExtra("type")!!
|
||||
urlLog = intent.getStringExtra("urlLog")!!
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
type = ""
|
||||
}
|
||||
|
||||
mToolbar = this.findViewById(R.id.toolbar)
|
||||
mToolbar.setTitleTextColor(Color.WHITE)
|
||||
mToolbar.title = ""
|
||||
mToolbar.setNavigationIcon(R.drawable.ac_back_icon)
|
||||
mTitleTextView = this.findViewById(R.id.toolbar_title)
|
||||
mTitleTextView.text = type
|
||||
this.setSupportActionBar(mToolbar)
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
mToolbar.setNavigationOnClickListener { finish() }
|
||||
|
||||
|
||||
//支持缩放
|
||||
mAgentWeb.webCreator.webView.settings.builtInZoomControls = true
|
||||
mAgentWeb.webCreator.webView.settings.displayZoomControls = false
|
||||
mAgentWeb.webCreator.webView.settings.setSupportZoom(true)
|
||||
|
||||
checkServerConnectStatus()
|
||||
}
|
||||
|
||||
|
||||
private fun getSingleLoginToken() {
|
||||
|
||||
val url = Contans.IP + urlToken + App.getInstance().userInfo.manid;
|
||||
|
||||
|
||||
//url = Contans.IP + urlToken + "280846";
|
||||
|
||||
val request = NoHttp.createStringRequest(url, RequestMethod.GET)
|
||||
showLog(url)
|
||||
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
||||
override fun onSucceed(what: Int, response: Response<String?>?) {
|
||||
val jsonResult = response?.get()
|
||||
showLog("-----login------")
|
||||
showLog(jsonResult?:"")
|
||||
val jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult)
|
||||
if (TextUtils.isEmpty(jsonDecode)) {
|
||||
showToast(UiUtlis.getString(context, R.string.data_error))
|
||||
} else {
|
||||
val loginResult: FwSingleLoginResult? = GsonUtils.GsonToBean(jsonDecode, FwSingleLoginResult::class.java)
|
||||
showLog(jsonDecode);
|
||||
if (loginResult != null) {
|
||||
if (loginResult.errmsg!=null&&loginResult.errmsg.equals("success")) {
|
||||
if(!TextUtils.isEmpty(loginResult.token)){
|
||||
loadSisPage(loginResult.token)
|
||||
}
|
||||
}else{
|
||||
showToast(loginResult.errmsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jsonResult != null && jsonResult.startsWith("http")) {
|
||||
|
||||
//FwSingleLoginResult
|
||||
loadSisPage(jsonResult)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String?>?) {
|
||||
Log.i("login", "onError")
|
||||
}
|
||||
}, true, true, "登录中...")
|
||||
}
|
||||
|
||||
private fun loadSisPage(token: String) {
|
||||
val tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken=$token&redirect_uri="
|
||||
startUrl = tempUrl + urlLog
|
||||
showLog(startUrl)
|
||||
|
||||
//startUrl = "https://www.hao123.com";
|
||||
mAgentWeb.urlLoader.loadUrl(startUrl)
|
||||
}
|
||||
|
||||
//检查服务器连接状态
|
||||
private fun checkServerConnectStatus() {
|
||||
var param = HashMap<String,String>()
|
||||
param["login"] = "dywoa";
|
||||
val json = GsonUtils.GsonString(param)
|
||||
val url = Contans.IP + Contans.check_server_connect
|
||||
Log.i("app",url)
|
||||
Log.i("app",json)
|
||||
val request = NoHttp.createStringRequest(
|
||||
url,
|
||||
RequestMethod.POST
|
||||
)
|
||||
request.setDefineRequestBodyForJson(json)
|
||||
NoProgresshttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
||||
override fun onSucceed(what: Int, response: Response<String?>?) {
|
||||
val result = response?.get()
|
||||
if (result != null) {
|
||||
showLog("-----onSucceed----")
|
||||
showLog(result)
|
||||
if(result == "1"){
|
||||
showLog("connect server success")
|
||||
getSingleLoginToken()
|
||||
}else{
|
||||
showToast("无法连接到服务器,请检查网络环境")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String?>?) {
|
||||
showLog("connect server onFailed")
|
||||
showToast("无法连接到服务器,请检查网络环境")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun getAgentWebParent(): ViewGroup {
|
||||
return findViewById<View>(R.id.container) as ViewGroup
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
override fun getIndicatorColor(): Int {
|
||||
return Color.parseColor("#ff0000")
|
||||
}
|
||||
|
||||
override fun setTitle(view: WebView?, title: String?) {
|
||||
super.setTitle(view, title)
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
if (mTitleTextView != null) {
|
||||
mTitleTextView.text = type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIndicatorHeight(): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override fun getUrl(): String? {
|
||||
return null
|
||||
//return "https://www.baidu.com/";
|
||||
}
|
||||
|
||||
private fun showLog(logText: String) {
|
||||
if (BuildConfig.LOG_ERROR) {
|
||||
if (TextUtils.isEmpty(logText)) {
|
||||
Log.i("app", "logText is null")
|
||||
} else {
|
||||
Log.i("app", logText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showToast(msg: String?) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
fun showToast(strId: Int) {
|
||||
Toast.makeText(this, strId, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,221 @@
|
||||
package com.rehome.dywoa.ui.activity
|
||||
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import com.rehome.dywoa.App
|
||||
import com.rehome.dywoa.BuildConfig
|
||||
import com.rehome.dywoa.Contans
|
||||
import com.rehome.dywoa.R
|
||||
import com.rehome.dywoa.base.BaseAgentWebActivity
|
||||
import com.rehome.dywoa.bean.FwSingleLoginResult
|
||||
import com.rehome.dywoa.databinding.ActivityUseSealBinding
|
||||
import com.rehome.dywoa.utils.GsonUtils
|
||||
import com.rehome.dywoa.utils.HttpListener
|
||||
import com.rehome.dywoa.utils.NoProgresshttpUtils
|
||||
import com.rehome.dywoa.utils.NohttpUtils
|
||||
import com.rehome.dywoa.utils.RSAUtils
|
||||
import com.rehome.dywoa.utils.UiUtlis
|
||||
import com.yolanda.nohttp.NoHttp
|
||||
import com.yolanda.nohttp.RequestMethod
|
||||
import com.yolanda.nohttp.rest.Response
|
||||
|
||||
|
||||
class UseSealActivity : BaseAgentWebActivity() {
|
||||
|
||||
private val urlToken = "api/app/login/singleLogin?account="
|
||||
private lateinit var startUrl:String
|
||||
|
||||
private lateinit var type:String
|
||||
private lateinit var urlLog:String
|
||||
|
||||
private lateinit var mToolbar: Toolbar
|
||||
private lateinit var mTitleTextView: TextView
|
||||
|
||||
private lateinit var context:Context
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_wait_for_to_do)
|
||||
|
||||
context = this;
|
||||
type = intent.getStringExtra("type")!!
|
||||
urlLog = intent.getStringExtra("urlLog")!!
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
type = ""
|
||||
}
|
||||
|
||||
mToolbar = this.findViewById(R.id.toolbar)
|
||||
mToolbar.setTitleTextColor(Color.WHITE)
|
||||
mToolbar.title = ""
|
||||
mToolbar.setNavigationIcon(R.drawable.ac_back_icon)
|
||||
mTitleTextView = this.findViewById(R.id.toolbar_title)
|
||||
mTitleTextView.text = type
|
||||
this.setSupportActionBar(mToolbar)
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
mToolbar.setNavigationOnClickListener { finish() }
|
||||
|
||||
|
||||
//支持缩放
|
||||
mAgentWeb.webCreator.webView.settings.builtInZoomControls = true
|
||||
mAgentWeb.webCreator.webView.settings.displayZoomControls = false
|
||||
mAgentWeb.webCreator.webView.settings.setSupportZoom(true)
|
||||
|
||||
checkServerConnectStatus()
|
||||
}
|
||||
|
||||
|
||||
private fun getSingleLoginToken() {
|
||||
|
||||
val url = Contans.IP + urlToken + App.getInstance().userInfo.manid;
|
||||
|
||||
|
||||
//url = Contans.IP + urlToken + "280846";
|
||||
|
||||
val request = NoHttp.createStringRequest(url, RequestMethod.GET)
|
||||
showLog(url)
|
||||
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
||||
override fun onSucceed(what: Int, response: Response<String?>?) {
|
||||
val jsonResult = response?.get()
|
||||
showLog("-----login------")
|
||||
showLog(jsonResult?:"")
|
||||
val jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult)
|
||||
if (TextUtils.isEmpty(jsonDecode)) {
|
||||
showToast(UiUtlis.getString(context, R.string.data_error))
|
||||
} else {
|
||||
val loginResult: FwSingleLoginResult? = GsonUtils.GsonToBean(jsonDecode, FwSingleLoginResult::class.java)
|
||||
showLog(jsonDecode);
|
||||
if (loginResult != null) {
|
||||
if (loginResult.errmsg!=null&&loginResult.errmsg.equals("success")) {
|
||||
if(!TextUtils.isEmpty(loginResult.token)){
|
||||
loadSisPage(loginResult.token)
|
||||
}
|
||||
}else{
|
||||
showToast(loginResult.errmsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jsonResult != null && jsonResult.startsWith("http")) {
|
||||
|
||||
//FwSingleLoginResult
|
||||
loadSisPage(jsonResult)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String?>?) {
|
||||
Log.i("login", "onError")
|
||||
}
|
||||
}, true, true, "登录中...")
|
||||
}
|
||||
|
||||
private fun loadSisPage(token: String) {
|
||||
val tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken=$token&redirect_uri="
|
||||
startUrl = tempUrl + urlLog
|
||||
showLog(startUrl)
|
||||
|
||||
//startUrl = "https://www.hao123.com";
|
||||
mAgentWeb.urlLoader.loadUrl(startUrl)
|
||||
}
|
||||
|
||||
//检查服务器连接状态
|
||||
private fun checkServerConnectStatus() {
|
||||
var param = HashMap<String,String>()
|
||||
param["login"] = "dywoa";
|
||||
val json = GsonUtils.GsonString(param)
|
||||
val url = Contans.IP + Contans.check_server_connect
|
||||
Log.i("app",url)
|
||||
Log.i("app",json)
|
||||
val request = NoHttp.createStringRequest(
|
||||
url,
|
||||
RequestMethod.POST
|
||||
)
|
||||
request.setDefineRequestBodyForJson(json)
|
||||
NoProgresshttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
||||
override fun onSucceed(what: Int, response: Response<String?>?) {
|
||||
val result = response?.get()
|
||||
if (result != null) {
|
||||
showLog("-----onSucceed----")
|
||||
showLog(result)
|
||||
if(result == "1"){
|
||||
showLog("connect server success")
|
||||
getSingleLoginToken()
|
||||
}else{
|
||||
showToast("无法连接到服务器,请检查网络环境")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String?>?) {
|
||||
showLog("connect server onFailed")
|
||||
showToast("无法连接到服务器,请检查网络环境")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun getAgentWebParent(): ViewGroup {
|
||||
return findViewById<View>(R.id.container) as ViewGroup
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
override fun getIndicatorColor(): Int {
|
||||
return Color.parseColor("#ff0000")
|
||||
}
|
||||
|
||||
override fun setTitle(view: WebView?, title: String?) {
|
||||
super.setTitle(view, title)
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
if (mTitleTextView != null) {
|
||||
mTitleTextView.text = type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIndicatorHeight(): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override fun getUrl(): String? {
|
||||
return null
|
||||
//return "https://www.baidu.com/";
|
||||
}
|
||||
|
||||
private fun showLog(logText: String) {
|
||||
if (BuildConfig.LOG_ERROR) {
|
||||
if (TextUtils.isEmpty(logText)) {
|
||||
Log.i("app", "logText is null")
|
||||
} else {
|
||||
Log.i("app", logText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showToast(msg: String?) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
fun showToast(strId: Int) {
|
||||
Toast.makeText(this, strId, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,277 @@
|
||||
package com.rehome.dywoa.ui.activity;
|
||||
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.just.agentweb.AgentWeb;
|
||||
import com.just.agentweb.DefaultWebClient;
|
||||
import com.just.agentweb.WebChromeClient;
|
||||
import com.just.agentweb.WebViewClient;
|
||||
import com.rehome.dywoa.App;
|
||||
import com.rehome.dywoa.BuildConfig;
|
||||
import com.rehome.dywoa.Contans;
|
||||
import com.rehome.dywoa.R;
|
||||
import com.rehome.dywoa.base.BaseAgentWebActivity;
|
||||
import com.rehome.dywoa.bean.FwSingleLoginResult;
|
||||
import com.rehome.dywoa.bean.SisTokenBeanData;
|
||||
import com.rehome.dywoa.utils.GsonUtils;
|
||||
import com.rehome.dywoa.utils.HttpListener;
|
||||
import com.rehome.dywoa.utils.NoProgresshttpUtils;
|
||||
import com.rehome.dywoa.utils.NohttpUtils;
|
||||
import com.rehome.dywoa.utils.RSAUtils;
|
||||
import com.rehome.dywoa.utils.UiUtlis;
|
||||
import com.rehome.dywoa.weiget.WebLayout;
|
||||
import com.yolanda.nohttp.NoHttp;
|
||||
import com.yolanda.nohttp.RequestMethod;
|
||||
import com.yolanda.nohttp.rest.Request;
|
||||
import com.yolanda.nohttp.rest.Response;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public class WaitForToDoActivity extends BaseAgentWebActivity {
|
||||
|
||||
private Toolbar mToolbar;
|
||||
private TextView mTitleTextView;
|
||||
|
||||
private String urlToken = "api/app/login/singleLogin?account=";
|
||||
private String startUrl;
|
||||
|
||||
|
||||
String type;
|
||||
String urlLog;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_wait_for_to_do);
|
||||
|
||||
type = getIntent().getStringExtra("type");
|
||||
urlLog = getIntent().getStringExtra("urlLog");
|
||||
if(TextUtils.isEmpty(type)){
|
||||
type = "";
|
||||
}
|
||||
|
||||
mToolbar = this.findViewById(R.id.toolbar);
|
||||
mToolbar.setTitleTextColor(Color.WHITE);
|
||||
mToolbar.setTitle("");
|
||||
mToolbar.setNavigationIcon(R.drawable.ac_back_icon);
|
||||
mTitleTextView = this.findViewById(R.id.toolbar_title);
|
||||
mTitleTextView.setText(type);
|
||||
this.setSupportActionBar(mToolbar);
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
mToolbar.setNavigationOnClickListener(v -> WaitForToDoActivity.this.finish());
|
||||
|
||||
|
||||
//支持缩放
|
||||
mAgentWeb.getWebCreator().getWebView().getSettings().setBuiltInZoomControls(true);
|
||||
mAgentWeb.getWebCreator().getWebView().getSettings().setDisplayZoomControls(false);
|
||||
mAgentWeb.getWebCreator().getWebView().getSettings().setSupportZoom(true);
|
||||
|
||||
checkServerConnectStatus();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
//检查服务器连接状态
|
||||
private void checkServerConnectStatus() {
|
||||
Map<String,String> param = new HashMap<>();
|
||||
param.put("login","dywoa");
|
||||
String json = GsonUtils.GsonString(param);
|
||||
String url = Contans.IP + Contans.check_server_connect;
|
||||
showLog(url);
|
||||
showLog(json);
|
||||
Request<String> request = NoHttp.createStringRequest(
|
||||
url,
|
||||
RequestMethod.POST
|
||||
);
|
||||
request.setDefineRequestBodyForJson(json);
|
||||
NoProgresshttpUtils.getInstance().add(this, 0, request, new HttpListener<String>() {
|
||||
|
||||
@Override
|
||||
public void onSucceed(int what, Response<String> response) {
|
||||
String result = response.get();
|
||||
showLog("-----onSucceed----");
|
||||
showLog(result);
|
||||
if(result.equals("1")){
|
||||
showLog("connect server success");
|
||||
//可以连接到服务器,请求数据
|
||||
getSingleLoginToken();
|
||||
}else{
|
||||
showToast("无法连接到服务器,请检查网络环境");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int what, Response<String> response) {
|
||||
showLog("connect server onFailed");
|
||||
showToast("无法连接到服务器,请检查网络环境");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getSingleLoginToken() {
|
||||
String url = Contans.IP + urlToken + App.getInstance().getUserInfo().getManid();
|
||||
|
||||
//url = Contans.IP + urlToken + "280846";
|
||||
|
||||
|
||||
Request request = NoHttp.createStringRequest(url, RequestMethod.GET);
|
||||
showLog(url);
|
||||
|
||||
// SSLSocketFactory socketFactory = NohttpUtils.getSisSSLSocketFactory(WaitForToDoActivity.this);
|
||||
// if (socketFactory != null) {
|
||||
// request.setSSLSocketFactory(socketFactory);
|
||||
// request.setHostnameVerifier(new HostnameVerifier() {
|
||||
// @Override
|
||||
// public boolean verify(String s, SSLSession sslSession) {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
NohttpUtils.getInstance().add(this,1,request,new HttpListener<String>(){
|
||||
@Override
|
||||
public void onSucceed(int what, Response<String> response) throws ParseException {
|
||||
|
||||
String jsonResult = response.get();
|
||||
showLog("-----login------");
|
||||
showLog(jsonResult);
|
||||
|
||||
String jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult);
|
||||
if (TextUtils.isEmpty(jsonDecode)) {
|
||||
showToast(UiUtlis.getString(WaitForToDoActivity.this, R.string.data_error));
|
||||
} else {
|
||||
FwSingleLoginResult loginResult = GsonUtils.GsonToBean(jsonDecode, FwSingleLoginResult.class);
|
||||
showLog(jsonDecode);
|
||||
if (loginResult != null) {
|
||||
if (loginResult.getErrmsg()!=null&&loginResult.getErrmsg().equals("success")) {
|
||||
if(!TextUtils.isEmpty(loginResult.getToken())){
|
||||
loadSisPage(loginResult.getToken());
|
||||
}
|
||||
}else{
|
||||
showToast(loginResult.getErrmsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int what, Response<String> response) {
|
||||
showLog("getSisToken onFailed");
|
||||
}
|
||||
}, true, true, "请稍候...");
|
||||
}
|
||||
|
||||
private void loadSisPage(String token) {
|
||||
var tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken="+ token +"&redirect_uri=";
|
||||
startUrl = tempUrl + urlLog;
|
||||
showLog(startUrl);
|
||||
|
||||
//startUrl = "https://www.hao123.com";
|
||||
|
||||
this.mAgentWeb.getUrlLoader().loadUrl(startUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ViewGroup getAgentWebParent() {
|
||||
return (ViewGroup) this.findViewById(R.id.container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIndicatorColor() {
|
||||
return Color.parseColor("#ff0000");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setTitle(WebView view, String title) {
|
||||
super.setTitle(view, title);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
if (mTitleTextView != null) {
|
||||
mTitleTextView.setText(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIndicatorHeight() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getUrl() {
|
||||
return null;
|
||||
//return "https://www.baidu.com/";
|
||||
}
|
||||
|
||||
|
||||
private void showLog(String logText) {
|
||||
if (BuildConfig.LOG_ERROR) {
|
||||
if (TextUtils.isEmpty(logText)) {
|
||||
Log.i("app", "logText is null");
|
||||
} else {
|
||||
Log.i("app", logText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showToast(String msg) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void showToast(int strId) {
|
||||
Toast.makeText(this, strId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,270 @@
|
||||
package com.rehome.dywoa.ui.activity;
|
||||
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.rehome.dywoa.App;
|
||||
import com.rehome.dywoa.BuildConfig;
|
||||
import com.rehome.dywoa.Contans;
|
||||
import com.rehome.dywoa.R;
|
||||
import com.rehome.dywoa.base.BaseAgentWebActivity;
|
||||
import com.rehome.dywoa.bean.FwSingleLoginResult;
|
||||
import com.rehome.dywoa.bean.SisTokenBeanData;
|
||||
import com.rehome.dywoa.utils.GsonUtils;
|
||||
import com.rehome.dywoa.utils.HttpListener;
|
||||
import com.rehome.dywoa.utils.NoProgresshttpUtils;
|
||||
import com.rehome.dywoa.utils.NohttpUtils;
|
||||
import com.rehome.dywoa.utils.RSAUtils;
|
||||
import com.rehome.dywoa.utils.UiUtlis;
|
||||
import com.yolanda.nohttp.NoHttp;
|
||||
import com.yolanda.nohttp.RequestMethod;
|
||||
import com.yolanda.nohttp.rest.Request;
|
||||
import com.yolanda.nohttp.rest.Response;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public class WaitForToDoBaseActivity extends BaseAgentWebActivity {
|
||||
|
||||
|
||||
private Toolbar mToolbar;
|
||||
private TextView mTitleTextView;
|
||||
|
||||
private String urlToken = "api/app/login/singleLogin?account=";
|
||||
private String startUrl;
|
||||
|
||||
|
||||
String type;
|
||||
String urlLog;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_wait_for_to_do_base);
|
||||
|
||||
type = getIntent().getStringExtra("type");
|
||||
urlLog = getIntent().getStringExtra("urlLog");
|
||||
if(TextUtils.isEmpty(type)){
|
||||
type = "";
|
||||
}
|
||||
|
||||
mToolbar = this.findViewById(R.id.toolbar);
|
||||
mToolbar.setTitleTextColor(Color.WHITE);
|
||||
mToolbar.setTitle("");
|
||||
mToolbar.setNavigationIcon(R.drawable.ac_back_icon);
|
||||
mTitleTextView = this.findViewById(R.id.toolbar_title);
|
||||
mTitleTextView.setText(type);
|
||||
this.setSupportActionBar(mToolbar);
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
mToolbar.setNavigationOnClickListener(v -> WaitForToDoBaseActivity.this.finish());
|
||||
|
||||
|
||||
//支持缩放
|
||||
mAgentWeb.getWebCreator().getWebView().getSettings().setBuiltInZoomControls(true);
|
||||
mAgentWeb.getWebCreator().getWebView().getSettings().setDisplayZoomControls(false);
|
||||
mAgentWeb.getWebCreator().getWebView().getSettings().setSupportZoom(true);
|
||||
|
||||
checkServerConnectStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
//检查服务器连接状态
|
||||
private void checkServerConnectStatus() {
|
||||
Map<String,String> param = new HashMap<>();
|
||||
param.put("login","dywoa");
|
||||
String json = GsonUtils.GsonString(param);
|
||||
String url = Contans.IP + Contans.check_server_connect;
|
||||
showLog(url);
|
||||
showLog(json);
|
||||
Request<String> request = NoHttp.createStringRequest(
|
||||
url,
|
||||
RequestMethod.POST
|
||||
);
|
||||
request.setDefineRequestBodyForJson(json);
|
||||
NoProgresshttpUtils.getInstance().add(this, 0, request, new HttpListener<String>() {
|
||||
|
||||
@Override
|
||||
public void onSucceed(int what, Response<String> response) {
|
||||
String result = response.get();
|
||||
showLog("-----onSucceed----");
|
||||
showLog(result);
|
||||
if(result.equals("1")){
|
||||
showLog("connect server success");
|
||||
//可以连接到服务器,请求数据
|
||||
getSingleLoginToken();
|
||||
}else{
|
||||
showToast("无法连接到服务器,请检查网络环境");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int what, Response<String> response) {
|
||||
showLog("connect server onFailed");
|
||||
showToast("无法连接到服务器,请检查网络环境");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getSingleLoginToken() {
|
||||
String url = Contans.IP + urlToken + App.getInstance().getUserInfo().getManid();
|
||||
|
||||
url = Contans.IP + urlToken + "280846";
|
||||
|
||||
|
||||
Request request = NoHttp.createStringRequest(url, RequestMethod.GET);
|
||||
showLog(url);
|
||||
|
||||
// SSLSocketFactory socketFactory = NohttpUtils.getSisSSLSocketFactory(WaitForToDoActivity.this);
|
||||
// if (socketFactory != null) {
|
||||
// request.setSSLSocketFactory(socketFactory);
|
||||
// request.setHostnameVerifier(new HostnameVerifier() {
|
||||
// @Override
|
||||
// public boolean verify(String s, SSLSession sslSession) {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
NohttpUtils.getInstance().add(this,1,request,new HttpListener<String>(){
|
||||
@Override
|
||||
public void onSucceed(int what, Response<String> response) throws ParseException {
|
||||
|
||||
String jsonResult = response.get();
|
||||
showLog("-----login------");
|
||||
showLog(jsonResult);
|
||||
|
||||
String jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult);
|
||||
if (TextUtils.isEmpty(jsonDecode)) {
|
||||
showToast(UiUtlis.getString(WaitForToDoBaseActivity.this, R.string.data_error));
|
||||
} else {
|
||||
FwSingleLoginResult loginResult = GsonUtils.GsonToBean(jsonDecode, FwSingleLoginResult.class);
|
||||
showLog(jsonDecode);
|
||||
if (loginResult != null) {
|
||||
if (loginResult.getErrmsg()!=null&&loginResult.getErrmsg().equals("success")) {
|
||||
if(!TextUtils.isEmpty(loginResult.getToken())){
|
||||
loadSisPage(loginResult.getToken());
|
||||
}
|
||||
}else{
|
||||
showToast(loginResult.getErrmsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int what, Response<String> response) {
|
||||
showLog("getSisToken onFailed");
|
||||
}
|
||||
}, true, true, "请稍候...");
|
||||
}
|
||||
|
||||
private void loadSisPage(String token) {
|
||||
var tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken="+ token +"&redirect_uri=";
|
||||
startUrl = tempUrl + urlLog;
|
||||
showLog(startUrl);
|
||||
|
||||
//startUrl = "https://www.hao123.com";
|
||||
|
||||
this.mAgentWeb.getUrlLoader().loadUrl(startUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ViewGroup getAgentWebParent() {
|
||||
return (ViewGroup) this.findViewById(R.id.container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIndicatorColor() {
|
||||
return Color.parseColor("#ff0000");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setTitle(WebView view, String title) {
|
||||
super.setTitle(view, title);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
if (mTitleTextView != null) {
|
||||
mTitleTextView.setText(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIndicatorHeight() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getUrl() {
|
||||
return null;
|
||||
//return "https://www.baidu.com/";
|
||||
}
|
||||
|
||||
|
||||
private void showLog(String logText) {
|
||||
if (BuildConfig.LOG_ERROR) {
|
||||
if (TextUtils.isEmpty(logText)) {
|
||||
Log.i("app", "logText is null");
|
||||
} else {
|
||||
Log.i("app", logText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showToast(String msg) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void showToast(int strId) {
|
||||
Toast.makeText(this, strId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff"
|
||||
tools:context=".ui.activity.UseCarActivity">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:titleTextColor="@android:color/white"
|
||||
app:theme="@style/Widget.AppCompat.Toolbar"
|
||||
app:titleTextColor="@android:color/white">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff"
|
||||
tools:context=".ui.activity.UseSealActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbarView"
|
||||
android:visibility="visible"
|
||||
layout="@layout/layout_base" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff"
|
||||
tools:context=".ui.activity.WaitForToDoActivity">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:titleTextColor="@android:color/white"
|
||||
app:theme="@style/Widget.AppCompat.Toolbar"
|
||||
app:titleTextColor="@android:color/white">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff"
|
||||
tools:context=".ui.activity.WaitForToDoBaseActivity">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:titleTextColor="@android:color/white"
|
||||
app:theme="@style/Widget.AppCompat.Toolbar"
|
||||
app:titleTextColor="@android:color/white">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue