|
@@ -3,10 +3,14 @@ package com.xwkj.sqjw.mvp.ui.activity;
|
|
import android.Manifest;
|
|
import android.Manifest;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
import android.content.SharedPreferences;
|
|
import android.content.SharedPreferences;
|
|
|
|
+import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.os.Handler;
|
|
|
|
+import android.os.Message;
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
import android.text.method.HideReturnsTransformationMethod;
|
|
import android.text.method.HideReturnsTransformationMethod;
|
|
import android.text.method.PasswordTransformationMethod;
|
|
import android.text.method.PasswordTransformationMethod;
|
|
|
|
+import android.util.Log;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
@@ -16,6 +20,7 @@ import android.widget.LinearLayout;
|
|
import android.widget.RadioGroup;
|
|
import android.widget.RadioGroup;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
@@ -30,23 +35,40 @@ import com.xm.permissions.OnRequestPermissionsCallback;
|
|
import com.xm.permissions.XmPermissions;
|
|
import com.xm.permissions.XmPermissions;
|
|
import com.zkjc.common.base.ZkjcBaseActivity;
|
|
import com.zkjc.common.base.ZkjcBaseActivity;
|
|
import com.zkjc.common.utils.ApkUtils;
|
|
import com.zkjc.common.utils.ApkUtils;
|
|
|
|
+import com.zkjc.common.utils.BitmapUtils;
|
|
import com.zkjc.common.utils.DevicesUtils;
|
|
import com.zkjc.common.utils.DevicesUtils;
|
|
|
|
+import com.zkjc.common.utils.UUIDUtils;
|
|
import com.zkjc.common.utils.Utils;
|
|
import com.zkjc.common.utils.Utils;
|
|
import com.zkjc.policedemo.R;
|
|
import com.zkjc.policedemo.R;
|
|
|
|
+import com.zkjc.policedemo.app.utils.FileUtils;
|
|
import com.zkjc.policedemo.di.component.DaggerLoginComponent;
|
|
import com.zkjc.policedemo.di.component.DaggerLoginComponent;
|
|
import com.zkjc.policedemo.mvp.contract.LoginContract;
|
|
import com.zkjc.policedemo.mvp.contract.LoginContract;
|
|
import com.zkjc.policedemo.mvp.model.entity.Login;
|
|
import com.zkjc.policedemo.mvp.model.entity.Login;
|
|
|
|
+import com.zkjc.policedemo.mvp.model.entity.UserCredential;
|
|
import com.zkjc.policedemo.mvp.presenter.LoginPresenter;
|
|
import com.zkjc.policedemo.mvp.presenter.LoginPresenter;
|
|
import com.zkjc.policedemo.mvp.ui.activity.StHomeActivity;
|
|
import com.zkjc.policedemo.mvp.ui.activity.StHomeActivity;
|
|
import com.zkjc.policedemo.mvp.ui.activity.SydwActivity;
|
|
import com.zkjc.policedemo.mvp.ui.activity.SydwActivity;
|
|
|
|
+import com.zkjc.policedemo.mvp.ui.activity.XfjcQdActivity;
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.xutils.common.util.MD5;
|
|
import org.xutils.common.util.MD5;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
|
+import io.reactivex.Observable;
|
|
|
|
+import io.reactivex.ObservableEmitter;
|
|
|
|
+import io.reactivex.ObservableOnSubscribe;
|
|
|
|
+import io.reactivex.Observer;
|
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
|
+import io.reactivex.disposables.Disposable;
|
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
|
+import okhttp3.MediaType;
|
|
|
|
+import okhttp3.MultipartBody;
|
|
|
|
+import okhttp3.RequestBody;
|
|
|
|
|
|
import static com.jess.arms.utils.Preconditions.checkNotNull;
|
|
import static com.jess.arms.utils.Preconditions.checkNotNull;
|
|
|
|
|
|
@@ -92,6 +114,20 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
private XmPermissions xmPermissions;
|
|
private XmPermissions xmPermissions;
|
|
private SharedPreferences sys;
|
|
private SharedPreferences sys;
|
|
private boolean isFj; // 目前取消此功能
|
|
private boolean isFj; // 目前取消此功能
|
|
|
|
+ private Handler handler = new Handler() {
|
|
|
|
+ @Override
|
|
|
|
+ public void handleMessage(@NonNull Message msg) {
|
|
|
|
+ super.handleMessage(msg);
|
|
|
|
+// getInterface();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ private void onTime(long time) {
|
|
|
|
+
|
|
|
|
+ handler.postDelayed(() -> {
|
|
|
|
+ getInterface();
|
|
|
|
+ }, time);
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void setupActivityComponent(@NonNull AppComponent appComponent) {
|
|
public void setupActivityComponent(@NonNull AppComponent appComponent) {
|
|
@@ -126,13 +162,9 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
if (ApkUtils.isSqjw(this)) {
|
|
if (ApkUtils.isSqjw(this)) {
|
|
layoutTop.setVisibility(View.GONE);
|
|
layoutTop.setVisibility(View.GONE);
|
|
layoutBottom.setVisibility(View.GONE);
|
|
layoutBottom.setVisibility(View.GONE);
|
|
- Map<String, Object> map1 = new HashMap<>();
|
|
|
|
- map1.put("className", "bladeTokenEndPoint");
|
|
|
|
- map1.put("methodName", "token3");
|
|
|
|
- map1.put("username", /*getIntent().getStringExtra("jh")*/"sqmj1");
|
|
|
|
- map1.put("password", MD5.md5("123456"));
|
|
|
|
- mPresenter.login(map1);
|
|
|
|
Utils.getInstances().showDialog(SqjwLoginActivity.this, "正在获取数据");
|
|
Utils.getInstances().showDialog(SqjwLoginActivity.this, "正在获取数据");
|
|
|
|
+ getInterface();
|
|
|
|
+
|
|
|
|
|
|
} else {
|
|
} else {
|
|
layoutTop.setVisibility(View.VISIBLE);
|
|
layoutTop.setVisibility(View.VISIBLE);
|
|
@@ -155,7 +187,7 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
map1.put("methodName", "token3");
|
|
map1.put("methodName", "token3");
|
|
map1.put("username", zh);
|
|
map1.put("username", zh);
|
|
map1.put("password", com.zkjc.policedemo.app.utils.MD5.md5(mm));
|
|
map1.put("password", com.zkjc.policedemo.app.utils.MD5.md5(mm));
|
|
- mPresenter.login(map1);
|
|
|
|
|
|
+ mPresenter.login(map1, zh);
|
|
Utils.getInstances().showDialog(SqjwLoginActivity.this, "正在登录");
|
|
Utils.getInstances().showDialog(SqjwLoginActivity.this, "正在登录");
|
|
|
|
|
|
});
|
|
});
|
|
@@ -261,7 +293,7 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onSuccess(String result) {
|
|
|
|
|
|
+ public void onSuccess(String result, String jinghao) {
|
|
|
|
|
|
Utils.getInstances().dismissDialog();
|
|
Utils.getInstances().dismissDialog();
|
|
System.out.println("****" + result);
|
|
System.out.println("****" + result);
|
|
@@ -284,7 +316,7 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
mPresenter.bindMj(map, entity);
|
|
mPresenter.bindMj(map, entity);
|
|
} else {
|
|
} else {
|
|
Utils.getInstances().dismissDialog();
|
|
Utils.getInstances().dismissDialog();
|
|
- saveLoginInfo(entity);
|
|
|
|
|
|
+ saveLoginInfo(entity, jinghao);
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -298,7 +330,7 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void saveLoginInfo(Login entity) {
|
|
|
|
|
|
+ private void saveLoginInfo(Login entity, String jinghao) {
|
|
SharedPreferences sharedPreferences = getSharedPreferences("sys", MODE_PRIVATE);
|
|
SharedPreferences sharedPreferences = getSharedPreferences("sys", MODE_PRIVATE);
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
edit.putString("token", entity.getAccess_token());
|
|
edit.putString("token", entity.getAccess_token());
|
|
@@ -322,7 +354,7 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
edit.putString("mj_name", entity.getMjname());
|
|
edit.putString("mj_name", entity.getMjname());
|
|
edit.putString("sspcs", entity.getSspcs());
|
|
edit.putString("sspcs", entity.getSspcs());
|
|
if (ApkUtils.isSqjw(this)) {
|
|
if (ApkUtils.isSqjw(this)) {
|
|
- edit.putString("zh", /*getIntent().getStringExtra("jh")*/"sqmj1");
|
|
|
|
|
|
+ edit.putString("zh", jinghao);
|
|
edit.putString("mm", MD5.md5(/*etMm.getText().toString().trim()*/"123456"));
|
|
edit.putString("mm", MD5.md5(/*etMm.getText().toString().trim()*/"123456"));
|
|
} else {
|
|
} else {
|
|
edit.putString("zh", etZh.getText().toString().trim());
|
|
edit.putString("zh", etZh.getText().toString().trim());
|
|
@@ -352,6 +384,125 @@ public class SqjwLoginActivity extends ZkjcBaseActivity<LoginPresenter> implemen
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onBindMjSuccess(Login login) {
|
|
public void onBindMjSuccess(Login login) {
|
|
- saveLoginInfo(login);
|
|
|
|
|
|
+ saveLoginInfo(login, "");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getInterface() {
|
|
|
|
+ Observable.create(new ObservableOnSubscribe<Boolean>(){
|
|
|
|
+ @Override
|
|
|
|
+ public void subscribe(ObservableEmitter<Boolean> emitter) throws Exception {
|
|
|
|
+ Uri uri = Uri.parse("content://com.ydjw.ua.getCredential");
|
|
|
|
+ Bundle params = new Bundle();
|
|
|
|
+ //构建参数
|
|
|
|
+ String paramsMessageId = UUID.randomUUID().toString();
|
|
|
|
+ params.putString("messageId", paramsMessageId);//消息id
|
|
|
|
+ params.putString("version", "1");//接口版本号,当前为1
|
|
|
|
+ params.putString("appId", "220000000000-3-1-97acefd890394d58a10b283e873b9ff3");//
|
|
|
|
+ params.putString("orgId", "220000000000");//
|
|
|
|
+ params.putString("networkAreaCode", "3");//
|
|
|
|
+ params.putString("packageName", "com.xwkj.sqjw");//应用包名,可空
|
|
|
|
+ //获取票据
|
|
|
|
+ Bundle bundle = null;
|
|
|
|
+ try {
|
|
|
|
+ bundle = getContentResolver().call(uri, "", null, params);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+// Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ //解析结果
|
|
|
|
+ if (bundle == null) {
|
|
|
|
+// UiUtils.toast("获取应用凭证失败,bundle为空!");
|
|
|
|
+ onTime(3000);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Log.e("eee", "bundle.getStringuserCredential ====== " + bundle.getString("userCredential"));
|
|
|
|
+ Log.e("eee", "bundle.getStringappCredential ====== " + bundle.getString("appCredential"));
|
|
|
|
+
|
|
|
|
+ String messageId = bundle.getString("messageId");
|
|
|
|
+
|
|
|
|
+ Log.e("eee", "getInterface messageId ====== " + messageId);
|
|
|
|
+ if (paramsMessageId.equals(messageId)) {
|
|
|
|
+ int resultCode = bundle.getInt("resultCode");
|
|
|
|
+ if (0 == resultCode) {
|
|
|
|
+ UserCredential userCredential = new Gson().fromJson(bundle.getString("userCredential"), UserCredential.class);
|
|
|
|
+ String jinghao = userCredential.getCredential().getLoad().getUserInfo().getJh();
|
|
|
|
+ String sfzh = userCredential.getCredential().getLoad().getUserInfo().getSfzh();
|
|
|
|
+ String orgid = userCredential.getCredential().getLoad().getUserInfo().getOrgId();
|
|
|
|
+ String xm = userCredential.getCredential().getLoad().getUserInfo().getXm();
|
|
|
|
+ if (TextUtils.isEmpty(sfzh)){
|
|
|
|
+ onTime(3000L);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ boolean success = getAddress(bundle.getString("appCredential"), bundle.getString("userCredential"));
|
|
|
|
+ if (success) {
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
+ map1.put("className", "bladeTokenEndPoint");
|
|
|
|
+ map1.put("methodName", "token3");
|
|
|
|
+ map1.put("username", jinghao);
|
|
|
|
+ map1.put("password", MD5.md5("123456"));
|
|
|
|
+ mPresenter.login(map1, jinghao);
|
|
|
|
+
|
|
|
|
+// mPresenter.getDictionary(new HashMap<>());
|
|
|
|
+ emitter.onNext(true);
|
|
|
|
+ } else {
|
|
|
|
+ onTime(3000);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ onTime(3000);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ onTime(3000);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }).subscribeOn(Schedulers.io())
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
+ .subscribe(new Observer<Boolean>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onNext(Boolean v) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(Throwable e) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onComplete() {
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean getAddress(String appCredential, String userCredential) {
|
|
|
|
+ SharedPreferences sp = getSharedPreferences("sys", MODE_PRIVATE);
|
|
|
|
+ Uri uri = Uri.parse("content://com.ydjw.rsb.getResourceAddress");
|
|
|
|
+ Bundle pararms = new Bundle();
|
|
|
|
+ String paramsMessageId = UUID.randomUUID().toString();
|
|
|
|
+ pararms.putString("messageId", paramsMessageId);
|
|
|
|
+ pararms.putString("version", "1");
|
|
|
|
+ pararms.putString("appCredential", appCredential);
|
|
|
|
+ Bundle bundle = getContentResolver().call(uri, "", null, pararms);
|
|
|
|
+ if (bundle == null) {
|
|
|
|
+ ToastUtils.show("获取应用地址失败!!!");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ String messageId = bundle.getString("messageId");
|
|
|
|
+ Log.e("eee", "getAddress messageId ====== " + messageId);
|
|
|
|
+ if (messageId.equals(paramsMessageId)) {
|
|
|
|
+ String resourceList = bundle.getString("resourceList");
|
|
|
|
+ int code = bundle.getInt("resultCode");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ SharedPreferences.Editor edit = sp.edit();
|
|
|
|
+ edit.putString("appCredential", appCredential);
|
|
|
|
+ edit.putString("userCredential", userCredential);
|
|
|
|
+ edit.putString("resourceList", resourceList);
|
|
|
|
+ System.out.println("寻址" + resourceList);
|
|
|
|
+ edit.commit();
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|