|
@@ -22,15 +22,23 @@ import android.widget.ListView;
|
|
|
import android.widget.PopupWindow;
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.android.arouter.facade.annotation.Autowired;
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
|
|
+import com.alibaba.android.arouter.launcher.ARouter;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.blankj.utilcode.util.LogUtils;
|
|
import com.blankj.utilcode.util.LogUtils;
|
|
|
|
|
+import com.blankj.utilcode.util.SPUtils;
|
|
|
import com.blankj.utilcode.util.ToastUtils;
|
|
import com.blankj.utilcode.util.ToastUtils;
|
|
|
import com.maning.mndialoglibrary.MProgressDialog;
|
|
import com.maning.mndialoglibrary.MProgressDialog;
|
|
|
|
|
+import com.maning.mndialoglibrary.MToast;
|
|
|
import com.uas.module.common.base.BaseActivity;
|
|
import com.uas.module.common.base.BaseActivity;
|
|
|
|
|
+import com.uas.module.common.utils.Constants;
|
|
|
import com.uas.module.common.utils.DisplayUtil;
|
|
import com.uas.module.common.utils.DisplayUtil;
|
|
|
import com.uas.module.common.utils.StatusBarUtil;
|
|
import com.uas.module.common.utils.StatusBarUtil;
|
|
|
|
|
+import com.uas.module.common.utils.StringUtils;
|
|
|
import com.uas.module.home.R;
|
|
import com.uas.module.home.R;
|
|
|
|
|
+import com.uas.module.home.model.GroupMessageBean;
|
|
|
|
|
+import com.uas.module.home.model.MessageConfigBean;
|
|
|
import com.uas.module.home.network.grpc.Authentication;
|
|
import com.uas.module.home.network.grpc.Authentication;
|
|
|
import com.uas.module.home.network.grpc.MobileClientAuthenticationInterceptor;
|
|
import com.uas.module.home.network.grpc.MobileClientAuthenticationInterceptor;
|
|
|
import com.uas.module.widget.adapter.ItemPopListAdapter;
|
|
import com.uas.module.widget.adapter.ItemPopListAdapter;
|
|
@@ -41,6 +49,8 @@ import com.usoftchina.uu.mobile.grpc.api.AccountSigninResponse;
|
|
|
import com.usoftchina.uu.mobile.grpc.api.AuthedToken;
|
|
import com.usoftchina.uu.mobile.grpc.api.AuthedToken;
|
|
|
import com.usoftchina.uu.mobile.grpc.api.DeviceInfo;
|
|
import com.usoftchina.uu.mobile.grpc.api.DeviceInfo;
|
|
|
import com.usoftchina.uu.mobile.grpc.api.ResponseHeader;
|
|
import com.usoftchina.uu.mobile.grpc.api.ResponseHeader;
|
|
|
|
|
+import com.usoftchina.uu.mobile.grpc.api.SwitchCompanyRequest;
|
|
|
|
|
+import com.usoftchina.uu.mobile.grpc.api.SwitchCompanyResponse;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -62,6 +72,11 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
private View mToastHead;
|
|
private View mToastHead;
|
|
|
private FrameLayout mToastLayout;
|
|
private FrameLayout mToastLayout;
|
|
|
|
|
|
|
|
|
|
+ @Autowired(name = "phone")
|
|
|
|
|
+ String mPhone;
|
|
|
|
|
+ @Autowired(name = "password")
|
|
|
|
|
+ String mPassword;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
@@ -86,6 +101,18 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
tv_register.setOnClickListener(this);
|
|
tv_register.setOnClickListener(this);
|
|
|
mPhoneNumberEdit.addTextChangedListener(new MyTextWatcher());
|
|
mPhoneNumberEdit.addTextChangedListener(new MyTextWatcher());
|
|
|
mPasswordEdit.addTextChangedListener(new MyTextWatcher());
|
|
mPasswordEdit.addTextChangedListener(new MyTextWatcher());
|
|
|
|
|
+
|
|
|
|
|
+ String phone= SPUtils.getInstance(Constants.spName).getString("phone");
|
|
|
|
|
+ String password= SPUtils.getInstance(Constants.spName).getString("password");
|
|
|
|
|
+ if(!StringUtils.isEmpty(phone)&&!StringUtils.isEmpty(password)){
|
|
|
|
|
+ mPhoneNumberEdit.setText(phone);
|
|
|
|
|
+ mPasswordEdit.setText(password);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!StringUtils.isEmpty(mPhone)&&!StringUtils.isEmpty(mPassword)){
|
|
|
|
|
+ mPhoneNumberEdit.setText(mPhone);
|
|
|
|
|
+ mPasswordEdit.setText(mPassword);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -158,10 +185,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
if (header.getSuccess()) {
|
|
if (header.getSuccess()) {
|
|
|
MProgressDialog.dismissProgress();
|
|
MProgressDialog.dismissProgress();
|
|
|
System.out.println(response.getAccount());
|
|
System.out.println(response.getAccount());
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
AuthedToken token = response.getAuthedToken();
|
|
AuthedToken token = response.getAuthedToken();
|
|
|
-
|
|
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("phone",phoneNumber);
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("password",password);
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("token",JSON.toJSONString(token));
|
|
|
LogUtils.d("login token:"+token.getToken());
|
|
LogUtils.d("login token:"+token.getToken());
|
|
|
LogUtils.d("account:"+JSON.toJSONString(response.getAccount()));
|
|
LogUtils.d("account:"+JSON.toJSONString(response.getAccount()));
|
|
|
// 登录成功后记录auth信息
|
|
// 登录成功后记录auth信息
|
|
@@ -175,15 +202,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
for (int i=0;i<response.getCompanyList().size();i++){
|
|
for (int i=0;i<response.getCompanyList().size();i++){
|
|
|
ItemsSelectType1 model=new ItemsSelectType1();
|
|
ItemsSelectType1 model=new ItemsSelectType1();
|
|
|
model.setName(response.getCompanyList().get(i).getName());
|
|
model.setName(response.getCompanyList().get(i).getName());
|
|
|
- model.setEn_name(response.getCompanyList().get(i).getName());
|
|
|
|
|
|
|
+ model.setEn_name(String.valueOf(response.getCompanyList().get(i).getId()));
|
|
|
datas.add(model);
|
|
datas.add(model);
|
|
|
}
|
|
}
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void run() {
|
|
|
|
|
- showPopDialog(LoginActivity.this,datas);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ runOnUiThread(() -> showPopDialog(LoginActivity.this,datas));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
if (response.getMessageConfigCount() > 0) {
|
|
if (response.getMessageConfigCount() > 0) {
|
|
@@ -200,14 +222,12 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
MProgressDialog.dismissProgress();
|
|
MProgressDialog.dismissProgress();
|
|
|
- // error return by ResponseHeader
|
|
|
|
|
- System.err.println(header.getCode() + "," + header.getMessage());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ runOnUiThread(()->MToast.makeTextLong(getApplicationContext(),header.getMessage()));
|
|
|
}
|
|
}
|
|
|
} catch (StatusRuntimeException e) {
|
|
} catch (StatusRuntimeException e) {
|
|
|
- // error return by Exception
|
|
|
|
|
- ToastUtils.showLong("接口异常"+ e.getStatus().getDescription());
|
|
|
|
|
|
|
+ runOnUiThread(()-> MToast.makeTextLong(getApplicationContext(),e.getStatus().getDescription()));
|
|
|
MProgressDialog.dismissProgress();
|
|
MProgressDialog.dismissProgress();
|
|
|
- System.err.println(e.getStatus().getCode() + "," + e.getStatus().getDescription());
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).start();
|
|
}).start();
|
|
@@ -247,6 +267,9 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
|
ItemPopListAdapter.ViewHolder viewHolder = (ItemPopListAdapter.ViewHolder) view.getTag();
|
|
ItemPopListAdapter.ViewHolder viewHolder = (ItemPopListAdapter.ViewHolder) view.getTag();
|
|
|
ItemsSelectType1 model = viewHolder.model;
|
|
ItemsSelectType1 model = viewHolder.model;
|
|
|
|
|
+
|
|
|
|
|
+ String companyId= model.getEn_name();
|
|
|
|
|
+ switchCompany(companyId);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -263,6 +286,93 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|
|
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
popupWindow.showAtLocation(ct.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
popupWindow.showAtLocation(ct.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /*切换公司-会产生新的Token*/
|
|
|
|
|
+ public void switchCompany(String companyID) {
|
|
|
|
|
+ runOnUiThread(()->MProgressDialog.showProgress(this,""));
|
|
|
|
|
+ new Thread(() -> {
|
|
|
|
|
+ ManagedChannel channel = ManagedChannelBuilder.forAddress("uu-api-test.usoftchina.com", 9620)
|
|
|
|
|
+ .intercept(new MobileClientAuthenticationInterceptor())
|
|
|
|
|
+ .usePlaintext(true)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ SwitchCompanyRequest request = SwitchCompanyRequest.newBuilder()
|
|
|
|
|
+ .setCompanyId(Integer.valueOf(companyID)).build();
|
|
|
|
|
+ try {
|
|
|
|
|
+ SwitchCompanyResponse response = AccountServiceGrpc.newBlockingStub(channel).switchCompany(request);
|
|
|
|
|
+ ResponseHeader header = response.getResponseHeader();
|
|
|
|
|
+ if (header.getSuccess()) {
|
|
|
|
|
+ runOnUiThread(()->MProgressDialog.dismissProgress());
|
|
|
|
|
+ // new authentication
|
|
|
|
|
+ AuthedToken token = response.getAuthedToken();
|
|
|
|
|
+ LogUtils.d("login token:"+token.getToken());
|
|
|
|
|
+ // 登录成功后记录auth信息
|
|
|
|
|
+ Authentication.set(token.getToken());
|
|
|
|
|
+ LogUtils.d(""+response.getAuthedToken());
|
|
|
|
|
+
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("token",JSON.toJSONString(token));
|
|
|
|
|
+// // 新的消息中心配置
|
|
|
|
|
+// repeated MessageConfig messageConfig = 3;
|
|
|
|
|
+// // 新的未读消息统计
|
|
|
|
|
+// repeated UnreadMessageCount unreadMessageCount = 4;
|
|
|
|
|
+// // 新的应用中心配置
|
|
|
|
|
+// repeated AppGroupConfig appGroupConfig = 5;
|
|
|
|
|
+// // 新的我的主页配置
|
|
|
|
|
+// repeated HomeConfig homeConfig = 6;
|
|
|
|
|
+ if (response.getMessageConfigCount()>0){
|
|
|
|
|
+ String messageList= JSON.toJSONString(response.getMessageConfigList());
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("messageList",messageList);
|
|
|
|
|
+ //LogUtils.d("messageList:"+messageList);
|
|
|
|
|
+
|
|
|
|
|
+ List<MessageConfigBean> messageConfigs=
|
|
|
|
|
+ //JSON.parseObject(messageList,new TypeReference<List<MessageConfigBean>>(){}); // Json 转List
|
|
|
|
|
+ JSON.parseArray(messageList,MessageConfigBean.class);
|
|
|
|
|
+ //LogUtils.d("messageConfigs:"+JSON.toJSONString(messageConfigs));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (response.getAppGroupConfigCount()>0){
|
|
|
|
|
+ String appGroupList=JSON.toJSONString(response.getAppGroupConfigList());
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("appGroupList",appGroupList);
|
|
|
|
|
+ LogUtils.d("appGroupList:"+appGroupList);
|
|
|
|
|
+
|
|
|
|
|
+ List<GroupMessageBean> messageBeans=JSON.parseArray(appGroupList,GroupMessageBean.class);
|
|
|
|
|
+ LogUtils.d("appGroupList:"+JSON.toJSONString(messageBeans));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (response.getHomeConfigCount()>0){
|
|
|
|
|
+ String homeList=JSON.toJSONString(response.getHomeConfigList());
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("homeList:",homeList);
|
|
|
|
|
+ //LogUtils.d("homeList:"+homeList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (response.getUnreadMessageCountCount()>0){
|
|
|
|
|
+ String unreadMessageList=JSON.toJSONString(response.getUnreadMessageCountList());
|
|
|
|
|
+ SPUtils.getInstance(Constants.spName).put("unreadMessageList:",unreadMessageList);
|
|
|
|
|
+
|
|
|
|
|
+ //LogUtils.d("unreadMessageList:"+unreadMessageList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //登录成功
|
|
|
|
|
+ ARouter.getInstance().build("/app/main").navigation();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ runOnUiThread(()->{
|
|
|
|
|
+ MProgressDialog.dismissProgress();
|
|
|
|
|
+ MToast.makeTextLong(getApplicationContext(),header.getMessage());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (StatusRuntimeException e) {
|
|
|
|
|
+ runOnUiThread(()->{MProgressDialog.dismissProgress();
|
|
|
|
|
+ MToast.makeTextLong(getApplicationContext(),e.getStatus().getDescription());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }).start();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|