|
@@ -23,6 +23,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
import com.blankj.utilcode.util.NetworkUtils;
|
|
import com.blankj.utilcode.util.NetworkUtils;
|
|
import com.example.informationkanban.utils.GetInformationUtils;
|
|
import com.example.informationkanban.utils.GetInformationUtils;
|
|
|
|
+import com.example.informationkanban.utils.LanguageSetDialogHelper;
|
|
|
|
+import com.example.informationkanban.utils.LocaleMangerUtils;
|
|
import com.example.informationkanban.utils.NetFunctionConfig;
|
|
import com.example.informationkanban.utils.NetFunctionConfig;
|
|
|
|
|
|
public class InitActivity extends AppCompatActivity {
|
|
public class InitActivity extends AppCompatActivity {
|
|
@@ -39,6 +41,7 @@ public class InitActivity extends AppCompatActivity {
|
|
private Button btnChangeIp;
|
|
private Button btnChangeIp;
|
|
private Button btnSettings;
|
|
private Button btnSettings;
|
|
private Button btnEnterMain;
|
|
private Button btnEnterMain;
|
|
|
|
+ private Button btnLanguageSet;
|
|
|
|
|
|
private boolean loop = true;
|
|
private boolean loop = true;
|
|
private boolean connected = false;
|
|
private boolean connected = false;
|
|
@@ -47,6 +50,9 @@ public class InitActivity extends AppCompatActivity {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
+ int languageId = NetFunctionConfig.getLanguageId(this);
|
|
|
|
+ LocaleMangerUtils.setApplicationLanguageByIndex(this, languageId);
|
|
|
|
+
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.init_layout);
|
|
setContentView(R.layout.init_layout);
|
|
|
|
|
|
@@ -60,7 +66,7 @@ public class InitActivity extends AppCompatActivity {
|
|
tvServer = findViewById(R.id.textView_server_ip);
|
|
tvServer = findViewById(R.id.textView_server_ip);
|
|
tvServerStatus = findViewById(R.id.textView_server_status);
|
|
tvServerStatus = findViewById(R.id.textView_server_status);
|
|
tvVersion = findViewById(R.id.textView_version);
|
|
tvVersion = findViewById(R.id.textView_version);
|
|
- tvVersion.setText("版本: V" + BuildConfig.VERSION_NAME);
|
|
|
|
|
|
+ tvVersion.setText("App version: V" + BuildConfig.VERSION_NAME);
|
|
tvTime = findViewById(R.id.textView_countdown);
|
|
tvTime = findViewById(R.id.textView_countdown);
|
|
group = findViewById(R.id.group_webview_type);
|
|
group = findViewById(R.id.group_webview_type);
|
|
btnWebview = findViewById(R.id.radio_webview);
|
|
btnWebview = findViewById(R.id.radio_webview);
|
|
@@ -68,6 +74,7 @@ public class InitActivity extends AppCompatActivity {
|
|
btnChangeIp = findViewById(R.id.btn_change_ip);
|
|
btnChangeIp = findViewById(R.id.btn_change_ip);
|
|
btnSettings = findViewById(R.id.btn_settings);
|
|
btnSettings = findViewById(R.id.btn_settings);
|
|
btnEnterMain = findViewById(R.id.btn_enter_main);
|
|
btnEnterMain = findViewById(R.id.btn_enter_main);
|
|
|
|
+ btnLanguageSet = findViewById(R.id.btn_change_language);
|
|
|
|
|
|
//webview类型,默认为原生webview
|
|
//webview类型,默认为原生webview
|
|
if (NetFunctionConfig.getWebviewType() == 1) {
|
|
if (NetFunctionConfig.getWebviewType() == 1) {
|
|
@@ -76,7 +83,7 @@ public class InitActivity extends AppCompatActivity {
|
|
btnXwalk.setChecked(true);
|
|
btnXwalk.setChecked(true);
|
|
}
|
|
}
|
|
|
|
|
|
- tvServer.setText("服务器IP: " + NetFunctionConfig.getServerIp() + ":" + NetFunctionConfig.getServerPort());
|
|
|
|
|
|
+ tvServer.setText("Server: " + NetFunctionConfig.getServerIp() + ":" + NetFunctionConfig.getServerPort());
|
|
|
|
|
|
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
@Override
|
|
@Override
|
|
@@ -133,6 +140,20 @@ public class InitActivity extends AppCompatActivity {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ btnLanguageSet.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ //取消倒计时
|
|
|
|
+ if (countDownTimer != null) {
|
|
|
|
+ countDownTimer.cancel();
|
|
|
|
+ }
|
|
|
|
+ btnEnterMain.setVisibility(View.VISIBLE);
|
|
|
|
+ tvTime.setVisibility(View.INVISIBLE);
|
|
|
|
+
|
|
|
|
+ LanguageSetDialogHelper.showDialog(InitActivity.this);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
//检查服务器连接情况
|
|
//检查服务器连接情况
|
|
checkServer();
|
|
checkServer();
|
|
}
|
|
}
|
|
@@ -145,19 +166,19 @@ public class InitActivity extends AppCompatActivity {
|
|
editIp.setText(NetFunctionConfig.getServerIp());
|
|
editIp.setText(NetFunctionConfig.getServerIp());
|
|
final EditText editPort = contentView.findViewById(R.id.edit_server_port);
|
|
final EditText editPort = contentView.findViewById(R.id.edit_server_port);
|
|
editPort.setText(NetFunctionConfig.getServerPort());
|
|
editPort.setText(NetFunctionConfig.getServerPort());
|
|
- builder.setTitle("设置服务器IP和端口");
|
|
|
|
- builder.setPositiveButton("保存", new DialogInterface.OnClickListener() {
|
|
|
|
|
|
+ builder.setTitle(R.string.str_set_server_ip);
|
|
|
|
+ builder.setPositiveButton(R.string.str_save, new DialogInterface.OnClickListener() {
|
|
@Override
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
String newIp = editIp.getText().toString();
|
|
String newIp = editIp.getText().toString();
|
|
String newPort = editPort.getText().toString();
|
|
String newPort = editPort.getText().toString();
|
|
NetFunctionConfig.setServerIp(newIp);
|
|
NetFunctionConfig.setServerIp(newIp);
|
|
NetFunctionConfig.setServerPort(newPort);
|
|
NetFunctionConfig.setServerPort(newPort);
|
|
- tvServer.setText("服务器IP: " + newIp + ":" + newPort);
|
|
|
|
|
|
+ tvServer.setText("Server: " + newIp + ":" + newPort);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
|
|
+ builder.setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
|
|
@Override
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//
|
|
//
|
|
@@ -173,7 +194,8 @@ public class InitActivity extends AppCompatActivity {
|
|
@Override
|
|
@Override
|
|
public void onTick(long millisUntilFinished) {
|
|
public void onTick(long millisUntilFinished) {
|
|
long untilTime = millisUntilFinished/1000;
|
|
long untilTime = millisUntilFinished/1000;
|
|
- tvTime.setText("倒计时: " + untilTime + "秒");
|
|
|
|
|
|
+ String time = getString(R.string.str_count_down, untilTime);
|
|
|
|
+ tvTime.setText(time);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -202,7 +224,7 @@ public class InitActivity extends AppCompatActivity {
|
|
showServerStatus(false);
|
|
showServerStatus(false);
|
|
showMessage();
|
|
showMessage();
|
|
try {
|
|
try {
|
|
- Thread.sleep(6000);
|
|
|
|
|
|
+ Thread.sleep(10000);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -232,10 +254,10 @@ public class InitActivity extends AppCompatActivity {
|
|
public void run() {
|
|
public void run() {
|
|
if (status) {
|
|
if (status) {
|
|
tvServerStatus.setTextColor(Color.GREEN);
|
|
tvServerStatus.setTextColor(Color.GREEN);
|
|
- tvServerStatus.setText("服务器连接成功");
|
|
|
|
|
|
+ tvServerStatus.setText(R.string.str_connect_success);
|
|
} else {
|
|
} else {
|
|
tvServerStatus.setTextColor(Color.RED);
|
|
tvServerStatus.setTextColor(Color.RED);
|
|
- tvServerStatus.setText("服务器连接失败");
|
|
|
|
|
|
+ tvServerStatus.setText(R.string.str_connect_fail);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -247,9 +269,9 @@ public class InitActivity extends AppCompatActivity {
|
|
public void run() {
|
|
public void run() {
|
|
if (tvMac != null && tvIP != null) {
|
|
if (tvMac != null && tvIP != null) {
|
|
//tvMac.setText("MAC地址: " + GetInformationUtils.getMacAddress(InitActivity.this));
|
|
//tvMac.setText("MAC地址: " + GetInformationUtils.getMacAddress(InitActivity.this));
|
|
- tvMac.setText("设备ID: " + GetInformationUtils.getSerialNo(getApplicationContext()));
|
|
|
|
- tvIP.setText("本机IP地址: " + GetInformationUtils.getLocalIP());
|
|
|
|
- tvServer.setText("服务器IP: " + NetFunctionConfig.getServerIp() + ":" + NetFunctionConfig.getServerPort());
|
|
|
|
|
|
+ tvMac.setText("Device ID: " + GetInformationUtils.getSerialNo(getApplicationContext()));
|
|
|
|
+ tvIP.setText("Local IP: " + GetInformationUtils.getLocalIP());
|
|
|
|
+ tvServer.setText("Server IP: " + NetFunctionConfig.getServerIp() + ":" + NetFunctionConfig.getServerPort());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -259,7 +281,7 @@ public class InitActivity extends AppCompatActivity {
|
|
runOnUiThread(new Runnable() {
|
|
runOnUiThread(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
- Toast.makeText(InitActivity.this, "连接服务器失败,请检查网络", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
+ Toast.makeText(InitActivity.this, R.string.tips_server_connect_error, Toast.LENGTH_SHORT).show();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|