管理页面更换图标
@ -0,0 +1,279 @@
|
|||||||
|
package com.rehome.dywoa.ui.activity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
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.WebView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import com.rehome.dywoa.App;
|
||||||
|
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.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 FanWeiActivity extends BaseAgentWebActivity {
|
||||||
|
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
private TextView mTitleTextView;
|
||||||
|
|
||||||
|
private String urlToken = "api/app/login/singleLogin?account=";
|
||||||
|
private String startUrl;
|
||||||
|
|
||||||
|
|
||||||
|
String type;
|
||||||
|
String url;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_fan_wei);
|
||||||
|
|
||||||
|
type = getIntent().getStringExtra("type");
|
||||||
|
url = getIntent().getStringExtra("url");
|
||||||
|
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 -> FanWeiActivity.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(FanWeiActivity.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 + url;
|
||||||
|
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 (isApkInDebug(FanWeiActivity.this)) {
|
||||||
|
if (TextUtils.isEmpty(logText)) {
|
||||||
|
Log.i("app", "logText is null");
|
||||||
|
} else {
|
||||||
|
Log.i("app", logText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前应用是否是debug状态
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static boolean isApkInDebug(Context context) {
|
||||||
|
try {
|
||||||
|
ApplicationInfo info = context.getApplicationInfo();
|
||||||
|
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 5.8 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.FanWeiActivity">
|
||||||
|
|
||||||
|
<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>
|
||||||