mirror of
https://gitee.com/willfree/min-vpn-client_v2.git
synced 2026-10-04 19:42:00 +08:00
CUTV版本界面
This commit is contained in:
1 parent
01e66f837c
commit
a3cd367bd4
4 files changed
+132
-99
No files matched your search
@@ -29,10 +29,12 @@ import com.pkusz.min_vpn_client.activity.register.RegisterActivity;
|
||||
import com.pkusz.min_vpn_client.activity.reset.ResetActivity;
|
||||
import com.pkusz.min_vpn_client.activity.setting.SettingActivity;
|
||||
import com.pkusz.min_vpn_client.model.MINVpnSettingAPI;
|
||||
import com.pkusz.min_vpn_client.model.MISRequestAPI;
|
||||
import com.pkusz.min_vpn_client.model.OriginalRequest.OriginalGetVpnInfoRequest;
|
||||
import com.pkusz.min_vpn_client.model.OriginalRequest.OriginalLoginRequest;
|
||||
import com.pkusz.min_vpn_client.utils.AccountValidatorRegexUtil;
|
||||
import com.pkusz.min_vpn_client.utils.DigestUtilKt;
|
||||
import com.pkusz.min_vpn_client.utils.IdentityEncryptedUtil;
|
||||
import com.pkusz.min_vpn_client.utils.KeyManager;
|
||||
import com.pkusz.min_vpn_client.utils.listview.ListActivity;
|
||||
import com.pkusz.min_vpn_client.utils.updateApp.UpdateAppUtils;
|
||||
@@ -43,6 +45,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import MISConnection.Model.MISGetValidIdentityRequest;
|
||||
import br.com.simplepass.loadingbutton.customViews.CircularProgressButton;
|
||||
import cn.qjm253.min_vpn.extensions.ActivityExtensionsKt;
|
||||
import cn.qjm253.quick_android_base.GlideApp;
|
||||
@@ -54,6 +57,7 @@ import cn.qjm253.quick_android_easy_bar.EasyBar;
|
||||
import cn.qjm253.quick_android_easy_bar.EasyBarExtensionsKt;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import security.SafeBag;
|
||||
|
||||
public class LoginActivity extends MINVpnBaseActivity<LoginActivityPresenter>
|
||||
implements LoginActivityContract.View{
|
||||
@@ -170,12 +174,41 @@ public class LoginActivity extends MINVpnBaseActivity<LoginActivityPresenter>
|
||||
this.rawUsername = Objects.requireNonNull(etUsername.getText()).toString();
|
||||
this.rawPassword = Objects.requireNonNull(etPassword.getText()).toString();
|
||||
|
||||
// 登录前判断本地是否有身份信息,如果无,则提醒使用新设备登录界面
|
||||
// 登录前判断本地是否有身份信息,如果无,则先获取用户身份信息
|
||||
boolean isHaveIdentity= KeyManager.INSTANCE.isInKeyChain("/"+this.rawUsername);
|
||||
if(!isHaveIdentity){
|
||||
showWarning("本地无此用户身份("+this.rawUsername+"),请使用\"新设备登录\"按钮进行登录。");
|
||||
btnLogin.revertAnimation();
|
||||
return;
|
||||
// 1. 从MIS获取加密的身份数据
|
||||
MISGetValidIdentityRequest identityRequest=new
|
||||
MISGetValidIdentityRequest("/"+rawUsername,DigestUtilKt.encodeToMD5(rawPassword),"17817733391","123456");
|
||||
byte[] encryptedIdentityData = MISRequestAPI.INSTANCE.getValidIdentityMIS(identityRequest);
|
||||
if(encryptedIdentityData==null){
|
||||
System.out.println("登陆时获取身份失败");
|
||||
mPresenter.loginFailed("获取身份失败");
|
||||
return;
|
||||
}else{
|
||||
System.out.println("用户新设备登录,获取身份成功");
|
||||
}
|
||||
// 2. 解密身份数据
|
||||
byte[] identityData= IdentityEncryptedUtil.decryptedIdentity(rawUsername,rawUsername,encryptedIdentityData);
|
||||
// 3. 保存身份数据到本地
|
||||
try {
|
||||
SafeBag safeBag=new SafeBag(identityData);
|
||||
KeyManager.INSTANCE.getKeyChain().importSafeBag(safeBag,"",true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mPresenter.loginFailed("保存身份失败");
|
||||
return;
|
||||
}
|
||||
// 4. 将当前身份设为此身份
|
||||
if(KeyManager.INSTANCE.isInKeyChain("/"+rawUsername)){
|
||||
KeyManager.INSTANCE.initKeyChain("/"+rawUsername);
|
||||
}else{
|
||||
mPresenter.loginFailed("保存身份失败");
|
||||
return;
|
||||
}
|
||||
// showWarning("本地无此用户身份("+this.rawUsername+"),请使用\"新设备登录\"按钮进行登录。");
|
||||
// btnLogin.revertAnimation();
|
||||
// return;
|
||||
}
|
||||
|
||||
boolean testFlag=false;
|
||||
|
||||
@@ -47,9 +47,9 @@ public class SettingActivity extends MINVpnBaseActivity<SettingActivityPresenter
|
||||
private ClearAbleEditText etVMSTCPPort;
|
||||
private ClearAbleEditText etVMSSSLPort;
|
||||
// MIS
|
||||
// private ClearAbleEditText etMISIp;
|
||||
// private ClearAbleEditText etMISTCPPort;
|
||||
// private ClearAbleEditText etMISSSLPort;
|
||||
private ClearAbleEditText etMISIp;
|
||||
private ClearAbleEditText etMISTCPPort;
|
||||
private ClearAbleEditText etMISSSLPort;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -73,9 +73,9 @@ public class SettingActivity extends MINVpnBaseActivity<SettingActivityPresenter
|
||||
etVMSTCPPort=findViewById(R.id.etVMSTCPPort);
|
||||
etVMSSSLPort=findViewById(R.id.etVMSSSLPort);
|
||||
// MIS
|
||||
// etMISIp=findViewById(R.id.etMISIp);
|
||||
// etMISTCPPort=findViewById(R.id.etMISTCPPort);
|
||||
// etMISSSLPort=findViewById(R.id.etMISSSLPort);
|
||||
etMISIp=findViewById(R.id.etMISIp);
|
||||
etMISTCPPort=findViewById(R.id.etMISTCPPort);
|
||||
etMISSSLPort=findViewById(R.id.etMISSSLPort);
|
||||
|
||||
initView();
|
||||
}
|
||||
@@ -111,9 +111,9 @@ public class SettingActivity extends MINVpnBaseActivity<SettingActivityPresenter
|
||||
etBlockChainIp.setText(MINVpnSettingAPI.INSTANCE.getBlockChainIpAddress());
|
||||
etVMSTCPPort.setText(String.valueOf(MINVpnSettingAPI.INSTANCE.getBcTcpPort()));
|
||||
etVMSSSLPort.setText(String.valueOf(MINVpnSettingAPI.INSTANCE.getBcSslPort()));
|
||||
// etMISIp.setText(MINVpnSettingAPI.INSTANCE.getMisIpAddress());
|
||||
// etMISTCPPort.setText(String.valueOf(MINVpnSettingAPI.INSTANCE.getMisTcpPort()));
|
||||
// etMISSSLPort.setText(String.valueOf(MINVpnSettingAPI.INSTANCE.getMisSslPort()));
|
||||
etMISIp.setText(MINVpnSettingAPI.INSTANCE.getMisIpAddress());
|
||||
etMISTCPPort.setText(String.valueOf(MINVpnSettingAPI.INSTANCE.getMisTcpPort()));
|
||||
etMISSSLPort.setText(String.valueOf(MINVpnSettingAPI.INSTANCE.getMisSslPort()));
|
||||
|
||||
// 设置按钮的监听(点击动作)
|
||||
btnSaveSetting.setOnClickListener(v->{
|
||||
@@ -186,24 +186,24 @@ public class SettingActivity extends MINVpnBaseActivity<SettingActivityPresenter
|
||||
btnSaveSetting.revertAnimation();
|
||||
return;
|
||||
}
|
||||
// String misIpAddress = Objects.requireNonNull(etMISIp.getText()).toString();
|
||||
// if(!AccountValidatorRegexUtil.INSTANCE.isIPAddr(misIpAddress)){
|
||||
// showWarning("请输入有效的MIS-IP地址");
|
||||
// btnSaveSetting.revertAnimation();
|
||||
// return;
|
||||
// }
|
||||
// String mistcpPort= Objects.requireNonNull(etMISTCPPort.getText()).toString();
|
||||
// if(!AccountValidatorRegexUtil.INSTANCE.isPort(mistcpPort)){
|
||||
// showWarning("请输入有效的MIS-TCP端口号");
|
||||
// btnSaveSetting.revertAnimation();
|
||||
// return;
|
||||
// }
|
||||
// String missslPort= Objects.requireNonNull(etMISSSLPort.getText()).toString();
|
||||
// if(!AccountValidatorRegexUtil.INSTANCE.isPort(missslPort)){
|
||||
// showWarning("请输入有效的MIS-SSL端口号");
|
||||
// btnSaveSetting.revertAnimation();
|
||||
// return;
|
||||
// }
|
||||
String misIpAddress = Objects.requireNonNull(etMISIp.getText()).toString();
|
||||
if(!AccountValidatorRegexUtil.INSTANCE.isIPAddr(misIpAddress)){
|
||||
showWarning("请输入有效的MIS-IP地址");
|
||||
btnSaveSetting.revertAnimation();
|
||||
return;
|
||||
}
|
||||
String mistcpPort= Objects.requireNonNull(etMISTCPPort.getText()).toString();
|
||||
if(!AccountValidatorRegexUtil.INSTANCE.isPort(mistcpPort)){
|
||||
showWarning("请输入有效的MIS-TCP端口号");
|
||||
btnSaveSetting.revertAnimation();
|
||||
return;
|
||||
}
|
||||
String missslPort= Objects.requireNonNull(etMISSSLPort.getText()).toString();
|
||||
if(!AccountValidatorRegexUtil.INSTANCE.isPort(missslPort)){
|
||||
showWarning("请输入有效的MIS-SSL端口号");
|
||||
btnSaveSetting.revertAnimation();
|
||||
return;
|
||||
}
|
||||
boolean isEncrypted=true;
|
||||
|
||||
// 将属性字段更新到MINVpnAPI
|
||||
@@ -220,8 +220,8 @@ public class SettingActivity extends MINVpnBaseActivity<SettingActivityPresenter
|
||||
MINVpnSettingAPI.INSTANCE.updateBcTcpPort(Integer.parseInt(tcpPort));
|
||||
MINVpnSettingAPI.INSTANCE.updateBcSslPort(Integer.parseInt(sslPort));
|
||||
MINVpnSettingAPI.INSTANCE.updateMisIpAddress(blockChainIpAddress);
|
||||
MINVpnSettingAPI.INSTANCE.updateMisTcpPort(Integer.parseInt(tcpPort));
|
||||
MINVpnSettingAPI.INSTANCE.updateMisSslPort(Integer.parseInt(sslPort));
|
||||
MINVpnSettingAPI.INSTANCE.updateMisTcpPort(Integer.parseInt(mistcpPort));
|
||||
MINVpnSettingAPI.INSTANCE.updateMisSslPort(Integer.parseInt(missslPort));
|
||||
MINVpnSettingAPI.INSTANCE.updateEncryptedConfig(isEncrypted);
|
||||
System.out.println(MINVpnSettingAPI.INSTANCE);
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ public enum MINVpnSettingAPI {
|
||||
|
||||
public Integer getExtranetMirPort(){
|
||||
return EncryptedSharedPreferenceUtil.get(context,
|
||||
SP_LOCAL_Extranet_SETTING_MIR_PORT,14922);
|
||||
SP_LOCAL_Extranet_SETTING_MIR_PORT,13899);
|
||||
}
|
||||
|
||||
public void updateExtranetMirPort(Integer mirPort){
|
||||
@@ -356,7 +356,7 @@ public enum MINVpnSettingAPI {
|
||||
|
||||
public Integer getMisTcpPort(){
|
||||
return EncryptedSharedPreferenceUtil.get(context,
|
||||
SP_LOCAL_SETTING_MIS_PORT_TCP,12365);
|
||||
SP_LOCAL_SETTING_MIS_PORT_TCP,12345);
|
||||
}
|
||||
|
||||
public void updateMisTcpPort(Integer misTcpPort){
|
||||
@@ -367,7 +367,7 @@ public enum MINVpnSettingAPI {
|
||||
|
||||
public Integer getMisSslPort(){
|
||||
return EncryptedSharedPreferenceUtil.get(context,
|
||||
SP_LOCAL_SETTING_MIS_PORT_SSL,54231);
|
||||
SP_LOCAL_SETTING_MIS_PORT_SSL,54321);
|
||||
}
|
||||
|
||||
public void updateMisSslPort(Integer misSslPort){
|
||||
|
||||
@@ -280,76 +280,76 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDecoration7" />
|
||||
|
||||
<!-- MIS IP地址 -->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tvDecoration8"-->
|
||||
<!-- style="@style/setting_title_decoration"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/etVMSSSLPort" />-->
|
||||
<TextView
|
||||
android:id="@+id/tvDecoration8"
|
||||
style="@style/setting_title_decoration"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etVMSSSLPort" />
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/settingTvTitle8"-->
|
||||
<!-- style="@style/setting_title"-->
|
||||
<!-- android:text="@string/setting_title_mis_ip_address"-->
|
||||
<!-- app:layout_constraintBottom_toTopOf="@+id/tvDecoration8"-->
|
||||
<!-- app:layout_constraintStart_toEndOf="@+id/tvDecoration8"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/tvDecoration8" />-->
|
||||
<TextView
|
||||
android:id="@+id/settingTvTitle8"
|
||||
style="@style/setting_title"
|
||||
android:text="@string/setting_title_mis_ip_address"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tvDecoration8"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvDecoration8"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvDecoration8" />
|
||||
|
||||
<!-- <cn.qjm253.quick_android_custom_view.other.ClearAbleEditText-->
|
||||
<!-- android:id="@+id/etMISIp"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:hint="@string/setting_block_chain_ip_address_example"-->
|
||||
<!-- app:layout_constraintLeft_toLeftOf="@id/settingTvTitle8"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tvDecoration8" />-->
|
||||
<cn.qjm253.quick_android_custom_view.other.ClearAbleEditText
|
||||
android:id="@+id/etMISIp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/setting_block_chain_ip_address_example"
|
||||
app:layout_constraintLeft_toLeftOf="@id/settingTvTitle8"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDecoration8" />
|
||||
|
||||
<!-- MIS TCP 端口号 -->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tvDecoration9"-->
|
||||
<!-- style="@style/setting_title_decoration"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/etMISIp" />-->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/settingTvTitle9"-->
|
||||
<!-- style="@style/setting_title"-->
|
||||
<!-- android:text="@string/setting_title_mis_tcp_port"-->
|
||||
<!-- app:layout_constraintBottom_toTopOf="@+id/tvDecoration9"-->
|
||||
<!-- app:layout_constraintStart_toEndOf="@+id/tvDecoration9"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/tvDecoration9" />-->
|
||||
<TextView
|
||||
android:id="@+id/tvDecoration9"
|
||||
style="@style/setting_title_decoration"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etMISIp" />
|
||||
<TextView
|
||||
android:id="@+id/settingTvTitle9"
|
||||
style="@style/setting_title"
|
||||
android:text="@string/setting_title_mis_tcp_port"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tvDecoration9"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvDecoration9"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvDecoration9" />
|
||||
|
||||
<!-- <cn.qjm253.quick_android_custom_view.other.ClearAbleEditText-->
|
||||
<!-- android:id="@+id/etMISTCPPort"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:hint="@string/setting_mis_tcp_port_example"-->
|
||||
<!-- android:inputType="number"-->
|
||||
<!-- app:layout_constraintLeft_toLeftOf="@id/settingTvTitle9"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tvDecoration9" />-->
|
||||
<cn.qjm253.quick_android_custom_view.other.ClearAbleEditText
|
||||
android:id="@+id/etMISTCPPort"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/setting_mis_tcp_port_example"
|
||||
android:inputType="number"
|
||||
app:layout_constraintLeft_toLeftOf="@id/settingTvTitle9"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDecoration9" />
|
||||
|
||||
<!-- MIS SSL 端口号 -->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tvDecoration10"-->
|
||||
<!-- style="@style/setting_title_decoration"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/etMISTCPPort" />-->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/settingTvTitle10"-->
|
||||
<!-- style="@style/setting_title"-->
|
||||
<!-- android:text="@string/setting_title_mis_ssl_port"-->
|
||||
<!-- app:layout_constraintBottom_toTopOf="@+id/tvDecoration10"-->
|
||||
<!-- app:layout_constraintStart_toEndOf="@+id/tvDecoration10"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/tvDecoration10" />-->
|
||||
<TextView
|
||||
android:id="@+id/tvDecoration10"
|
||||
style="@style/setting_title_decoration"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etMISTCPPort" />
|
||||
<TextView
|
||||
android:id="@+id/settingTvTitle10"
|
||||
style="@style/setting_title"
|
||||
android:text="@string/setting_title_mis_ssl_port"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tvDecoration10"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvDecoration10"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvDecoration10" />
|
||||
|
||||
<!-- <cn.qjm253.quick_android_custom_view.other.ClearAbleEditText-->
|
||||
<!-- android:id="@+id/etMISSSLPort"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:hint="@string/setting_mis_ssl_port_example"-->
|
||||
<!-- android:inputType="number"-->
|
||||
<!-- app:layout_constraintLeft_toLeftOf="@id/settingTvTitle10"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tvDecoration10" />-->
|
||||
<cn.qjm253.quick_android_custom_view.other.ClearAbleEditText
|
||||
android:id="@+id/etMISSSLPort"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/setting_mis_ssl_port_example"
|
||||
android:inputType="number"
|
||||
app:layout_constraintLeft_toLeftOf="@id/settingTvTitle10"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDecoration10" />
|
||||
|
||||
<br.com.simplepass.loadingbutton.customViews.CircularProgressButton
|
||||
android:id="@+id/btnSaveSetting"
|
||||
@@ -366,7 +366,7 @@
|
||||
app:initialCornerAngle="0dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etVMSSSLPort"
|
||||
app:layout_constraintTop_toBottomOf="@id/etMISSSLPort"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:spinning_bar_color="#FFFFFF"
|
||||
app:spinning_bar_padding="4dp"
|
||||
|
||||
Reference in new issue
Block a user